|
@@ -11,21 +11,28 @@ import org.springblade.core.excel.util.ExcelUtil;
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.secure.BladeUser;
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.support.Kv;
|
|
import org.springblade.core.tool.support.Kv;
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
import org.springblade.manager.dto.*;
|
|
import org.springblade.manager.dto.*;
|
|
import org.springblade.manager.entity.*;
|
|
import org.springblade.manager.entity.*;
|
|
import org.springblade.manager.excel.WbsFormElementBatchExcel;
|
|
import org.springblade.manager.excel.WbsFormElementBatchExcel;
|
|
import org.springblade.manager.excel.WbsTreeExcel;
|
|
import org.springblade.manager.excel.WbsTreeExcel;
|
|
import org.springblade.manager.mapper.WbsInfoMapper;
|
|
import org.springblade.manager.mapper.WbsInfoMapper;
|
|
|
|
+import org.springblade.manager.mapper.WbsTreeContractMapper;
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
import org.springblade.manager.service.IFormulaService;
|
|
import org.springblade.manager.service.IFormulaService;
|
|
import org.springblade.manager.service.IWbsFormElementService;
|
|
import org.springblade.manager.service.IWbsFormElementService;
|
|
import org.springblade.manager.vo.*;
|
|
import org.springblade.manager.vo.*;
|
|
import org.springblade.system.cache.DictCache;
|
|
import org.springblade.system.cache.DictCache;
|
|
|
|
+import org.springblade.system.entity.Role;
|
|
import org.springblade.system.enums.DictEnum;
|
|
import org.springblade.system.enums.DictEnum;
|
|
|
|
+import org.springblade.system.feign.ISysClient;
|
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
|
+import org.springblade.system.user.feign.IUserClient;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -50,7 +57,11 @@ public class WbsTreeController extends BladeController {
|
|
private final IWbsTreeService wbsTreeService;
|
|
private final IWbsTreeService wbsTreeService;
|
|
private final IWbsFormElementService wbsFormElementService;
|
|
private final IWbsFormElementService wbsFormElementService;
|
|
private final WbsTreePrivateMapper wbsTreePrivateMapper;
|
|
private final WbsTreePrivateMapper wbsTreePrivateMapper;
|
|
|
|
+ private final WbsTreeContractMapper wbsTreeContractMapper;
|
|
private final WbsInfoMapper wbsInfoMapper;
|
|
private final WbsInfoMapper wbsInfoMapper;
|
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
|
+ private final IUserClient iUserClient;
|
|
|
|
+ private final ISysClient iSysClient;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 详情
|
|
* 详情
|
|
@@ -170,29 +181,50 @@ public class WbsTreeController extends BladeController {
|
|
@ApiImplicitParam(name = "id", value = "表单id", required = true)
|
|
@ApiImplicitParam(name = "id", value = "表单id", required = true)
|
|
public R removeTableById(@RequestParam("id") String id) {
|
|
public R removeTableById(@RequestParam("id") String id) {
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
- /*List<WbsFormElementVO> wbsFormElements = wbsTreeService.selectFormElements(id,null); //此处nodeId为后续其他开发加的,不知道有什么用,所以传null
|
|
|
|
- if (wbsFormElements.size() > 0) {
|
|
|
|
- throw new ServiceException("该表单中存在元素,删除失败");
|
|
|
|
- }*/
|
|
|
|
- Long wbsTreePrivates = wbsTreePrivateMapper.selectCount(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
|
- .eq(WbsTreePrivate::getStatus, 1)
|
|
|
|
- .eq(WbsTreePrivate::getId, id));
|
|
|
|
- if (wbsTreePrivates > 0L) {
|
|
|
|
- throw new ServiceException("该表单已被项目引用,删除失败");
|
|
|
|
|
|
+ boolean var = false;
|
|
|
|
+ if (ObjectUtil.isEmpty(AuthUtil.getUser())) {
|
|
|
|
+ throw new ServiceException("获取当前用户信息失败");
|
|
|
|
+ }
|
|
|
|
+ User user = iUserClient.userInfoById(AuthUtil.getUserId()).getData();
|
|
|
|
+ if (user == null) {
|
|
|
|
+ throw new ServiceException("获取当前用户信息失败");
|
|
|
|
+ } else {
|
|
|
|
+ String[] roles = user.getRoleId().split(",");
|
|
|
|
+ for (String roleId : roles) {
|
|
|
|
+ Role data = iSysClient.getRole(Long.parseLong(roleId)).getData();
|
|
|
|
+ if (data.getRoleName().equals("超级管理员") && data.getRoleAlias().equals("administrator")) {
|
|
|
|
+ var = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if (wbsTreeService.removeTableById(id)) {
|
|
|
|
- //如果当前节点没有表单,那么修改is_exist_form = 0
|
|
|
|
- WbsTree wbsTreeZi = wbsTreeService.getBaseMapper().selectOne(Wrappers.<WbsTree>lambdaQuery().eq(WbsTree::getId, id));
|
|
|
|
- if (wbsTreeZi != null) {
|
|
|
|
- WbsTree wbsTreeFu = wbsTreeService.getBaseMapper().selectOne(Wrappers.<WbsTree>lambdaQuery().eq(WbsTree::getId, wbsTreeZi.getParentId()));
|
|
|
|
- if (wbsTreeFu != null) {
|
|
|
|
- List<WbsTree> nodes = wbsTreeService.getBaseMapper().selectList(Wrappers.<WbsTree>lambdaQuery().eq(WbsTree::getParentId, wbsTreeFu.getId()));
|
|
|
|
- if (nodes.size() == 0) {
|
|
|
|
- wbsTreeService.update(Wrappers.<WbsTree>lambdaUpdate().set(WbsTree::getIsExistForm, 0).eq(WbsTree::getId, wbsTreeFu.getId()));
|
|
|
|
|
|
+
|
|
|
|
+ if (var) {
|
|
|
|
+ if (wbsTreeService.removeTableById(id)) {
|
|
|
|
+ //如果当前节点没有表单,那么修改is_exist_form = 0
|
|
|
|
+ WbsTree wbsTreeZi = wbsTreeService.getBaseMapper().selectOne(Wrappers.<WbsTree>lambdaQuery().eq(WbsTree::getId, id));
|
|
|
|
+ if (wbsTreeZi != null) {
|
|
|
|
+ WbsTree wbsTreeFu = wbsTreeService.getBaseMapper().selectOne(Wrappers.<WbsTree>lambdaQuery().eq(WbsTree::getId, wbsTreeZi.getParentId()));
|
|
|
|
+ if (wbsTreeFu != null) {
|
|
|
|
+ List<WbsTree> nodes = wbsTreeService.getBaseMapper().selectList(Wrappers.<WbsTree>lambdaQuery().eq(WbsTree::getParentId, wbsTreeFu.getId()));
|
|
|
|
+ if (nodes.size() == 0) {
|
|
|
|
+ wbsTreeService.update(Wrappers.<WbsTree>lambdaUpdate().set(WbsTree::getIsExistForm, 0).eq(WbsTree::getId, wbsTreeFu.getId()));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //删除对应到项目合同段的表
|
|
|
|
+ List<Long> projectPKeyIds = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
|
+ .select(WbsTreePrivate::getPKeyId).eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getType, 2).eq(WbsTreePrivate::getId, id)).stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
|
|
|
|
+ List<Long> contractPKeyIds = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
|
+ .select(WbsTreeContract::getPKeyId).eq(WbsTreeContract::getStatus, 1).eq(WbsTreeContract::getType, 2).and(obj -> obj.eq(WbsTreeContract::getId, id).or().eq(WbsTreeContract::getOldId, id))).stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
|
|
|
|
+ jdbcTemplate.execute("update m_wbs_tree_private set is_deleted = 1 where p_key_id in(" + StringUtils.join(projectPKeyIds, ",") + ")");
|
|
|
|
+ jdbcTemplate.execute("update m_wbs_tree_contract set is_deleted = 1 where p_key_id in(" + StringUtils.join(contractPKeyIds, ",") + ")");
|
|
|
|
+
|
|
|
|
+ return R.success("删除成功");
|
|
}
|
|
}
|
|
- return R.success("删除成功");
|
|
|
|
|
|
+ } else {
|
|
|
|
+ throw new ServiceException("没有管理员权限,操作失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return R.fail("删除失败");
|
|
return R.fail("删除失败");
|
|
@@ -205,13 +237,13 @@ public class WbsTreeController extends BladeController {
|
|
@ApiOperationSupport(order = 8)
|
|
@ApiOperationSupport(order = 8)
|
|
@ApiOperation(value = "根据表单id查询所有元素", notes = "传入表单id")
|
|
@ApiOperation(value = "根据表单id查询所有元素", notes = "传入表单id")
|
|
@ApiImplicitParam(name = "id", value = "表单id", required = true)
|
|
@ApiImplicitParam(name = "id", value = "表单id", required = true)
|
|
- public R<List<WbsFormElementVO>> selectFormElements(@RequestParam("id") String id, String nodeId, String search,Integer type) {
|
|
|
|
|
|
+ public R<List<WbsFormElementVO>> selectFormElements(@RequestParam("id") String id, String nodeId, String search, Integer type) {
|
|
List<WbsFormElementVO> wbsFormElements = null;
|
|
List<WbsFormElementVO> wbsFormElements = null;
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
-// if(StringUtils.isNotEmpty(nodeId)){
|
|
|
|
-// id=nodeId;
|
|
|
|
-// }
|
|
|
|
- wbsFormElements = wbsTreeService.selectFormElements(id,nodeId,type);
|
|
|
|
|
|
+ /*if(StringUtils.isNotEmpty(nodeId)){
|
|
|
|
+ id=nodeId;
|
|
|
|
+ }*/
|
|
|
|
+ wbsFormElements = wbsTreeService.selectFormElements(id, nodeId, type);
|
|
if (wbsFormElements.size() > 0) {
|
|
if (wbsFormElements.size() > 0) {
|
|
if (StringUtils.isNotEmpty(search)) {
|
|
if (StringUtils.isNotEmpty(search)) {
|
|
wbsFormElements = wbsFormElements.stream().filter(e -> e.getEName().contains(search)).collect(Collectors.toList());
|
|
wbsFormElements = wbsFormElements.stream().filter(e -> e.getEName().contains(search)).collect(Collectors.toList());
|
|
@@ -392,10 +424,10 @@ public class WbsTreeController extends BladeController {
|
|
@ApiOperationSupport(order = 20)
|
|
@ApiOperationSupport(order = 20)
|
|
@ApiOperation(value = "根据表单id查询所有元素", notes = "传入表单id")
|
|
@ApiOperation(value = "根据表单id查询所有元素", notes = "传入表单id")
|
|
@ApiImplicitParam(name = "id", value = "表单id", required = true)
|
|
@ApiImplicitParam(name = "id", value = "表单id", required = true)
|
|
- public R<List<WbsFormElementVO>> selectPrivateFormElements(@RequestParam("id") String id,String eName) {
|
|
|
|
|
|
+ public R<List<WbsFormElementVO>> selectPrivateFormElements(@RequestParam("id") String id, String eName) {
|
|
List<WbsFormElementVO> wbsFormElements = null;
|
|
List<WbsFormElementVO> wbsFormElements = null;
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
- wbsFormElements = wbsTreeService.selectPrivateFormElements(id,eName);
|
|
|
|
|
|
+ wbsFormElements = wbsTreeService.selectPrivateFormElements(id, eName);
|
|
if (wbsFormElements.size() > 0) {
|
|
if (wbsFormElements.size() > 0) {
|
|
return R.data(wbsFormElements);
|
|
return R.data(wbsFormElements);
|
|
}
|
|
}
|