dongdingding 2 months ago
commit 7bc094af3d

@ -13,6 +13,7 @@ import com.ruoyi.tc.entity.request.AssetCurrentPageRequest;
import com.ruoyi.tc.service.*; import com.ruoyi.tc.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -95,12 +96,13 @@ public class AssetCurrentController extends BaseController {
*/ */
@ApiOperation(value = "新增数据") @ApiOperation(value = "新增数据")
@PostMapping @PostMapping
@PreAuthorize("@ss.hasAnyRoles('admin,common')")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult insert(@RequestBody AssetCurrent assetCurrent) { public AjaxResult insert(@RequestBody AssetCurrent assetCurrent) {
StringBuilder a = new StringBuilder(); StringBuilder a = new StringBuilder();
if(!assetCurrent.getGlymList().isEmpty()){ if(!assetCurrent.getGlymList().isEmpty()){
assetCurrent.getGlymList().forEach(x->{ assetCurrent.getGlymList().forEach(x->{
a.append(x); a.append(x.getKey());
a.append(","); a.append(",");
}); });
} }
@ -108,7 +110,7 @@ public class AssetCurrentController extends BaseController {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
if(!assetCurrent.getGlIpList().isEmpty()){ if(!assetCurrent.getGlIpList().isEmpty()){
assetCurrent.getGlymList().forEach(x->{ assetCurrent.getGlymList().forEach(x->{
b.append(x); b.append(x.getKey());
b.append(","); b.append(",");
}); });
} }
@ -150,12 +152,13 @@ public class AssetCurrentController extends BaseController {
* @return * @return
*/ */
@ApiOperation(value = "修改数据") @ApiOperation(value = "修改数据")
@PreAuthorize("@ss.hasAnyRoles('admin,common')")
@PutMapping @PutMapping
public AjaxResult update(@RequestBody @Valid AssetCurrent assetCurrent) { public AjaxResult update(@RequestBody AssetCurrent assetCurrent) {
StringBuilder a = new StringBuilder(); StringBuilder a = new StringBuilder();
if(!assetCurrent.getGlymList().isEmpty()){ if(!assetCurrent.getGlymList().isEmpty()){
assetCurrent.getGlymList().forEach(x->{ assetCurrent.getGlymList().forEach(x->{
a.append(x); a.append(x.getKey());
a.append(","); a.append(",");
}); });
} }
@ -163,7 +166,7 @@ public class AssetCurrentController extends BaseController {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
if(!assetCurrent.getGlIpList().isEmpty()){ if(!assetCurrent.getGlIpList().isEmpty()){
assetCurrent.getGlymList().forEach(x->{ assetCurrent.getGlymList().forEach(x->{
b.append(x); b.append(x.getKey());
b.append(","); b.append(",");
}); });
} }
@ -203,6 +206,7 @@ public class AssetCurrentController extends BaseController {
* @param id * @param id
* @return * @return
*/ */
@PreAuthorize("@ss.hasAnyRoles('admin,common')")
@ApiOperation(value = "删除数据") @ApiOperation(value = "删除数据")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
public AjaxResult delete(@PathVariable Long id) { public AjaxResult delete(@PathVariable Long id) {
@ -231,57 +235,22 @@ public class AssetCurrentController extends BaseController {
@ApiOperation(value = "导出现有资产") @ApiOperation(value = "导出现有资产")
@PostMapping("/export") @PostMapping("/export")
public void exportProject(HttpServletResponse response, AssetCurrentPageRequest as) { public void exportProject(HttpServletResponse response, AssetCurrentPageRequest as) {
List<AssetCurrent> list = assetCurrentService.page(as); try {
List<AssetExport> proList = new ArrayList<>(); if (!SecurityUtils.getLoginUser().getUser().isAdmin() && !SecurityUtils.hasRole("common")) {
for (AssetCurrent x : list) { as.setDwmc(SecurityUtils.getLoginUser().getUser().getNickName());
//对应的资产
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<AssetBasicNetwork> 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());
}
} }
proList.add(assetExport); } catch (Exception e) {
throw new ServiceException("获取用户信息异常");
} }
List<AssetExport> list = assetCurrentService.page(as);
ExcelUtil<AssetExport> util = new ExcelUtil<>(AssetExport.class); ExcelUtil<AssetExport> util = new ExcelUtil<>(AssetExport.class);
util.exportExcel(response, proList, "现有资产记录"); util.exportExcel(response, list, "现有资产记录");
} }
/** /**
* *
*/ */
@PreAuthorize("@ss.hasAnyRoles('admin,common')")
@ApiOperation(value = "导入现有资产") @ApiOperation(value = "导入现有资产")
@PostMapping(value = "/import", consumes = "multipart/form-data") @PostMapping(value = "/import", consumes = "multipart/form-data")
public AjaxResult export(@RequestPart("file") MultipartFile file) throws Exception { public AjaxResult export(@RequestPart("file") MultipartFile file) throws Exception {

@ -31,7 +31,7 @@ import java.util.List;
*/ */
@Api(tags = "单位表控制层") @Api(tags = "单位表控制层")
@RestController @RestController
//@PreAuthorize("@ss.hasAnyRoles('admin,common')") @PreAuthorize("@ss.hasAnyRoles('admin,common')")
@RequestMapping("/tc/unit") @RequestMapping("/tc/unit")
public class UnitController { public class UnitController {

@ -3,6 +3,7 @@ package com.ruoyi.tc.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.tc.entity.AssetCurrent; import com.ruoyi.tc.entity.AssetCurrent;
import com.ruoyi.tc.entity.AssetExport;
import com.ruoyi.tc.entity.request.AssetCurrentPageRequest; import com.ruoyi.tc.entity.request.AssetCurrentPageRequest;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -25,7 +26,7 @@ public interface AssetCurrentMapper extends BaseMapper<AssetCurrent> {
*/ */
Page<AssetCurrent> page(Page<AssetCurrent> page,@Param("req") AssetCurrentPageRequest as); Page<AssetCurrent> page(Page<AssetCurrent> page,@Param("req") AssetCurrentPageRequest as);
List<AssetCurrent> page(@Param("req") AssetCurrentPageRequest as); List<AssetExport> page1(@Param("req") AssetCurrentPageRequest as);
/** /**

@ -3,6 +3,7 @@ package com.ruoyi.tc.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.tc.entity.AssetCurrent; import com.ruoyi.tc.entity.AssetCurrent;
import com.ruoyi.tc.entity.AssetExport;
import com.ruoyi.tc.entity.request.AssetCurrentPageRequest; import com.ruoyi.tc.entity.request.AssetCurrentPageRequest;
import java.io.Serializable; import java.io.Serializable;
@ -31,7 +32,7 @@ public interface AssetCurrentService extends IService<AssetCurrent> {
* @param as * @param as
* @return * @return
*/ */
List<AssetCurrent> page( AssetCurrentPageRequest as ); List<AssetExport> page(AssetCurrentPageRequest as );
/** /**
* *

@ -54,8 +54,8 @@ public class AssetCurrentServiceImpl extends ServiceImpl<AssetCurrentMapper, Ass
* @return * @return
*/ */
@Override @Override
public List<AssetCurrent> page(AssetCurrentPageRequest as) { public List<AssetExport> page(AssetCurrentPageRequest as) {
return baseMapper.page(as); return baseMapper.page1(as);
} }
/** /**

@ -30,6 +30,97 @@
</where> </where>
</select> </select>
<select id="page1" resultType="com.ruoyi.tc.entity.AssetExport">
SELECT
a.*,
b.*,
c.*,
d.*,
e.*,
l.*
FROM
asset_current a
LEFT JOIN ( SELECT asset_id, NAME, tyshxydm, lxr, lxdh, gyszcdz, sfwtc FROM asset_supply_chain WHERE type = 5 GROUP BY asset_id ) b ON a.id = b.asset_id
LEFT JOIN (
SELECT
asset_id,
NAME AS name1,
tyshxydm AS tyshxydm1,
lxr AS lxr1,
lxdh AS lxdh1,
gyszcdz AS gyszcdz1,
sfwtc AS sfwtc1
FROM
asset_supply_chain
WHERE
type = 7
GROUP BY
asset_id
) c ON a.id = c.asset_id
LEFT JOIN (
SELECT
asset_id,
sblx,
pp,
sb_ip AS sbIp,
czxt,
czxtbb,
yjxh,
yjxlh,
yjbbxx,
yjyt,
yjbsxx
FROM
asset_basic_network
WHERE
type = 1
GROUP BY
asset_id
) d ON a.id = d.asset_id
LEFT JOIN (
SELECT
asset_id,
sblx AS wlsblx,
pp AS wlpp,
sb_ip AS wlsbIp,
yjxh AS wlyjxh,
yjxlh AS wlyjxlh,
yjbbxx AS wlyjbbxx,
yjyt AS wlyjyt,
yjbsxx AS wlyjbsxx
FROM
asset_basic_network
WHERE
type = 2
GROUP BY
asset_id
) e ON a.id = e.asset_id
LEFT JOIN ( SELECT
asset_id, sblx AS aqwlsblx, pp AS aqwlpp, sb_ip AS aqwlsbIp
FROM asset_basic_network WHERE type = 3 GROUP BY asset_id ) l ON a.id = l.asset_id
<where>
a.del_flag = '0' and a.isbf = '0'
<if test="req.xtmc!=null and req.xtmc!='' ">
and a.xtmc like concat('%',#{req.xtmc},'%')
</if>
<if test="req.dwmc!=null and req.dwmc!='' ">
and a.dwmc like concat('%',#{req.dwmc},'%')
</if>
<if test="req.xtlx!=null">
and a.xtlx = #{req.xtlx}
</if>
<if test="req.xtzt!=null">
and a.xtzt = #{req.xtzt}
</if>
<if test="req.startTime != null ">
and a.create_time &gt;= #{req.startTime}
</if>
<if test="req.endTime != null">
and a.create_time &lt;= #{req.endTime}
</if>
</where>
</select>
<update id="deleteByUnitIds"> <update id="deleteByUnitIds">
update asset_current update asset_current
set del_flag = '2' set del_flag = '2'

Loading…
Cancel
Save