@ -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 , proL ist, "现有资产记录" ) ;
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 {