Commit 921e0a73 authored by maoying's avatar maoying

Merge branch 'dev_rule' into upgrade

parents 78b6507f ef154a1d
......@@ -4,7 +4,12 @@ import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.yeejoin.amos.fas.business.service.model.RiskSourceRuleRo;
import com.yeejoin.amos.fas.core.common.request.DateUtil;
import com.yeejoin.amos.fas.core.util.StringUtil;
import org.jsoup.helper.DataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -19,6 +24,8 @@ import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.dao.entity.BusinessEntity;
import com.yeejoin.amos.fas.dao.entity.Message;
import com.yeejoin.amos.fas.dao.entity.MessageRo;
import org.springframework.util.unit.DataUnit;
/**
*
* <pre>
......@@ -39,10 +46,8 @@ public class SimpleTipAction implements CustomerAction
//@ExposeAction("消息提示")
public void sendMessageTip(Object bizobj, String title, String content,String type)
{
try
{
ELEvaluationContext.setVariable("bizobj",bizobj);
TipResult result = new TipResult();
result.add(bizobj);
......@@ -54,7 +59,6 @@ public class SimpleTipAction implements CustomerAction
tempmap2.put("content", content);
result.add(tempmap2);
Constructor<?> constructor;
constructor = Class.forName(
......@@ -91,11 +95,20 @@ public class SimpleTipAction implements CustomerAction
message.setTitle(map.get("title").toString());
}
}
MessageRo messageRo = (MessageRo)abstractActionResult.getToipResponse().getBizObj();
message.setTime(messageRo.getDateTime());
message.setBizId(messageRo.getId());
if (abstractActionResult.getToipResponse().getBizObj() instanceof MessageRo) {
MessageRo messageRo = (MessageRo)abstractActionResult.getToipResponse().getBizObj();
message.setTime(messageRo.getDateTime());
message.setBizId(messageRo.getId());
}
if (abstractActionResult.getToipResponse().getBizObj() instanceof RiskSourceRuleRo) {
RiskSourceRuleRo riskSourceRuleRo = (RiskSourceRuleRo) abstractActionResult.getToipResponse().getBizObj();
message.setTime(DateUtil.getNow());
message.setBizId(StringUtil.isNotEmpty(riskSourceRuleRo.getId()) ?
String.valueOf(riskSourceRuleRo.getId()) : "");
}
message.setBizclassName(abstractActionResult.getToipResponse().getBizObj().getClass().toString());
message.setType(type);
message.setId(UUID.randomUUID().toString());
messageService.save(message);
}
}
......
......@@ -21,6 +21,15 @@ public class JpushMsgContentBo {
* 巡检状态
*/
private String checkStatus;
public String getCheckStatus() {
return checkStatus;
}
public void setCheckStatus(String checkStatus) {
this.checkStatus = checkStatus;
}
/**
* 执行日期
*/
......
......@@ -19,6 +19,15 @@ public class MsgParamBo {
private BigDecimal rpn;
private String level;
private String relationName;
private String checkStatus;
public String getCheckStatus() {
return checkStatus;
}
public void setCheckStatus(String checkStatus) {
this.checkStatus = checkStatus;
}
public String getToke() {
return toke;
......
......@@ -564,7 +564,7 @@ public class RiskSourceController extends BaseController {
}
//@Authorization(ingore = true)
// @Authorization(ingore = true)
@ApiOperation(httpMethod = "PUT", value = "上传巡检数据", notes = "上传巡检数据")
@RequestMapping(value = "/data/patroldata", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
public CommonResponse postPatrolData(@RequestBody ProtalDataRo protalData) throws Exception {
......
......@@ -76,4 +76,6 @@ public interface FireEquipMapper extends BaseMapper {
Long queryEquimentRelationCount(
@Param("equipmentId") String equipmentId,
@Param("fname") String fname);
FireEquipmentEntity findById(@Param("id") Long id);
}
......@@ -15,6 +15,7 @@ import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.param.CommonPageInfoParam;
import com.yeejoin.amos.fas.business.service.intfc.IFmeaService;
import com.yeejoin.amos.fas.business.service.model.RiskSourceRo;
import com.yeejoin.amos.fas.core.util.StringUtil;
import com.yeejoin.amos.fas.dao.entity.Fmea;
import com.yeejoin.amos.fas.dao.entity.RiskFactor;
import com.yeejoin.amos.fas.dao.entity.RiskLevel;
......@@ -94,6 +95,7 @@ public class FmeaServiceImpl implements IFmeaService {
userIds.add(String.valueOf(map.get("personLeaderId")));
userIds.add(String.valueOf(map.get("identifyUserId")));
}
userIds.remove("null");
userIds.remove(null);
userIds.remove("");
if(!CollectionUtils.isEmpty(userIds)){
......@@ -101,13 +103,15 @@ public class FmeaServiceImpl implements IFmeaService {
if(!CollectionUtils.isEmpty(userIds)){
users = remoteSecurityService.listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
}
Map<String, String> userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
for (HashMap<String, Object> map : content) {
map.put("companyLeaderName", userMap.get(map.get("companyLeaderId")));
map.put("departmentLeaderName", userMap.get(map.get("departmentLeaderId")));
map.put("groupLeaderName", userMap.get(map.get("groupLeaderId")));
map.put("personLeaderName", userMap.get(map.get("personLeaderId")));
map.put("identifyUserName", userMap.get(map.get("identifyUserId")));
if (StringUtil.isNotEmpty(users)) {
Map<String, String> userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
for (HashMap<String, Object> map : content) {
map.put("companyLeaderName", userMap.get(map.get("companyLeaderId")));
map.put("departmentLeaderName", userMap.get(map.get("departmentLeaderId")));
map.put("groupLeaderName", userMap.get(map.get("groupLeaderId")));
map.put("personLeaderName", userMap.get(map.get("personLeaderId")));
map.put("identifyUserName", userMap.get(map.get("identifyUserId")));
}
}
}
......
......@@ -547,17 +547,30 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if(!CollectionUtils.isEmpty(userIds)){
users = remoteSecurityService.listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
}
Map<String, String> userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
// Map<String, String> userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
Map<String, String> userMap = new HashMap<>();
if(users!=null){
userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
}
List<DepartmentModel> depts = new ArrayList<>();
if(!CollectionUtils.isEmpty(deptIds)){
depts = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, Joiner.on(",").join(deptIds));
}
Map<Long, String > deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName));
content.forEach(e -> {
e.put("userName",userMap.get(e.get("userId")));
e.put("deptName",deptMap.get(e.get("deptId")));
e.put("tel",userMap.get(String.valueOf(e.get("deptId")+"tel")));
});
// Map<Long, String > deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName));
Map<Long, String> deptMap = new HashMap<>();
if(depts!=null){
deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName));
}
// content.forEach(e -> {
// e.put("userName",userMap.get(e.get("userId")));
// e.put("deptName",deptMap.get(e.get("deptId")));
// e.put("tel",userMap.get(String.valueOf(e.get("deptId")+"tel")));
// });
for(int i=0;i<content.size();i++){
content.get(i).put("userName",userMap.get(content.get(i).get("userId")));
content.get(i).put("deptName",deptMap.get(content.get(i).get("deptId")));
content.get(i).put("tel",userMap.get(String.valueOf(content.get(i).get("deptId")+"tel")));
}
}
return new PageImpl<>(content, pageable, total);
}
......@@ -581,11 +594,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
@Async
public void processProtalData(String toke, String product, String appKey, ProtalDataRo protalData) {
if (!CollectionUtils.isEmpty(protalData.getItems())) {
if (!CollectionUtils.isEmpty(protalData.getPointInputitems())) {
Long pointId = protalData.getId();
List<Long> inputIds = Lists.newArrayList();
Map<Long, CheckInputItemRo> map = Maps.newHashMap();
for (CheckInputItemRo checkInputItemRo : protalData.getItems()) {
for (CheckInputItemRo checkInputItemRo : protalData.getPointInputitems()) {
inputIds.add(checkInputItemRo.getPointInputitemId());
map.put(checkInputItemRo.getPointInputitemId(), checkInputItemRo);
}
......@@ -928,12 +941,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} else if (param.getState().equals("false")) {
state = 0;
}
if (state != null) {
if (ids.size() > 0) {
fmeaEquipmentPointMapper.updateStateByIds(state, ids);
}
final Integer st=state;
String monitor=fireEquipMapper.findById(fireEquipPointMapper.getByCode(param.getPointCode()).getFireEquipmentId()).getName();
RsDataQueue rsDataQueue = RsDataQueue.getInstance();
fmeaIds.forEach(fmeaId -> rsDataQueue.addEquipmentMessage(fmeaId,param.getMonitor()));
fmeaIds.forEach(fmeaId -> rsDataQueue.addEquipmentMessage(fmeaId,monitor,st));
}
}
......@@ -1136,6 +1152,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
jpushMsgContentBo.setLevel(msgParam.getLevel());
jpushMsgContentBo.setRelationName(msgParam.getRelationName());
jpushMsgContentBo.setRpn(msgParam.getRpn());
jpushMsgContentBo.setCheckStatus(msgParam.getCheckStatus());
msgBo.setTarget(this.getJpushTarget(msgParam));
msgBo.setMsg(jpushMsgContentBo);
}
......@@ -1182,7 +1199,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public void notifyFmeaFromAbnormal(
String toke, String product, String appKey,
Long fmeaId, String notifyType,String userName, String relationName) {
Long fmeaId, String notifyType,String userName, String relationName, String checkStatus) {
Fmea fmea = fmeaMapper.getById(fmeaId);
if (fmea == null) {
return;
......@@ -1218,7 +1235,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
msgParamBo.setLevel(newLevel.getName());
msgParamBo.setUserName(userName);
msgParamBo.setNotifyType(notifyType);
msgParamBo.setCheckStatus(checkStatus);
msgParamBo.setRelationName(relationName);
msgParamBo.setRpn(rpn);
jpushMsgBo = this.getJushMessageInfo(msgParamBo);
}
//1.3.更新fmea的rpn、风险等级及newOid
......@@ -1286,6 +1305,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (rpnValueBo.isEmpty()) {
return;
}
Fmea caluFmea=fmeaMapper.getById(fmeaId);
Integer rpnDiffer=caluFmea.getRpn().intValue()-caluFmea.getRpni().intValue();
String checkStatus=jpushMsgBo.getMsg().getCheckStatus();
BigDecimal rpn = rpnValueBo.getRpn();
BigDecimal rpni = rpnValueBo.getRpni();
List<RiskLevel> levels = riskLevelDao.findAll();
......@@ -1305,9 +1327,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
//3.更新父节点rpn、rpni、风险等级
this.updateParentRpn(riskSource.getParentId());
//4.极光推送给手机客户端
if(notifyType=="recovery"||notifyType=="fmeaUpdate"||(notifyType=="alarm"&&rpnDiffer>0)||(notifyType=="patrol"&&rpnDiffer>0&&checkStatus.equals("不合格")))
jpushRiskSourceMessage(jpushMsgBo);
//5.规则告警(消息)TODO
notifyRule(riskSourceId, rpn, rpni, notifyType,changeType);
if(notifyType=="recovery"||notifyType=="fmeaUpdate"||(notifyType=="alarm"&&rpnDiffer>0)||(notifyType=="patrol"&&rpnDiffer>0&&checkStatus.equals("不合格")))
notifyRule(riskSourceId, rpn, rpni, notifyType,changeType, jpushMsgBo.getMsg());
//6.通知全景监控屏幕数据刷新
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
}
......@@ -1412,15 +1436,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
BigDecimal rpnr,
BigDecimal rpni,
String notifyType,
String changeType) {
String changeType, JpushMsgContentBo msgContentBo) {
RiskSourceRuleRo riskSourceRuleRo = new RiskSourceRuleRo();
riskSourceRuleRo.setId(id);
riskSourceRuleRo.setRpnr(rpnr);
riskSourceRuleRo.setRpni(rpni);
riskSourceRuleRo.setLevelChangeType(changeType);
riskSourceRuleRo.setNotifyType(notifyType);
riskSourceRuleRo.setType(notifyType);
riskSourceRuleRo.setContent(msgContentBo.genMessage());
riskSourceRuleRo.setTitle(msgContentBo.getSubject());
riskSourceRuleRo.setRg(String.valueOf(rpnr.subtract(rpni).toBigInteger()));
try {
remoteRuleServer.fireRule(riskSourceRuleRo, "风险管控/riskSource");
// remoteRuleServer.fireRule(riskSourceRuleRo, "风险管控/riskSource");
ruleTrigger.publish(riskSourceRuleRo, "风险管控/riskSource", null);// 没有配决策流,processIds传null即可
} catch (Exception e) {
log.error("调用规则异常", e);
}
......
......@@ -109,7 +109,7 @@ public interface IRiskSourceService {
Integer getChildTypeByPid(Long riskSourceId);
void notifyFmeaFromAbnormal(String toke,String product,String appKey,Long fmeaId, String notifyType,String userName, String relationName);
void notifyFmeaFromAbnormal(String toke,String product,String appKey,Long fmeaId, String notifyType,String userName, String relationName,String checkStatus);
void notifyFmeaFromUpdate(String toke,String product,String appKey,Long fmeaId, String nofityType,String userName);
......
package com.yeejoin.amos.fas.business.service.model;
import com.yeejoin.amos.fas.dao.entity.BusinessEntity;
import java.io.Serializable;
public class BasicsRo implements Serializable {
public class BasicsRo extends BusinessEntity implements Serializable {
private String batchNo;
......
......@@ -49,6 +49,16 @@ public class ProtalDataRo extends BasicsRo {
private List<CheckInputItemRo> items;
private List<CheckInputItemRo> pointInputitems;
public List<CheckInputItemRo> getPointInputitems() {
return pointInputitems;
}
public void setPointInputitems(List<CheckInputItemRo> pointInputitems) {
this.pointInputitems = pointInputitems;
}
public List<CheckInputItemRo> getItems() {
return items;
}
......
......@@ -4,10 +4,11 @@ import java.math.BigDecimal;
public class RiskSourceRuleRo extends BasicsRo {
private static final long serialVersionUID = -1029442967802232957L;
/**
* patrol、equipment、update、delete
*/
private String notifyType;
private String type;
private Long id;
......@@ -16,10 +17,24 @@ public class RiskSourceRuleRo extends BasicsRo {
private BigDecimal rpni;
/**
* 风险增益
*/
private String rg;
/**
* up、down、no
*/
private String levelChangeType;
/**
* 消息内容
*/
private String content;
/**
* 消息标题
*/
private String title;
public Long getId() {
return id;
}
......@@ -52,11 +67,35 @@ public class RiskSourceRuleRo extends BasicsRo {
this.levelChangeType = levelChangeType;
}
public String getNotifyType() {
return notifyType;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getRg() {
return rg;
}
public void setNotifyType(String notifyType) {
this.notifyType = notifyType;
public void setRg(String rg) {
this.rg = rg;
}
}
......@@ -78,6 +78,15 @@ public class RsDataQueue {
blockingQueue.add(new FmeaMessage(fmeaId, TriggerRpnChangeTypeEum.alarm.getCode(),"",equipmentName,""));
}
public void addEquipmentMessage(Long fmeaId,String equipmentName,Integer state) {
if(state==0){
blockingQueue.add(new FmeaMessage(fmeaId, TriggerRpnChangeTypeEum.alarmRecovery.getCode(),"",equipmentName,""));
}else{
blockingQueue.add(new FmeaMessage(fmeaId, TriggerRpnChangeTypeEum.alarm.getCode(),"",equipmentName,""));
}
}
public void addDeleteMessage(Long riskSourceId) {
blockingQueue.add(new FmeaMessage(riskSourceId, TriggerRpnChangeTypeEum.fmeaDelete.getCode()));
}
......@@ -105,12 +114,19 @@ public class RsDataQueue {
Long handId = fmeaMessage.getHandId();
String userName = fmeaMessage.getUserName();
String relationName = fmeaMessage.getRelationName();
String checkStatus =null;
if(fmeaMessage.getCheckStatus()!=null){
checkStatus =(fmeaMessage.getCheckStatus().equals("1"))?"合格":"不合格";
}
if (from.equals(TriggerRpnChangeTypeEum.patrol.getCode())) {
//巡检不合格通知
riskSourceService.notifyFmeaFromAbnormal(toke.getToke(), toke.getProduct(), toke.getAppKey(), handId, from, userName,relationName);
riskSourceService.notifyFmeaFromAbnormal(toke.getToke(), toke.getProduct(), toke.getAppKey(), handId, from, userName,relationName,checkStatus);
} else if (from.equals(TriggerRpnChangeTypeEum.alarm.getCode())) {
//设备告警
riskSourceService.notifyFmeaFromAbnormal(toke.getToke(), toke.getProduct(), toke.getAppKey(), handId, from, userName,relationName);
riskSourceService.notifyFmeaFromAbnormal(toke.getToke(), toke.getProduct(), toke.getAppKey(), handId, from, userName,relationName,checkStatus);
} else if (from.equals(TriggerRpnChangeTypeEum.alarmRecovery.getCode())) {
//设备告警恢复
riskSourceService.notifyFmeaFromAbnormal(toke.getToke(), toke.getProduct(), toke.getAppKey(), handId, from, userName,relationName,checkStatus);
} else if (from.equals(TriggerRpnChangeTypeEum.fmeaUpdate.getCode())) {
//危险因素评价修改通知
riskSourceService.notifyFmeaFromUpdate(toke.getToke(), toke.getProduct(), toke.getAppKey(), handId, from, userName);
......
......@@ -62,4 +62,6 @@ dutyMode.fegin.name=AMOS-DUTY
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true
rule.definition.model-package=com.yeejoin.amos.fas.business.service.model
\ No newline at end of file
rule.definition.model-package=com.yeejoin.amos.fas.business.service.model
amos.feign.gennerator.use-gateway=false
\ No newline at end of file
spring.application.name = AMOS-AUTOSYS-WJ
spring.application.name = AMOS-AUTOSYS
server.port = 8083
......
......@@ -500,4 +500,8 @@
AND fe.`name` like '%${fname}%'
</if>
</select>
<select id="findById" resultType="com.yeejoin.amos.fas.business.entity.mybatis.FireEquipmentEntity">
select name from f_fire_equipment where id= #{id}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment