设备类型删除时验证设备

This commit is contained in:
JinLu.Yin 2022-06-13 14:18:46 +08:00
parent f0b08fa752
commit dde5d6a26b

View File

@ -3,7 +3,10 @@ package com.ktg.mes.dv.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollUtil;
import com.ktg.common.constant.UserConstants; import com.ktg.common.constant.UserConstants;
import com.ktg.mes.dv.domain.DvMachinery;
import com.ktg.mes.dv.service.IDvMachineryService;
import com.ktg.system.strategy.AutoCodeUtil; import com.ktg.system.strategy.AutoCodeUtil;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -36,6 +39,9 @@ public class DvMachineryTypeController extends BaseController
@Autowired @Autowired
private IDvMachineryTypeService dvMachineryTypeService; private IDvMachineryTypeService dvMachineryTypeService;
@Autowired
private IDvMachineryService dvMachineryService;
@Autowired @Autowired
private AutoCodeUtil autoCodeUtil; private AutoCodeUtil autoCodeUtil;
/** /**
@ -103,6 +109,16 @@ public class DvMachineryTypeController extends BaseController
@DeleteMapping("/{machineryTypeIds}") @DeleteMapping("/{machineryTypeIds}")
public AjaxResult remove(@PathVariable Long[] machineryTypeIds) public AjaxResult remove(@PathVariable Long[] machineryTypeIds)
{ {
for (Long typeId:machineryTypeIds
) {
DvMachinery param = new DvMachinery();
param.setMachineryId(typeId);
List<DvMachinery> machinerys = dvMachineryService.selectDvMachineryList(param);
if(CollUtil.isNotEmpty(machinerys)){
return AjaxResult.error("设备类型下已配置了设备,不能删除!");
}
}
return toAjax(dvMachineryTypeService.deleteDvMachineryTypeByMachineryTypeIds(machineryTypeIds)); return toAjax(dvMachineryTypeService.deleteDvMachineryTypeByMachineryTypeIds(machineryTypeIds));
} }
} }