package com.ruoyi.project.patrol.patrol.controller;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.patrol.commonuse.domain.*;
import com.ruoyi.project.patrol.commonuse.service.*;
import com.ruoyi.project.patrol.emergency.domain.*;
import com.ruoyi.project.patrol.emergency.service.*;
import com.ruoyi.project.patrol.fire.domain.*;
import com.ruoyi.project.patrol.fire.service.*;
import com.ruoyi.project.patrol.patrol.domain.TPatrolIssues;
import com.ruoyi.project.patrol.patrol.domain.TPatrolMain;
import com.ruoyi.project.patrol.patrol.domain.TPatrolPlan;
import com.ruoyi.project.patrol.patrol.service.ITPatrolIssuesService;
import com.ruoyi.project.patrol.patrol.service.ITPatrolMainService;
import com.ruoyi.project.patrol.patrol.service.ITPatrolPlanService;
import com.ruoyi.project.pssr.controller.TPssrApproveController;
import com.ruoyi.project.pssr.domain.TPssrPatrol;
import com.ruoyi.project.pssr.service.ITPssrPatrolService;
import com.ruoyi.project.pssr.service.ITPssrSubcontentService;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 检查计划Controller
 *
 * @author ruoyi
 * @date 2023-08-29
 */
@RestController
@RequestMapping("/patrol/plan")
public class TPatrolPlanController extends BaseController {
    @Autowired
    private ITPatrolPlanService tPatrolPlanService;

    @Autowired
    private ITPatrolIssuesService tPatrolIssuesService;

    @Autowired
    private ITEmergencyEyewashService tEmergencyEyewashService;

    @Autowired
    private ITEmergencyPagaService tEmergencyPagaService;

    @Autowired
    private ITEmergencyCctvService tEmergencyCctvService;

    @Autowired
    private ITEmergencyCofferdamService tEmergencyCofferdamService;

    @Autowired
    private ITEmergencyCabinetService tEmergencyCabinetService;

    @Autowired
    private ITFireAnnihilatorService tFireAnnihilatorService;

    @Autowired
    private ITFireWaterCannonService tFireWaterCannonService;

    @Autowired
    private ITFireAlarmService tFireAlarmService;

    @Autowired
    private ITFireGasShieldService tFireGasShieldService;

    @Autowired
    private ITFireHoseBoxService tFireHoseBoxService;

    @Autowired
    private ITFirePostFireService tFirePostFireService;

    @Autowired
    private ITFireSandboxService tFireSandboxService;

    @Autowired
    private ITFireDoorService tFireDoorService;

    @Autowired
    private ITFireAidkitService tFireAidkitService;

    @Autowired
    private ITCommonuseTesterService TCommonuseTesterService;

    @Autowired
    private ITCommonuseEarplugService TCommonuseEarplugService;

    @Autowired
    private ITCommonuseMovementService TCommonuseMovementService;

    @Autowired
    private ITCommonuseBicycleService TCommonuseBicycleService;

    @Autowired
    private ITCommonuseManholeCoverService TCommonuseManholeCoverService;

    @Autowired
    private ITCommonuseDownspoutService TCommonuseDownspoutService;

    @Autowired
    private ITCommonuseSafetyBeltService TCommonuseSafetyBeltService;

    @Autowired
    private ITCommonuseWalkieTalkieService TCommonuseWalkieTalkieService;

    @Autowired
    private ITCommonuseWaterPumpService TCommonuseWaterPumpService;

    @Autowired
    private ITFireSprinklerService tFireSprinklerService;

    @Autowired
    private ITFireStandpipeService tFireStandpipeService;

    @Autowired
    private ITFireSteamCurtainService tFireSteamCurtainService;

    @Autowired
    private ITFireWeathervaneService tFireWeathervaneService;

    @Autowired
    private ITPatrolMainService tPatrolMainService;

    @Autowired
    private ISysUserService sysUserService;

    @Autowired
    private ITPssrPatrolService tPssrPatrolService;

    @Autowired
    private ITPssrSubcontentService tPssrSubcontentService;

    @Autowired
    private TPssrApproveController tPssrApproveController;

