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
0a8405c4
Commit
0a8405c4
authored
May 28, 2020
by
吴江
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
规则修改适配
parent
6e7ae3b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
461 additions
and
452 deletions
+461
-452
ContingencyAction.java
...m/yeejoin/amos/fas/business/action/ContingencyAction.java
+437
-437
RiskSourceServiceImpl.java
...amos/fas/business/service/impl/RiskSourceServiceImpl.java
+5
-0
IContingencyInstance.java
...amos/fas/business/service/intfc/IContingencyInstance.java
+19
-15
No files found.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/ContingencyAction.java
View file @
0a8405c4
//
package com.yeejoin.amos.fas.business.action;
//
//
//
import java.io.IOException;
//
import java.lang.reflect.Constructor;
//
import java.lang.reflect.Field;
//
import java.lang.reflect.Method;
//
import java.text.SimpleDateFormat;
//
import java.util.Date;
//
import java.util.HashMap;
//
import java.util.List;
//
import java.util.Map;
//
//
import org.springframework.beans.factory.annotation.Autowired;
//
import org.springframework.stereotype.Component;
//
import org.springframework.util.CollectionUtils;
//
//
import com.fasterxml.jackson.databind.ObjectMapper;
//
import com.yeejoin.amos.fas.business.action.result.ActionResult;
//
import com.yeejoin.amos.fas.business.action.result.BubbleTipResult;
//
import com.yeejoin.amos.fas.business.action.result.message.ActionResultMessage;
//
import com.yeejoin.amos.fas.business.service.impl.RuleRunigSnapshotServiceImpl;
//
import com.yeejoin.amos.fas.business.service.intfc.FireStengthService;
//
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
//
import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
//
import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
//
import com.yeejoin.amos.fas.business.service.model.ContingencyRo;
//
import com.yeejoin.amos.fas.business.util.StringUtil;
//
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
//
import com.yeejoin.amos.fas.dao.entity.FireStrength;
//
//
@Component
//
public class ContingencyAction implements CustomerAction {
//
//
//
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
//
//
@Autowired
//
private IContingencyInstance iContingencyInstance;
//
//
@Autowired
//
private FireStengthService fireStrengthService;
//
//
// private RestTemplate restTemplate = new RestTemplate();
//
//
// @Value("${bussunis.domain}")
//
// private String bussunisDomain ;
//
//
@Autowired
//
private IRiskSourceService riskSourceService;
//
//
private static Map<String, String> OPERATE_RECORD_ID = new HashMap<>();
//
//
private static Map<String, Map<String,String>> stringStringMap = new HashMap<>();
//
static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
//
//
//当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1)
//
/* private static Map<String, String> positionMap = new HashMap<String, String>() {{
//
put("S1", "S1");
//
put("S2", "S2");
//
put("A1", "A1");
//
put("A2", "A2");
//
put("A3", "A3");
//
put("F1", "F1");
//
}};
//
*/
//
//
private Map<String, String> getStrengthMap(String batchNo) {
//
//
Map<String,String> returnMap = stringStringMap.get(batchNo);
//
if (CollectionUtils.isEmpty(returnMap)) {
//
stringStringMap = new HashMap<>();
//
returnMap = new HashMap<>();
//
//
//
//
Date now = new Date();
//
String time = sdf.format(now);
//
//
//
List<FireStrength> strengths = fireStrengthService.queryForStrengthList(time);
//
// List<FireStrength> strengths = iStrengthRepository.queryForStrengthList(time);
//
//
if (!CollectionUtils.isEmpty(strengths))
//
{
//
for (FireStrength fireStrength : strengths)
//
{
//
String name = returnMap.get(fireStrength.getPosition());
//
if (StringUtil.isNotEmpty(name))
//
{
//
returnMap.put(fireStrength.getPosition(), name + "、" + fireStrength.getUsername());
//
}else
//
{
//
returnMap.put(fireStrength.getPosition(), fireStrength.getUsername());
//
}
//
}
//
}
//
stringStringMap.put(batchNo,returnMap);
//
}
//
return returnMap;
//
}
//
//
//
public static void sendcmd(String firstStr, String secondStr, String thirdStr, BubbleTipResult result) {
//
//
Constructor<?> constructor;
//
try {
//
constructor = Class.forName(
//
PACKAGEURL + result.getClass().getSimpleName() + "Message")
//
.getConstructor(ActionResult.class);
//
ActionResultMessage<?> action = (ActionResultMessage<?>) constructor.newInstance(result);
//
action.execute(firstStr, secondStr, thirdStr);
//
} catch (Exception e) {
//
e.printStackTrace();
//
}
//
}
//
//
//
/**
//
* @param stepCode 当前步骤编号
//
* @param stepName 当前步骤名称
//
* @param state 当前步骤状态
//
* @param nextStepCode 下一步编号
//
* @param nextStepName 下一步名称
//
* @param stepType 步骤类型,总览步骤、详细步骤
//
* @param paramObj 预案对象
//
*/
//
public void stepInfo(String stepCode, String stepName, String state, String nextStepCode, String nextStepName, String stepType, Object paramObj) {
//
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
//
stopSnapshop(contingencyRo);
//
//
//
BubbleTipResult result = new BubbleTipResult();
//
Map<String, Object> tempmap1 = new HashMap<>();
//
//
tempmap1.put("stepCode", stepCode);
//
tempmap1.put("stepName", stepName);
//
tempmap1.put("state", state);
//
tempmap1.put("nextStepCode", nextStepCode);
//
tempmap1.put("nextStepName", nextStepName);
//
tempmap1.put("batchNo", contingencyRo.getBatchNo());
//
tempmap1.put("contingencyRo", contingencyRo);
//
result.add(tempmap1);
//
//
this.sendcmd("fromws", "stepArea", stepType, result);
//
}
//
//
/**
//
* @param stepCode 当前步骤编号
//
* @param paramObj 预案对象
//
*/
//
public void saveStepInfo(String stepCode, Object paramObj) {
//
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
//
iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo());
//
}
//
//
//
/**
//
* @param content 消息内容
//
* @param paramObj 预案对象
//
*/
//
public void messageRecord(String content, Object paramObj) {
//
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
//
stopSnapshop(contingencyRo);
//
//转换content中的变量
//
content = instedParams(content,contingencyRo);
//
//
BubbleTipResult result = new BubbleTipResult();
//
Map<String, Object> tempmap1 = new HashMap<>();
//
//
tempmap1.put("refresh", "refresh");
//
tempmap1.put("batchNo", contingencyRo.getBatchNo());
//
result.add(tempmap1);
//
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", "");
//
this.sendcmd("fromws", "recordArea", "refresh", result);
//
}
//
//
/**
//
* <pre>
//
* 智能辅助
//
* </pre>
//
*
//
* @param step 当前步骤
//
* @param icon 图标
//
* @param title 标题
//
* @param image 图片集合
//
* @param table 表格
//
* @param content 内容
//
* @param paramObj 预案对象
//
*/
//
public void help(String step, String icon, String title, String image, String table, String content, Object paramObj) {
//
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
//
stopSnapshop(contingencyRo);
//
//
//
//转换智能辅助中的变量
//
content = instedParams(content,contingencyRo);
//
//
BubbleTipResult result = new BubbleTipResult();
//
Map<String, Object> tempmap1 = new HashMap<>();
//
//
tempmap1.put("icon", icon);
//
tempmap1.put("step", step);
//
tempmap1.put("title", title);
//
tempmap1.put("content", content);
//
tempmap1.put("image", image);
//
tempmap1.put("table", table);
//
tempmap1.put("batchNo", contingencyRo.getBatchNo());
//
tempmap1.put("contingencyRo", contingencyRo);
//
result.add(tempmap1);
//
//
this.sendcmd("fromws", "helpArea", "", result);
//
}
//
//
//
private String instedParams(String content, ContingencyRo contingencyRo) {
//
//
Map<String, String> strengthMap = this.getStrengthMap(contingencyRo.getBatchNo());
//
for (String key : strengthMap.keySet())
//
content = content.replaceAll("\\$\\{" + key + "}", strengthMap.get(key));
//
//
//
/* for (String key : positionMap.keySet())
//
c ontent = content.replaceAll("\\$\\{" + key + "}", positionMap.get(key));
//
*/
//
//
Field[] fields = contingencyRo.getClass().getDeclaredFields();
//
Method getMethod = null;
//
try {
//
for (Field field : fields) {
//
if(field.getName().equals("serialVersionUID"))
//
continue;
//
String fileNameInMethod = String.valueOf(field.getName().charAt(0)).toUpperCase() + field.getName().substring(1);
//
getMethod = contingencyRo.getClass().getMethod("get" + fileNameInMethod);
//
String value = String.valueOf(getMethod.invoke(contingencyRo));
//
content = content.replaceAll("\\$\\{" + field.getName() + "}", value);
//
}
//
//
content = content.replaceAll("\\$\\{", "");
//
content = content.replaceAll("}", "");
//
} catch (Exception e) {
//
e.printStackTrace();
//
}
//
return content;
//
}
//
//
//
/**
//
* 交互动作
//
*
//
* @param actionName 动作名称
//
* @param icon 图标
//
* @param tips 提示信息
//
* @param buttonJson 按钮json字符串
//
* @param paramObj 预案对象
//
*/
//
public void operation(String actionName, String icon, String tips, String buttonJson, Object paramObj) {
//
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
//
stopSnapshop(contingencyRo);
//
//
//转换content中的变量
//
tips = instedParams(tips,contingencyRo);
//
//
//
BubbleTipResult result = new BubbleTipResult();
//
Map<String, Object> tempmap1 = new HashMap<>();
//
//
//
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
//
//
//
tempmap1.put("actionName", actionName);
//
tempmap1.put("icon", icon);
//
tempmap1.put("tips", tips);
//
tempmap1.put("buttonJson", buttonJson);
//
tempmap1.put("batchNo", contingencyRo.getBatchNo());
//
tempmap1.put("contingencyRo", contingencyRo);
//
tempmap1.put("contingencyPlanId", contingencyPlanId);
//
result.add(tempmap1);
//
//
//
this.sendcmd("fromws", "optionArea", "", result);
//
//
//
sendButton(contingencyRo.getBatchNo(),contingencyPlanId,contingencyRo.getEquipmentId(),actionName,buttonJson);
//
//
}
//
//
//
private boolean sendButton(String batchNo,String contingencyPlanId,String equipmentId,String actionName,String buttonJson) {
//
//
// String url = bussunisDomain+ "/api/risksource/contingency/setup";
//
//
ObjectMapper objectMapper = new ObjectMapper();
//
//Map<String,Object> map = new HashMap<>();
//
//
/**
//
* batchNo
//
* stepCode
//
* buttonCode
//
* confirm
//
* contingencyPlanId
//
* stepState
//
*/
//
//
try {
//
Map button = objectMapper.readValue(buttonJson,Map.class);
//
Map operateInstance = (Map)((List)button.get("operate")).get(0);
//
//
map.put("batchNo",batchNo);
//
//
map.put("actionName",actionName);
//
//
map.put("equipmentId",equipmentId);
//
//
map.put("stepCode",button.get("stepCode"));
//
//
map.put("buttonCode",operateInstance.get("code"));
//
//
map.put("confirm","CONFIRM");
//
//
map.put("stepState",operateInstance.get("stepState"));
//
//
map.put("contingencyPlanId",contingencyPlanId);
//
ContingencyDeviceStatus contingencyDeviceStatus = new ContingencyDeviceStatus();
//
contingencyDeviceStatus.setActionName(actionName);
//
contingencyDeviceStatus.setButtonCode(String.valueOf(operateInstance.get("code")));
//
contingencyDeviceStatus.setConfirm("CONFIRM");
//
contingencyDeviceStatus.setContingencyPlanId(contingencyPlanId);
//
contingencyDeviceStatus.setEquipmentId(equipmentId);
//
contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode")));
//
contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState")));
//
riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus);
//
//HttpEntity<Map> entity = new HttpEntity<>(map);
//
// restTemplate.exchange(url, HttpMethod.POST,entity,Map.class);
//
//
} catch (IOException e) {
//
e.printStackTrace();
//
}
//
//
return false;
//
}
//
//
//
/**
//
* 保存交互动作
//
*
//
* @param actionName 动作名称
//
* @param icon 图标
//
* @param tips 提示信息
//
* @param buttonJson 按钮json字符串
//
* @param paramObj 预案对象
//
*/
//
public void saveOperation(String actionName, String icon, String tips, String buttonJson, Object paramObj) {
//
//
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
//
stopSnapshop(contingencyRo);
//
//
//转换content中的变量
//
tips = instedParams(tips,contingencyRo);
//
//
BubbleTipResult result1 = new BubbleTipResult();
//
Map<String, Object> tempmap2 = new HashMap<>();
//
tempmap2.put("refresh", "refresh");
//
tempmap2.put("batchNo", contingencyRo.getBatchNo());
//
result1.add(tempmap2);
//
//
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
//
//
this.sendcmd("fromws", "recordArea", "refresh", result1);
//
//
}
//
//
private String getContingencyPlanId(String batchNo, String actionName, String icon, String tips, String buttonJson) {
//
String cacheKey = batchNo + actionName;
//
String contingencyPlanId = null;
//
ContingencyPlanInstance contingencyPlanInstance = null;
//
if (OPERATE_RECORD_ID.get(cacheKey) == null) {
//
contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon);
//
contingencyPlanId = contingencyPlanInstance.getId();
//
OPERATE_RECORD_ID.put(cacheKey, contingencyPlanId);
//
} else {
//
contingencyPlanId = OPERATE_RECORD_ID.get(cacheKey);
//
OPERATE_RECORD_ID.remove(cacheKey);
//
}
//
return contingencyPlanId;
//
}
//
//
//
/**
//
* 地图动作推送
//
*
//
* @param actionName 动作名称标识
//
* @param paramObj 预案对象
//
*/
//
public void mapAction(String actionName, Object paramObj) {
//
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
//
stopSnapshop(contingencyRo);
//
//
//
BubbleTipResult result = new BubbleTipResult();
//
Map<String, Object> tempmap1 = new HashMap<>();
//
//
tempmap1.put("actionName", actionName);
//
tempmap1.put("batchNo", contingencyRo.getBatchNo());
//
tempmap1.put("contingencyRo", contingencyRo);
//
result.add(tempmap1);
//
//
this.sendcmd("fromws", "mapArea", actionName, result);
//
}
//
//
//
/**
//
* 顶部消息提示
//
*
//
* @param content 消息内容
//
* @param messageType 消息类型 messageType 黑色框消息类型CONTINGENCY,,滚动消息:CURRENTMESSAGE
//
* @param paramObj 预案对象
//
*/
//
public void topMessage(String content, String messageType, Object paramObj) {
//
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
//
stopSnapshop(contingencyRo);
//
//
//
BubbleTipResult result = new BubbleTipResult();
//
Map<String, Object> tempmap1 = new HashMap<>();
//
//转换content中的变量
//
content = instedParams(content,contingencyRo);
//
//
tempmap1.put("content", content);
//
tempmap1.put("messageType", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE
//
tempmap1.put("batchNo", contingencyRo.getBatchNo());
//
tempmap1.put("contingencyRo", contingencyRo);
//
result.add(tempmap1);
//
//
this.sendcmd("fromws", "topArea", messageType, result);
//
}
//
//
//
private void stopSnapshop(ContingencyRo contingencyRo) {
//
if (RuleRunigSnapshotServiceImpl.getReplayBatchNo() != null && !RuleRunigSnapshotServiceImpl.getReplayBatchNo().equals(contingencyRo.getBatchNo()))
//
RuleRunigSnapshotServiceImpl.setReplayBatchNoToNull();
//
}
//
//
}
package
com
.
yeejoin
.
amos
.
fas
.
business
.
action
;
import
java.io.IOException
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.yeejoin.amos.fas.business.action.result.ActionResult
;
import
com.yeejoin.amos.fas.business.action.result.BubbleTipResult
;
import
com.yeejoin.amos.fas.business.action.result.message.ActionResultMessage
;
import
com.yeejoin.amos.fas.business.service.impl.RuleRunigSnapshotServiceImpl
;
import
com.yeejoin.amos.fas.business.service.intfc.FireStengthService
;
import
com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance
;
import
com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService
;
import
com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus
;
import
com.yeejoin.amos.fas.business.service.model.ContingencyRo
;
import
com.yeejoin.amos.fas.business.util.StringUtil
;
import
com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance
;
import
com.yeejoin.amos.fas.dao.entity.FireStrength
;
@Component
public
class
ContingencyAction
implements
CustomerAction
{
private
static
String
PACKAGEURL
=
"com.yeejoin.amos.fas.business.action.result.message."
;
@Autowired
private
IContingencyInstance
iContingencyInstance
;
@Autowired
private
FireStengthService
fireStrengthService
;
// private RestTemplate restTemplate = new RestTemplate();
// @Value("${bussunis.domain}")
// private String bussunisDomain ;
@Autowired
private
IRiskSourceService
riskSourceService
;
private
static
Map
<
String
,
String
>
OPERATE_RECORD_ID
=
new
HashMap
<>();
private
static
Map
<
String
,
Map
<
String
,
String
>>
stringStringMap
=
new
HashMap
<>();
static
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
//当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1)
/* private static Map<String, String> positionMap = new HashMap<String, String>() {{
put("S1", "S1");
put("S2", "S2");
put("A1", "A1");
put("A2", "A2");
put("A3", "A3");
put("F1", "F1");
}};
*/
private
Map
<
String
,
String
>
getStrengthMap
(
String
batchNo
)
{
Map
<
String
,
String
>
returnMap
=
stringStringMap
.
get
(
batchNo
);
if
(
CollectionUtils
.
isEmpty
(
returnMap
))
{
stringStringMap
=
new
HashMap
<>();
returnMap
=
new
HashMap
<>();
Date
now
=
new
Date
();
String
time
=
sdf
.
format
(
now
);
List
<
FireStrength
>
strengths
=
fireStrengthService
.
queryForStrengthList
(
time
);
// List<FireStrength> strengths = iStrengthRepository.queryForStrengthList(time);
if
(!
CollectionUtils
.
isEmpty
(
strengths
))
{
for
(
FireStrength
fireStrength
:
strengths
)
{
String
name
=
returnMap
.
get
(
fireStrength
.
getPosition
());
if
(
StringUtil
.
isNotEmpty
(
name
))
{
returnMap
.
put
(
fireStrength
.
getPosition
(),
name
+
"、"
+
fireStrength
.
getUsername
());
}
else
{
returnMap
.
put
(
fireStrength
.
getPosition
(),
fireStrength
.
getUsername
());
}
}
}
stringStringMap
.
put
(
batchNo
,
returnMap
);
}
return
returnMap
;
}
public
static
void
sendcmd
(
String
firstStr
,
String
secondStr
,
String
thirdStr
,
BubbleTipResult
result
)
{
Constructor
<?>
constructor
;
try
{
constructor
=
Class
.
forName
(
PACKAGEURL
+
result
.
getClass
().
getSimpleName
()
+
"Message"
)
.
getConstructor
(
ActionResult
.
class
);
ActionResultMessage
<?>
action
=
(
ActionResultMessage
<?>)
constructor
.
newInstance
(
result
);
action
.
execute
(
firstStr
,
secondStr
,
thirdStr
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* @param stepCode 当前步骤编号
* @param stepName 当前步骤名称
* @param state 当前步骤状态
* @param nextStepCode 下一步编号
* @param nextStepName 下一步名称
* @param stepType 步骤类型,总览步骤、详细步骤
* @param paramObj 预案对象
*/
public
void
stepInfo
(
String
stepCode
,
String
stepName
,
String
state
,
String
nextStepCode
,
String
nextStepName
,
String
stepType
,
Object
paramObj
)
{
ContingencyRo
contingencyRo
=
(
ContingencyRo
)
paramObj
;
stopSnapshop
(
contingencyRo
);
BubbleTipResult
result
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
tempmap1
.
put
(
"stepCode"
,
stepCode
);
tempmap1
.
put
(
"stepName"
,
stepName
);
tempmap1
.
put
(
"state"
,
state
);
tempmap1
.
put
(
"nextStepCode"
,
nextStepCode
);
tempmap1
.
put
(
"nextStepName"
,
nextStepName
);
tempmap1
.
put
(
"batchNo"
,
contingencyRo
.
getBatchNo
());
tempmap1
.
put
(
"contingencyRo"
,
contingencyRo
);
result
.
add
(
tempmap1
);
this
.
sendcmd
(
"fromws"
,
"stepArea"
,
stepType
,
result
);
}
/**
* @param stepCode 当前步骤编号
* @param paramObj 预案对象
*/
public
void
saveStepInfo
(
String
stepCode
,
Object
paramObj
)
{
ContingencyRo
contingencyRo
=
(
ContingencyRo
)
paramObj
;
iContingencyInstance
.
updateStep
(
stepCode
,
contingencyRo
.
getBatchNo
());
}
/**
* @param content 消息内容
* @param paramObj 预案对象
*/
public
void
messageRecord
(
String
content
,
Object
paramObj
)
{
ContingencyRo
contingencyRo
=
(
ContingencyRo
)
paramObj
;
stopSnapshop
(
contingencyRo
);
//转换content中的变量
content
=
instedParams
(
content
,
contingencyRo
);
BubbleTipResult
result
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
tempmap1
.
put
(
"refresh"
,
"refresh"
);
tempmap1
.
put
(
"batchNo"
,
contingencyRo
.
getBatchNo
());
result
.
add
(
tempmap1
);
iContingencyInstance
.
createInstanceRecord
(
contingencyRo
.
getBatchNo
(),
""
,
"DEFAULT"
,
content
,
"MESSAGE"
,
""
);
this
.
sendcmd
(
"fromws"
,
"recordArea"
,
"refresh"
,
result
);
}
/**
* <pre>
* 智能辅助
* </pre>
*
* @param step 当前步骤
* @param icon 图标
* @param title 标题
* @param image 图片集合
* @param table 表格
* @param content 内容
* @param paramObj 预案对象
*/
public
void
help
(
String
step
,
String
icon
,
String
title
,
String
image
,
String
table
,
String
content
,
Object
paramObj
)
{
ContingencyRo
contingencyRo
=
(
ContingencyRo
)
paramObj
;
stopSnapshop
(
contingencyRo
);
//转换智能辅助中的变量
content
=
instedParams
(
content
,
contingencyRo
);
BubbleTipResult
result
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
tempmap1
.
put
(
"icon"
,
icon
);
tempmap1
.
put
(
"step"
,
step
);
tempmap1
.
put
(
"title"
,
title
);
tempmap1
.
put
(
"content"
,
content
);
tempmap1
.
put
(
"image"
,
image
);
tempmap1
.
put
(
"table"
,
table
);
tempmap1
.
put
(
"batchNo"
,
contingencyRo
.
getBatchNo
());
tempmap1
.
put
(
"contingencyRo"
,
contingencyRo
);
result
.
add
(
tempmap1
);
this
.
sendcmd
(
"fromws"
,
"helpArea"
,
""
,
result
);
}
private
String
instedParams
(
String
content
,
ContingencyRo
contingencyRo
)
{
Map
<
String
,
String
>
strengthMap
=
this
.
getStrengthMap
(
contingencyRo
.
getBatchNo
());
for
(
String
key
:
strengthMap
.
keySet
())
content
=
content
.
replaceAll
(
"\\$\\{"
+
key
+
"}"
,
strengthMap
.
get
(
key
));
/* for (String key : positionMap.keySet())
c ontent = content.replaceAll("\\$\\{" + key + "}", positionMap.get(key));
*/
Field
[]
fields
=
contingencyRo
.
getClass
().
getDeclaredFields
();
Method
getMethod
=
null
;
try
{
for
(
Field
field
:
fields
)
{
if
(
field
.
getName
().
equals
(
"serialVersionUID"
))
continue
;
String
fileNameInMethod
=
String
.
valueOf
(
field
.
getName
().
charAt
(
0
)).
toUpperCase
()
+
field
.
getName
().
substring
(
1
);
getMethod
=
contingencyRo
.
getClass
().
getMethod
(
"get"
+
fileNameInMethod
);
String
value
=
String
.
valueOf
(
getMethod
.
invoke
(
contingencyRo
));
content
=
content
.
replaceAll
(
"\\$\\{"
+
field
.
getName
()
+
"}"
,
value
);
}
content
=
content
.
replaceAll
(
"\\$\\{"
,
""
);
content
=
content
.
replaceAll
(
"}"
,
""
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
content
;
}
/**
* 交互动作
*
* @param actionName 动作名称
* @param icon 图标
* @param tips 提示信息
* @param buttonJson 按钮json字符串
* @param paramObj 预案对象
*/
public
void
operation
(
String
actionName
,
String
icon
,
String
tips
,
String
buttonJson
,
Object
paramObj
)
{
ContingencyRo
contingencyRo
=
(
ContingencyRo
)
paramObj
;
stopSnapshop
(
contingencyRo
);
//转换content中的变量
tips
=
instedParams
(
tips
,
contingencyRo
);
BubbleTipResult
result
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
String
contingencyPlanId
=
getContingencyPlanId
(
contingencyRo
.
getBatchNo
(),
actionName
,
icon
,
tips
,
buttonJson
);
tempmap1
.
put
(
"actionName"
,
actionName
);
tempmap1
.
put
(
"icon"
,
icon
);
tempmap1
.
put
(
"tips"
,
tips
);
tempmap1
.
put
(
"buttonJson"
,
buttonJson
);
tempmap1
.
put
(
"batchNo"
,
contingencyRo
.
getBatchNo
());
tempmap1
.
put
(
"contingencyRo"
,
contingencyRo
);
tempmap1
.
put
(
"contingencyPlanId"
,
contingencyPlanId
);
result
.
add
(
tempmap1
);
this
.
sendcmd
(
"fromws"
,
"optionArea"
,
""
,
result
);
sendButton
(
contingencyRo
.
getBatchNo
(),
contingencyPlanId
,
contingencyRo
.
getEquipmentId
(),
actionName
,
buttonJson
);
}
private
boolean
sendButton
(
String
batchNo
,
String
contingencyPlanId
,
String
equipmentId
,
String
actionName
,
String
buttonJson
)
{
// String url = bussunisDomain+ "/api/risksource/contingency/setup";
ObjectMapper
objectMapper
=
new
ObjectMapper
();
//Map<String,Object> map = new HashMap<>();
/**
* batchNo
* stepCode
* buttonCode
* confirm
* contingencyPlanId
* stepState
*/
try
{
Map
button
=
objectMapper
.
readValue
(
buttonJson
,
Map
.
class
);
Map
operateInstance
=
(
Map
)((
List
)
button
.
get
(
"operate"
)).
get
(
0
);
// map.put("batchNo",batchNo);
// map.put("actionName",actionName);
// map.put("equipmentId",equipmentId);
// map.put("stepCode",button.get("stepCode"));
// map.put("buttonCode",operateInstance.get("code"));
// map.put("confirm","CONFIRM");
// map.put("stepState",operateInstance.get("stepState"));
// map.put("contingencyPlanId",contingencyPlanId);
ContingencyDeviceStatus
contingencyDeviceStatus
=
new
ContingencyDeviceStatus
();
contingencyDeviceStatus
.
setActionName
(
actionName
);
contingencyDeviceStatus
.
setButtonCode
(
String
.
valueOf
(
operateInstance
.
get
(
"code"
)));
contingencyDeviceStatus
.
setConfirm
(
"CONFIRM"
);
contingencyDeviceStatus
.
setContingencyPlanId
(
contingencyPlanId
);
contingencyDeviceStatus
.
setEquipmentId
(
equipmentId
);
contingencyDeviceStatus
.
setStepCode
(
String
.
valueOf
(
button
.
get
(
"stepCode"
)));
contingencyDeviceStatus
.
setStepState
(
String
.
valueOf
(
operateInstance
.
get
(
"stepState"
)));
riskSourceService
.
queryContingencyDeviceStatus
(
contingencyDeviceStatus
);
//HttpEntity<Map> entity = new HttpEntity<>(map);
// restTemplate.exchange(url, HttpMethod.POST,entity,Map.class);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
/**
* 保存交互动作
*
* @param actionName 动作名称
* @param icon 图标
* @param tips 提示信息
* @param buttonJson 按钮json字符串
* @param paramObj 预案对象
*/
public
void
saveOperation
(
String
actionName
,
String
icon
,
String
tips
,
String
buttonJson
,
Object
paramObj
)
{
ContingencyRo
contingencyRo
=
(
ContingencyRo
)
paramObj
;
stopSnapshop
(
contingencyRo
);
//转换content中的变量
tips
=
instedParams
(
tips
,
contingencyRo
);
BubbleTipResult
result1
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap2
=
new
HashMap
<>();
tempmap2
.
put
(
"refresh"
,
"refresh"
);
tempmap2
.
put
(
"batchNo"
,
contingencyRo
.
getBatchNo
());
result1
.
add
(
tempmap2
);
String
contingencyPlanId
=
getContingencyPlanId
(
contingencyRo
.
getBatchNo
(),
actionName
,
icon
,
tips
,
buttonJson
);
this
.
sendcmd
(
"fromws"
,
"recordArea"
,
"refresh"
,
result1
);
}
private
String
getContingencyPlanId
(
String
batchNo
,
String
actionName
,
String
icon
,
String
tips
,
String
buttonJson
)
{
String
cacheKey
=
batchNo
+
actionName
;
String
contingencyPlanId
=
null
;
ContingencyPlanInstance
contingencyPlanInstance
=
null
;
if
(
OPERATE_RECORD_ID
.
get
(
cacheKey
)
==
null
)
{
contingencyPlanInstance
=
iContingencyInstance
.
createInstanceRecord
(
batchNo
,
actionName
,
"DEFAULT"
,
buttonJson
,
"OPERATE"
,
icon
);
contingencyPlanId
=
contingencyPlanInstance
.
getId
();
OPERATE_RECORD_ID
.
put
(
cacheKey
,
contingencyPlanId
);
}
else
{
contingencyPlanId
=
OPERATE_RECORD_ID
.
get
(
cacheKey
);
OPERATE_RECORD_ID
.
remove
(
cacheKey
);
}
return
contingencyPlanId
;
}
/**
* 地图动作推送
*
* @param actionName 动作名称标识
* @param paramObj 预案对象
*/
public
void
mapAction
(
String
actionName
,
Object
paramObj
)
{
ContingencyRo
contingencyRo
=
(
ContingencyRo
)
paramObj
;
stopSnapshop
(
contingencyRo
);
BubbleTipResult
result
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
tempmap1
.
put
(
"actionName"
,
actionName
);
tempmap1
.
put
(
"batchNo"
,
contingencyRo
.
getBatchNo
());
tempmap1
.
put
(
"contingencyRo"
,
contingencyRo
);
result
.
add
(
tempmap1
);
this
.
sendcmd
(
"fromws"
,
"mapArea"
,
actionName
,
result
);
}
/**
* 顶部消息提示
*
* @param content 消息内容
* @param messageType 消息类型 messageType 黑色框消息类型CONTINGENCY,,滚动消息:CURRENTMESSAGE
* @param paramObj 预案对象
*/
public
void
topMessage
(
String
content
,
String
messageType
,
Object
paramObj
)
{
ContingencyRo
contingencyRo
=
(
ContingencyRo
)
paramObj
;
stopSnapshop
(
contingencyRo
);
BubbleTipResult
result
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
//转换content中的变量
content
=
instedParams
(
content
,
contingencyRo
);
tempmap1
.
put
(
"content"
,
content
);
tempmap1
.
put
(
"messageType"
,
messageType
);
//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE
tempmap1
.
put
(
"batchNo"
,
contingencyRo
.
getBatchNo
());
tempmap1
.
put
(
"contingencyRo"
,
contingencyRo
);
result
.
add
(
tempmap1
);
this
.
sendcmd
(
"fromws"
,
"topArea"
,
messageType
,
result
);
}
private
void
stopSnapshop
(
ContingencyRo
contingencyRo
)
{
if
(
RuleRunigSnapshotServiceImpl
.
getReplayBatchNo
()
!=
null
&&
!
RuleRunigSnapshotServiceImpl
.
getReplayBatchNo
().
equals
(
contingencyRo
.
getBatchNo
()))
RuleRunigSnapshotServiceImpl
.
setReplayBatchNoToNull
();
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RiskSourceServiceImpl.java
View file @
0a8405c4
...
...
@@ -7,6 +7,7 @@ import com.google.common.base.Joiner;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
import
com.yeejoin.amos.fas.business.bo.*
;
import
com.yeejoin.amos.fas.business.constants.FasConstant
;
import
com.yeejoin.amos.fas.business.dao.mapper.*
;
...
...
@@ -40,6 +41,8 @@ import com.yeejoin.amos.fas.dao.entity.*;
import
com.yeejoin.amos.fas.exception.YeeException
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.DepartmentModel
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -147,6 +150,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private
IDictDao
dictDao
;
@Autowired
private
RedisTemplate
redisTemplate
;
private
RuleTrigger
ruleTrigger
;
@Autowired
private
FmeaEquipmentPointMapper
fmeaEquipmentPointMapper
;
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/intfc/IContingencyInstance.java
View file @
0a8405c4
package
com
.
yeejoin
.
amos
.
fas
.
business
.
service
.
intfc
;
import
java.util.List
;
import
com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance
;
public
interface
IContingencyInstance
{
//
//
ContingencyPlanInstance createInstanceRecord(String instanceNo, String category, String subCategory, String content, String recordType, String icon);
//
//
//
//
List<ContingencyPlanInstance> queryForTimeLine(String instanceNo,String recordType) throws Exception;
//
//
//
void setButtonExecuted(String batchNo,String contingencyPlanId,String code,String buttonState) throws Exception;
//
void setButtonWait(String batchNo,String contingencyPlanId,String buttonState) throws Exception;
//
//
//
void fire(String batchNo,String stepCode, String contingencyPlanId, String buttonCode,String buttonState,String stepStateOnbutton) throws Exception;
//
//
void updateStep(String step, String batchNo);
ContingencyPlanInstance
createInstanceRecord
(
String
instanceNo
,
String
category
,
String
subCategory
,
String
content
,
String
recordType
,
String
icon
);
List
<
ContingencyPlanInstance
>
queryForTimeLine
(
String
instanceNo
,
String
recordType
)
throws
Exception
;
void
setButtonExecuted
(
String
batchNo
,
String
contingencyPlanId
,
String
code
,
String
buttonState
)
throws
Exception
;
void
setButtonWait
(
String
batchNo
,
String
contingencyPlanId
,
String
buttonState
)
throws
Exception
;
void
fire
(
String
batchNo
,
String
stepCode
,
String
contingencyPlanId
,
String
buttonCode
,
String
buttonState
,
String
stepStateOnbutton
)
throws
Exception
;
void
updateStep
(
String
step
,
String
batchNo
);
}
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