From 6761277da9076f5ee8b3dbc97b4ec4f09f6a5cc9 Mon Sep 17 00:00:00 2001 From: du <1725534722@qq.com> Date: Thu, 12 Dec 2024 10:52:38 +0800 Subject: [PATCH] bugfix --- .../ruoyi/tc/controller/UnitController.java | 141 ++++++++++++++++-- .../java/com/ruoyi/tc/mapper/UnitMapper.java | 7 +- .../com/ruoyi/tc/service/UnitService.java | 7 +- .../tc/service/impl/UnitServiceImpl.java | 10 +- .../main/resources/mapper/AssetAppMapper.xml | 2 +- .../resources/mapper/AssetCurrentMapper.xml | 2 +- .../resources/mapper/AssetEmailMapper.xml | 2 +- .../mapper/AssetMiniProgramsMapper.xml | 2 +- .../mapper/AssetOfficialAccountMapper.xml | 2 +- .../src/main/resources/mapper/UnitMapper.xml | 16 +- 10 files changed, 163 insertions(+), 28 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java index 9182da9..9c6d44b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java @@ -1,6 +1,7 @@ package com.ruoyi.tc.controller; import cn.hutool.core.util.CreditCodeUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.AjaxResult; @@ -13,13 +14,12 @@ import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysUserService; -import com.ruoyi.tc.entity.Unit; +import com.ruoyi.tc.entity.*; +import com.ruoyi.tc.entity.po.*; import com.ruoyi.tc.entity.request.UnitRequest; import com.ruoyi.tc.regular.AssetCurrentChange; import com.ruoyi.tc.regular.UnitChange; -import com.ruoyi.tc.service.ExamineInfoService; -import com.ruoyi.tc.service.UnitOtherConcatService; -import com.ruoyi.tc.service.UnitService; +import com.ruoyi.tc.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; @@ -43,6 +43,8 @@ import java.util.*; @PreAuthorize("@ss.hasAnyRoles('admin,common')") @RequestMapping("/tc/unit") public class UnitController { + @Resource + private AssetCurrentService assetCurrentService; @Resource private UnitService unitService; @@ -64,7 +66,52 @@ public class UnitController { @Resource private AssetCurrentChange assetCurrentChange; + @Resource + private AssetCurrentCpService assetCurrentCpService; + + @Resource + private AssetBusinessFormCpService assetBusinessFormCpService; + + @Resource + private AssetSupplyChainCpService assetSupplyChainCpService; + + @Resource + private AssetBasicNetworkCpService assetBasicNetworkCpService; + @Resource + private AssetSupplyChainService assetSupplyChainService; + + @Resource + private AssetBasicNetworkService assetBasicNetworkService; + + @Resource + private AssetBusinessFormService assetBusinessFormService; + + @Resource + private UnitOtherConcatCpService unitOtherConcatCpService; + + @Resource + private AssetAppService assetAppService; + + @Resource + private AssetAppCpService assetAppCpService; + + @Resource + private AssetEmailService assetEmailService; + + @Resource + private AssetEmailCpService assetEmailCpService; + + @Resource + private AssetOfficialAccountService assetOfficialAccountService; + @Resource + private AssetOfficialAccountCpService assetOfficialAccountCpService; + + @Resource + private AssetMiniProgramsService assetMiniProgramsService; + + @Resource + private AssetMiniProgramsCpService assetMiniProgramsCpService; /** * 获取单位列表 @@ -274,18 +321,84 @@ public class UnitController { @Log(title = "删除单位", businessType = BusinessType.DELETE) @DeleteMapping("/{id}") public AjaxResult remove(@PathVariable Long id) { - List userNames = unitService.selectByIds(id); - //逻辑删除单位和用户 - if (!userNames.isEmpty()) { - for (String it : userNames) { - if (it != null) { - unitService.deleteUsers(it); - } + String userNames = unitService.selectByIds(id); + //根据单位名称查询任务 + List units = unitService.selectTaskIdToDwmc(userNames); + if(units!=null && units.size()>0){ + unitService.deleteUsers(userNames); + unitService.deleteUnits(id); + unitOtherConcatService.deleteByUnitIds(id); + examineInfoService.deleteByUnitIds(id); + + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq("dwmc", userNames); + wrapper1.eq("del_flag","0"); + List list = assetCurrentService.list(wrapper1); + if(list!=null&&list.size()>0){ + list.forEach(x->{ + assetSupplyChainService.deleteByAssetIds(x.getId()); + assetBasicNetworkService.deleteByAssetIds(x.getId()); + assetBusinessFormService.deleteByAssetIds(x.getId()); + unitOtherConcatService.deleteByAssetIds(x.getId()); + QueryWrapper queryWrapper2 = new QueryWrapper<>(); + queryWrapper2.eq("asset_id", x.getId()); + assetSupplyChainCpService.remove(queryWrapper2); + QueryWrapper queryWrapper3 = new QueryWrapper<>(); + queryWrapper3.eq("asset_id", x.getId()); + assetBasicNetworkCpService.remove(queryWrapper3); + QueryWrapper queryWrapper4 = new QueryWrapper<>(); + queryWrapper4.eq("asset_id", x.getId()); + assetBusinessFormCpService.remove(queryWrapper4); + QueryWrapper queryWrapper5 = new QueryWrapper<>(); + queryWrapper5.eq("asset_id", x.getId()); + unitOtherConcatCpService.remove(queryWrapper5); + }); } + QueryWrapper r1 = new QueryWrapper<>(); + r1.eq("ssdw", userNames); + AssetApp e1 = new AssetApp(); + e1.setDelFlag("2"); + assetAppService.update(e1, r1); + + + QueryWrapper r2 = new QueryWrapper<>(); + r2.eq("ssdw", userNames); + AssetEmail e2 = new AssetEmail(); + e2.setDelFlag("2"); + assetEmailService.update(e2, r2); + + QueryWrapper r3 = new QueryWrapper<>(); + r3.eq("ssdw", userNames); + AssetOfficialAccount e3 = new AssetOfficialAccount(); + e3.setDelFlag("2"); + assetOfficialAccountService.update(e3, r3); + + QueryWrapper r4 = new QueryWrapper<>(); + r4.eq("ssdw", userNames); + AssetMiniPrograms e4 = new AssetMiniPrograms(); + e4.setDelFlag("2"); + assetMiniProgramsService.update(e4, r4); + + + QueryWrapper s1 = new QueryWrapper<>(); + s1.eq("ssdw", userNames); + assetAppCpService.remove(s1); + + QueryWrapper s2 = new QueryWrapper<>(); + s2.eq("ssdw", userNames); + assetEmailCpService.remove(s2); + + QueryWrapper s3 = new QueryWrapper<>(); + s3.eq("ssdw", userNames); + assetOfficialAccountCpService.remove(s3); + + QueryWrapper s4 = new QueryWrapper<>(); + s4.eq("ssdw", userNames); + assetMiniProgramsCpService.remove(s4); + + }else { + throw new ServiceException("该单位有在运行的任务,无法删除!"); } - unitService.deleteUnits(id); - unitOtherConcatService.deleteByUnitIds(id); - examineInfoService.deleteByUnitIds(id); return AjaxResult.success(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java index c5ab8cf..6f56a2e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java @@ -36,7 +36,7 @@ public interface UnitMapper extends BaseMapper { /** * 根据id列表查询单位 */ - List selectByIds(Long id); + String selectByIds(Long id); /** * 逻辑删除单位 @@ -86,6 +86,11 @@ public interface UnitMapper extends BaseMapper { */ Integer selectTaskId(@Param("dwmc") String dwmc,@Param("type") String type); + /** + * 根据单位名称查询 + */ + List selectTaskIdToDwmc(@Param("dwmc") String dwmc); + /** * app资产的单位组织架构不为空的部门 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java index d673048..6ace952 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java @@ -48,7 +48,7 @@ public interface UnitService extends IService { /** * 根据id列表查询单位 */ - List selectByIds(Long id); + String selectByIds(Long id); /** * 逻辑删除用户 @@ -81,6 +81,11 @@ public interface UnitService extends IService { */ Integer selectTaskId(String dwmc,String type); + /** + * 根据单位名称查询 + */ + List selectTaskIdToDwmc(String dwmc); + /** * 根据单位查询资产总数 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java index 6289d26..7ef14d5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java @@ -11,6 +11,7 @@ import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysUserService; +import com.ruoyi.tc.entity.AssetTask; import com.ruoyi.tc.entity.Unit; import com.ruoyi.tc.entity.request.GeneralQueryRequest; import com.ruoyi.tc.entity.request.UnitRequest; @@ -102,7 +103,7 @@ public class UnitServiceImpl extends ServiceImpl implements Un * 根据id列表查询单位 */ @Override - public List selectByIds(Long id) { + public String selectByIds(Long id) { return baseMapper.selectByIds(id); } @@ -145,6 +146,13 @@ public class UnitServiceImpl extends ServiceImpl implements Un public Integer selectTaskId(String dwmc, String type) { return baseMapper.selectTaskId(dwmc, type); } + /** + * 根据单位名称查询 + */ + @Override + public List selectTaskIdToDwmc(String dwmc) { + return baseMapper.selectTaskIdToDwmc(dwmc); + } @Override public Integer findBydwmc(String part) { diff --git a/ruoyi-admin/src/main/resources/mapper/AssetAppMapper.xml b/ruoyi-admin/src/main/resources/mapper/AssetAppMapper.xml index 1b4e3d2..11cd552 100644 --- a/ruoyi-admin/src/main/resources/mapper/AssetAppMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/AssetAppMapper.xml @@ -19,7 +19,7 @@ left join unit_info b on a.ssdw = b.nick_name left join sys_dept c on b.dept_id = c.dept_id - a.del_flag = '0' and b.del_flag = '0' + a.del_flag = '0' and a.app_name like concat('%',#{req.yymc},'%') diff --git a/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml b/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml index 885fd6e..c77d443 100644 --- a/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml @@ -17,7 +17,7 @@ left join unit_info b on a.dwmc = b.nick_name left join sys_dept c on b.dept_id = c.dept_id - a. del_flag = '0' and b.del_flag = '0' + a. del_flag = '0' and a.xtmc like concat('%',#{req.xtmc},'%') diff --git a/ruoyi-admin/src/main/resources/mapper/AssetEmailMapper.xml b/ruoyi-admin/src/main/resources/mapper/AssetEmailMapper.xml index eba84dc..8f4a1b9 100644 --- a/ruoyi-admin/src/main/resources/mapper/AssetEmailMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/AssetEmailMapper.xml @@ -19,7 +19,7 @@ left join unit_info b on a.ssdw = b.nick_name left join sys_dept c on b.dept_id = c.dept_id - a.del_flag = '0' and b.del_flag = '0' + a.del_flag = '0' and a.dzyxhz like concat('%',#{req.dzyxhz},'%') diff --git a/ruoyi-admin/src/main/resources/mapper/AssetMiniProgramsMapper.xml b/ruoyi-admin/src/main/resources/mapper/AssetMiniProgramsMapper.xml index 477b563..612a65e 100644 --- a/ruoyi-admin/src/main/resources/mapper/AssetMiniProgramsMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/AssetMiniProgramsMapper.xml @@ -19,7 +19,7 @@ left join unit_info b on a.ssdw = b.nick_name left join sys_dept c on b.dept_id = c.dept_id - a.del_flag = '0' and b.del_flag = '0' + a.del_flag = '0' and a.xcxmc like concat('%',#{req.xcxmc},'%') diff --git a/ruoyi-admin/src/main/resources/mapper/AssetOfficialAccountMapper.xml b/ruoyi-admin/src/main/resources/mapper/AssetOfficialAccountMapper.xml index 951207e..58813c2 100644 --- a/ruoyi-admin/src/main/resources/mapper/AssetOfficialAccountMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/AssetOfficialAccountMapper.xml @@ -23,7 +23,7 @@ left join unit_info b on a.ssdw = b.nick_name left join sys_dept c on b.dept_id = c.dept_id - a.del_flag = '0' and b.del_flag = '0' + a.del_flag = '0' and a.gzhmc like concat('%',#{req.gzhmc},'%') diff --git a/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml b/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml index e8b55bb..3467425 100644 --- a/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml @@ -125,7 +125,7 @@ select id from asset_task where dwmc like concat('%',#{dwmc},'%') and type like concat('%',#{type},'%') and task_status = '1' + + update unit_info set del_flag = '2'