From 30001080d67ec74a333aa4199865def38011d1b8 Mon Sep 17 00:00:00 2001 From: du <1725534722@qq.com> Date: Wed, 20 Nov 2024 17:32:04 +0800 Subject: [PATCH 1/3] bugfix --- .../java/com/ruoyi/tc/controller/AssetCurrentController.java | 2 +- ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java index 0589868..2c30cc9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java @@ -151,7 +151,7 @@ public class AssetCurrentController extends BaseController { */ @ApiOperation(value = "修改数据") @PutMapping - public AjaxResult update(@RequestBody @Valid AssetCurrent assetCurrent) { + public AjaxResult update(@RequestBody AssetCurrent assetCurrent) { StringBuilder a = new StringBuilder(); if(!assetCurrent.getGlymList().isEmpty()){ assetCurrent.getGlymList().forEach(x->{ 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 f973dbc..20c89e9 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 @@ -54,7 +54,7 @@ public interface UnitService extends IService { /** * 逻辑删除单位 */ - void deleteUnits(List ids); + void deleteUnits(Long ids); From ade14fdcc09221ad589aee5c0a4b367eb210fc76 Mon Sep 17 00:00:00 2001 From: du <1725534722@qq.com> Date: Thu, 21 Nov 2024 15:36:07 +0800 Subject: [PATCH 2/3] bugfix --- .../tc/controller/AssetCurrentController.java | 55 +++-------- .../ruoyi/tc/controller/UnitController.java | 2 +- .../java/com/ruoyi/tc/entity/AssetExport.java | 2 +- .../ruoyi/tc/mapper/AssetCurrentMapper.java | 3 +- .../ruoyi/tc/service/AssetCurrentService.java | 3 +- .../service/impl/AssetCurrentServiceImpl.java | 4 +- .../resources/mapper/AssetCurrentMapper.xml | 91 +++++++++++++++++++ 7 files changed, 111 insertions(+), 49 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java index 2c30cc9..c6ce1df 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java @@ -13,6 +13,7 @@ import com.ruoyi.tc.entity.request.AssetCurrentPageRequest; import com.ruoyi.tc.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -95,6 +96,7 @@ public class AssetCurrentController extends BaseController { */ @ApiOperation(value = "新增数据") @PostMapping + @PreAuthorize("@ss.hasAnyRoles('admin,common')") @Transactional(rollbackFor = Exception.class) public AjaxResult insert(@RequestBody AssetCurrent assetCurrent) { StringBuilder a = new StringBuilder(); @@ -150,6 +152,7 @@ public class AssetCurrentController extends BaseController { * @return 修改结果 */ @ApiOperation(value = "修改数据") + @PreAuthorize("@ss.hasAnyRoles('admin,common')") @PutMapping public AjaxResult update(@RequestBody AssetCurrent assetCurrent) { StringBuilder a = new StringBuilder(); @@ -203,6 +206,7 @@ public class AssetCurrentController extends BaseController { * @param id 主键 * @return 删除结果 */ + @PreAuthorize("@ss.hasAnyRoles('admin,common')") @ApiOperation(value = "删除数据") @DeleteMapping("/{id}") public AjaxResult delete(@PathVariable Long id) { @@ -231,57 +235,22 @@ public class AssetCurrentController extends BaseController { @ApiOperation(value = "导出现有资产") @PostMapping("/export") public void exportProject(HttpServletResponse response, AssetCurrentPageRequest as) { - List list = assetCurrentService.page(as); - List proList = new ArrayList<>(); - for (AssetCurrent x : list) { - //对应的资产 - AssetExport assetExport = new AssetExport(); - BeanUtil.copyProperties(x, assetExport); - //查找对应的系统建设单位 - AssetSupplyChain jsdw = assetSupplyChainService.getJsdw(x.getId()); - BeanUtil.copyProperties(jsdw, assetExport); - - //查找对应的系统运营单位 - AssetSupplyChain yydw = assetSupplyChainService.getYydw(x.getId()); - assetExport.setGyszcdz1(yydw.getGyszcdz()); - assetExport.setLxr1(yydw.getLxr()); - assetExport.setLxdh1(yydw.getLxdh()); - assetExport.setSfwtc1(yydw.getSfwtc()); - assetExport.setName1(yydw.getName()); - assetExport.setTyshxydm1(yydw.getTyshxydm()); - List byList = assetBasicNetworkService.getByAssetId(x.getId()); - for (AssetBasicNetwork items : byList) { - if (items.getType() == 1) { - //查找对应的服务器信息 - BeanUtil.copyProperties(items, assetExport); - } - if (items.getType() == 2) { - //查找对应网络设备 - assetExport.setWlpp(items.getPp()); - assetExport.setWlyjxh(items.getYjxh()); - assetExport.setWlyjbsxx(items.getYjbsxx()); - assetExport.setWlsblx(items.getSblx()); - assetExport.setWlyjbbxx(items.getYjbbxx()); - assetExport.setWlyjxlh(items.getYjxlh()); - assetExport.setWlsbIp(items.getSbIp()); - assetExport.setWlyjyt(items.getYjyt()); - } - if (items.getType() == 3) { - //查找对应安全设备 - assetExport.setAqwlpp(items.getPp()); - assetExport.setAqwlsblx(items.getSblx()); - assetExport.setAqwlsbIp(items.getSbIp()); - } + try { + if (!SecurityUtils.getLoginUser().getUser().isAdmin() && !SecurityUtils.hasRole("common")) { + as.setDwmc(SecurityUtils.getLoginUser().getUser().getNickName()); } - proList.add(assetExport); + } catch (Exception e) { + throw new ServiceException("获取用户信息异常"); } + List list = assetCurrentService.page(as); ExcelUtil util = new ExcelUtil<>(AssetExport.class); - util.exportExcel(response, proList, "现有资产记录"); + util.exportExcel(response, list, "现有资产记录"); } /** * 导入现有资产 */ + @PreAuthorize("@ss.hasAnyRoles('admin,common')") @ApiOperation(value = "导入现有资产") @PostMapping(value = "/import", consumes = "multipart/form-data") public AjaxResult export(@RequestPart("file") MultipartFile file) throws Exception { 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 a48fefd..65781f9 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 @@ -31,7 +31,7 @@ import java.util.List; */ @Api(tags = "单位表控制层") @RestController -//@PreAuthorize("@ss.hasAnyRoles('admin,common')") +@PreAuthorize("@ss.hasAnyRoles('admin,common')") @RequestMapping("/tc/unit") public class UnitController { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetExport.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetExport.java index 11373b9..83d710c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetExport.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetExport.java @@ -126,7 +126,7 @@ public class AssetExport extends AssetCurrent{ private String yjbsxx; @Excel(name = "*网络设备-设备类型",width=26,sort = 86) - private String wlsblx; + private String wlsblx; @Excel(name = "*网络设备-品牌",width=26,sort = 87) private String wlpp; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/AssetCurrentMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/AssetCurrentMapper.java index 54111fc..e6b3946 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/AssetCurrentMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/AssetCurrentMapper.java @@ -3,6 +3,7 @@ package com.ruoyi.tc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.tc.entity.AssetCurrent; +import com.ruoyi.tc.entity.AssetExport; import com.ruoyi.tc.entity.request.AssetCurrentPageRequest; import org.apache.ibatis.annotations.Param; @@ -25,7 +26,7 @@ public interface AssetCurrentMapper extends BaseMapper { */ Page page(Page page,@Param("req") AssetCurrentPageRequest as); - List page(@Param("req") AssetCurrentPageRequest as); + List page1(@Param("req") AssetCurrentPageRequest as); /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/AssetCurrentService.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/AssetCurrentService.java index aa95b58..936a1a8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/AssetCurrentService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/AssetCurrentService.java @@ -3,6 +3,7 @@ package com.ruoyi.tc.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.tc.entity.AssetCurrent; +import com.ruoyi.tc.entity.AssetExport; import com.ruoyi.tc.entity.request.AssetCurrentPageRequest; import java.io.Serializable; @@ -31,7 +32,7 @@ public interface AssetCurrentService extends IService { * @param as 查询实体 * @return 所有数据 */ - List page( AssetCurrentPageRequest as ); + List page(AssetCurrentPageRequest as ); /** * 通过主键查询单条数据 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java index 8b3bfcd..fc200cd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java @@ -54,8 +54,8 @@ public class AssetCurrentServiceImpl extends ServiceImpl page(AssetCurrentPageRequest as) { - return baseMapper.page(as); + public List page(AssetCurrentPageRequest as) { + return baseMapper.page1(as); } /** diff --git a/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml b/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml index a955d86..4349c0f 100644 --- a/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml @@ -30,6 +30,97 @@ + + update asset_current set del_flag = '2' From 69eeadf8fb348d97cca3b07261d007d7dad218d7 Mon Sep 17 00:00:00 2001 From: du <1725534722@qq.com> Date: Thu, 21 Nov 2024 17:26:53 +0800 Subject: [PATCH 3/3] bugfix --- .../com/ruoyi/tc/controller/AssetCurrentController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java index c6ce1df..00e8a13 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java @@ -102,7 +102,7 @@ public class AssetCurrentController extends BaseController { StringBuilder a = new StringBuilder(); if(!assetCurrent.getGlymList().isEmpty()){ assetCurrent.getGlymList().forEach(x->{ - a.append(x); + a.append(x.getKey()); a.append(","); }); } @@ -110,7 +110,7 @@ public class AssetCurrentController extends BaseController { StringBuilder b = new StringBuilder(); if(!assetCurrent.getGlIpList().isEmpty()){ assetCurrent.getGlymList().forEach(x->{ - b.append(x); + b.append(x.getKey()); b.append(","); }); } @@ -158,7 +158,7 @@ public class AssetCurrentController extends BaseController { StringBuilder a = new StringBuilder(); if(!assetCurrent.getGlymList().isEmpty()){ assetCurrent.getGlymList().forEach(x->{ - a.append(x); + a.append(x.getKey()); a.append(","); }); } @@ -166,7 +166,7 @@ public class AssetCurrentController extends BaseController { StringBuilder b = new StringBuilder(); if(!assetCurrent.getGlIpList().isEmpty()){ assetCurrent.getGlymList().forEach(x->{ - b.append(x); + b.append(x.getKey()); b.append(","); }); }