    /**
     * 查询检查计划列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:plan:list')")
    @Log(title = "检查计划", businessType = BusinessType.OTHER)
    @GetMapping("/list")
    public TableDataInfo list(TPatrolPlan tPatrolPlan) {
        startPage();
        List<TPatrolPlan> list = tPatrolPlanService.selectTPatrolPlanList(tPatrolPlan);
        for (TPatrolPlan plan : list) {
            if (StringUtils.isNotEmpty(plan.getConfirmed())) {
                SysUser sysUser = sysUserService.selectUserById(Long.valueOf(plan.getConfirmed()));
                if (sysUser != null)
                    plan.setConfirmed(sysUser.getNickName());
            }
        }
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('patrol:plan:list')")
    @Log(title = "检查计划", businessType = BusinessType.OTHER)
    @GetMapping("/allPlan")
    public AjaxResult allPlan(TPatrolPlan tPatrolPlan) {
        return AjaxResult.success(tPatrolPlanService.selectTPatrolPlanList(tPatrolPlan));
    }

    /**
     * 导出检查计划列表
     */
    
    @Log(title = "检查计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public AjaxResult export(TPatrolPlan tPatrolPlan) {
        List<TPatrolPlan> list = tPatrolPlanService.selectTPatrolPlanList(tPatrolPlan);
        ExcelUtil<TPatrolPlan> util = new ExcelUtil<TPatrolPlan>(TPatrolPlan.class);
        return util.exportExcel(list, "检查计划数据");
    }

