Commit eb00ed17b4b4103e6e637ce02228648c15f737cf
1 parent
3c9544cf
增加存在档案的档案架不可修改删除的限制
Showing
5 changed files
with
37 additions
and
11 deletions
ruoyi-service/src/main/java/com/ruoyi/service/controller/DeptNodeController.java renamed to ruoyi-service/src/main/java/com/ruoyi/service/controller/DepotNodeController.java
| @@ -25,7 +25,7 @@ import java.util.List; | @@ -25,7 +25,7 @@ import java.util.List; | ||
| 25 | */ | 25 | */ |
| 26 | @RestController | 26 | @RestController |
| 27 | @RequestMapping("/service/depotNode") | 27 | @RequestMapping("/service/depotNode") |
| 28 | -public class DeptNodeController extends BaseController | 28 | +public class DepotNodeController extends BaseController |
| 29 | { | 29 | { |
| 30 | @Autowired | 30 | @Autowired |
| 31 | private DepotNodeService depotNodeService; | 31 | private DepotNodeService depotNodeService; |
| @@ -48,9 +48,9 @@ public class DeptNodeController extends BaseController | @@ -48,9 +48,9 @@ public class DeptNodeController extends BaseController | ||
| 48 | @PreAuthorize("@ss.hasPermi('service:depotNode:export')") | 48 | @PreAuthorize("@ss.hasPermi('service:depotNode:export')") |
| 49 | @Log(title = "库房", businessType = BusinessType.EXPORT) | 49 | @Log(title = "库房", businessType = BusinessType.EXPORT) |
| 50 | @PostMapping("/export") | 50 | @PostMapping("/export") |
| 51 | - public void export(HttpServletResponse response, DepotNode serviceDept) | 51 | + public void export(HttpServletResponse response, DepotNode depotNode) |
| 52 | { | 52 | { |
| 53 | - List<DepotNode> list = depotNodeService.selectDepotNodeList(serviceDept); | 53 | + List<DepotNode> list = depotNodeService.selectDepotNodeList(depotNode); |
| 54 | ExcelUtil<DepotNode> util = new ExcelUtil<DepotNode>(DepotNode.class); | 54 | ExcelUtil<DepotNode> util = new ExcelUtil<DepotNode>(DepotNode.class); |
| 55 | util.exportExcel(response, list, "库房数据"); | 55 | util.exportExcel(response, list, "库房数据"); |
| 56 | } | 56 | } |
| @@ -73,9 +73,9 @@ public class DeptNodeController extends BaseController | @@ -73,9 +73,9 @@ public class DeptNodeController extends BaseController | ||
| 73 | @PreAuthorize("@ss.hasPermi('service:depotNode:add')") | 73 | @PreAuthorize("@ss.hasPermi('service:depotNode:add')") |
| 74 | @Log(title = "库房", businessType = BusinessType.INSERT) | 74 | @Log(title = "库房", businessType = BusinessType.INSERT) |
| 75 | @PostMapping | 75 | @PostMapping |
| 76 | - public AjaxResult add(@RequestBody DepotNode serviceDept) | 76 | + public AjaxResult add(@RequestBody DepotNode depotNode) |
| 77 | { | 77 | { |
| 78 | - return toAjax(depotNodeService.insertDepotNode(serviceDept)); | 78 | + return toAjax(depotNodeService.insertDepotNode(depotNode)); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | /** | 81 | /** |
| @@ -84,9 +84,12 @@ public class DeptNodeController extends BaseController | @@ -84,9 +84,12 @@ public class DeptNodeController extends BaseController | ||
| 84 | @PreAuthorize("@ss.hasPermi('service:depotNode:edit')") | 84 | @PreAuthorize("@ss.hasPermi('service:depotNode:edit')") |
| 85 | @Log(title = "库房", businessType = BusinessType.UPDATE) | 85 | @Log(title = "库房", businessType = BusinessType.UPDATE) |
| 86 | @PutMapping | 86 | @PutMapping |
| 87 | - public AjaxResult edit(@RequestBody DepotNode serviceDept) | 87 | + public AjaxResult edit(@RequestBody DepotNode depotNode) |
| 88 | { | 88 | { |
| 89 | - return toAjax(depotNodeService.updateDepotNode(serviceDept)); | 89 | + if(depotNodeService.selectCountBox(depotNode.getId())>0 && ("1".equals(depotNode.getStatus()) || "2".equals(depotNode.getNodeFlag()))){ |
| 90 | + return AjaxResult.error("档案架存在文件不可修改"); | ||
| 91 | + } | ||
| 92 | + return toAjax(depotNodeService.updateDepotNode(depotNode)); | ||
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | /** | 95 | /** |
| @@ -97,13 +100,17 @@ public class DeptNodeController extends BaseController | @@ -97,13 +100,17 @@ public class DeptNodeController extends BaseController | ||
| 97 | @DeleteMapping("/{depotNodeIds}") | 100 | @DeleteMapping("/{depotNodeIds}") |
| 98 | public AjaxResult remove(@PathVariable Long[] depotNodeIds) | 101 | public AjaxResult remove(@PathVariable Long[] depotNodeIds) |
| 99 | { | 102 | { |
| 103 | + if(depotNodeService.selectCountBox(depotNodeIds[0])>0){ | ||
| 104 | + return AjaxResult.error("档案架存在文件不可删除"); | ||
| 105 | + } | ||
| 100 | return toAjax(depotNodeService.deleteDepotNodeByIds(depotNodeIds)); | 106 | return toAjax(depotNodeService.deleteDepotNodeByIds(depotNodeIds)); |
| 101 | } | 107 | } |
| 102 | 108 | ||
| 103 | @GetMapping("/treeselect") | 109 | @GetMapping("/treeselect") |
| 104 | - public AjaxResult treeselect(DepotNode serviceDept) | 110 | + public AjaxResult treeselect(DepotNode depotNode) |
| 105 | { | 111 | { |
| 106 | - List<DepotNode> depotNodes = depotNodeService.selectDepotNodeList(serviceDept); | 112 | + depotNode.setStatus("0"); |
| 113 | + List<DepotNode> depotNodes = depotNodeService.selectDepotNodeList(depotNode); | ||
| 107 | return AjaxResult.success(depotNodeService.buildDepotNodeTreeSelect(depotNodes)); | 114 | return AjaxResult.success(depotNodeService.buildDepotNodeTreeSelect(depotNodes)); |
| 108 | } | 115 | } |
| 109 | 116 |
ruoyi-service/src/main/java/com/ruoyi/service/mapper/DepotNodeMapper.java
| @@ -45,7 +45,7 @@ public interface DepotNodeMapper | @@ -45,7 +45,7 @@ public interface DepotNodeMapper | ||
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | * 删除库房 | 47 | * 删除库房 |
| 48 | - * | 48 | + * |
| 49 | * @param deptId 库房主键 | 49 | * @param deptId 库房主键 |
| 50 | * @return 结果 | 50 | * @return 结果 |
| 51 | */ | 51 | */ |
| @@ -59,4 +59,12 @@ public interface DepotNodeMapper | @@ -59,4 +59,12 @@ public interface DepotNodeMapper | ||
| 59 | */ | 59 | */ |
| 60 | int deleteDepotNodeByIds(Long[] deptIds); | 60 | int deleteDepotNodeByIds(Long[] deptIds); |
| 61 | 61 | ||
| 62 | + /** | ||
| 63 | + * 查询当前及其子节点是否有上架档案 | ||
| 64 | + * | ||
| 65 | + * @param deptId 库房主键 | ||
| 66 | + * @return 结果 | ||
| 67 | + */ | ||
| 68 | + int selectCountBox(Long deptId); | ||
| 69 | + | ||
| 62 | } | 70 | } |
ruoyi-service/src/main/java/com/ruoyi/service/service/DepotNodeService.java
| @@ -62,6 +62,7 @@ public interface DepotNodeService | @@ -62,6 +62,7 @@ public interface DepotNodeService | ||
| 62 | */ | 62 | */ |
| 63 | int deleteDepotNodeById(Long id); | 63 | int deleteDepotNodeById(Long id); |
| 64 | 64 | ||
| 65 | + int selectCountBox(Long id); | ||
| 65 | 66 | ||
| 66 | List<DepotNode> buildDepotNodeTree(List<DepotNode> depotNodes); | 67 | List<DepotNode> buildDepotNodeTree(List<DepotNode> depotNodes); |
| 67 | /** | 68 | /** |
ruoyi-service/src/main/java/com/ruoyi/service/service/impl/DepotNodeServiceImpl.java
| @@ -107,7 +107,11 @@ public class DepotNodeServiceImpl implements DepotNodeService | @@ -107,7 +107,11 @@ public class DepotNodeServiceImpl implements DepotNodeService | ||
| 107 | return depotNodeMapper.deleteDepotNodeById(id); | 107 | return depotNodeMapper.deleteDepotNodeById(id); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | - | 110 | + @Override |
| 111 | + public int selectCountBox(Long id) | ||
| 112 | + { | ||
| 113 | + return depotNodeMapper.selectCountBox(id); | ||
| 114 | + } | ||
| 111 | 115 | ||
| 112 | /** | 116 | /** |
| 113 | * 构建前端所需要下拉树结构 | 117 | * 构建前端所需要下拉树结构 |
ruoyi-service/src/main/resources/mapper/sevice/DepotNodeMapper.xml
| @@ -76,4 +76,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -76,4 +76,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 76 | </foreach> | 76 | </foreach> |
| 77 | </delete> | 77 | </delete> |
| 78 | 78 | ||
| 79 | + <select id="selectCountBox" resultType="int" parameterType="Long"> | ||
| 80 | + SELECT count(*) from archives_box WHERE deport_node_id in ( | ||
| 81 | + SELECT depotCode FROM `depot_node` where (id=#{id} or FIND_IN_SET(#{id},ancestors)) and nodeFlag='1' | ||
| 82 | + ) | ||
| 83 | + </select> | ||
| 84 | + | ||
| 79 | </mapper> | 85 | </mapper> |
| 80 | \ No newline at end of file | 86 | \ No newline at end of file |