Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YeeAmosFireAutoSysRoot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
station
YeeAmosFireAutoSysRoot
Commits
153973f9
Commit
153973f9
authored
Jan 15, 2021
by
田涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数字预案增删改查/启停用接口
parent
e1d5bb1b
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
414 additions
and
30 deletions
+414
-30
ContingencyPlanStatusEnum.java
...join/amos/fas/common/enums/ContingencyPlanStatusEnum.java
+10
-22
ContingencyPlanController.java
...os/fas/business/controller/ContingencyPlanController.java
+108
-2
PlanDetailMapper.java
...eejoin/amos/fas/business/dao/mapper/PlanDetailMapper.java
+7
-0
IPlanClassifyTreeDao.java
...mos/fas/business/dao/repository/IPlanClassifyTreeDao.java
+1
-1
IPlanDetailDao.java
...join/amos/fas/business/dao/repository/IPlanDetailDao.java
+3
-0
IPlanDocDao.java
...yeejoin/amos/fas/business/dao/repository/IPlanDocDao.java
+6
-0
IPlanEquipmentDao.java
...n/amos/fas/business/dao/repository/IPlanEquipmentDao.java
+6
-0
IPlanRuleDao.java
...eejoin/amos/fas/business/dao/repository/IPlanRuleDao.java
+6
-0
ContingencyPlanServiceImpl.java
...fas/business/service/impl/ContingencyPlanServiceImpl.java
+170
-5
ContingencyPlanService.java
...os/fas/business/service/intfc/ContingencyPlanService.java
+46
-0
PlanDetailVo.java
...n/java/com/yeejoin/amos/fas/business/vo/PlanDetailVo.java
+36
-0
PlanDetailMapper.xml
...ysStart/src/main/resources/db/mapper/PlanDetailMapper.xml
+15
-0
No files found.
YeeAmosFireAutoSysCommon/src/main/java/com/yeejoin/amos/fas/common/enums/ContingencyPlanStatusEnum.java
View file @
153973f9
...
@@ -10,11 +10,11 @@ import java.util.Map;
...
@@ -10,11 +10,11 @@ import java.util.Map;
*/
*/
public
enum
ContingencyPlanStatusEnum
{
public
enum
ContingencyPlanStatusEnum
{
DRAFT
(
"草稿"
,
"1"
),
DRAFT
(
"草稿"
,
1
),
AVAILABLE
(
"可用"
,
"2"
),
AVAILABLE
(
"可用"
,
2
),
NOAVAILABLE
(
"不可用"
,
"3"
),
NOAVAILABLE
(
"不可用"
,
3
),
SIMULATION_START
(
"模拟启动"
,
"4"
),
SIMULATION_START
(
"模拟启动"
,
4
),
ONGOING
(
"进行中"
,
"5"
);
ONGOING
(
"进行中"
,
5
);
/**
/**
* 名称,描述
* 名称,描述
*/
*/
...
@@ -22,14 +22,14 @@ public enum ContingencyPlanStatusEnum {
...
@@ -22,14 +22,14 @@ public enum ContingencyPlanStatusEnum {
/**
/**
* 编码
* 编码
*/
*/
private
String
code
;
private
Integer
code
;
private
ContingencyPlanStatusEnum
(
String
name
,
String
code
){
private
ContingencyPlanStatusEnum
(
String
name
,
Integer
code
){
this
.
name
=
name
;
this
.
name
=
name
;
this
.
code
=
code
;
this
.
code
=
code
;
}
}
public
static
ContingencyPlanStatusEnum
getEnum
(
String
code
)
{
public
static
ContingencyPlanStatusEnum
getEnum
(
Integer
code
)
{
ContingencyPlanStatusEnum
checkStatusEnum
=
null
;
ContingencyPlanStatusEnum
checkStatusEnum
=
null
;
for
(
ContingencyPlanStatusEnum
type:
ContingencyPlanStatusEnum
.
values
())
{
for
(
ContingencyPlanStatusEnum
type:
ContingencyPlanStatusEnum
.
values
())
{
if
(
type
.
getCode
().
equals
(
code
))
{
if
(
type
.
getCode
().
equals
(
code
))
{
...
@@ -37,21 +37,9 @@ public enum ContingencyPlanStatusEnum {
...
@@ -37,21 +37,9 @@ public enum ContingencyPlanStatusEnum {
break
;
break
;
}
}
}
}
return
checkStatusEnum
;
return
checkStatusEnum
;
}
}
public
static
List
<
Map
<
String
,
String
>>
getEnumList
()
{
List
<
Map
<
String
,
String
>>
nameList
=
new
ArrayList
<>();
for
(
ContingencyPlanStatusEnum
c:
ContingencyPlanStatusEnum
.
values
())
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"name"
,
c
.
getName
());
map
.
put
(
"code"
,
c
.
getCode
());
nameList
.
add
(
map
);
}
return
nameList
;
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
...
@@ -60,11 +48,11 @@ public enum ContingencyPlanStatusEnum {
...
@@ -60,11 +48,11 @@ public enum ContingencyPlanStatusEnum {
this
.
name
=
name
;
this
.
name
=
name
;
}
}
public
String
getCode
()
{
public
Integer
getCode
()
{
return
code
;
return
code
;
}
}
public
void
setCode
(
String
code
)
{
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
this
.
code
=
code
;
}
}
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/ContingencyPlanController.java
View file @
153973f9
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
import
com.yeejoin.amos.fas.business.service.intfc.ContingencyPlanService
;
import
com.yeejoin.amos.fas.business.vo.PlanDetailVo
;
import
com.yeejoin.amos.fas.config.Permission
;
import
com.yeejoin.amos.fas.core.util.CommonResponse
;
import
com.yeejoin.amos.fas.core.util.CommonResponseUtil
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@RestController
@RestController
@RequestMapping
(
"/api/contingencyPlan"
)
@RequestMapping
(
"/api/contingencyPlan"
)
@Api
(
"预案api"
)
@Api
(
"预案api"
)
public
class
ContingencyPlanController
extends
BaseController
{
public
class
ContingencyPlanController
extends
BaseController
{
@Autowired
private
ContingencyPlanService
contingencyPlanService
;
/**
* 创建数字预案
*/
@Permission
@ApiOperation
(
value
=
"创建数字预案"
,
notes
=
"创建数字预案"
)
@PostMapping
(
value
=
""
,
produces
=
"application/json;charset=UTF-8"
)
public
CommonResponse
createPlan
(
@RequestBody
PlanDetailVo
planDetail
)
{
if
(
null
==
planDetail
)
{
return
CommonResponseUtil
.
failure
(
"参数有误"
);
}
AgencyUserModel
curUser
=
getUserInfo
();
planDetail
.
setCreator
(
curUser
.
getUserId
());
planDetail
.
setOrgCode
(
getOrgCode
(
getSelectedOrgInfo
()));
return
CommonResponseUtil
.
success
(
contingencyPlanService
.
createPlan
(
planDetail
));
}
/**
* 修改数字预案
*/
@Permission
@ApiOperation
(
value
=
"修改数字预案"
,
notes
=
"修改数字预案"
)
@PutMapping
(
value
=
""
,
produces
=
"application/json;charset=UTF-8"
)
public
CommonResponse
editPlan
(
@RequestBody
PlanDetailVo
planDetail
)
{
if
(
null
==
planDetail
)
{
return
CommonResponseUtil
.
failure
(
"参数有误"
);
}
AgencyUserModel
curUser
=
getUserInfo
();
planDetail
.
setReviser
(
curUser
.
getUserId
());
planDetail
.
setUpdateTime
(
new
Date
());
return
CommonResponseUtil
.
success
(
contingencyPlanService
.
editPlan
(
planDetail
));
}
/**
* 查看数字预案详情
*/
@Permission
@ApiOperation
(
value
=
"查看数字预案详情"
,
notes
=
"查看数字预案详情"
)
@GetMapping
(
value
=
"/{id}"
,
produces
=
"application/json;charset=UTF-8"
)
public
CommonResponse
createPlan
(
@PathVariable
(
value
=
"id"
)
Long
id
)
{
if
(
null
==
id
)
{
return
CommonResponseUtil
.
failure
(
"参数有误"
);
}
return
CommonResponseUtil
.
success
(
contingencyPlanService
.
detail
(
id
));
}
/**
* 启用预案
*/
@Permission
@ApiOperation
(
value
=
"启用预案"
,
notes
=
"启用预案"
)
@PutMapping
(
value
=
"/activate"
,
produces
=
"application/json;charset=UTF-8"
)
public
CommonResponse
activatePlan
(
@RequestBody
List
<
Long
>
idList
)
{
if
(
null
==
idList
||
idList
.
isEmpty
())
{
return
CommonResponseUtil
.
failure
(
"参数有误"
);
}
return
CommonResponseUtil
.
success
(
contingencyPlanService
.
activatePlan
(
idList
));
}
/**
* 停用预案
*/
@Permission
@ApiOperation
(
value
=
"停用预案"
,
notes
=
"停用预案"
)
@PutMapping
(
value
=
"/deactivate"
,
produces
=
"application/json;charset=UTF-8"
)
public
CommonResponse
deactivatePlan
(
@RequestBody
List
<
Long
>
idList
)
{
if
(
null
==
idList
||
idList
.
isEmpty
())
{
return
CommonResponseUtil
.
failure
(
"参数有误"
);
}
return
CommonResponseUtil
.
success
(
contingencyPlanService
.
deactivatePlan
(
idList
));
}
/**
* 删除预案
*/
@Permission
@ApiOperation
(
value
=
"停用预案"
,
notes
=
"停用预案"
)
@DeleteMapping
(
value
=
"/{ids}"
,
produces
=
"application/json;charset=UTF-8"
)
public
CommonResponse
deactivatePlan
(
@PathVariable
(
value
=
"ids"
)
String
idStr
)
{
if
(
StringUtils
.
isBlank
(
idStr
))
{
return
CommonResponseUtil
.
failure
(
"参数有误"
);
}
String
[]
idArr
=
idStr
.
split
(
","
);
List
<
Long
>
idList
=
new
ArrayList
();
for
(
String
id
:
idArr
)
{
if
(
id
.
trim
().
length
()
>
0
&&
StringUtils
.
isNumeric
(
id
.
trim
()))
{
idList
.
add
(
Long
.
valueOf
(
id
.
trim
()));
}
}
return
CommonResponseUtil
.
success
(
contingencyPlanService
.
delete
(
idList
));
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/mapper/PlanDetailMapper.java
View file @
153973f9
package
com
.
yeejoin
.
amos
.
fas
.
business
.
dao
.
mapper
;
package
com
.
yeejoin
.
amos
.
fas
.
business
.
dao
.
mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
/**
* <h1><h1>
* <h1><h1>
*
*
...
@@ -10,4 +13,8 @@ import org.springframework.stereotype.Repository;
...
@@ -10,4 +13,8 @@ import org.springframework.stereotype.Repository;
*/
*/
@Repository
@Repository
public
interface
PlanDetailMapper
{
public
interface
PlanDetailMapper
{
int
updatePlanStatusByIdList
(
@Param
(
"idList"
)
List
<
Long
>
idList
,
@Param
(
"status"
)
Integer
status
);
int
updateIsDeleteByIdList
(
@Param
(
"idList"
)
List
<
Long
>
idList
,
@Param
(
"isDelete"
)
Boolean
isDelete
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/IPlanClassifyTreeDao.java
View file @
153973f9
...
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Repository;
...
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Repository;
import
java.util.List
;
import
java.util.List
;
@Repository
(
"IPlanClassifyTreeDao"
)
@Repository
public
interface
IPlanClassifyTreeDao
extends
BaseDao
<
PlanClassifyTree
,
Long
>
{
public
interface
IPlanClassifyTreeDao
extends
BaseDao
<
PlanClassifyTree
,
Long
>
{
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/IPlanDetailDao.java
View file @
153973f9
...
@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.dao.repository;
...
@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.dao.repository;
import
com.yeejoin.amos.fas.dao.entity.PlanDetail
;
import
com.yeejoin.amos.fas.dao.entity.PlanDetail
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
/**
* <h1><h1>
* <h1><h1>
*
*
...
@@ -12,4 +14,5 @@ import org.springframework.stereotype.Repository;
...
@@ -12,4 +14,5 @@ import org.springframework.stereotype.Repository;
@Repository
@Repository
public
interface
IPlanDetailDao
extends
BaseDao
<
PlanDetail
,
Long
>
{
public
interface
IPlanDetailDao
extends
BaseDao
<
PlanDetail
,
Long
>
{
List
<
PlanDetail
>
getPlanDetailsByIdInAndIsDelete
(
List
<
Long
>
idList
,
Boolean
isDelete
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/IPlanDocDao.java
View file @
153973f9
...
@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.dao.repository;
...
@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.dao.repository;
import
com.yeejoin.amos.fas.dao.entity.PlanDoc
;
import
com.yeejoin.amos.fas.dao.entity.PlanDoc
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
/**
* <h1><h1>
* <h1><h1>
*
*
...
@@ -11,4 +13,8 @@ import org.springframework.stereotype.Repository;
...
@@ -11,4 +13,8 @@ import org.springframework.stereotype.Repository;
*/
*/
@Repository
@Repository
public
interface
IPlanDocDao
extends
BaseDao
<
PlanDoc
,
Long
>
{
public
interface
IPlanDocDao
extends
BaseDao
<
PlanDoc
,
Long
>
{
void
deleteByPlanId
(
Long
planId
);
List
<
PlanDoc
>
getPlanDocsByPlanId
(
Long
planId
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/IPlanEquipmentDao.java
View file @
153973f9
...
@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.dao.repository;
...
@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.dao.repository;
import
com.yeejoin.amos.fas.dao.entity.PlanEquipment
;
import
com.yeejoin.amos.fas.dao.entity.PlanEquipment
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
/**
* <h1><h1>
* <h1><h1>
*
*
...
@@ -11,4 +13,8 @@ import org.springframework.stereotype.Repository;
...
@@ -11,4 +13,8 @@ import org.springframework.stereotype.Repository;
*/
*/
@Repository
@Repository
public
interface
IPlanEquipmentDao
extends
BaseDao
<
PlanEquipment
,
Long
>
{
public
interface
IPlanEquipmentDao
extends
BaseDao
<
PlanEquipment
,
Long
>
{
void
deleteByPlanId
(
long
planId
);
List
<
PlanEquipment
>
getPlanDocsByPlanId
(
Long
planId
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/IPlanRuleDao.java
View file @
153973f9
...
@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.dao.repository;
...
@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.dao.repository;
import
com.yeejoin.amos.fas.dao.entity.PlanRule
;
import
com.yeejoin.amos.fas.dao.entity.PlanRule
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
/**
* <h1><h1>
* <h1><h1>
*
*
...
@@ -11,4 +13,8 @@ import org.springframework.stereotype.Repository;
...
@@ -11,4 +13,8 @@ import org.springframework.stereotype.Repository;
*/
*/
@Repository
@Repository
public
interface
IPlanRuleDao
extends
BaseDao
<
PlanRule
,
Long
>{
public
interface
IPlanRuleDao
extends
BaseDao
<
PlanRule
,
Long
>{
void
deleteByPlanId
(
long
planId
);
List
<
PlanRule
>
getPlanDocsByPlanId
(
Long
planId
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyPlanServiceImpl.java
View file @
153973f9
package
com
.
yeejoin
.
amos
.
fas
.
business
.
service
.
impl
;
package
com
.
yeejoin
.
amos
.
fas
.
business
.
service
.
impl
;
import
com.yeejoin.amos.fas.business.dao.mapper.PlanDetailMapper
;
import
com.yeejoin.amos.fas.business.dao.repository.*
;
import
com.yeejoin.amos.fas.business.service.intfc.ContingencyPlanService
;
import
com.yeejoin.amos.fas.business.service.intfc.ContingencyPlanService
;
import
com.yeejoin.amos.fas.business.vo.PlanDetailVo
;
import
com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum
;
import
com.yeejoin.amos.fas.dao.entity.*
;
import
com.yeejoin.amos.fas.exception.YeeException
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
/**
*@program: YeeAmosFireAutoSysRoot
*
@program: YeeAmosFireAutoSysRoot
*@description: 预案实现类
*
@description: 预案实现类
*@author: wujunkai
*
@author: wujunkai
*@create: 2021-01-14 14:59
*
@create: 2021-01-14 14:59
*/
*/
@Service
(
"ContingencyPlanService"
)
@Service
public
class
ContingencyPlanServiceImpl
implements
ContingencyPlanService
{
public
class
ContingencyPlanServiceImpl
implements
ContingencyPlanService
{
private
final
IPlanDetailDao
planDetailDao
;
private
final
IPlanDocDao
planDocDao
;
private
final
IPlanEquipmentDao
planEquipmentDao
;
private
final
IPlanRuleDao
planRuleDao
;
private
final
IPlanClassifyTreeDao
classifyTreeDao
;
private
final
PlanDetailMapper
planDetailMapper
;
@Autowired
public
ContingencyPlanServiceImpl
(
IPlanDetailDao
planDetailDao
,
IPlanDocDao
planDocDao
,
IPlanEquipmentDao
planEquipmentDao
,
IPlanRuleDao
planRuleDao
,
IPlanClassifyTreeDao
classifyTreeDao
,
PlanDetailMapper
planDetailMapper
)
{
this
.
planDetailDao
=
planDetailDao
;
this
.
planDocDao
=
planDocDao
;
this
.
planEquipmentDao
=
planEquipmentDao
;
this
.
planRuleDao
=
planRuleDao
;
this
.
classifyTreeDao
=
classifyTreeDao
;
this
.
planDetailMapper
=
planDetailMapper
;
}
@Override
@Transactional
(
rollbackFor
=
{
YeeException
.
class
,
Exception
.
class
})
public
PlanDetailVo
createPlan
(
PlanDetailVo
planDetail
)
{
PlanDoc
planDoc
=
planDetail
.
getPlanDoc
();
PlanRule
planRule
=
planDetail
.
getPlanRule
();
List
<
PlanEquipment
>
planEquipment
=
planDetail
.
getPlanEquipment
();
if
(
StringUtils
.
isBlank
(
planDetail
.
getPlanName
())
||
null
==
planDetail
.
getClassifyId
()
||
null
==
planDoc
||
null
==
planDoc
.
getDocId
()
||
null
==
planRule
||
null
==
planRule
.
getRuleId
()
||
null
==
planEquipment
||
planEquipment
.
isEmpty
())
{
throw
new
YeeException
(
"参数错误"
);
}
planEquipment
.
forEach
(
equipment
->
{
if
(
null
==
equipment
||
null
==
equipment
.
getFireEquipmentId
())
{
throw
new
YeeException
(
"参数错误"
);
}
});
// 状态为草稿
planDetail
.
setStatus
(
ContingencyPlanStatusEnum
.
DRAFT
.
getCode
());
long
planId
=
planDetailDao
.
save
(
planDetail
).
getId
();
planDetail
.
setId
(
planId
);
planDoc
.
setPlanId
(
planId
);
planDocDao
.
save
(
planDoc
);
planRule
.
setPlanId
(
planId
);
planRuleDao
.
save
(
planRule
);
planEquipment
.
forEach
(
equipment
->
equipment
.
setPlanId
(
planId
));
planEquipmentDao
.
saveAll
(
planEquipment
);
return
planDetail
;
}
@Override
public
PlanDetailVo
editPlan
(
PlanDetailVo
planDetail
)
{
PlanDoc
planDoc
=
planDetail
.
getPlanDoc
();
PlanRule
planRule
=
planDetail
.
getPlanRule
();
List
<
PlanEquipment
>
planEquipment
=
planDetail
.
getPlanEquipment
();
if
(
StringUtils
.
isBlank
(
planDetail
.
getPlanName
())
||
null
==
planDetail
.
getClassifyId
()
||
null
==
planDoc
||
null
==
planDoc
.
getDocId
()
||
null
==
planRule
||
null
==
planRule
.
getRuleId
()
||
null
==
planEquipment
||
planEquipment
.
isEmpty
())
{
throw
new
YeeException
(
"参数错误"
);
}
planEquipment
.
forEach
(
equipment
->
{
if
(
null
==
equipment
||
null
==
equipment
.
getFireEquipmentId
())
{
throw
new
YeeException
(
"参数错误"
);
}
});
long
planId
=
planDetail
.
getId
();
PlanDetail
oldPlan
=
planDetailDao
.
getOne
(
planId
);
if
(
null
==
oldPlan
)
{
throw
new
YeeException
(
"数据不存在"
);
}
if
(
ContingencyPlanStatusEnum
.
getEnum
(
oldPlan
.
getStatus
())
==
ContingencyPlanStatusEnum
.
DRAFT
||
ContingencyPlanStatusEnum
.
getEnum
(
oldPlan
.
getStatus
())
==
ContingencyPlanStatusEnum
.
NOAVAILABLE
)
{
// 状态设置为草稿
planDetail
.
setStatus
(
ContingencyPlanStatusEnum
.
DRAFT
.
getCode
());
}
else
{
throw
new
YeeException
(
"不可编辑的状态"
);
}
planDoc
.
setPlanId
(
planId
);
planDocDao
.
deleteByPlanId
(
planId
);
planDocDao
.
save
(
planDoc
);
planRule
.
setPlanId
(
planId
);
planRuleDao
.
deleteByPlanId
(
planId
);
planRuleDao
.
save
(
planRule
);
planEquipment
.
forEach
(
equipment
->
equipment
.
setPlanId
(
planId
));
planEquipmentDao
.
deleteByPlanId
(
planId
);
planEquipmentDao
.
saveAll
(
planEquipment
);
return
planDetail
;
}
@Override
public
PlanDetailVo
detail
(
Long
id
)
{
PlanDetail
detail
=
planDetailDao
.
getOne
(
id
);
if
(
null
==
detail
)
{
throw
new
YeeException
(
"数据不存在"
);
}
PlanDetailVo
detailVo
=
(
PlanDetailVo
)
detail
;
List
<
PlanDoc
>
docs
=
planDocDao
.
getPlanDocsByPlanId
(
id
);
if
(!
docs
.
isEmpty
())
{
detailVo
.
setPlanDoc
(
docs
.
get
(
0
));
}
List
<
PlanRule
>
rules
=
planRuleDao
.
getPlanDocsByPlanId
(
id
);
if
(!
rules
.
isEmpty
())
{
detailVo
.
setPlanRule
(
rules
.
get
(
0
));
}
List
<
PlanEquipment
>
equipments
=
planEquipmentDao
.
getPlanDocsByPlanId
(
id
);
detailVo
.
setPlanEquipment
(
equipments
);
//TODO-设置执行次数
detailVo
.
setExecutionTimes
(
0
);
PlanClassifyTree
classifyTree
=
classifyTreeDao
.
getOne
(
detailVo
.
getClassifyId
());
if
(
null
!=
classifyTree
)
{
detailVo
.
setClassifyName
(
classifyTree
.
getClassifyName
());
}
return
detailVo
;
}
@Override
public
List
<
PlanDetail
>
activatePlan
(
List
<
Long
>
idList
)
{
List
<
PlanDetail
>
planDetailList
=
planDetailDao
.
getPlanDetailsByIdInAndIsDelete
(
idList
,
false
);
if
(!
planDetailList
.
isEmpty
())
{
planDetailList
.
forEach
(
plan
->
{
if
(
ContingencyPlanStatusEnum
.
getEnum
(
plan
.
getStatus
())
!=
ContingencyPlanStatusEnum
.
DRAFT
&&
ContingencyPlanStatusEnum
.
getEnum
(
plan
.
getStatus
())
!=
ContingencyPlanStatusEnum
.
AVAILABLE
&&
ContingencyPlanStatusEnum
.
getEnum
(
plan
.
getStatus
())
!=
ContingencyPlanStatusEnum
.
NOAVAILABLE
)
{
throw
new
YeeException
(
"包含不可启用的状态"
);
}
plan
.
setStatus
(
ContingencyPlanStatusEnum
.
AVAILABLE
.
getCode
());
});
planDetailMapper
.
updatePlanStatusByIdList
(
idList
,
ContingencyPlanStatusEnum
.
AVAILABLE
.
getCode
());
}
return
planDetailList
;
}
@Override
public
List
<
PlanDetail
>
deactivatePlan
(
List
<
Long
>
idList
)
{
List
<
PlanDetail
>
planDetailList
=
planDetailDao
.
getPlanDetailsByIdInAndIsDelete
(
idList
,
false
);
if
(!
planDetailList
.
isEmpty
())
{
planDetailList
.
forEach
(
plan
->
{
if
(
ContingencyPlanStatusEnum
.
getEnum
(
plan
.
getStatus
())
!=
ContingencyPlanStatusEnum
.
AVAILABLE
&&
ContingencyPlanStatusEnum
.
getEnum
(
plan
.
getStatus
())
!=
ContingencyPlanStatusEnum
.
NOAVAILABLE
)
{
throw
new
YeeException
(
"包含不可禁用的状态"
);
}
plan
.
setStatus
(
ContingencyPlanStatusEnum
.
NOAVAILABLE
.
getCode
());
});
planDetailMapper
.
updatePlanStatusByIdList
(
idList
,
ContingencyPlanStatusEnum
.
NOAVAILABLE
.
getCode
());
}
return
planDetailList
;
}
@Override
public
Boolean
delete
(
List
<
Long
>
idList
)
{
planDetailMapper
.
updateIsDeleteByIdList
(
idList
,
true
);
return
true
;
}
}
}
\ No newline at end of file
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/intfc/ContingencyPlanService.java
View file @
153973f9
package
com
.
yeejoin
.
amos
.
fas
.
business
.
service
.
intfc
;
package
com
.
yeejoin
.
amos
.
fas
.
business
.
service
.
intfc
;
import
com.yeejoin.amos.fas.business.vo.PlanDetailVo
;
import
com.yeejoin.amos.fas.dao.entity.PlanDetail
;
import
java.util.List
;
/**
/**
* @author wjk
* @author wjk
* @date 2021-01-14
* @date 2021-01-14
...
@@ -7,4 +12,45 @@ package com.yeejoin.amos.fas.business.service.intfc;
...
@@ -7,4 +12,45 @@ package com.yeejoin.amos.fas.business.service.intfc;
*/
*/
public
interface
ContingencyPlanService
{
public
interface
ContingencyPlanService
{
/**
* 创建
* @param planDetail
* @return
*/
PlanDetailVo
createPlan
(
PlanDetailVo
planDetail
);
/**
* 编辑
* @param planDetail
* @return
*/
PlanDetailVo
editPlan
(
PlanDetailVo
planDetail
);
/**
* 单个详情
* @param id
* @return
*/
PlanDetailVo
detail
(
Long
id
);
/**
* 启用
* @param idList
* @return
*/
List
<
PlanDetail
>
activatePlan
(
List
<
Long
>
idList
);
/**
* 停用
* @param idList
* @return
*/
List
<
PlanDetail
>
deactivatePlan
(
List
<
Long
>
idList
);
/**
* 删除
* @param idList
* @return
*/
Boolean
delete
(
List
<
Long
>
idList
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/vo/PlanDetailVo.java
0 → 100644
View file @
153973f9
package
com
.
yeejoin
.
amos
.
fas
.
business
.
vo
;
import
com.yeejoin.amos.fas.dao.entity.*
;
import
lombok.Data
;
import
java.util.List
;
/**
* <h1><h1>
*
* @author tiantao
* @date 2021/1/15 11:18
*/
@Data
public
class
PlanDetailVo
extends
PlanDetail
{
/**
* 预案所属分类名称
*/
private
String
classifyName
;
/**
* 绑定规则
*/
private
PlanRule
planRule
;
/**
* 绑定文档
*/
private
PlanDoc
planDoc
;
/**
* 绑定装备
*/
private
List
<
PlanEquipment
>
planEquipment
;
/**
* 执行次数
*/
private
int
executionTimes
;
}
YeeAmosFireAutoSysStart/src/main/resources/db/mapper/PlanDetailMapper.xml
View file @
153973f9
...
@@ -2,4 +2,18 @@
...
@@ -2,4 +2,18 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.yeejoin.amos.fas.business.dao.mapper.PlanDetailMapper"
>
<mapper
namespace=
"com.yeejoin.amos.fas.business.dao.mapper.PlanDetailMapper"
>
<update
id=
"updatePlanStatusByIdList"
parameterType=
"list"
>
UPDATE c_plan_detail SET status = #{status} WHERE id IN
<foreach
collection=
"idList"
separator=
","
item=
"id"
open=
"("
close=
")"
>
#{id}
</foreach>
</update>
<update
id=
"updateIsDeleteByIdList"
parameterType=
"list"
>
UPDATE c_plan_detail SET is_delete = #{isDelete} WHERE id IN
<foreach
collection=
"idList"
separator=
","
item=
"id"
open=
"("
close=
")"
>
#{id}
</foreach>
</update>
</mapper>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment