@ -2,29 +2,24 @@ package com.ruoyi.tc.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl ;
import com.ruoyi. tc.entity.AssetTask ;
import com.ruoyi.tc.entity. request.AssestTaskXqRequest ;
import com.ruoyi.tc.entity. request.AssetCurrentShRequest ;
import com.ruoyi.tc.entity.request. AssetTaskPageRequest ;
import com.ruoyi. common.utils.bean.BeanUtils ;
import com.ruoyi.tc.entity. * ;
import com.ruoyi.tc.entity. po.* ;
import com.ruoyi.tc.entity.request. * ;
import com.ruoyi.tc.entity.response.AssestTaskXqresponse ;
import com.ruoyi.tc.entity.response.AssetBasicNetworkCpResponse ;
import com.ruoyi.tc.entity.response.AssetBusinessFormCpResponse ;
import com.ruoyi.tc.entity.response.AssetCurrentResponse ;
import com.ruoyi.tc.entity.response.AssetSupplyChainCpResponse ;
import com.ruoyi.tc.entity.response.AssetTaskResponse ;
import com.ruoyi.tc.entity.response.UnitOtherConcatCpResponse ;
import com.ruoyi.tc.entity.response.AssetTaskStatusResponse ;
import com.ruoyi.tc.entity.response.AssetdwHcResponse ;
import com.ruoyi.tc.mapper.AssetTaskMapper ;
import com.ruoyi.tc.service.AssetBasicNetworkCpService ;
import com.ruoyi.tc.service.AssetBusinessFormCpService ;
import com.ruoyi.tc.service.AssetCurrentCpService ;
import com.ruoyi.tc.service.AssetSupplyChainCpService ;
import com.ruoyi.tc.service.AssetTaskService ;
import com.ruoyi.tc.service.UnitOtherConcatCpService ;
import com.ruoyi.tc.service.* ;
import org.springframework.stereotype.Service ;
import javax.annotation.Resource ;
import java.time.LocalDateTime ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.List ;
import java.util.stream.Collectors ;
/ * *
* 任 务 主 表 ( AssetTask ) 表 服 务 实 现 类
@ -54,7 +49,25 @@ public class AssetTaskServiceImpl extends ServiceImpl<AssetTaskMapper, AssetTask
@Resource
private UnitOtherConcatCpService unitOtherConcatCpService ;
@Resource
private AssetLcService assetLcService ;
@Resource
private AssetCurrentService assetCurrentService ;
@Resource
private AssetBusinessFormService assetBusinessFormService ;
@Resource
private AssetBasicNetworkService assetBasicNetworkService ;
@Resource
private AssetSupplyChainService assetSupplyChainService ;
@Resource
private UnitOtherConcatService unitOtherConcatService ;
/ * *
* 通 过 ID 查 询 单 条 数 据
*
@ -88,22 +101,28 @@ public class AssetTaskServiceImpl extends ServiceImpl<AssetTaskMapper, AssetTask
public void insert ( AssetTask assetTask ) {
//任务新增
int id = assetTaskDao . insert ( assetTask ) ;
//新增流程节点
AssetLc assetLc = new AssetLc ( ) ;
assetLc . setTaskId ( id ) ;
assetLc . setXfTime ( LocalDateTime . now ( ) ) ;
assetLc . setAssetName ( "管理员任务下发" ) ;
assetLcService . insert ( assetLc ) ;
String [ ] parts = assetTask . getDwmc ( ) . split ( "," ) ;
for ( String part : parts ) {
//根据单位名称查询资产
List < AssetCurrentResponse > list = assetTaskDao . findByDwmcAssetCurrent ( part ) ;
for ( AssetCurrentResponse assetCurrentResponse : list ) {
List < AssetCurrent CpPo > list = assetTaskDao . findByDwmcAssetCurrent ( part ) ;
for ( AssetCurrent CpPo assetCurrentResponse : list ) {
assetCurrentResponse . setTaskId ( id ) ;
}
assetCurrentCpService . saveBatch ( list ) ;
List < AssetBusinessFormCp Response > assetBusinessFormCpResponseList = new ArrayList < > ( ) ;
for ( AssetCurrent Response assetCurrentResponse : list ) {
List < AssetBusinessFormCp Po > assetBusinessFormCpResponseList = new ArrayList < > ( ) ;
for ( AssetCurrent CpPo assetCurrentResponse : list ) {
//新增新监管业务形态
//根据资产id查询新监管业务形态主表id
List < AssetBusinessFormCp Response > bussList = assetBusinessFormCpService . findByassetId ( assetCurrentResponse . getId ( ) ) ;
List < AssetBusinessFormCp Po > bussList = assetBusinessFormCpService . findByassetId ( assetCurrentResponse . getId ( ) ) ;
if ( bussList ! = null ) {
for ( AssetBusinessFormCp Response assetBusinessFormCpResponse : bussList ) {
assetCurrentResponse . getXjgywxt ( ) . set Id( assetBusinessFormCpResponse . get Id( ) ) ;
for ( AssetBusinessFormCp Po assetBusinessFormCpResponse : bussList ) {
assetCurrentResponse . getXjgywxt ( ) . set Business Id( assetBusinessFormCpResponse . get Business Id( ) ) ;
assetCurrentResponse . getXjgywxt ( ) . setAssetId ( assetCurrentResponse . getId ( ) ) ;
assetCurrentResponse . getXjgywxt ( ) . setTaskId ( id ) ;
assetBusinessFormCpResponseList . add ( assetCurrentResponse . getXjgywxt ( ) ) ;
@ -111,30 +130,30 @@ public class AssetTaskServiceImpl extends ServiceImpl<AssetTaskMapper, AssetTask
assetBusinessFormCpService . saveBatch ( assetBusinessFormCpResponseList ) ;
}
//根据资产id查询供应链主表id-
List < AssetSupplyChainCp Response > supplyChainList = assetSupplyChainCpService . findByassetId ( assetCurrentResponse . getId ( ) ) ;
List < AssetSupplyChainCp Po > supplyChainList = assetSupplyChainCpService . findByassetId ( assetCurrentResponse . getId ( ) ) ;
if ( supplyChainList ! = null ) {
for ( AssetSupplyChainCp Response items : supplyChainList ) {
for ( AssetSupplyChainCp Po items : supplyChainList ) {
items . setAssetId ( assetCurrentResponse . getId ( ) ) ;
items . set Id( items . get Id( ) ) ;
items . set Supply Id( items . get Supply Id( ) ) ;
items . setTaskId ( id ) ;
//新增供应链
}
assetSupplyChainCpService . saveBatch ( supplyChainList ) ;
}
List < AssetBasicNetworkCp Response > BasicNetworkCpList = assetBasicNetworkCpService . findByassetId ( assetCurrentResponse . getId ( ) ) ;
List < AssetBasicNetworkCp Po > BasicNetworkCpList = assetBasicNetworkCpService . findByassetId ( assetCurrentResponse . getId ( ) ) ;
if ( BasicNetworkCpList ! = null ) {
for ( AssetBasicNetworkCp Response items : BasicNetworkCpList ) {
for ( AssetBasicNetworkCp Po items : BasicNetworkCpList ) {
//根据资产id查询基础网络主表id
items . setAssetId ( assetCurrentResponse . getId ( ) ) ;
items . set Id( items . get Id( ) ) ;
items . set Network Id( items . get Network Id( ) ) ;
items . setTaskId ( id ) ;
//新增基础网络
}
assetBasicNetworkCpService . saveBatch ( BasicNetworkCpList ) ;
}
List < UnitOtherConcatCp Response > unitOtherConcatList = unitOtherConcatCpService . findByassetId ( assetCurrentResponse . getId ( ) ) ;
List < UnitOtherConcatCp Po > unitOtherConcatList = unitOtherConcatCpService . findByassetId ( assetCurrentResponse . getId ( ) ) ;
if ( unitOtherConcatList ! = null ) {
for ( UnitOtherConcatCp Response items : unitOtherConcatList ) {
for ( UnitOtherConcatCp Po items : unitOtherConcatList ) {
//根据资产id查询其他联系人主表id
items . setAssetId ( assetCurrentResponse . getId ( ) ) ;
items . setConcatId ( items . getConcatId ( ) ) ;
@ -172,23 +191,167 @@ public class AssetTaskServiceImpl extends ServiceImpl<AssetTaskMapper, AssetTask
}
@Override
public AssetCurrentResponse taskSh ( int taskId , int assetId ) {
AssetCurrentResponse byId = assetTaskDao . findBytaskIdandAssestId ( taskId , assetId ) ;
byId . setGylxxList ( assetSupplyChainCpService . lambdaQuery ( ) . eq ( AssetSupplyChainCpResponse : : getAssetId , assetId ) . eq ( AssetSupplyChainCpResponse : : getDelFlag , "0" ) . eq ( AssetSupplyChainCpResponse : : getTaskId , taskId ) . list ( ) ) ;
byId . setJcwlList ( assetBasicNetworkCpService . lambdaQuery ( ) . eq ( AssetBasicNetworkCpResponse : : getAssetId , assetId ) . eq ( AssetBasicNetworkCpResponse : : getDelFlag , "0" ) . eq ( AssetBasicNetworkCpResponse : : getTaskId , taskId ) . list ( ) ) ;
byId . setXjgywxt ( assetBusinessFormCpService . lambdaQuery ( ) . eq ( AssetBusinessFormCpResponse : : getAssetId , assetId ) . eq ( AssetBusinessFormCpResponse : : getDelFlag , "0" ) . eq ( AssetBusinessFormCpResponse : : getTaskId , taskId ) . one ( ) ) ;
byId . setOtherConcat ( unitOtherConcatCpService . lambdaQuery ( ) . eq ( UnitOtherConcatCpResponse : : getAssetId , assetId ) . eq ( UnitOtherConcatCpResponse : : getDelFlag , "0" ) . eq ( UnitOtherConcatCpResponse : : getTaskId , taskId ) . list ( ) ) ;
public AssetCurrentCpPo taskSh ( int taskId , int assetId ) {
AssetCurrentCpPo byId = assetTaskDao . findBytaskIdandAssestId ( taskId , assetId ) ;
byId . setGylxxList ( assetSupplyChainCpService . lambdaQuery ( ) . eq ( AssetSupplyChainCpPo : : getAssetId , assetId ) . eq ( AssetSupplyChainCpPo : : getDelFlag , "0" ) . eq ( AssetSupplyChainCpPo : : getTaskId , taskId ) . list ( ) ) ;
byId . setJcwlList ( assetBasicNetworkCpService . lambdaQuery ( ) . eq ( AssetBasicNetworkCpPo : : getAssetId , assetId ) . eq ( AssetBasicNetworkCpPo : : getDelFlag , "0" ) . eq ( AssetBasicNetworkCpPo : : getTaskId , taskId ) . list ( ) ) ;
byId . setXjgywxt ( assetBusinessFormCpService . lambdaQuery ( ) . eq ( AssetBusinessFormCpPo : : getAssetId , assetId ) . eq ( AssetBusinessFormCpPo : : getDelFlag , "0" ) . eq ( AssetBusinessFormCpPo : : getTaskId , taskId ) . one ( ) ) ;
byId . setOtherConcat ( unitOtherConcatCpService . lambdaQuery ( ) . eq ( UnitOtherConcatCpPo : : getAssetId , assetId ) . eq ( UnitOtherConcatCpPo : : getDelFlag , "0" ) . eq ( UnitOtherConcatCpPo : : getTaskId , taskId ) . list ( ) ) ;
List < Acomma > a1 = new ArrayList < > ( ) ;
Arrays . asList ( byId . getGlym ( ) . split ( "," ) ) . forEach ( x - > {
Acomma acomma = new Acomma ( ) ;
acomma . setKey ( x ) ;
a1 . add ( acomma ) ;
} ) ;
byId . setGlymList ( a1 ) ;
List < Acomma > a2 = new ArrayList < > ( ) ;
Arrays . asList ( byId . getGlIp ( ) . split ( "," ) ) . forEach ( x - > {
Acomma acomma = new Acomma ( ) ;
acomma . setKey ( x ) ;
a2 . add ( acomma ) ;
} ) ;
byId . setGlIpList ( a2 ) ;
return byId ;
}
@Override
public Page < AssestTaskXqresponse > zcHc ( Page < AssestTaskXqresponse > assetTask , AssestTaskXqRequest pageRequest ) {
assetTask . setOptimizeCountSql ( false ) ;
return assetTaskDao . zcHc ( assetTask , pageRequest ) ;
}
@Override
public int sh ( AssetCurrentShRequest req ) {
AssetLc assetLc = new AssetLc ( ) ;
int taskStatus = 0 ;
if ( req . getStatus ( ) = = 3 ) {
assetLc . setTaskId ( req . getTaskId ( ) ) ;
assetLc . setXfTime ( LocalDateTime . now ( ) ) ;
assetLc . setAssetName ( "管理员审核通过" ) ;
assetLcService . insert ( assetLc ) ;
} else if ( req . getStatus ( ) = = 4 ) {
assetLc . setTaskId ( req . getTaskId ( ) ) ;
assetLc . setAssetName ( "管理员审核不通过" ) ;
assetLc . setXfTime ( LocalDateTime . now ( ) ) ;
assetLcService . insert ( assetLc ) ;
}
int a = assetTaskDao . sh ( req ) ;
//单位端资产审核,更新任务表状态
//查询当前任务下的所有资产状态和完成时间
List < AssetTaskStatusResponse > list = assetTaskDao . findByTaskId ( req . getTaskId ( ) ) ;
// 检查状态
boolean hasPendingApproval = list . stream ( ) . anyMatch ( item - > item . getStatus ( ) = = 0 | | item . getStatus ( ) = = 1 ) ;
boolean allApproved = list . stream ( ) . allMatch ( item - > item . getStatus ( ) = = 3 ) ;
boolean hasExpired = list . stream ( ) . anyMatch ( item - > item . getDeadstatus ( ) = = 6 ) ;
boolean hasRejected = list . stream ( ) . anyMatch ( item - > item . getStatus ( ) = = 4 ) ;
LocalDateTime finishTime = null ;
if ( hasPendingApproval ) {
// 资产状态存在待审批,任务状态为进行中
taskStatus = 1 ;
} else if ( allApproved & & ! hasPendingApproval & & ! hasRejected & & ! hasExpired ) {
// 资产状态全部为已通过中并且全部资产完成时间在任务期限之前
taskStatus = 2 ;
finishTime = LocalDateTime . now ( ) ;
taskSaveOrDelete ( req ) ;
} else if ( allApproved & & ! hasPendingApproval & & ! hasRejected & & hasExpired ) {
// 资产状态全部为已通过,资产完成时间有超期的为超期完成
taskStatus = 3 ;
finishTime = LocalDateTime . now ( ) ;
taskSaveOrDelete ( req ) ;
} else if ( hasRejected ) {
// 审核不通过
taskStatus = 4 ;
}
//修改主表任务状态
assetTaskDao . updateByTaskId ( taskStatus , req . getTaskId ( ) , finishTime ) ;
return a ;
}
private void taskSaveOrDelete ( AssetCurrentShRequest req ) {
// 根据taskid查询五张数据
List < AssetCurrentCpPo > currentList = assetCurrentCpService . findByTaskId ( req . getTaskId ( ) ) ;
List < Long > idList = currentList . stream ( )
. map ( AssetCurrentCpPo : : getId )
. collect ( Collectors . toList ( ) ) ;
//删除原有数据
assetCurrentService . removeBatchByIds ( idList ) ;
//将子表数据复制到主表中
List < AssetCurrent > currentNewList = currentList . stream ( )
. map ( cpPo - > {
AssetCurrent current = new AssetCurrent ( ) ;
BeanUtils . copyProperties ( cpPo , current ) ; // 复制属性
return current ; // 返回新对象
} )
. collect ( Collectors . toList ( ) ) ; // 收集到列表中
assetCurrentService . saveBatch ( currentNewList ) ;
//AssetBusinessFormCpPo
List < AssetBusinessFormCpPo > bussinessList = assetBusinessFormCpService . findByTaskId ( req . getTaskId ( ) ) ;
List < Long > bussinessidList = bussinessList . stream ( )
. map ( AssetBusinessFormCpPo : : getAssetId )
. collect ( Collectors . toList ( ) ) ;
//删除原有数据
assetBusinessFormService . removeBatchByIds ( bussinessidList ) ;
//将子表数据复制到主表中
List < AssetBusinessForm > bussinessNewList = bussinessList . stream ( )
. map ( cpPo - > {
AssetBusinessForm businessForm = new AssetBusinessForm ( ) ;
BeanUtils . copyProperties ( cpPo , businessForm ) ; // 复制属性
return businessForm ; // 返回新对象
} )
. collect ( Collectors . toList ( ) ) ; // 收集到列表中
assetBusinessFormService . saveBatch ( bussinessNewList ) ;
//AssetBasicNetworkCpPo
List < AssetBasicNetworkCpPo > netWorkList = assetBasicNetworkCpService . findByTaskId ( req . getTaskId ( ) ) ;
List < Long > netWorkidList = netWorkList . stream ( )
. map ( AssetBasicNetworkCpPo : : getAssetId )
. collect ( Collectors . toList ( ) ) ;
//删除原有数据
assetBasicNetworkService . removeBatchByIds ( netWorkidList ) ;
//将子表数据复制到主表中
List < AssetBasicNetwork > netWorkNewList = netWorkList . stream ( )
. map ( cpPo - > {
AssetBasicNetwork network = new AssetBasicNetwork ( ) ;
BeanUtils . copyProperties ( cpPo , network ) ; // 复制属性
return network ; // 返回新对象
} )
. collect ( Collectors . toList ( ) ) ; // 收集到列表中
assetBasicNetworkService . saveBatch ( netWorkNewList ) ;
//AssetSupplyChainCpPo
List < AssetSupplyChainCpPo > SupplyChainList = assetSupplyChainCpService . findByTaskId ( req . getTaskId ( ) ) ;
List < Long > SupplyChainidList = SupplyChainList . stream ( )
. map ( AssetSupplyChainCpPo : : getAssetId )
. collect ( Collectors . toList ( ) ) ;
//删除原有数据
assetSupplyChainService . removeBatchByIds ( SupplyChainidList ) ;
List < AssetSupplyChain > SupplyChainNewList = SupplyChainList . stream ( )
. map ( cpPo - > {
AssetSupplyChain supplyChain = new AssetSupplyChain ( ) ;
BeanUtils . copyProperties ( cpPo , supplyChain ) ; // 复制属性
return supplyChain ; // 返回新对象
} )
. collect ( Collectors . toList ( ) ) ;
assetSupplyChainService . saveBatch ( SupplyChainNewList ) ;
//UnitOtherConcatCpPo
List < UnitOtherConcatCpPo > UnitOtherConcatList = unitOtherConcatCpService . findByTaskId ( req . getTaskId ( ) ) ;
List < Long > UnitOtherConcatidList = UnitOtherConcatList . stream ( )
. map ( UnitOtherConcatCpPo : : getAssetId )
. collect ( Collectors . toList ( ) ) ;
//删除原有数据
unitOtherConcatService . removeBatchByIds ( UnitOtherConcatidList ) ;
List < UnitOtherConcat > UnitOtherConcatNewList = UnitOtherConcatList . stream ( )
. map ( cpPo - > {
UnitOtherConcat unitOtherConcat = new UnitOtherConcat ( ) ;
BeanUtils . copyProperties ( cpPo , unitOtherConcat ) ; // 复制属性
return unitOtherConcat ; // 返回新对象
} )
. collect ( Collectors . toList ( ) ) ;
assetSupplyChainService . saveBatch ( SupplyChainNewList ) ;
unitOtherConcatService . saveBatch ( UnitOtherConcatNewList ) ;
}
@Override
public Page < AssetdwHcResponse > dwHc ( Page < AssetdwHcResponse > assetdwHcResponsePage , AssetdwHcRequest req ) {
return assetTaskDao . sh ( req ) ;
return assetTaskDao . dwHc ( assetdwHcResponsePage , req ) ;
}
}