    /**
     * 获取检查计划详细信息
     */
    @PreAuthorize("@ss.hasPermi('patrol:plan:query')")
    @Log(title = "检查计划", businessType = BusinessType.OTHER)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(tPatrolPlanService.selectTPatrolPlanById(id));
    }

    /**
     * 新增检查计划
     */
    @PreAuthorize("@ss.hasPermi('patrol:plan:add')")
    @Log(title = "检查计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPatrolPlan tPatrolPlan) {
        TPatrolPlan add = tPatrolPlanService.add(tPatrolPlan, String.valueOf(getUserId()));
        if (add != null)
            return AjaxResult.success();
        else
            return AjaxResult.error("创建计划失败！");
    }

    /**
     * 修改检查计划
     */
    @PreAuthorize("@ss.hasPermi('patrol:plan:edit')")
    @Log(title = "检查计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPatrolPlan tPatrolPlan) {
        return toAjax(tPatrolPlanService.updateTPatrolPlan(tPatrolPlan));
    }

    @PutMapping("/conform")
    @PreAuthorize("@ss.hasPermi('patrol:plan:edit')")
    @Log(title = "检查计划", businessType = BusinessType.UPDATE)
    public AjaxResult conform(@RequestBody TPatrolPlan plan) {
        TPatrolPlan tPatrolPlan = tPatrolPlanService.selectTPatrolPlanById(plan.getId());
        if (tPatrolPlan.getStatus() == 1) {
            return AjaxResult.error("当前计划已完成确认！请勿重复确认");
        }
        if (Objects.equals(tPatrolPlan.getDevNum(), tPatrolPlan.getCheckedNum())) {
            tPatrolPlan.setConfirmed(String.valueOf(getUserId()));
            tPatrolPlan.setConfirmDate(new Date());
            tPatrolPlan.setStatus(1L);
            TPatrolMain tPatrolMain = new TPatrolMain();
            tPatrolMain.setYear(String.valueOf(tPatrolPlan.getPlanYear()));
            tPatrolMain.setPatrolType(tPatrolPlan.getPatrolType());
            updatePatrolMain(tPatrolPlan, tPatrolMain);
            updateDevices(tPatrolPlan);
            int i = tPatrolPlanService.updateTPatrolPlan(tPatrolPlan);
            try {
                // 确认计划如果有关联的pssr巡检，修改pssr巡检状态
                TPssrPatrol tPssrPatrol = new TPssrPatrol();
                tPssrPatrol.setPlanId(tPatrolPlan.getId());
                for (TPssrPatrol pssrPatrol : tPssrPatrolService.selectTPssrPatrolList(tPssrPatrol)) {
                    pssrPatrol.setPlanStatus(2L);
                    pssrPatrol.setApproveStatus(2L);
                    pssrPatrol.setConfirmDate(new Date());
                    pssrPatrol.setConfirmer(getUserId().toString());
                    pssrPatrol.setUpdatedate(new Date());
                    pssrPatrol.setUpdaterCode(getUserId().toString());
                    tPssrPatrolService.updateTPssrPatrol(pssrPatrol);

                    try {
                        TPssrPatrol patrol = new TPssrPatrol();
                        patrol.setSubId(pssrPatrol.getSubId());
                        boolean flag = true;
                        //当所有的pssr巡检都确认过后，发起申请
                        for (TPssrPatrol tpssrPatrol : tPssrPatrolService.selectTPssrPatrolList(patrol)) {
                            if (tpssrPatrol.getPlanStatus() != 2L) {
                                flag = false;
                                break;
                            }
                        }
                        if (flag) {
                            tPssrApproveController.doApprove(pssrPatrol.getSubId());
                        }
                    } catch (Exception e) {
                        logger.error(e.getMessage(), e);
                    }
                }
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
            return toAjax(i);
        } else {
            return AjaxResult.error("有未检测的设施！请确认所有设施已检查后进行确认！");
        }
    }

    private void updatePatrolMain(TPatrolPlan tPatrolPlan, TPatrolMain tPatrolMain) {
        if (tPatrolPlan.getPatrolType().equals("27")) {
            return;
        }
        TPatrolMain main = tPatrolMainService.selectTPatrolMainList(tPatrolMain).get(0);
        String checkCycle = main.getCheckCycle();
        if (tPatrolPlan.getPlanQuarter() == 1) {
            if ("1".equals(checkCycle)) {
                main.setJan("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getJan().charAt(2) :
                        main.getJan().charAt(0) + ",1");
            } else if ("3".equals(checkCycle)) {
                main.setJan("-");
            } else {
                main.setJan("1");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 2) {
            if ("1".equals(checkCycle)) {
                main.setFeb("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getFeb().charAt(2) :
                        main.getFeb().charAt(0) + ",1");
            } else if ("2".equals(checkCycle) || "3".equals(checkCycle)) {
                main.setFeb("1");
            } else {
                main.setFeb("-");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 3) {
            if ("1".equals(checkCycle)) {
                main.setMar("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getMar().charAt(2) :
                        main.getMar().charAt(0) + ",1");
            } else if ("2".equals(checkCycle)) {
                main.setMar("1");
            } else {
                main.setMar("-");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 4) {
            if ("1".equals(checkCycle)) {
                main.setApr("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getApr().charAt(2) :
                        main.getApr().charAt(0) + ",1");
            } else if ("2".equals(checkCycle)) {
                main.setApr("1");
            } else {
                main.setApr("-");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 5) {
            if ("1".equals(checkCycle)) {
                main.setMay("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getMay().charAt(2) :
                        main.getMay().charAt(0) + ",1");
            } else if ("2".equals(checkCycle) || "3".equals(checkCycle)) {
                main.setMay("1");
            } else {
                main.setMay("-");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 6) {
            if ("1".equals(checkCycle)) {
                main.setJun("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getJun().charAt(2) :
                        main.getJun().charAt(0) + ",1");
            } else if ("2".equals(checkCycle)) {
                main.setJun("1");
            } else {
                main.setJun("-");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 7) {
            if ("1".equals(checkCycle)) {
                main.setJul("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getJul().charAt(2) :
                        main.getJul().charAt(0) + ",1");
            } else if ("2".equals(checkCycle) || "4".equals(checkCycle)) {
                main.setJul("1");
            } else {
                main.setJul("-");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 8) {
            if ("1".equals(checkCycle)) {
                main.setAug("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getAug().charAt(2) :
                        main.getAug().charAt(0) + ",1");
            } else if ("2".equals(checkCycle) || "3".equals(checkCycle)) {
                main.setAug("1");
            } else {
                main.setAug("-");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 9) {
            if ("1".equals(checkCycle)) {
                main.setSep("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getSep().charAt(2) :
                        main.getSep().charAt(0) + ",1");
            } else if ("2".equals(checkCycle)) {
                main.setSep("1");
            } else {
                main.setSep("-");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 10) {
            if ("1".equals(checkCycle)) {
                main.setOct("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getOct().charAt(2) :
                        main.getOct().charAt(0) + ",1");
            } else if ("2".equals(checkCycle)) {
                main.setOct("1");
            } else {
                main.setOct("-");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 11) {
            if ("1".equals(checkCycle)) {
                main.setNov("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getNov().charAt(2) :
                        main.getNov().charAt(0) + ",1");
            } else if ("2".equals(checkCycle) || "3".equals(checkCycle)) {
                main.setNov("1");
            } else {
                main.setNov("-");
            }
        } else if (tPatrolPlan.getPlanQuarter() == 12) {
            if ("1".equals(checkCycle)) {
                main.setDec("1".equals(tPatrolPlan.getDetectionFrequency()) ?
                        "1," + main.getDec().charAt(2) :
                        main.getDec().charAt(0) + ",1");
            } else if ("2".equals(checkCycle)) {
                main.setDec("1");
            } else {
                main.setDec("-");
            }
        }
        tPatrolMainService.updateTPatrolMain(main);
    }

    private void updateDevices(TPatrolPlan tPatrolPlan) {
        switch (tPatrolPlan.getPatrolType()) {
            case "1":
                TFireAnnihilator annihilator = new TFireAnnihilator();
                annihilator.setPlanId(tPatrolPlan.getId());
                for (TFireAnnihilator item : tFireAnnihilatorService.selectTFireAnnihilatorList(annihilator)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireAnnihilatorService.updateTFireAnnihilator(item);
                }
                break;
            case "2":
                TFireWaterCannon cannon = new TFireWaterCannon();
                cannon.setPlanId(tPatrolPlan.getId());
                for (TFireWaterCannon item : tFireWaterCannonService.selectTFireWaterCannonList(cannon)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireWaterCannonService.updateTFireWaterCannon(item);
                }
                break;
            case "3":
                TFirePostFire postFire = new TFirePostFire();
                postFire.setPlanId(tPatrolPlan.getId());
                for (TFirePostFire item : tFirePostFireService.selectTFirePostFireList(postFire)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFirePostFireService.updateTFirePostFire(item);
                }
                break;
            case "4":
                TFireHoseBox hoseBox = new TFireHoseBox();
                hoseBox.setPlanId(tPatrolPlan.getId());
                for (TFireHoseBox item : tFireHoseBoxService.selectTFireHoseBoxList(hoseBox)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireHoseBoxService.updateTFireHoseBox(item);
                }
                break;
            case "5":
                TFireStandpipePatrol standpipe = new TFireStandpipePatrol();
                standpipe.setPlanId(tPatrolPlan.getId());
                for (TFireStandpipePatrol item : tFireStandpipeService.selectTFireStandpipeList(standpipe)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireStandpipeService.updateTFireStandpipe(item);
                }
                break;
            case "6":
                TFireSprinkler sprinkler = new TFireSprinkler();
                sprinkler.setPlanId(tPatrolPlan.getId());
                for (TFireSprinkler item : tFireSprinklerService.selectTFireSprinklerList(sprinkler)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireSprinklerService.updateTFireSprinkler(item);
                }
                break;
            case "7":
                TEmergencyCabinet cabinet = new TEmergencyCabinet();
                cabinet.setPlanId(tPatrolPlan.getId());
                for (TEmergencyCabinet item : tEmergencyCabinetService.selectTEmergencyCabinetList(cabinet)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tEmergencyCabinetService.updateTEmergencyCabinet(item);
                }
                break;
            case "8":
                TFireAlarm alarm = new TFireAlarm();
                alarm.setPlanId(tPatrolPlan.getId());
                for (TFireAlarm item : tFireAlarmService.selectTFireAlarmList(alarm)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireAlarmService.updateTFireAlarm(item);
                }
                break;
            case "9":
                TFireGasShield gasShield = new TFireGasShield();
                gasShield.setPlanId(tPatrolPlan.getId());
                for (TFireGasShield item : tFireGasShieldService.selectTFireGasShieldList(gasShield)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireGasShieldService.updateTFireGasShield(item);
                }
                break;
            case "10":
                TEmergencyPaga paga = new TEmergencyPaga();
                paga.setPlanId(tPatrolPlan.getId());
                for (TEmergencyPaga item : tEmergencyPagaService.selectTEmergencyPagaList(paga)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tEmergencyPagaService.updateTEmergencyPaga(item);
                }
                break;
            case "11":
                TEmergencyCctv cctv = new TEmergencyCctv();
                cctv.setPlanId(tPatrolPlan.getId());
                for (TEmergencyCctv item : tEmergencyCctvService.selectTEmergencyCctvList(cctv)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tEmergencyCctvService.updateTEmergencyCctv(item);
                }
                break;
            case "12":
                TEmergencyEyewash eyewash = new TEmergencyEyewash();
                eyewash.setPlanId(tPatrolPlan.getId());
                for (TEmergencyEyewash item : tEmergencyEyewashService.selectTEmergencyEyewashList(eyewash)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tEmergencyEyewashService.updateTEmergencyEyewash(item);
                }
                break;
            case "13":
                TFireSandbox sandbox = new TFireSandbox();
                sandbox.setPlanId(tPatrolPlan.getId());
                for (TFireSandbox item : tFireSandboxService.selectTFireSandboxList(sandbox)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireSandboxService.updateTFireSandbox(item);
                }
                break;
            case "14":
                TFireDoor door = new TFireDoor();
                door.setPlanId(tPatrolPlan.getId());
                for (TFireDoor item : tFireDoorService.selectTFireDoorList(door)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireDoorService.updateTFireDoor(item);
                }
                break;
            case "15":
                TFireWeathervane weathervane = new TFireWeathervane();
                weathervane.setPlanId(tPatrolPlan.getId());
                for (TFireWeathervane item : tFireWeathervaneService.selectTFireWeathervaneList(weathervane)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireWeathervaneService.updateTFireWeathervane(item);
                }
                break;
            case "16":
                TFireSteamCurtain curtain = new TFireSteamCurtain();
                curtain.setPlanId(tPatrolPlan.getId());
                for (TFireSteamCurtain item : tFireSteamCurtainService.selectTFireSteamCurtainList(curtain)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireSteamCurtainService.updateTFireSteamCurtain(item);
                }
                break;
            case "17":
                TEmergencyCofferdam cofferdam = new TEmergencyCofferdam();
                cofferdam.setPlanId(tPatrolPlan.getId());
                for (TEmergencyCofferdam item : tEmergencyCofferdamService.selectTEmergencyCofferdamList(cofferdam)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tEmergencyCofferdamService.updateTEmergencyCofferdam(item);
                }
                break;
            case "18":
                TCommonuseTester tester = new TCommonuseTester();
                tester.setPlanId(tPatrolPlan.getId());
                for (TCommonuseTester item : TCommonuseTesterService.selectTCommonuseTesterList(tester)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    TCommonuseTesterService.updateTCommonuseTester(item);
                }
                break;
            case "19":
                TCommonuseEarplug earplug = new TCommonuseEarplug();
                earplug.setPlanId(tPatrolPlan.getId());
                for (TCommonuseEarplug item : TCommonuseEarplugService.selectTCommonuseEarplugList(earplug)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    TCommonuseEarplugService.updateTCommonuseEarplug(item);
                }
                break;
            case "20":
                TCommonuseMovement movement = new TCommonuseMovement();
                movement.setPlanId(tPatrolPlan.getId());
                for (TCommonuseMovement item : TCommonuseMovementService.selectTCommonuseMovementList(movement)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    TCommonuseMovementService.updateTCommonuseMovement(item);
                }
                break;
            case "21":
                TCommonuseBicycle bicycle = new TCommonuseBicycle();
                bicycle.setPlanId(tPatrolPlan.getId());
                for (TCommonuseBicycle item : TCommonuseBicycleService.selectTCommonuseBicycleList(bicycle)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    TCommonuseBicycleService.updateTCommonuseBicycle(item);
                }
                break;
            case "22":
                TCommonuseManholeCover manholeCover = new TCommonuseManholeCover();
                manholeCover.setPlanId(tPatrolPlan.getId());
                for (TCommonuseManholeCover item : TCommonuseManholeCoverService.selectTCommonuseManholeCoverList(manholeCover)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    TCommonuseManholeCoverService.updateTCommonuseManholeCover(item);
                }
                break;
            case "23":
                TCommonuseWalkieTalkie walkieTalkie = new TCommonuseWalkieTalkie();
                walkieTalkie.setPlanId(tPatrolPlan.getId());
                for (TCommonuseWalkieTalkie item : TCommonuseWalkieTalkieService.selectTCommonuseWalkieTalkieList(walkieTalkie)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    TCommonuseWalkieTalkieService.updateTCommonuseWalkieTalkie(item);
                }
                break;
            case "24":
                TCommonuseSafetyBelt safetyBelt = new TCommonuseSafetyBelt();
                safetyBelt.setPlanId(tPatrolPlan.getId());
                for (TCommonuseSafetyBelt item : TCommonuseSafetyBeltService.selectTCommonuseSafetyBeltList(safetyBelt)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    TCommonuseSafetyBeltService.updateTCommonuseSafetyBelt(item);
                }
                break;
            case "25":
                TCommonuseDownspout downspout = new TCommonuseDownspout();
                downspout.setPlanId(tPatrolPlan.getId());
                for (TCommonuseDownspout item : TCommonuseDownspoutService.selectTCommonuseDownspoutList(downspout)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    TCommonuseDownspoutService.updateTCommonuseDownspout(item);
                }
                break;
            case "26":
                TCommonuseWaterPump waterPump = new TCommonuseWaterPump();
                waterPump.setPlanId(tPatrolPlan.getId());
                for (TCommonuseWaterPump item : TCommonuseWaterPumpService.selectTCommonuseWaterPumpList(waterPump)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    TCommonuseWaterPumpService.updateTCommonuseWaterPump(item);
                }
                break;
            case "27":
                TFireAidkit aidkit = new TFireAidkit();
                aidkit.setPlanId(tPatrolPlan.getId());
                for (TFireAidkit item : tFireAidkitService.selectTFireAidkitList(aidkit)) {
                    item.setConfirmed(getNickName());
                    item.setCheckDate(new Date());
                    item.setCheckStatus("1");
                    tFireAidkitService.updateTFireAidkit(item);
                }
                break;
        }
    }

    /**
     * 删除检查计划
     */
    @PreAuthorize("@ss.hasPermi('patrol:plan:remove')")
    @Log(title = "检查计划", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        for (Long id : ids) {
            TPatrolPlan tPatrolPlan = tPatrolPlanService.selectTPatrolPlanById(id);
            if (tPatrolPlan.getPlanName().contains("固定计划")) {
                return AjaxResult.error("固定计划不可删除！");
            }if (tPatrolPlan.getPlanName().contains("PSSR临时计划")) {
                return AjaxResult.error("PSSR临时计划不可删除！");
            } else if (tPatrolPlan.getStatus() == 1) {
                return AjaxResult.error("已确认的计划不可删除！");
            }
            switch (tPatrolPlan.getPatrolType()) {
                case "1":
                    TFireAnnihilator annihilator = new TFireAnnihilator();
                    annihilator.setPlanId(tPatrolPlan.getId());
                    for (TFireAnnihilator item : tFireAnnihilatorService.selectTFireAnnihilatorList(annihilator)) {
                        tFireAnnihilatorService.deleteTFireAnnihilatorById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "2":
                    TFireWaterCannon cannon = new TFireWaterCannon();
                    cannon.setPlanId(tPatrolPlan.getId());
                    for (TFireWaterCannon item : tFireWaterCannonService.selectTFireWaterCannonList(cannon)) {
                        tFireWaterCannonService.deleteTFireWaterCannonById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "3":
                    TFirePostFire postFire = new TFirePostFire();
                    postFire.setPlanId(tPatrolPlan.getId());
                    for (TFirePostFire item : tFirePostFireService.selectTFirePostFireList(postFire)) {
                        tFirePostFireService.deleteTFirePostFireById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "4":
                    TFireHoseBox hoseBox = new TFireHoseBox();
                    hoseBox.setPlanId(tPatrolPlan.getId());
                    for (TFireHoseBox item : tFireHoseBoxService.selectTFireHoseBoxList(hoseBox)) {
                        tFireHoseBoxService.deleteTFireHoseBoxById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "5":
                    TFireStandpipePatrol standpipe = new TFireStandpipePatrol();
                    standpipe.setPlanId(tPatrolPlan.getId());
                    for (TFireStandpipePatrol item : tFireStandpipeService.selectTFireStandpipeList(standpipe)) {
                        tFireStandpipeService.deleteTFireStandpipeById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "6":
                    TFireSprinkler sprinkler = new TFireSprinkler();
                    sprinkler.setPlanId(tPatrolPlan.getId());
                    for (TFireSprinkler item : tFireSprinklerService.selectTFireSprinklerList(sprinkler)) {
                        tFireSprinklerService.deleteTFireSprinklerById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "7":
                    TEmergencyCabinet cabinet = new TEmergencyCabinet();
                    cabinet.setPlanId(tPatrolPlan.getId());
                    for (TEmergencyCabinet item : tEmergencyCabinetService.selectTEmergencyCabinetList(cabinet)) {
                        tEmergencyCabinetService.deleteTEmergencyCabinetById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "8":
                    TFireAlarm alarm = new TFireAlarm();
                    alarm.setPlanId(tPatrolPlan.getId());
                    for (TFireAlarm item : tFireAlarmService.selectTFireAlarmList(alarm)) {
                        tFireAlarmService.deleteTFireAlarmById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "9":
                    TFireGasShield gasShield = new TFireGasShield();
                    gasShield.setPlanId(tPatrolPlan.getId());
                    for (TFireGasShield item : tFireGasShieldService.selectTFireGasShieldList(gasShield)) {
                        tFireGasShieldService.deleteTFireGasShieldById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "10":
                    TEmergencyPaga paga = new TEmergencyPaga();
                    paga.setPlanId(tPatrolPlan.getId());
                    for (TEmergencyPaga item : tEmergencyPagaService.selectTEmergencyPagaList(paga)) {
                        tEmergencyPagaService.deleteTEmergencyPagaById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "11":
                    TEmergencyCctv cctv = new TEmergencyCctv();
                    cctv.setPlanId(tPatrolPlan.getId());
                    for (TEmergencyCctv item : tEmergencyCctvService.selectTEmergencyCctvList(cctv)) {
                        tEmergencyCctvService.deleteTEmergencyCctvById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "12":
                    TEmergencyEyewash eyewash = new TEmergencyEyewash();
                    eyewash.setPlanId(tPatrolPlan.getId());
                    for (TEmergencyEyewash item : tEmergencyEyewashService.selectTEmergencyEyewashList(eyewash)) {
                        tEmergencyEyewashService.deleteTEmergencyEyewashById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "13":
                    TFireSandbox sandbox = new TFireSandbox();
                    sandbox.setPlanId(tPatrolPlan.getId());
                    for (TFireSandbox item : tFireSandboxService.selectTFireSandboxList(sandbox)) {
                        tFireSandboxService.deleteTFireSandboxById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "14":
                    TFireDoor door = new TFireDoor();
                    door.setPlanId(tPatrolPlan.getId());
                    for (TFireDoor item : tFireDoorService.selectTFireDoorList(door)) {
                        tFireDoorService.deleteTFireDoorById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "15":
                    TFireWeathervane weathervane = new TFireWeathervane();
                    weathervane.setPlanId(tPatrolPlan.getId());
                    for (TFireWeathervane item : tFireWeathervaneService.selectTFireWeathervaneList(weathervane)) {
                        tFireWeathervaneService.deleteTFireWeathervaneById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "16":
                    TFireSteamCurtain curtain = new TFireSteamCurtain();
                    curtain.setPlanId(tPatrolPlan.getId());
                    for (TFireSteamCurtain item : tFireSteamCurtainService.selectTFireSteamCurtainList(curtain)) {
                        tFireSteamCurtainService.deleteTFireSteamCurtainById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "17":
                    TEmergencyCofferdam cofferdam = new TEmergencyCofferdam();
                    cofferdam.setPlanId(tPatrolPlan.getId());
                    for (TEmergencyCofferdam item : tEmergencyCofferdamService.selectTEmergencyCofferdamList(cofferdam)) {
                        tEmergencyCofferdamService.deleteTEmergencyCofferdamById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "18":
                    TCommonuseTester tester = new TCommonuseTester();
                    tester.setPlanId(tPatrolPlan.getId());
                    for (TCommonuseTester item : TCommonuseTesterService.selectTCommonuseTesterList(tester)) {
                        TCommonuseTesterService.deleteTCommonuseTesterById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "19":
                    TCommonuseEarplug earplug = new TCommonuseEarplug();
                    earplug.setPlanId(tPatrolPlan.getId());
                    for (TCommonuseEarplug item : TCommonuseEarplugService.selectTCommonuseEarplugList(earplug)) {
                        TCommonuseEarplugService.deleteTCommonuseEarplugById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "20":
                    TCommonuseMovement movement = new TCommonuseMovement();
                    movement.setPlanId(tPatrolPlan.getId());
                    for (TCommonuseMovement item : TCommonuseMovementService.selectTCommonuseMovementList(movement)) {
                        TCommonuseMovementService.deleteTCommonuseMovementById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "21":
                    TCommonuseBicycle bicycle = new TCommonuseBicycle();
                    bicycle.setPlanId(tPatrolPlan.getId());
                    for (TCommonuseBicycle item : TCommonuseBicycleService.selectTCommonuseBicycleList(bicycle)) {
                        TCommonuseBicycleService.deleteTCommonuseBicycleById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "22":
                    TCommonuseManholeCover manholeCover = new TCommonuseManholeCover();
                    manholeCover.setPlanId(tPatrolPlan.getId());
                    for (TCommonuseManholeCover item : TCommonuseManholeCoverService.selectTCommonuseManholeCoverList(manholeCover)) {
                        TCommonuseManholeCoverService.deleteTCommonuseManholeCoverById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "23":
                    TCommonuseWalkieTalkie walkieTalkie = new TCommonuseWalkieTalkie();
                    walkieTalkie.setPlanId(tPatrolPlan.getId());
                    for (TCommonuseWalkieTalkie item : TCommonuseWalkieTalkieService.selectTCommonuseWalkieTalkieList(walkieTalkie)) {
                        TCommonuseWalkieTalkieService.deleteTCommonuseWalkieTalkieById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "24":
                    TCommonuseSafetyBelt safetyBelt = new TCommonuseSafetyBelt();
                    safetyBelt.setPlanId(tPatrolPlan.getId());
                    for (TCommonuseSafetyBelt item : TCommonuseSafetyBeltService.selectTCommonuseSafetyBeltList(safetyBelt)) {
                        TCommonuseSafetyBeltService.deleteTCommonuseSafetyBeltById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "25":
                    TCommonuseDownspout downspout = new TCommonuseDownspout();
                    downspout.setPlanId(tPatrolPlan.getId());
                    for (TCommonuseDownspout item : TCommonuseDownspoutService.selectTCommonuseDownspoutList(downspout)) {
                        TCommonuseDownspoutService.deleteTCommonuseDownspoutById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "26":
                    TCommonuseWaterPump waterPump = new TCommonuseWaterPump();
                    waterPump.setPlanId(tPatrolPlan.getId());
                    for (TCommonuseWaterPump item : TCommonuseWaterPumpService.selectTCommonuseWaterPumpList(waterPump)) {
                        TCommonuseWaterPumpService.deleteTCommonuseWaterPumpById(item.getId());
                        TPatrolIssues tPatrolIssues = new TPatrolIssues();
                        tPatrolIssues.setPatrolType(tPatrolPlan.getPatrolType());
                        tPatrolIssues.setLinkId(item.getId());
                        for (TPatrolIssues patrolIssues : tPatrolIssuesService.selectTPatrolIssuesList(tPatrolIssues)) {
                            tPatrolIssuesService.deleteTPatrolIssuesById(patrolIssues.getId());
                        }
                    }
                    break;
                case "27":
                    TFireAidkit aidkit = new TFireAidkit();
                    aidkit.setPlanId(tPatrolPlan.getId());
                    for (TFireAidkit item : tFireAidkitService.selectTFireAidkitList(aidkit)) {
                        tFireAidkitService.selectTFireAidkitById(item.getId());
                    }
                    break;
            }

        }
        return toAjax(tPatrolPlanService.deleteTPatrolPlanByIds(ids));
    }


}
