Commit e4af6fbc authored by suhuiguang's avatar suhuiguang

Merge branch 'develop' into dev_upgrade

# Conflicts: # YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/PlanVisual3dController.java # YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/FireEquipPointServiceImpl.java # YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/FmeaServiceImpl.java # YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ITopographyNodeServiceImpl.java # YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RiskSourceServiceImpl.java # YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/intfc/IRiskSourceService.java # YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/client/invoke/RsDataQueue.java # YeeAmosFireAutoSysStart/src/main/resources/db/changelog/fas-1.0.2.xml
parents e28ff62a 5a275471
package com.yeejoin.amos.fas.common.enums;
/**
* rpn变化类型枚举
*/
public enum RpnChangeLogTypeEum {
/**
* 类型枚举
*/
upper("上升",0),
down("下降",1),
unChange("未发生变化",2);
private String name;
private int code;
RpnChangeLogTypeEum(String name,int code){
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
package com.yeejoin.amos.fas.common.enums;
/**
* @author DELL
*/
public enum TriggerRpnChangeTypeEum {
/**
* 触发类型枚举
*/
patrol("巡检","patrol"),
equipment("设备告警","equipment"),
fmeaUpdate("危险因素评价","fmeaUpdate"),
fmeaDelete("危险因素删除","fmeaDelete"),
riskDelete("风险点删除","riskDelete");
private String name;
private String code;
TriggerRpnChangeTypeEum(String name,String code){
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
...@@ -47,6 +47,8 @@ public class RiskLevel extends BasicEntity { ...@@ -47,6 +47,8 @@ public class RiskLevel extends BasicEntity {
@Column(name = "down_limit") @Column(name = "down_limit")
private BigDecimal downLimit; private BigDecimal downLimit;
private Integer manageLevel;
private String remark; private String remark;
private String severity; private String severity;
...@@ -125,4 +127,12 @@ public class RiskLevel extends BasicEntity { ...@@ -125,4 +127,12 @@ public class RiskLevel extends BasicEntity {
public void setDownLimit(BigDecimal downLimit) { public void setDownLimit(BigDecimal downLimit) {
this.downLimit = downLimit; this.downLimit = downLimit;
} }
public Integer getManageLevel() {
return manageLevel;
}
public void setManageLevel(Integer manageLevel) {
this.manageLevel = manageLevel;
}
} }
\ No newline at end of file
...@@ -67,6 +67,12 @@ public class TopographyLine extends BusinessEntity{ ...@@ -67,6 +67,12 @@ public class TopographyLine extends BusinessEntity{
@Column(name = "to_port", columnDefinition = "varchar(32) COMMENT '终点'") @Column(name = "to_port", columnDefinition = "varchar(32) COMMENT '终点'")
private String toPort; private String toPort;
@Column(name = "type", columnDefinition = "varchar(32) COMMENT '1 领导架构 | 2 任务流程'")
private String type;
@Column(name = "category", columnDefinition = "varchar(32) COMMENT '类别'")
private String category;
public String getId() { public String getId() {
return id; return id;
} }
...@@ -127,6 +133,18 @@ public class TopographyLine extends BusinessEntity{ ...@@ -127,6 +133,18 @@ public class TopographyLine extends BusinessEntity{
public void setToPort(String toPort) { public void setToPort(String toPort) {
this.toPort = toPort; this.toPort = toPort;
} }
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
} }
...@@ -74,6 +74,9 @@ public class TopographyNode extends BusinessEntity{ ...@@ -74,6 +74,9 @@ public class TopographyNode extends BusinessEntity{
@Column(name = "source_id", columnDefinition = "varchar(32) COMMENT '资源id'") @Column(name = "source_id", columnDefinition = "varchar(32) COMMENT '资源id'")
private String sourceId; private String sourceId;
@Column(name = "type", columnDefinition = "varchar(32) COMMENT '1 领导架构 | 2 任务流程'")
private String type;
public String getId() { public String getId() {
return id; return id;
} }
...@@ -140,4 +143,10 @@ public class TopographyNode extends BusinessEntity{ ...@@ -140,4 +143,10 @@ public class TopographyNode extends BusinessEntity{
public void setSourceId(String sourceId) { public void setSourceId(String sourceId) {
this.sourceId = sourceId; this.sourceId = sourceId;
} }
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
} }
package com.yeejoin.amos.fas.business.bo;
import java.math.BigDecimal;
/**
* @author DELL
*/
public class RpnCalculationBo {
/**
* rpn
*/
BigDecimal rpn;
/**
* rpni
*/
BigDecimal rpni;
/**
* 长度
*/
long size;
public long getSize() {
return size;
}
public void setSize(long size) {
this.size = size;
}
public BigDecimal getRpn() {
return rpn;
}
public void setRpn(BigDecimal rpn) {
this.rpn = rpn;
}
public BigDecimal getRpni() {
return rpni;
}
public void setRpni(BigDecimal rpni) {
this.rpni = rpni;
}
public boolean isEmpty(){
return size <= 0;
}
}
...@@ -210,7 +210,7 @@ public class FileController extends BaseController { ...@@ -210,7 +210,7 @@ public class FileController extends BaseController {
return new CommonResponse(SUCCESS, "访问的文件不存在!", "查询成功"); return new CommonResponse(SUCCESS, "访问的文件不存在!", "查询成功");
} }
if (fileName.endsWith(".doc") || fileName.endsWith(".docx")) { if (fileName.endsWith(".doc") || fileName.endsWith(".docx")) {
String htmlFileName = fileName.substring(0, fileName.indexOf(".")) + ".html"; String htmlFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ".html";
File htmlFile = new File(htmlFileName); File htmlFile = new File(htmlFileName);
String data = WordConverterUtils.wordToHtmlString(fileName, readUrl); String data = WordConverterUtils.wordToHtmlString(fileName, readUrl);
Map<String, Object> processData = null; Map<String, Object> processData = null;
......
...@@ -7,28 +7,15 @@ import com.yeejoin.amos.fas.dao.entity.TextPlan; ...@@ -7,28 +7,15 @@ import com.yeejoin.amos.fas.dao.entity.TextPlan;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -38,14 +25,14 @@ import java.util.Map; ...@@ -38,14 +25,14 @@ import java.util.Map;
public class PlanVisual3dController extends BaseController { public class PlanVisual3dController extends BaseController {
private final Logger log = LoggerFactory.getLogger(PlanVisual3dController.class); private final Logger log = LoggerFactory.getLogger(PlanVisual3dController.class);
// 上传路径 // 上传路径
@Value("${file.uploadUrl}") @Value("${file.uploadUrl}")
private String fileUploadDir; private String fileUploadDir;
@Autowired @Autowired
private IPlanVisual3dService planVisual3dService; private IPlanVisual3dService planVisual3dService;
@Autowired @Autowired
HttpServletResponse response; HttpServletResponse response;
@Autowired @Autowired
...@@ -62,50 +49,50 @@ public class PlanVisual3dController extends BaseController { ...@@ -62,50 +49,50 @@ public class PlanVisual3dController extends BaseController {
public CommonResponse getTextPlanById(@PathVariable(value = "id") Long id) { public CommonResponse getTextPlanById(@PathVariable(value = "id") Long id) {
return CommonResponseUtil.success(planVisual3dService.getTextPlanInfoById(id)); return CommonResponseUtil.success(planVisual3dService.getTextPlanInfoById(id));
} }
//@Authorization(ingore = true) //@Authorization(ingore = true)
@RequestMapping(value = "/plan/text/downloadFile/{id}", method = RequestMethod.GET) @RequestMapping(value = "/plan/text/downloadFile/{id}", method = RequestMethod.GET)
public HttpServletResponse download(@PathVariable("id") Long id) { public HttpServletResponse download(@PathVariable("id") Long id) {
TextPlan testPlan = planVisual3dService.getTextPlanInfoById(id); TextPlan testPlan = planVisual3dService.getTextPlanInfoById(id);
if(testPlan != null) { if (testPlan != null) {
String path = testPlan.getFilePath(); String path = testPlan.getFilePath();
if( path != null && !"".equals(path)) { if (path != null && !"".equals(path)) {
try { try {
// path是指欲下载的文件的路径。 // path是指欲下载的文件的路径。
File file = new File(fileUploadDir + path); File file = new File(fileUploadDir + path);
if(file.exists()) { if (file.exists()) {
// 取得文件名。 // 取得文件名。
String filename = file.getName(); String filename = file.getName();
// 取得文件的后缀名。 // 取得文件的后缀名。
String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase(); String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase();
// 以流的形式下载文件。 // 以流的形式下载文件。
InputStream fis = new BufferedInputStream(new FileInputStream(fileUploadDir + path)); InputStream fis = new BufferedInputStream(new FileInputStream(fileUploadDir + path));
byte[] buffer = new byte[fis.available()]; byte[] buffer = new byte[fis.available()];
fis.read(buffer); fis.read(buffer);
fis.close(); fis.close();
// 清空response // 清空response
// response.reset(); // response.reset();
// 设置response的Header // 设置response的Header
response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes())); response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes()));
response.addHeader("Content-Length", "" + file.length()); response.addHeader("Content-Length", "" + file.length());
response.setContentType("application/x-download"); response.setContentType("application/x-download");
OutputStream toClient = new BufferedOutputStream(response.getOutputStream()); OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
toClient.write(buffer); toClient.write(buffer);
toClient.flush(); toClient.flush();
toClient.close(); toClient.close();
}else { } else {
response.setStatus(404); response.setStatus(404);
} }
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
}else { } else {
response.setStatus(404); response.setStatus(404);
} }
return response; return response;
} }
/** /**
......
...@@ -42,11 +42,22 @@ public class TopographyController { ...@@ -42,11 +42,22 @@ public class TopographyController {
@Autowired @Autowired
private ITopographyLineService lineService; private ITopographyLineService lineService;
@ApiOperation(value = "根据appID查询节点及线", notes = "根据appID查询节点及线") @ApiOperation(value = "根据appId查询节点及线", notes = "根据appID查询节点及线")
@GetMapping(value = "/{appId}") @GetMapping(value = "/query/{type}/{appId}")
public CommonResponse getTextPlanById(@PathVariable(value = "appId") String appId) { public CommonResponse getTextPlanByIdAndType(@PathVariable(value = "appId") String appId,@PathVariable(value = "type") String type) {
List<TopographyNode> nodes = nodeService.getNodesByAppId(appId); List<TopographyNode> nodes = nodeService.getNodesByAppIdAndType(appId,type);
List<TopographyLine> links = lineService.getLinksByAppId(appId); List<TopographyLine> links = lineService.getLinesByAppIdAndType(appId,type);
Map<String,Object> results = new HashMap<>();
results.put("nodeData", nodes);
results.put("linkData", links);
return CommonResponseUtil.success(results);
}
@ApiOperation(value = "根据type查询节点及线", notes = "根据type查询节点及线")
@GetMapping(value = "/query/{type}")
public CommonResponse getTextPlanByType(@PathVariable(value = "type") String type) {
List<TopographyNode> nodes = nodeService.getNodesByType(type);
List<TopographyLine> links = lineService.getLinesByType(type);
Map<String,Object> results = new HashMap<>(); Map<String,Object> results = new HashMap<>();
results.put("nodeData", nodes); results.put("nodeData", nodes);
results.put("linkData", links); results.put("linkData", links);
...@@ -61,58 +72,73 @@ public class TopographyController { ...@@ -61,58 +72,73 @@ public class TopographyController {
@PostMapping(value = "/updateTopo", produces = "application/json;charset=UTF-8") @PostMapping(value = "/updateTopo", produces = "application/json;charset=UTF-8")
@ApiOperation(value = "保存拓扑图", notes = "保存拓扑图") @ApiOperation(value = "保存拓扑图", notes = "保存拓扑图")
public CommonResponse savedonghuanNodes(@ApiParam(value = "", required = false) @RequestBody JSONObject topographyParam) { public CommonResponse savedonghuanNodes(@ApiParam(value = "", required = false) @RequestBody JSONObject topographyParam) {
String appId = topographyParam.getString("appId"); synchronized (TopographyController.class) {
//节点
JSONArray nodes = topographyParam.getJSONArray("nodeData"); String appId = topographyParam.getString("appId") != null ? topographyParam.getString("appId") : null;
List<TopographyNode> nodeData = JSON.parseArray(JSON.toJSONString(nodes), TopographyNode.class); String type = topographyParam.getString("type");
HashMap<String, String> convertKeyMap = new HashMap<>(); //节点
int curSize = nodeService.queryMaxKeyByAppId(appId); JSONArray nodes = topographyParam.getJSONArray("nodeData");
for(TopographyNode e:nodeData){ List<TopographyNode> nodeData = JSON.parseArray(JSON.toJSONString(nodes), TopographyNode.class);
if(Integer.valueOf(e.getKey()) < 0) { HashMap<String, String> convertKeyMap = new HashMap<>();
curSize = curSize + 1 ; int curSize = nodeService.queryMaxKeyByAppIdAndType(appId,type);
String newKey = String.format("%05d", curSize); for(TopographyNode e:nodeData){
convertKeyMap.put(e.getKey(), newKey); if(Integer.valueOf(e.getKey()) < 0) {
e.setKey(newKey); curSize = curSize + 1 ;
e.setAppId(appId); String newKey = String.format("%05d", curSize);
e.setGroup(""); convertKeyMap.put(e.getKey(), newKey);
} e.setKey(newKey);
}; e.setType(type);
//线 e.setAppId(appId);
JSONArray links = topographyParam.getJSONArray("linkData"); if(e.getGroup() == null) {
List<TopographyLine> lineData = JSON.parseArray(JSON.toJSONString(links), TopographyLine.class); e.setGroup("");
lineData.forEach(l -> { }else if(Integer.valueOf(e.getGroup()) < 0){//修改新节点组
if(Integer.parseInt(l.getFrom()) < 0) { e.setGroup(convertKeyMap.get(e.getGroup()));
l.setFrom(convertKeyMap.get(l.getFrom())); }
} }
if(Integer.parseInt(l.getTo()) < 0) { };
l.setTo(convertKeyMap.get(l.getTo())); //线
} JSONArray links = topographyParam.getJSONArray("linkData");
if(l.getAppId() == null) { List<TopographyLine> lineData = JSON.parseArray(JSON.toJSONString(links), TopographyLine.class);
l.setAppId(appId); lineData.forEach(l -> {//修改新增节点之间线的连接
} if(Integer.parseInt(l.getFrom()) < 0) {
}); l.setFrom(convertKeyMap.get(l.getFrom()));
}
nodeService.saveNodes(nodeData); if(Integer.parseInt(l.getTo()) < 0) {
lineService.saveLines(lineData); l.setTo(convertKeyMap.get(l.getTo()));
}
//节点详情 if(l.getCategory() == null) {
JSONObject nodeDetailJson = topographyParam.getJSONObject("nodeDetail"); l.setCategory("");
if(nodeDetailJson != null) { }
TopographyNodeDetail nodeDetail = JSON.parseObject(JSON.toJSONString(nodeDetailJson), TopographyNodeDetail.class); if(l.getAppId() == null) {
String nodekey = nodeDetail.getNodekey(); l.setAppId(appId);
if(nodekey != null && Integer.parseInt(nodekey) < 0) { l.setType(type);
TopographyNode node = nodeService.queryByKeyAndAppId(convertKeyMap.get(nodekey),appId); }
nodeDetail.setNodeid(node.getId()); });
}
nodeService.saveNodeDetail(nodeDetail); nodeService.saveNodes(nodeData);
lineService.saveLines(lineData);
//节点详情
JSONObject nodeDetailJson = topographyParam.getJSONObject("nodeDetail");
if(nodeDetailJson != null) {
TopographyNodeDetail nodeDetail = JSON.parseObject(JSON.toJSONString(nodeDetailJson), TopographyNodeDetail.class);
String nodekey = nodeDetail.getNodekey();
if(nodekey != null && Integer.parseInt(nodekey) < 0) {
TopographyNode node = nodeService.queryByKeyAndAppIdAndType(convertKeyMap.get(nodekey),appId,type);
nodeDetail.setNodeid(node.getId());
}
nodeService.saveNodeDetail(nodeDetail);
}
//返回保存后的数据
List<TopographyNode> newNodes = nodeService.getNodesByAppIdAndType(appId,type);
List<TopographyLine> newLinks = lineService.getLinesByAppIdAndType(appId,type);
Map<String,Object> results = new HashMap<>();
results.put("nodeData", newNodes);
results.put("linkData", newLinks);
return CommonResponseUtil.success(results);
} }
List<TopographyNode> newNodes = nodeService.getNodesByAppId(appId);
List<TopographyLine> newLinks = lineService.getLinksByAppId(appId);
Map<String,Object> results = new HashMap<>();
results.put("nodeData", newNodes);
results.put("linkData", newLinks);
return CommonResponseUtil.success(results);
} }
@ApiOperation(value = "根据nodeid查询节点详情", notes = "根据nodeid查询节点详情") @ApiOperation(value = "根据nodeid查询节点详情", notes = "根据nodeid查询节点详情")
...@@ -143,7 +169,8 @@ public class TopographyController { ...@@ -143,7 +169,8 @@ public class TopographyController {
if("Link".equals(type)) { if("Link".equals(type)) {
lineService.deleteLine(id); lineService.deleteLine(id);
}else { }else {
nodeService.deleteNode(id); TopographyNode node = nodeService.queryById(id);
nodeService.deleteNode(node);
} }
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
...@@ -36,5 +36,7 @@ public interface FmeaMapper extends BaseMapper { ...@@ -36,5 +36,7 @@ public interface FmeaMapper extends BaseMapper {
List<Fmea> listByRiskSourceId(Long riskSourceId); List<Fmea> listByRiskSourceId(Long riskSourceId);
List<Fmea> listByRiskSourceIds(@Param("ids") List<Long> ids);
void updateRpn(Fmea fmea); void updateRpn(Fmea fmea);
} }
...@@ -6,7 +6,7 @@ import java.util.List; ...@@ -6,7 +6,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public interface PlanVisual3dMapper extends BaseMapper { public interface PlanVisual3dMapper extends BaseMapper {
List<HashMap<String,String>> getResourceListByType(@Param("type") String type); List<HashMap<String,Object>> getResourceListByType(@Param("type") String type);
Map<String, Object> queryOneByTypeAndId(@Param("type") String type, @Param("id") Long id); Map<String, Object> queryOneByTypeAndId(@Param("type") String type, @Param("id") Long id);
} }
...@@ -12,5 +12,7 @@ public interface IFireEquipmentPointDao extends BaseDao<FireEquipmentPoint, Long ...@@ -12,5 +12,7 @@ public interface IFireEquipmentPointDao extends BaseDao<FireEquipmentPoint, Long
Optional<FireEquipmentPoint> findById(Long id); Optional<FireEquipmentPoint> findById(Long id);
FireEquipmentPoint findOneByCode(String pointCode); FireEquipmentPoint findOneByCode(String pointCode);
int countByCode(String code);
} }
...@@ -30,7 +30,7 @@ public interface IFmeaDao extends BaseDao<Fmea, Long> { ...@@ -30,7 +30,7 @@ public interface IFmeaDao extends BaseDao<Fmea, Long> {
/** /**
* 根据ID删除fmea对象 * 根据ID删除fmea对象
* *
* @param riskSourceId * @param fmeaIds
*/ */
@Modifying @Modifying
@Transactional @Transactional
...@@ -45,4 +45,7 @@ public interface IFmeaDao extends BaseDao<Fmea, Long> { ...@@ -45,4 +45,7 @@ public interface IFmeaDao extends BaseDao<Fmea, Long> {
@Query(value = "SELECT count(1) FROM `f_fmea_equipment_point` WHERE fmea_id in ?1", nativeQuery = true) @Query(value = "SELECT count(1) FROM `f_fmea_equipment_point` WHERE fmea_id in ?1", nativeQuery = true)
int countAssociatedEquipPointByIds(String[] ids); int countAssociatedEquipPointByIds(String[] ids);
@Query(value = "select * from `f_fmea` where id in ?1",nativeQuery = true)
List<Fmea> findAllByRiskSourceIds(List<Long> ids);
} }
...@@ -10,11 +10,13 @@ import com.yeejoin.amos.fas.dao.entity.TopographyLine; ...@@ -10,11 +10,13 @@ import com.yeejoin.amos.fas.dao.entity.TopographyLine;
@Repository("iTopographyLineDao") @Repository("iTopographyLineDao")
public interface ITopographyLineDao extends BaseDao<TopographyLine, Long> { public interface ITopographyLineDao extends BaseDao<TopographyLine, Long> {
List<TopographyLine> findByAppId(String appId); List<TopographyLine> findByAppIdAndType(String appId,String type);
TopographyLine findById(String id); TopographyLine findById(String id);
@Query(value = "select * from f_topography_line " + " where `from` = (?1) or `to` = (?1)",nativeQuery = true) @Query(value = "select * from f_topography_line " + " where `from` = (?1) or `to` = (?1)",nativeQuery = true)
List<TopographyLine> findByKey(String key); List<TopographyLine> findByKey(String key);
List<TopographyLine> findByType(String type);
} }
...@@ -11,16 +11,23 @@ import com.yeejoin.amos.fas.dao.entity.TopographyNode; ...@@ -11,16 +11,23 @@ import com.yeejoin.amos.fas.dao.entity.TopographyNode;
@Repository("iTopographyNodeDao") @Repository("iTopographyNodeDao")
public interface ITopographyNodeDao extends BaseDao<TopographyNode, Long> { public interface ITopographyNodeDao extends BaseDao<TopographyNode, Long> {
List<TopographyNode> findByAppId(String appId); List<TopographyNode> findByAppIdAndType(String appId,String type);
@Query(value = "select * from f_topography_node " + " where id in (?1)",nativeQuery = true) @Query(value = "select * from f_topography_node " + " where id in (?1)",nativeQuery = true)
List<TopographyNode> findAllByIds(@Param("ids") List<String> ids); List<TopographyNode> findAllByIds(@Param("ids") List<String> ids);
TopographyNode findById(String id); TopographyNode findById(String id);
TopographyNode findByKeyAndAppId(String nodekey, String appId); TopographyNode findByKeyAndAppIdAndType(String nodekey, String appId,String type);
@Query(value = "select max(`key`) from f_topography_node where app_id = (?1)",nativeQuery = true) @Query(value = "select max(`key`) from f_topography_node where app_id = (?1) and type = (?2)",nativeQuery = true)
Integer queryMaxKeyByAppId(String appId); Integer queryMaxKeyByAppIdAndType(String appId,String type);
List<TopographyNode> findByGroupAndAppIdAndType(String key, String appId, String type);
List<TopographyNode> findByType(String type);
@Query(value = "select max(`key`) from f_topography_node where type = (?1)",nativeQuery = true)
Integer queryMaxKeyByType(String type);
} }
...@@ -29,6 +29,8 @@ public class FireEquipmentPointEntity extends FireEquipmentPointExtend { ...@@ -29,6 +29,8 @@ public class FireEquipmentPointEntity extends FireEquipmentPointExtend {
private String orgCode; private String orgCode;
private Long alarmType; private Long alarmType;
private String alarmTypeName;
private String fireEquipmentCode; private String fireEquipmentCode;
...@@ -135,4 +137,12 @@ public class FireEquipmentPointEntity extends FireEquipmentPointExtend { ...@@ -135,4 +137,12 @@ public class FireEquipmentPointEntity extends FireEquipmentPointExtend {
public void setFireEquipmentCode(String fireEquipmentCode) { public void setFireEquipmentCode(String fireEquipmentCode) {
this.fireEquipmentCode = fireEquipmentCode; this.fireEquipmentCode = fireEquipmentCode;
} }
public String getAlarmTypeName() {
return alarmTypeName;
}
public void setAlarmTypeName(String alarmTypeName) {
this.alarmTypeName = alarmTypeName;
}
} }
...@@ -29,7 +29,7 @@ public class FireEquipmentPointParam { ...@@ -29,7 +29,7 @@ public class FireEquipmentPointParam {
@Excel(name = "单位", orderNum = "7", width = 12) @Excel(name = "单位", orderNum = "7", width = 12)
private String unit; private String unit;
@Excel(name = "告警类型", replace = {"火灾告警_1", "电源开关_2", "换流变_6", "液位_3", "流量_4", "容量_5"}, orderNum = "8") @Excel(name = "告警类型", replace = {"火灾告警_1", "电源开关_2", "换流变_6", "液位_3", "流量_4", "容量_5", "故障告警_7"}, orderNum = "8")
private Long alarmType; private Long alarmType;
public Long getId() { public Long getId() {
......
...@@ -67,10 +67,7 @@ public class FmeaServiceImpl implements IFmeaService { ...@@ -67,10 +67,7 @@ public class FmeaServiceImpl implements IFmeaService {
fmeas.forEach(fmea -> { fmeas.forEach(fmea -> {
String userId = paramMap.get("user_id") == null ? "0" : paramMap.get("user_id").toString(); String userId = paramMap.get("user_id") == null ? "0" : paramMap.get("user_id").toString();
fmea.setCreateBy(userId); fmea.setCreateBy(userId);
// RiskSource riskSource = iRiskSourceDao.findById(fmea.getRiskSourceId());
// fmea.setRiskSource(riskSource);
iFmeaDao.save(fmea); iFmeaDao.save(fmea);
//updateRpniInfo(fmea.getRiskSourceId());
}); });
} }
...@@ -235,8 +232,9 @@ public class FmeaServiceImpl implements IFmeaService { ...@@ -235,8 +232,9 @@ public class FmeaServiceImpl implements IFmeaService {
if(anomalyLevel1.isPresent()){ if(anomalyLevel1.isPresent()){
anomalyLevel =anomalyLevel1.get(); anomalyLevel =anomalyLevel1.get();
} }
if (anomalyLevel != null && anomalyLevel.getLevel() > maxLevel) if (anomalyLevel != null && anomalyLevel.getLevel() > maxLevel){
maxLevel = anomalyLevel.getLevel(); maxLevel = anomalyLevel.getLevel();
}
} }
return maxLevel; return maxLevel;
} }
...@@ -245,36 +243,14 @@ public class FmeaServiceImpl implements IFmeaService { ...@@ -245,36 +243,14 @@ public class FmeaServiceImpl implements IFmeaService {
private List<RiskSource> findAnomalyRiskSource(Long riskSourceId) { private List<RiskSource> findAnomalyRiskSource(Long riskSourceId) {
List<RiskSource> returnList = new ArrayList<>(); List<RiskSource> returnList = new ArrayList<>();
List<RiskSource> childs = iRiskSourceDao.findByParentId(riskSourceId); List<RiskSource> childs = iRiskSourceDao.findByParentId(riskSourceId);
if (CollectionUtils.isEmpty(childs)){
if (CollectionUtils.isEmpty(childs))
return returnList; return returnList;
}
for (RiskSource child : childs) { for (RiskSource child : childs) {
/*if("ANOMALY".equals(child.getStatus()))
{
returnList.add(child);
}*/
returnList.add(child); returnList.add(child);
returnList.addAll(this.findAnomalyRiskSource(child.getId())); returnList.addAll(this.findAnomalyRiskSource(child.getId()));
} }
return returnList; return returnList;
} }
private BigDecimal updateRpn(Object result, RiskSource riskSource, BigDecimal RPNi) {
/*"RPNr": 16,
"RPNi": -14*/
Map map = (Map) result;
RPNi = new BigDecimal(Double.parseDouble(String.valueOf(map.get("RPNi"))));
if (RPNi != null) {
riskSource.setRpni(RPNi);
this.iRiskSourceDao.save(riskSource);
}
return RPNi;
}
} }
...@@ -16,8 +16,11 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{ ...@@ -16,8 +16,11 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{
private ITopographyLineDao topographyLineDao; private ITopographyLineDao topographyLineDao;
@Override @Override
public List<TopographyLine> getLinksByAppId(String appId) { public List<TopographyLine> getLinesByAppIdAndType(String appId,String type) {
return topographyLineDao.findByAppId(appId); if(appId == null) {
return topographyLineDao.findByType(type);
}
return topographyLineDao.findByAppIdAndType(appId,type);
} }
@Override @Override
...@@ -32,6 +35,11 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{ ...@@ -32,6 +35,11 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{
topographyLineDao.delete(line); topographyLineDao.delete(line);
} }
} }
@Override
public List<TopographyLine> getLinesByType(String type) {
return topographyLineDao.findByType(type);
}
} }
...@@ -26,8 +26,11 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{ ...@@ -26,8 +26,11 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
private ITopographyLineDao lineDao; private ITopographyLineDao lineDao;
@Override @Override
public List<TopographyNode> getNodesByAppId(String appId) { public List<TopographyNode> getNodesByAppIdAndType(String appId,String type) {
return nodeDao.findByAppId(appId); if(appId == null) {
return nodeDao.findByType(type);
}
return nodeDao.findByAppIdAndType(appId,type);
} }
@Override @Override
...@@ -53,8 +56,8 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{ ...@@ -53,8 +56,8 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
} }
@Override @Override
public void deleteNode(String id) { public void deleteNode(TopographyNode node) {
TopographyNode node = nodeDao.findById(id); // TopographyNode node = nodeDao.findById(id);
if(node != null) { if(node != null) {
String key = node.getKey(); String key = node.getKey();
nodeDao.delete(node); nodeDao.delete(node);
...@@ -62,17 +65,41 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{ ...@@ -62,17 +65,41 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
if(lines != null && lines.size() > 0) { if(lines != null && lines.size() > 0) {
lineDao.deleteAll(lines); lineDao.deleteAll(lines);
} }
if(node.getIsGroup() != null && node.getIsGroup()) {
List<TopographyNode> childNodes = nodeDao.findByGroupAndAppIdAndType(node.getKey(),node.getAppId(),node.getType());
childNodes.forEach(c -> deleteNode(c));
}
return;
}
}
@Override
public TopographyNode queryByKeyAndAppIdAndType(String nodekey, String appId,String type) {
return nodeDao.findByKeyAndAppIdAndType(nodekey,appId,type);
}
@Override
public int queryMaxKeyByAppIdAndType(String appId,String type) {
Integer maxKey;
if(null == appId) {
maxKey = nodeDao.queryMaxKeyByType(type);
}else {
maxKey = nodeDao.queryMaxKeyByAppIdAndType(appId,type);
}
if(maxKey == null) {
maxKey = 0;
} }
return maxKey;
} }
@Override @Override
public TopographyNode queryByKeyAndAppId(String nodekey, String appId) { public TopographyNode queryById(String id) {
return nodeDao.findByKeyAndAppId(nodekey,appId); return nodeDao.findById(id);
} }
@Override @Override
public int queryMaxKeyByAppId(String appId) { public List<TopographyNode> getNodesByType(String type) {
return nodeDao.queryMaxKeyByAppId(appId); return nodeDao.findByType(type);
} }
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.service.impl; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.service.impl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.yeejoin.amos.fas.business.constants.FasConstant; import com.yeejoin.amos.fas.business.constants.FasConstant;
import com.yeejoin.amos.fas.business.dao.mapper.DictMapper;
import com.yeejoin.amos.fas.business.dao.mapper.PlanVisual3dMapper; import com.yeejoin.amos.fas.business.dao.mapper.PlanVisual3dMapper;
import com.yeejoin.amos.fas.business.dao.repository.ITextPlanDao; import com.yeejoin.amos.fas.business.dao.repository.ITextPlanDao;
import com.yeejoin.amos.fas.business.feign.IMaasVisualServer; import com.yeejoin.amos.fas.business.feign.IMaasVisualServer;
...@@ -34,6 +35,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -34,6 +35,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Autowired @Autowired
IDictService dictService; IDictService dictService;
@Autowired
private DictMapper dictMapper;
@Override @Override
public List<TreeSubjectVo> getPlanTree() { public List<TreeSubjectVo> getPlanTree() {
...@@ -75,9 +79,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -75,9 +79,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
for (Object obj : list) { for (Object obj : list) {
TreeSubjectVo treeItem = new TreeSubjectVo(); TreeSubjectVo treeItem = new TreeSubjectVo();
LinkedHashMap<String, Object> map = (LinkedHashMap<String, Object>) obj; LinkedHashMap<String, Object> map = (LinkedHashMap<String, Object>) obj;
treeItem.setId((Integer) map.get("id")); treeItem.setId((String) map.get("id"));
treeItem.setTreeName((String) map.get("treeName")); treeItem.setTreeName((String) map.get("treeName"));
treeItem.setParentId((Integer) map.get("parentId")); treeItem.setParentId((String) map.get("parentId"));
treeItem.setMaxSubjectNumber((Integer) map.get("maxSubjectNumber")); treeItem.setMaxSubjectNumber((Integer) map.get("maxSubjectNumber"));
treeItem.setType("treeNode"); treeItem.setType("treeNode");
...@@ -92,30 +96,34 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -92,30 +96,34 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
List<TreeSubjectVo> childrenVos = Lists.newArrayList(); List<TreeSubjectVo> childrenVos = Lists.newArrayList();
List<Object> res = (List<Object>) response.getDataList(); List<Object> res = (List<Object>) response.getDataList();
res.forEach(r -> { res.forEach(r -> {
LinkedHashMap<String, Object> map1 = (LinkedHashMap<String, Object>) r;
Integer state = (Integer) map1.get("publishState");
if(state == 0) {//过滤 未发布状态
return;
}
TreeSubjectVo subjectVo = new TreeSubjectVo(); TreeSubjectVo subjectVo = new TreeSubjectVo();
LinkedHashMap<String, Object> map1 = (LinkedHashMap<String, Object>) r;
subjectVo.setType("listNode"); subjectVo.setType("listNode");
subjectVo.setParentId((Integer) map.get("id")); subjectVo.setParentId((String) map.get("id"));
subjectVo.setId((Integer) map1.get("id")); subjectVo.setId((String) map1.get("id"));
subjectVo.setDelete(map1.get("isDelete") == null ? false : (Boolean) map1.get("isDelete")); subjectVo.setDelete(map1.get("isDelete") == null || (Integer) map1.get("isDelete") == 0 ? false : true);
subjectVo.setCreateTime((Long) map1.get("createTime")); subjectVo.setCreateTime((String) map1.get("createTime"));
subjectVo.setCreator(map1.get("creator") == null ? 0 : (Integer) map1.get("creator")); subjectVo.setCreator(map1.get("creator") == null ? 0 : (Integer) map1.get("creator"));
subjectVo.setSubjectName((String) map1.get("subjectName")); subjectVo.setSubjectName((String) map1.get("subjectName"));
subjectVo.setTreeName((String) map1.get("subjectName")); subjectVo.setTreeName((String) map1.get("subjectName"));
subjectVo.setSubjectDetail((String) map1.get("subjectDetail")); subjectVo.setSubjectDetail((String) map1.get("subjectDetail"));
subjectVo.setSubjectType((String) map1.get("subjectType")); subjectVo.setSubjectType((String) map1.get("subjectType"));
subjectVo.setSubjectTypeName((String) map1.get("subjectTypeName")); subjectVo.setSubjectTypeName((String) map1.get("subjectTypeName"));
subjectVo.setPublishState((Integer) map1.get("publishState")); subjectVo.setPublishState(state);
subjectVo.setBelongTreeId((Integer) map1.get("belongTreeId")); subjectVo.setBelongTreeId((String) map1.get("belongTreeId"));
subjectVo.setScenes(map1.get("scenes") == null ? "" : (String) map1.get("scenes")); subjectVo.setScenes(map1.get("scenes") == null ? "" : (String) map1.get("scenes"));
//关联文字预案 //关联文字预案
List<TextPlan> textPlans = iTextPlanDao.findByAppId(String.valueOf(subjectVo.getId())); List<TextPlan> textPlans = iTextPlanDao.findByAppId(String.valueOf(subjectVo.getId()));
textPlans.forEach(t -> { textPlans.forEach(t -> {
TreeSubjectVo textTreeSubjectVo = new TreeSubjectVo(); TreeSubjectVo textTreeSubjectVo = new TreeSubjectVo();
textTreeSubjectVo.setParentId(Integer.valueOf(t.getAppId())); textTreeSubjectVo.setParentId(String.valueOf(t.getAppId()));
textTreeSubjectVo.setTreeName(t.getTextName()); textTreeSubjectVo.setTreeName(t.getTextName());
textTreeSubjectVo.setId((int) t.getId()); textTreeSubjectVo.setId(String.valueOf(t.getId()));
textTreeSubjectVo.setType("textNode"); textTreeSubjectVo.setType("textNode");
subjectVo.getChildren().add(textTreeSubjectVo); subjectVo.getChildren().add(textTreeSubjectVo);
}); });
...@@ -178,5 +186,44 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -178,5 +186,44 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
return list; return list;
} }
@Override
public List<Map<String, Object>> getResourceTypeList() {
Dict dict = new Dict();
dict.setDictCode(FasConstant.PLAN_SOURCE_TYPE);
List<Dict> dictList = dictMapper.getDictList(dict);
List<Map<String, Object>> list = new ArrayList<>();
list = dictList.stream().map(e->{
Map<String, Object> newMap = new HashMap<String, Object>();
newMap.put("key",e.getDictValue());
newMap.put("value",e.getDictValue());//前端级联Cascader使用
newMap.put("isLeaf",false);////前端级联Cascader使用
newMap.put("dataType","type");
newMap.put("label",e.getDictName());
return newMap;
}).collect(Collectors.toList());
return list;
}
@Override
public List<TreeSubjectVo> getTextPlanBySubjectId(String appId) {
//关联文字预案
List<TreeSubjectVo> subjectVos = new ArrayList<>();
List<TextPlan> textPlans = iTextPlanDao.findByAppId(appId);
textPlans.forEach(t -> {
TreeSubjectVo textTreeSubjectVo = new TreeSubjectVo();
textTreeSubjectVo.setParentId(String.valueOf(t.getAppId()));
textTreeSubjectVo.setTreeName(t.getTextName());
textTreeSubjectVo.setId(String.valueOf(t.getId()));
textTreeSubjectVo.setType("textNode");
subjectVos.add(textTreeSubjectVo);
});
return subjectVos;
}
@Override
public void deleteTextPlanFile(Long id) {
iTextPlanDao.deleteById(id);
}
} }
...@@ -6,6 +6,7 @@ import com.google.common.collect.Lists; ...@@ -6,6 +6,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.yeejoin.amos.fas.business.bo.BindRegionBo; import com.yeejoin.amos.fas.business.bo.BindRegionBo;
import com.yeejoin.amos.fas.business.bo.RpnCalculationBo;
import com.yeejoin.amos.fas.business.constants.FasConstant; import com.yeejoin.amos.fas.business.constants.FasConstant;
import com.yeejoin.amos.fas.business.dao.mapper.*; import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.mongo.EquipCommunicationDao; import com.yeejoin.amos.fas.business.dao.mongo.EquipCommunicationDao;
...@@ -23,6 +24,7 @@ import com.yeejoin.amos.fas.business.service.intfc.*; ...@@ -23,6 +24,7 @@ import com.yeejoin.amos.fas.business.service.intfc.*;
import com.yeejoin.amos.fas.business.service.model.*; import com.yeejoin.amos.fas.business.service.model.*;
import com.yeejoin.amos.fas.business.util.DateUtils; import com.yeejoin.amos.fas.business.util.DateUtils;
import com.yeejoin.amos.fas.business.util.JexlUtil; import com.yeejoin.amos.fas.business.util.JexlUtil;
import com.yeejoin.amos.fas.business.util.RpnUtils;
import com.yeejoin.amos.fas.business.vo.EquipCommunicationData; import com.yeejoin.amos.fas.business.vo.EquipCommunicationData;
import com.yeejoin.amos.fas.client.invoke.RsDataQueue; import com.yeejoin.amos.fas.client.invoke.RsDataQueue;
import com.yeejoin.amos.fas.common.enums.DataRefreshTypeEum; import com.yeejoin.amos.fas.common.enums.DataRefreshTypeEum;
...@@ -42,16 +44,13 @@ import org.springframework.data.redis.core.HashOperations; ...@@ -42,16 +44,13 @@ import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.component.cache.Redis; import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.component.cache.enumeration.CacheType; import org.typroject.tyboot.component.cache.enumeration.CacheType;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import static org.hamcrest.CoreMatchers.nullValue;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -74,11 +73,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -74,11 +73,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private static final String DATETYPE_YYYY = "yyyy";//年 private static final String DATETYPE_YYYY = "yyyy";//年
private static final String PACKAGE_ID = "风险管控/risk";
//计算风险点rpni对应规则packageid
private static final String PACKAGE_ID_COUNT_RPNI = "风险管控/countRPNi";
@Autowired @Autowired
private IRiskSourceDao iRiskSourceDao; private IRiskSourceDao iRiskSourceDao;
...@@ -98,9 +92,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -98,9 +92,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private FmeaMapper fmeaMapper; private FmeaMapper fmeaMapper;
@Autowired @Autowired
private IRiskFactorDao iRiskFactorDao;
@Autowired
private RiskSourceMapper riskSourceMapper; private RiskSourceMapper riskSourceMapper;
@Autowired @Autowired
...@@ -179,16 +170,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -179,16 +170,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override @Override
public RiskSource editRiskSource(HashMap<String, Object> map) throws Exception { public RiskSource editRiskSource(HashMap<String, Object> map) throws Exception {
RiskSource riskSource = (RiskSource) map.get("param"); RiskSource riskSource = (RiskSource) map.get("param");
// String id = String.valueOf(map.get("id"));
Long id = riskSource.getId(); Long id = riskSource.getId();
String orgCode = map.get("org_code") == null ? "" : map.get("org_code").toString(); String orgCode = map.get("org_code") == null ? "" : map.get("org_code").toString();
String userId = map.get("user_id") == null ? "0" : map.get("user_id").toString(); String userId = map.get("user_id") == null ? "0" : map.get("user_id").toString();
riskSource.setOrgCode(orgCode); riskSource.setOrgCode(orgCode);
riskSource.setCreateBy(Integer.parseInt(userId)); riskSource.setCreateBy(Integer.parseInt(userId));
Optional<RiskSource> oldRiskSource1 = iRiskSourceDao.findById(id); Optional<RiskSource> oldRiskSource1 = iRiskSourceDao.findById(id);
RiskSource oldRiskSource=null; RiskSource oldRiskSource = null;
if(oldRiskSource1.isPresent()){ if (oldRiskSource1.isPresent()) {
oldRiskSource=oldRiskSource1.get(); oldRiskSource = oldRiskSource1.get();
} }
if (id == 0) {//新增 if (id == 0) {//新增
riskSource.setStatus(FasConstant.RISK_SOURCE_STATUS_NORMAL); riskSource.setStatus(FasConstant.RISK_SOURCE_STATUS_NORMAL);
...@@ -197,52 +187,47 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -197,52 +187,47 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource.setCreateDate(oldRiskSource.getCreateDate()); riskSource.setCreateDate(oldRiskSource.getCreateDate());
riskSource.setFmeaList(oldRiskSource.getFmeaList()); riskSource.setFmeaList(oldRiskSource.getFmeaList());
riskSource.setIncrement(oldRiskSource.getIncrement()); riskSource.setIncrement(oldRiskSource.getIncrement());
// riskSource.setRiskSourceEquipment(oldRiskSource.getRiskSourceEquipment());
// riskSource.setRiskSourcePointInputitem(oldRiskSource.getRiskSourcePointInputitem());
riskSource.setRpn(oldRiskSource.getRpn()); riskSource.setRpn(oldRiskSource.getRpn());
riskSource.setRpnChangeLogList(oldRiskSource.getRpnChangeLogList()); riskSource.setRpnChangeLogList(oldRiskSource.getRpnChangeLogList());
riskSource.setRpni(oldRiskSource.getRpni()); riskSource.setRpni(oldRiskSource.getRpni());
riskSource.setStatus(oldRiskSource.getStatus()); riskSource.setStatus(oldRiskSource.getStatus());
} }
iRiskSourceDao.saveAndFlush(riskSource); iRiskSourceDao.saveAndFlush(riskSource);
//同步数据 //同步数据
if (id == null || id == 0) if (id == 0) {
node3dVoService.syncData(() -> node3dVoService.incrementalCreate(Node3dVoService.DATATYPE_RISKSOURCE)); node3dVoService.syncData(() -> node3dVoService.incrementalCreate(Node3dVoService.DATATYPE_RISKSOURCE));
else } else {
node3dVoService.syncData(() -> node3dVoService.incrementalUpdate(Node3dVoService.DATATYPE_RISKSOURCE)); node3dVoService.syncData(() -> node3dVoService.incrementalUpdate(Node3dVoService.DATATYPE_RISKSOURCE));
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
}
return riskSource; return riskSource;
} }
@Override @Override
public void deleteRiskSource(Long[] riskSourceId) throws Exception { public void deleteRiskSource(Long[] riskSourceId) throws Exception {
Long id = Collections.min(Arrays.asList(riskSourceId)); Set<Long> parentIds = new LinkedHashSet<>();
Long parentId = 0L;
if (null != id) {
Optional<RiskSource> rs1 = iRiskSourceDao.findById(id);
RiskSource rs =null;
if(rs1.isPresent()){
rs=rs1.get();
}
parentId = rs.getParentId();
}
for (Long rId : riskSourceId) { for (Long rId : riskSourceId) {
int count = iRiskSourceDao.countByParentId(rId); int count = iRiskSourceDao.countByParentId(rId);
Optional<RiskSource> rs = iRiskSourceDao.findById(rId);
rs.ifPresent(riskSource -> parentIds.add(riskSource.getParentId()));
if (count > 0) { if (count > 0) {
throw new YeeException("该数据有关联子项,请先删除子项数据"); throw new YeeException("该数据有关联子项,请先删除子项数据");
} }
iRiskSourceDao.deleteById(rId); iRiskSourceDao.deleteById(rId);
} }
// if (null != parentId) {
//// updateRiskSourceRpni(parentId);
//// }
//同步数据 //1.同步数据
node3dVoService.syncData(() -> node3dVoService.incrementalRemove(Node3dVoService.DATATYPE_RISKSOURCE)); node3dVoService.syncData(() -> node3dVoService.incrementalRemove(Node3dVoService.DATATYPE_RISKSOURCE));
//2.3d屏数据刷新
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
//3.重新计算rpn
List<Long> existIds = parentIds.stream().filter(e ->
iRiskSourceDao.findById(e).isPresent()
).collect(Collectors.toList());
RsDataQueue rs = RsDataQueue.getInstance();
existIds.forEach(rs::addRiskSourcePointDeleteMessage);
} }
@Override @Override
...@@ -253,6 +238,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -253,6 +238,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override
public List<Map> queryForRegion() { public List<Map> queryForRegion() {
List<Map> result = riskSourceMapper.queryForRegion(); List<Map> result = riskSourceMapper.queryForRegion();
if (!CollectionUtils.isEmpty(result)) { if (!CollectionUtils.isEmpty(result)) {
...@@ -265,6 +251,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -265,6 +251,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override
public Map queryFor3DStatistics() { public Map queryFor3DStatistics() {
Map<String, List> result = riskSourceMapper.statistics3dCount(); Map<String, List> result = riskSourceMapper.statistics3dCount();
result.put("equipClassify", riskSourceMapper.statisticsEquipClassify()); result.put("equipClassify", riskSourceMapper.statisticsEquipClassify());
...@@ -274,11 +261,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -274,11 +261,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override
public List<Map> queryRPNReport() { public List<Map> queryRPNReport() {
return riskSourceMapper.queryRPNReport(); return riskSourceMapper.queryRPNReport();
} }
@Override
public Map queryForRiseUp() throws Exception { public Map queryForRiseUp() throws Exception {
Map<String, Map> result = new HashMap<>(); Map<String, Map> result = new HashMap<>();
...@@ -312,6 +301,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -312,6 +301,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return result; return result;
} }
@Override
public List<Map> queryForMatrix() { public List<Map> queryForMatrix() {
return this.riskSourceMapper.queryForMatrix(); return this.riskSourceMapper.queryForMatrix();
} }
...@@ -356,14 +346,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -356,14 +346,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return riskSourceMapper.getRiskSources(); return riskSourceMapper.getRiskSources();
} }
// @Override
// public Page<HashMap<String, Object>> getRiskSourcePoints(RiskSourceParam param) {
// long total = riskSourceMapper.getRiskSourcePointCount(param);
// List<HashMap<String, Object>> content = riskSourceMapper.getRiskSourcePoints(param);
// Page<HashMap<String, Object>> result = new PageImpl<HashMap<String, Object>>(content, param, total);
// return result;
// }
@Override @Override
public List<FmeaEquipmentPoint> bindFireEquiment(FmeaBindParam fmeaBindParam) { public List<FmeaEquipmentPoint> bindFireEquiment(FmeaBindParam fmeaBindParam) {
Long fmeaId = fmeaBindParam.getFmeaId(); Long fmeaId = fmeaBindParam.getFmeaId();
...@@ -410,21 +392,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -410,21 +392,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return returnList; return returnList;
} }
// public String[] removeBoundRelation(String[] idArray) {
// for (String id : idArray)
// this.iRiskSourceEquipmentDao.delete(Long.parseLong(id));
// return idArray;
// }
/** /**
* 查询指定风险点和设备之间的关系,包含绑定和未绑定 * 查询指定风险点和设备之间的关系,包含绑定和未绑定
*/ */
@Override
public Page<Map> queryEquimentRelation(CommonPageable commonPageable, String equipmentId, String fname) { public Page<Map> queryEquimentRelation(CommonPageable commonPageable, String equipmentId, String fname) {
Long total = fireEquipMapper.queryEquimentRelationCount(equipmentId, fname); Long total = fireEquipMapper.queryEquimentRelationCount(equipmentId, fname);
List<Map> list = fireEquipMapper.queryEquimentRelation(commonPageable.getOffset(), commonPageable.getPageSize(), equipmentId, fname); List<Map> list = fireEquipMapper.queryEquimentRelation(commonPageable.getOffset(), commonPageable.getPageSize(), equipmentId, fname);
return new PageImpl<>(list, commonPageable, total); return new PageImpl<>(list, commonPageable, total);
} }
@Override
public List<Map<String, Object>> listEquipmentPointById(Long fmeaId, Long importantEquipId, Long equipmentId, String equipmentPointName) { public List<Map<String, Object>> listEquipmentPointById(Long fmeaId, Long importantEquipId, Long equipmentId, String equipmentPointName) {
List<Map<String, Object>> list = fmeaEquipmentPointMapper.listEquipmentPoint(fmeaId, importantEquipId, equipmentId, equipmentPointName); List<Map<String, Object>> list = fmeaEquipmentPointMapper.listEquipmentPoint(fmeaId, importantEquipId, equipmentId, equipmentPointName);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
...@@ -434,6 +412,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -434,6 +412,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override
@Async @Async
public String processFireEqumtData(FireEquimentDataRo deviceData) throws Exception { public String processFireEqumtData(FireEquimentDataRo deviceData) throws Exception {
//处理设备和巡检数据 //处理设备和巡检数据
...@@ -441,10 +420,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -441,10 +420,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
String batchNo = UUID.randomUUID().toString(); String batchNo = UUID.randomUUID().toString();
deviceData.setBatchNo(batchNo); deviceData.setBatchNo(batchNo);
Optional<FireEquipment> fireEquipment1 = this.iFireEquipmentDao.findById(deviceData.getFireEquimentId()); Optional<FireEquipment> fireEquipment1 = this.iFireEquipmentDao.findById(deviceData.getFireEquimentId());
FireEquipment fireEquipment =null; FireEquipment fireEquipment = null;
if(fireEquipment1.isPresent()){ if (fireEquipment1.isPresent()) {
fireEquipment =fireEquipment1.get(); fireEquipment = fireEquipment1.get();
} }
Equipment equipment = null; Equipment equipment = null;
if (fireEquipment != null) { if (fireEquipment != null) {
...@@ -475,8 +454,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -475,8 +454,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public void alermContingency(String batchNo, FireEquipment fireEquipment, Equipment equipment) throws Exception { public void alermContingency(String batchNo, FireEquipment fireEquipment, Equipment equipment) throws Exception {
ContingencyRo contingencyRo = new ContingencyRo(); ContingencyRo contingencyRo = new ContingencyRo();
contingencyRo.setBatchNo(batchNo); contingencyRo.setBatchNo(batchNo);
contingencyRo.setEquipmentId(String.valueOf(equipment.getId())); contingencyRo.setEquipmentId(String.valueOf(equipment.getId()));
contingencyRo.setEquipmentName(equipment.getName()); contingencyRo.setEquipmentName(equipment.getName());
...@@ -499,225 +476,45 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -499,225 +476,45 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contingencyRo.setAdminName("admin"); contingencyRo.setAdminName("admin");
contingencyRo.setFireEquipmentPosition(fireEquipment.getPosition3d()); contingencyRo.setFireEquipmentPosition(fireEquipment.getPosition3d());
List<PreplanPicture> pictures = iPreplanPictureDao.findByEquipmentId(Long.valueOf(equipment.getId())); List<PreplanPicture> pictures = iPreplanPictureDao.findByEquipmentId(Long.valueOf(equipment.getId()));
if (!CollectionUtils.isEmpty(pictures)) { if (!CollectionUtils.isEmpty(pictures)) {
for (PreplanPicture picture : pictures) { for (PreplanPicture picture : pictures) {
if (1 == picture.getType()) if (1 == picture.getType()) {
contingencyRo.setPicture1(picture.getPicture()); contingencyRo.setPicture1(picture.getPicture());
if (2 == picture.getType()) }
if (2 == picture.getType()) {
contingencyRo.setPicture2(picture.getPicture()); contingencyRo.setPicture2(picture.getPicture());
if (3 == picture.getType()) }
if (3 == picture.getType()) {
contingencyRo.setPicture3(picture.getPicture()); contingencyRo.setPicture3(picture.getPicture());
if (4 == picture.getType()) }
if (4 == picture.getType()) {
contingencyRo.setPicture4(picture.getPicture()); contingencyRo.setPicture4(picture.getPicture());
}
} }
} }
Object result = remoteRuleServer.fireRuleFlow(contingencyRo, equipment.getReservePlan(), equipment.getName()); Object result = remoteRuleServer.fireRuleFlow(contingencyRo, equipment.getReservePlan(), equipment.getName());
ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData(); ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData();
BeanUtils.copyProperties(contingencyRo, contingencyOriginalData); BeanUtils.copyProperties(contingencyRo, contingencyOriginalData);
iContingencyOriginalDataDao.save(contingencyOriginalData); iContingencyOriginalDataDao.save(contingencyOriginalData);
} }
// public boolean asymbleWithParent(String bacthNo, List<RiskSource> riskSourceList, String from, Long fromId, String nodeState, String originalNodeState, List<FmeaPointInputitem> pointInputitems) throws Exception {
// if (!CollectionUtils.isEmpty(riskSourceList)) {
// for (RiskSource riskSource : riskSourceList) {
// //当前规则
// RiskSourceRo riskSourceRo = this.transfer(bacthNo, riskSource, from, nodeState, originalNodeState, new BigDecimal(0), pointInputitems);
//
// Object result = remoteRuleServer.fireRule(riskSourceRo, PACKAGE_ID);
// //BigDecimal RPNi = updateRpn(result,riskSource,null,fromId);
// //处理返回结果
//
// //反查 父级风险点,取得处于第二级的父级风险点
// findParent(bacthNo, riskSource, nodeState, originalNodeState, new BigDecimal(0), fromId);
// }
// }
// return true;
// }
// /**
// * 查询父节点风险点
// *
// * @param riskSource
// * @param nodeState
// * @param originalNodeState
// * @param RPNi
// * @return
// */
// private BigDecimal findParent(String bacthNo, RiskSource riskSource, String nodeState, String originalNodeState,
// BigDecimal RPNi, Long fromId) throws Exception {
// if (riskSource != null && riskSource.getId() != 0 && RPNi.doubleValue() != 0) {
// RiskSource parent = this.iRiskSourceDao.findById(riskSource.getParentId());
// if (null != parent) {
// RiskSourceRo parentRiskResource = this.transfer(bacthNo, parent, "child", nodeState, originalNodeState,
// RPNi, null);
// Object result = remoteRuleServer.fireRule(parentRiskResource, "风险管控/parentRisk");
// //updateRpn(result, parent, RPNi, fromId);
//
// if (parent.getParentId() != 0)
// this.findParent(bacthNo, parent, nodeState, originalNodeState, RPNi, fromId);
// }
// }
//
// return RPNi;
// }
private RiskSourceRo transfer(String bacthNo, RiskSource riskSource, String from, String nodeState, String originalNodeState, BigDecimal rpni, List<FmeaPointInputitem> pointInputitems) {
RiskSourceRo riskSourceRo = new RiskSourceRo();
riskSourceRo.setBatchNo(bacthNo);
riskSourceRo.setId(String.valueOf(riskSource.getId()));
riskSourceRo.setCode(riskSource.getCode());
riskSourceRo.setFrom(from);
riskSourceRo.setName(riskSource.getName());
riskSourceRo.setNodeState(nodeState);
riskSourceRo.setOriginalNodeState(originalNodeState);
riskSourceRo.setIsRegion(riskSource.getIsRegion());
riskSourceRo.setRiskFactor(null);
riskSourceRo.setRpn(riskSource.getRpn());
riskSourceRo.setRiskState(riskSource.getStatus());
riskSourceRo.setRpni(rpni);
Optional<RiskLevel> riskLevel1 = iRiskLevelDao.findById(riskSource.getRiskLevelId());
RiskLevel riskLevel =null;
if(riskLevel1.isPresent()){
riskLevel=riskLevel1.get();
}
if (riskLevel != null) {
riskSourceRo.setRiskLevel(riskLevel.getLevel());
}
List<BigDecimal> RPNiSum = new ArrayList<>();
List<Fmea> fmeaList = iFmeaDao.findByRiskSourceId(riskSource.getId());
String riskFactor = "";
if (!CollectionUtils.isEmpty(fmeaList)) {
for (Fmea fmea : fmeaList) {
RPNiSum.add(fmea.getRpni());
Optional<RiskFactor> factor1 = iRiskFactorDao.findById(fmea.getRiskFactorsId());
RiskFactor factor =null;
if(factor1.isPresent()){
factor=factor1.get();
}
if (factor != null)
riskFactor += factor.getName() + "\n";
}
}
//获取所有子节点的rpni值
List<Map<String, BigDecimal>> rpniList = riskSourceMapper.queryForRiskSourceRpni(riskSource.getId());
if (!CollectionUtils.isEmpty(rpniList)) {
for (Map<String, BigDecimal> map : rpniList) {
RPNiSum.addAll(map.values());
}
}
/* for(Fmea fmea:fmeaList)
{
Map<String,BigDecimal> map = new HashMap<>();
map.put("rpni",fmea.getRpni());
RPNiSum.add(map);
}*/
//巡检
if (ProtalDataRo.class.getSimpleName().equals(from)) {
if (!CollectionUtils.isEmpty(pointInputitems)) {
// for (RiskSourcePointInputitem pointInputitem : pointInputitems) {
// RiskSourcePointInputitem riskSourcePointInputitem = iRiskSourcePointInputitemDao.findAllByRiskSourceIdAndPointIdAndPointInputitemId(riskSource.getId(), pointInputitem.getPointId(), pointInputitem.getPointInputitemId());
//
// if (riskSourcePointInputitem != null) {
// riskSourcePointInputitem.setCheckInputitemId(pointInputitem.getCheckInputitemId());
// /*//正常1,异常2 正常变异常 负的,异常变正常 正的
// String status = pointInputitem.getStatus();
// String oldStatus = riskSourcePointInputitem.getStatus();
//
// *//*if(StringUtils.isEmpty(oldStatus))
// oldStatus = "1";
//
// if("1".equals(oldStatus) && "2".equals(status))
// {
// if(!CollectionUtils.isEmpty(fmeaList))
// {
// for(Fmea fmea:fmeaList)
// {
// Map<String,BigDecimal> map = new HashMap<>();
//
// //正常变异常 累加负的
// map.put("rpni",fmea.getRpni().multiply(new BigDecimal(-1)));
// RPNiSum.add(map);
// }
// }
// riskSourcePointInputitem.setStatus(status);
// }
//
// if("2".equals(oldStatus) && "1".equals(status))
// {
// if(!CollectionUtils.isEmpty(fmeaList))
// {
// for(Fmea fmea:fmeaList)
// {
// Map<String,BigDecimal> map = new HashMap<>();
// map.put("rpni",fmea.getRpni());
// RPNiSum.add(map);
// }
// }
// riskSourcePointInputitem.setStatus(status);
// }*//*
//
//
// for(Fmea fmea:fmeaList)
// {
// Map<String,BigDecimal> map = new HashMap<>();
// map.put("rpni",fmea.getRpni());
// RPNiSum.add(map);
// }
// // riskSourcePointInputitem.setStatus(status);*/
// riskSourcePointInputitem.setStatus(pointInputitem.getStatus());
// iRiskSourcePointInputitemDao.save(riskSourcePointInputitem);
// }
// }
}
}
riskSourceRo.setRiskFactor(riskFactor);
riskSourceRo.setRPNiSum(RPNiSum);
//是否是区域节点
if ("TRUE".equals(riskSource.getIsRegion())) {
riskSourceRo.setRegionMaxLevel(findRegionMaxLevel(riskSource.getId()));
}
return riskSourceRo;
}
private Integer findRegionMaxLevel(Long regionRiskSourceId) { private Integer findRegionMaxLevel(Long regionRiskSourceId) {
Integer maxLevel = 0; Integer maxLevel = 0;
List<RiskSource> anomalyRiskSource = findAnomalyRiskSource(regionRiskSourceId); List<RiskSource> anomalyRiskSource = findAnomalyRiskSource(regionRiskSourceId);
for (RiskSource anomaly : anomalyRiskSource) { for (RiskSource anomaly : anomalyRiskSource) {
Optional<RiskLevel> anomalyLevel1 = this.iRiskLevelDao.findById(anomaly.getRiskLevelId()); Optional<RiskLevel> anomalyLevel1 = this.iRiskLevelDao.findById(anomaly.getRiskLevelId());
RiskLevel anomalyLevel = null; RiskLevel anomalyLevel = null;
if(anomalyLevel1.isPresent()){ if (anomalyLevel1.isPresent()) {
anomalyLevel=anomalyLevel1.get(); anomalyLevel = anomalyLevel1.get();
} }
if (anomalyLevel != null && anomalyLevel.getLevel() > maxLevel) if (anomalyLevel != null && anomalyLevel.getLevel() > maxLevel) {
maxLevel = anomalyLevel.getLevel(); maxLevel = anomalyLevel.getLevel();
}
} }
return maxLevel; return maxLevel;
} }
...@@ -725,63 +522,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -725,63 +522,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
List<RiskSource> returnList = new ArrayList<>(); List<RiskSource> returnList = new ArrayList<>();
List<RiskSource> childs = iRiskSourceDao.findByParentId(riskSourceId); List<RiskSource> childs = iRiskSourceDao.findByParentId(riskSourceId);
if (CollectionUtils.isEmpty(childs)) if (CollectionUtils.isEmpty(childs)) {
return returnList; return returnList;
}
for (RiskSource child : childs) { for (RiskSource child : childs) {
/*if("ANOMALY".equals(child.getStatus()))
{
returnList.add(child);
}*/
returnList.add(child); returnList.add(child);
returnList.addAll(this.findAnomalyRiskSource(child.getId())); returnList.addAll(this.findAnomalyRiskSource(child.getId()));
} }
return returnList; return returnList;
} }
/*private BigDecimal updateRpn(Object result,RiskSource riskSource,BigDecimal RPNi,Long fromId)
{
*//*"RPNr": 16,
"RPNi": -14*//*
Map map = (Map) result;
RPNi = new BigDecimal(Double.parseDouble(String.valueOf(map.get("RPNi"))));
if(RPNi != null)
{
riskSource.setRpni(RPNi);
this.iRiskSourceDao.save(riskSource);
}
*//*if(RPNr.doubleValue() != 0 && !"ANOMALY".equals(riskSource.getStatus()))
{
riskSource.setStatus("ANOMALY");
this.iRiskSourceDao.save(riskSource);
}
if(RPNr.doubleValue() == 0 && !"NORMAL".equals(riskSource.getStatus()))
{
riskSource.setStatus("NORMAL");
this.iRiskSourceDao.save(riskSource);
}*//*
return RPNi;
}*/
private void createRpnChangeLog(BigDecimal rpni, BigDecimal rpnr, Long riskSourceId, Long fromId) {
RpnChangeLog rpnChangeLog = new RpnChangeLog();
rpnChangeLog.setCreateDate(new Date());
rpnChangeLog.setRiskSourceId(Long.valueOf(riskSourceId));
rpnChangeLog.setRpn(rpnr);
rpnChangeLog.setRpni(rpni);
rpnChangeLog.setTriggerBy(Long.valueOf(fromId));
rpnChangeLog.setType(rpni.doubleValue() > 0 ? 0 : 1);
iRpnChangeLogDao.save(rpnChangeLog);
}
@Override @Override
public Page<Map<String, Object>> listFmeaPointInputitem(Long fmeaId, Integer pageNumber, Integer pageSize) { public Page<Map<String, Object>> listFmeaPointInputitem(Long fmeaId, Integer pageNumber, Integer pageSize) {
List<Map<String, Object>> content = Lists.newArrayList(); List<Map<String, Object>> content = Lists.newArrayList();
...@@ -801,6 +551,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -801,6 +551,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override
public boolean processTaskData(ProtalDataRo taskData) throws Exception { public boolean processTaskData(ProtalDataRo taskData) throws Exception {
taskData.setBatchNo(UUID.randomUUID().toString()); taskData.setBatchNo(UUID.randomUUID().toString());
//Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol"); //Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol");
...@@ -808,25 +559,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -808,25 +559,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override
@Async @Async
public void processProtalData(String toke,String product,String appKey,ProtalDataRo protalData) { public void processProtalData(String toke, String product, String appKey, ProtalDataRo protalData) {
String bacthNo = UUID.randomUUID().toString(); String bacthNo = UUID.randomUUID().toString();
protalData.setBatchNo(bacthNo); protalData.setBatchNo(bacthNo);
Optional<PPoint> pPoint1 = iPPointDao.findById(protalData.getId()); Optional<PPoint> pPoint1 = iPPointDao.findById(protalData.getId());
PPoint pPoint =null; PPoint pPoint = null;
if(pPoint1.isPresent()){ if (pPoint1.isPresent()) {
pPoint=pPoint1.get(); pPoint = pPoint1.get();
} }
if (pPoint != null) { if (pPoint != null) {
protalData.setOriginalNodeState(pPoint.getStatus()); protalData.setOriginalNodeState(pPoint.getStatus());
protalData.setLevel(pPoint.getLevel()); protalData.setLevel(pPoint.getLevel());
protalData.setPointNo(pPoint.getPointNo()); protalData.setPointNo(pPoint.getPointNo());
protalData.setPointName(pPoint.getName()); protalData.setPointName(pPoint.getName());
AgencyUserModel sUser = remoteSecurityService.getUserById(toke, product, appKey, pPoint.getChargePersonId());
AgencyUserModel sUser = remoteSecurityService.getUserById( toke, product, appKey, pPoint.getChargePersonId());
if (sUser != null) { if (sUser != null) {
protalData.setUserName(sUser.getUserName()); protalData.setUserName(sUser.getUserName());
} else { } else {
...@@ -865,22 +613,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -865,22 +613,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fmeaIds.forEach(fmeaId -> rsDataQueue.addPatrolMessage(fmeaId)); fmeaIds.forEach(fmeaId -> rsDataQueue.addPatrolMessage(fmeaId));
} }
iDataRefreshService.refreshViewData(DataRefreshTypeEum.check.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.check.getCode());
//asymbleWithParent(bacthNo,riskSources, ProtalDataRo.class.getSimpleName(),protalData.getId(),protalData.getNodeState(),protalData.getOriginalNodeState(),protalData.getPointInputitems());
} }
// @Override
// @Transactional
// public void removeByRSIdAndPId(List<HashMap<String, String>> list) {
// // TODO Auto-generated method stub
// if (list.size() > 0) {
// for (HashMap<String, String> hashMap : list) {
// iRiskSourcePointInputitemDao.removeByRSIdAndPId(hashMap.get("riskId"), hashMap.get("pointId"));
// }
//
// }
//
// }
@Override @Override
public RiskSourceTreeResponse queryRiskSourceDetailById(Long id) { public RiskSourceTreeResponse queryRiskSourceDetailById(Long id) {
RiskSourceTreeResponse det = riskSourceMapper.findRiskSourceDetatil(id); RiskSourceTreeResponse det = riskSourceMapper.findRiskSourceDetatil(id);
...@@ -888,13 +622,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -888,13 +622,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override
public Map earlyWarning(Long riskSourceId) { public Map earlyWarning(Long riskSourceId) {
Map returnMap = new HashMap(); Map returnMap = new HashMap();
Map riskSourceInfo = this.riskSourceMapper.queryForRiskSourceLevel(riskSourceId); Map riskSourceInfo = this.riskSourceMapper.queryForRiskSourceLevel(riskSourceId);
List<Map> fmeaList = this.fmeaMapper.queryForFmeaList(riskSourceId); List<Map> fmeaList = this.fmeaMapper.queryForFmeaList(riskSourceId);
List<Map> inputitemContent = this.riskSourceMapper.queryForUnqualified(riskSourceId); List<Map> inputitemContent = this.riskSourceMapper.queryForUnqualified(riskSourceId);
List<Map> fireEquipmentPointMap = fireEquipPointMapper.queryForEqueAndPointName(riskSourceId); List<Map> fireEquipmentPointMap = fireEquipPointMapper.queryForEqueAndPointName(riskSourceId);
returnMap.put("riskSourceInfo", riskSourceInfo); returnMap.put("riskSourceInfo", riskSourceInfo);
returnMap.put("fmeaList", fmeaList); returnMap.put("fmeaList", fmeaList);
returnMap.put("inputitemContent", inputitemContent); returnMap.put("inputitemContent", inputitemContent);
...@@ -902,113 +636,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -902,113 +636,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return returnMap; return returnMap;
} }
// @Override
// public BigDecimal updateRiskSourceRpni(Long riskSourceId) throws Exception {
// BigDecimal newRpni = new BigDecimal(0);
// //风险点添加或删除风险因素时
// RiskSource riskSource = iRiskSourceDao.findById(riskSourceId);
// if (null != riskSource) {
// List<BigDecimal> childRpniList = new ArrayList<>();
// List<RiskSource> children = iRiskSourceDao.findByParentId(riskSource.getId());
// for (RiskSource child : children) {
// childRpniList.add(child.getRpni());
// }
// RiskSourceRo riskSourceRo = fillRiskSourceRo(riskSource, childRpniList);
// //Object result = remoteRuleServer.fireRule(riskSourceRo, PACKAGE_ID_COUNT_RPNI);
// //BigDecimal RPNi = updateRpni(result, riskSource);
// //findParent(riskSource, RPNi);
// //newRpni = RPNi;
// }
// return newRpni;
// }
private RiskSourceRo fillRiskSourceRo(RiskSource riskSource, List<BigDecimal> rpniList) {
RiskSourceRo riskSourceRo = new RiskSourceRo();
String batchNo = UUID.randomUUID().toString();
riskSourceRo.setId(String.valueOf(riskSource.getId()));
riskSourceRo.setBatchNo(batchNo);
riskSourceRo.setIsRegion(riskSource.getIsRegion());
riskSourceRo.setRiskState(riskSource.getStatus());
List<BigDecimal> RPNiSum = new ArrayList<>();
List<Fmea> fmeaList = iFmeaDao.findByRiskSourceId(riskSource.getId());
if (!CollectionUtils.isEmpty(fmeaList)) {// 风险点自身危险因素的rpni值
for (Fmea fmea : fmeaList) {
RPNiSum.add(fmea.getRpni());
}
}
if (null != rpniList) {// 若风险点为父节点,则将所有子节点的rpni值加入RPNiSum列表中
for (BigDecimal rpni : rpniList) {
RPNiSum.add(rpni);
}
}
riskSourceRo.setRPNiSum(RPNiSum);
return riskSourceRo;
}
private BigDecimal updateRpni(Object result, RiskSource riskSource) {
/*
* "RPNr": 16, "RPNi": -14
*/
BigDecimal RPNi = null;
Map map = (Map) result;
if (null != map.get("RPNi")) {
RPNi = new BigDecimal(Double.parseDouble(String.valueOf(map.get("RPNi"))));
if (RPNi != null) {
riskSource.setRpni(RPNi);
this.iRiskSourceDao.save(riskSource);
}
}
return RPNi;
}
/**
* 查询父节点风险点
*
* @param riskSource
* @param RPNi
* @return
*/
private BigDecimal findParent(RiskSource riskSource, BigDecimal RPNi) throws Exception {
if (null != riskSource && riskSource.getId() != 0 && riskSource.getParentId() != 0 && null != RPNi && RPNi.doubleValue() != 0) {
// RiskSource parent = iRiskSourceDao.getOne(0L);
Optional<RiskSource> parent1 = iRiskSourceDao.findById(riskSource.getParentId());
RiskSource parent=null;
if(parent1.isPresent()){
parent=parent1.get();
}
if (null != parent) {
List<BigDecimal> childRpniList = new ArrayList<>();
List<RiskSource> children = iRiskSourceDao.findByParentId(parent.getId());
for (RiskSource child : children) {
childRpniList.add(child.getRpni());
}
RiskSourceRo parentRiskResourceRo = fillRiskSourceRo(parent, childRpniList);
//Object result = remoteRuleServer.fireRule(parentRiskResourceRo, PACKAGE_ID_COUNT_RPNI);
//updateRpni(result, parent);
if (parent.getParentId() != 0)
this.findParent(parent, RPNi);
}
}
return RPNi;
}
@Override @Override
public List<HashMap<String, Object>> queryRiskAreaRpn() { public List<HashMap<String, Object>> queryRiskAreaRpn() {
return riskSourceMapper.queryRiskAreaRpn(); return riskSourceMapper.queryRiskAreaRpn();
} }
@javax.transaction.Transactional @Transactional
public void updateFirePointValue(Long id, String state) { public void updateFirePointValue(Long id, String state) {
fireEquipPointMapper.updateValue(id, state); fireEquipPointMapper.updateValue(id, state);
} }
private static final BlockingQueue<AlarmParam> blockingQueue = new LinkedBlockingQueue<AlarmParam>(); private static final BlockingQueue<AlarmParam> blockingQueue = new LinkedBlockingQueue<AlarmParam>();
private static ExecutorService executorService = Executors.newSingleThreadExecutor(); private static ExecutorService executorService = Executors.newSingleThreadExecutor();
private static boolean isRunning = true;
@PostConstruct @PostConstruct
public void start() { public void start() {
...@@ -1022,6 +662,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1022,6 +662,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
*/ */
@Override @Override
public void run() { public void run() {
boolean isRunning = true;
while (isRunning) { while (isRunning) {
AlarmParam alarmParam = null; AlarmParam alarmParam = null;
try { try {
...@@ -1059,9 +700,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1059,9 +700,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fireEquipmentPointType = dict.getDictValue(); fireEquipmentPointType = dict.getDictValue();
} }
Optional<FireEquipment> fireEquipment1 = this.iFireEquipmentDao.findById(fireEquipmentPoint.getFireEquipmentId()); Optional<FireEquipment> fireEquipment1 = this.iFireEquipmentDao.findById(fireEquipmentPoint.getFireEquipmentId());
FireEquipment fireEquipment =null; FireEquipment fireEquipment = null;
if(fireEquipment1.isPresent()){ if (fireEquipment1.isPresent()) {
fireEquipment=fireEquipment1.get(); fireEquipment = fireEquipment1.get();
} }
Equipment equipment = null; Equipment equipment = null;
if (fireEquipment != null) { if (fireEquipment != null) {
...@@ -1073,7 +714,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1073,7 +714,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
list.add(deviceData); list.add(deviceData);
//保存到mongo //保存到mongo
saveData(list, "soe"); saveData(list, "soe");
if (equipment != null) { if (equipment != null) {
String batchNo = null; String batchNo = null;
Object batch = null; Object batch = null;
...@@ -1096,38 +736,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1096,38 +736,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (ObjectUtils.isEmpty(batchNo)) { if (ObjectUtils.isEmpty(batchNo)) {
return; return;
} }
// if (batch == null) {
// batchNo = UUID.randomUUID().toString();
deviceData.setBatchNo(batchNo); deviceData.setBatchNo(batchNo);
deviceData.setMonitor(equipment.getName()); deviceData.setMonitor(equipment.getName());
deviceData.setEquimentId(String.valueOf(equipment.getId())); deviceData.setEquimentId(String.valueOf(equipment.getId()));
// FireEquimentDataRo ruleData = new FireEquimentDataRo();
// ruleData.setBatchNo(batchNo);
// ruleData.setEquimentId(String.valueOf(equipment.getId()));
// ruleData.setMonitor(equipment.getName());
// ruleData.setCode(deviceData.getCode());
// ruleData.setFireEquimentId(fireEquipment.getId());
// ruleData.setName(fireEquipmentPoint.getName());
// ruleData.setNodeState("true".equals(deviceData.getState()) ? "1" : "0");
// ruleData.setUnit(fireEquipmentPoint.getUnit());
// ruleData.setValue(deviceData.getState());
// ruleData.setFireEqumentName(fireEquipment.getName());
// Object result = remoteRuleServer.fireRule(ruleData, "风险管控/fireEquiment");
//处理返回结果
// } else {
// if (batch == null) {
// batchNo = batch.toString();
// }
//List<RiskSource> riskSources = this.riskSourceMapper.queryByFireEqument(fireEquipmentPoint.getFireEquipmentId());
//asymbleWithParent(batchNo, riskSources, FireEquimentDataRo.class.getSimpleName(), fireEquipmentPoint.getFireEquipmentId(), deviceData.getNodeState(), null, null);
// if (ObjectUtils.isEmpty(fireEquipmentPointType) || "false".equals(deviceData.getState())) {
// return;
// }
if ("alarm_type_fire".equals(fireEquipmentPointType)) { if ("alarm_type_fire".equals(fireEquipmentPointType)) {
if (deviceData.getIsMock()) { if (deviceData.getIsMock()) {
redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning()); redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
...@@ -1146,7 +758,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1146,7 +758,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
redisTemplate.opsForHash().put("currentContingency", "batchNo", batchNo); redisTemplate.opsForHash().put("currentContingency", "batchNo", batchNo);
redisTemplate.opsForHash().put("currentContingency", "contingencyPlan", null); redisTemplate.opsForHash().put("currentContingency", "contingencyPlan", null);
redisTemplate.opsForHash().put("currentContingency", "alarmType", null); redisTemplate.opsForHash().put("currentContingency", "alarmType", null);
// redisTemplate.opsForValue().set("equipmentId", null);
//通知刷新3d页面告警数据 //通知刷新3d页面告警数据
iDataRefreshService.refreshViewData(DataRefreshTypeEum.alarm.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.alarm.getCode());
} else { } else {
...@@ -1185,22 +796,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1185,22 +796,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fireEquipmentData.setEqPointUnit(fireEquipmentPoint.getUnit()); fireEquipmentData.setEqPointUnit(fireEquipmentPoint.getUnit());
fireEquipmentData.setFireEquipmentPointId(fireEquipmentPoint.getId()); fireEquipmentData.setFireEquipmentPointId(fireEquipmentPoint.getId());
fireEquipmentData.setFireEquipmentId(fireEquipmentPoint.getFireEquipmentId()); fireEquipmentData.setFireEquipmentId(fireEquipmentPoint.getFireEquipmentId());
if (fireEquipmentPointType == null || !"alarm_type_fire".equals(fireEquipmentPointType)) { if (!"alarm_type_fire".equals(fireEquipmentPointType)) {
fireEquipmentData.setType("monitor"); fireEquipmentData.setType("monitor");
} }
iFireEquipmentDataDao.save(fireEquipmentData); iFireEquipmentDataDao.save(fireEquipmentData);
if (!"alarm_type_fire".equals(fireEquipmentPointType)) { if (!"alarm_type_fire".equals(fireEquipmentPointType)) {
Map<String,Object> content = new HashMap<>(); Map<String, Object> content = new HashMap<>();
content.put("id",fireEquipmentData.getId()); content.put("id", fireEquipmentData.getId());
content.put("label",fireEquipmentData.getEqPointName()); content.put("label", fireEquipmentData.getEqPointName());
content.put("changeDate",fireEquipmentData.getCreateDate()); content.put("changeDate", fireEquipmentData.getCreateDate());
Optional<FireEquipment> fireEquipment = iFireEquipmentDao.findById(fireEquipmentPoint.getFireEquipmentId()); Optional<FireEquipment> fireEquipment = iFireEquipmentDao.findById(fireEquipmentPoint.getFireEquipmentId());
if(fireEquipment.isPresent()) { if (fireEquipment.isPresent()) {
content.put("orgCode",fireEquipment.get().getOrgCode()); content.put("orgCode", fireEquipment.get().getOrgCode());
}else { } else {
log.info(fireEquipmentPoint.getFireEquipmentId() + "设备不存在!!!"); log.info(fireEquipmentPoint.getFireEquipmentId() + "设备不存在!!!");
} }
iDataRefreshService.sendRefreshDataWithArea(DataRefreshTypeEum.monitor.getCode(),content); iDataRefreshService.sendRefreshDataWithArea(DataRefreshTypeEum.monitor.getCode(), content);
} }
} }
...@@ -1234,10 +845,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1234,10 +845,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
FireEquipmentPoint fireEquipmentPoint = iFireEquipmentPointDao.findOneByCode(param.getPointCode()); FireEquipmentPoint fireEquipmentPoint = iFireEquipmentPointDao.findOneByCode(param.getPointCode());
Dict dict = null; Dict dict = null;
if (fireEquipmentPoint.getAlarmType() != null) { if (fireEquipmentPoint.getAlarmType() != null) {
Optional<Dict> dict1 = dictDao.findById(fireEquipmentPoint.getAlarmType()); Optional<Dict> dict1 = dictDao.findById(fireEquipmentPoint.getAlarmType());
if(dict1.isPresent()){ if (dict1.isPresent()) {
dict=dict1.get(); dict = dict1.get();
} }
} }
if (!param.getState().equals(fireEquipmentPoint.getValue())) { if (!param.getState().equals(fireEquipmentPoint.getValue())) {
fireEquipmentPoint.setValue(param.getState()); fireEquipmentPoint.setValue(param.getState());
...@@ -1247,23 +858,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1247,23 +858,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (dict != null && dict.getDictValue().equals("alarm_type_trouble")) { if (dict != null && dict.getDictValue().equals("alarm_type_trouble")) {
notifyAlarm(fireEquipmentPoint, param); notifyAlarm(fireEquipmentPoint, param);
} }
// String batchNo = UUID.randomUUID().toString();
// FireEquimentDataRo ruleData = new FireEquimentDataRo();
// ruleData.setBatchNo(batchNo);
// ruleData.setEquimentId(String.valueOf(equipment.getId()));
// ruleData.setMonitor(equipment.getName());
// ruleData.setCode(data.getFireEquipmentCode());
// ruleData.setFireEquimentId(Long.valueOf(data.getFireEquipmentId()));
// ruleData.setName(data.getPointName());
// ruleData.setNodeState("true".equals(data.getState()) ? "1" : "0");
// ruleData.setUnit(data.getUnit());
// ruleData.setValue(data.getSoe() + "");
// ruleData.setFireEqumentName(data.getFireEquipmentName());
// try {
// Object result = remoteRuleServer.fireRule(ruleData, "风险管控/fireEquiment");
// } catch (Exception e) {
// e.printStackTrace();
// }
} }
} }
} }
...@@ -1276,6 +870,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1276,6 +870,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
equipCommunicationDao.saveAll(list); equipCommunicationDao.saveAll(list);
} }
/**
* 设备告警触发fema的sod值
*/
private void notifyAlarm(FireEquipmentPoint fireEquipmentPoint, AlarmParam param) { private void notifyAlarm(FireEquipmentPoint fireEquipmentPoint, AlarmParam param) {
List<FmeaEquipmentPoint> fmeaEquipmentPoints = fmeaEquipmentPointMapper.listByEquipmentPointId(fireEquipmentPoint.getId()); List<FmeaEquipmentPoint> fmeaEquipmentPoints = fmeaEquipmentPointMapper.listByEquipmentPointId(fireEquipmentPoint.getId());
Set<Long> fmeaIds = Sets.newHashSet(); Set<Long> fmeaIds = Sets.newHashSet();
...@@ -1358,9 +955,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1358,9 +955,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
redisTemplate.opsForValue().set("equipmentId", null); redisTemplate.opsForValue().set("equipmentId", null);
break; break;
default: default:
// redisTemplate.opsForHash().put("currentContingency", "contingencyPlan", null);
redisTemplate.opsForValue().set("equipmentId", contingencyDeviceStatus.getEquipmentId()); redisTemplate.opsForValue().set("equipmentId", contingencyDeviceStatus.getEquipmentId());
// redisTemplate.opsForHash().put("currentContingency", "equipmentId", null);
break; break;
} }
if (alarmType == null) { if (alarmType == null) {
...@@ -1442,7 +1037,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1442,7 +1037,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 修改、添加导致rpn、rpni改变 * 修改、添加导致rpn、rpni改变
*/ */
@Override @Override
public void notifyFmeaFromUpdate(String toke,String product,String appKey,Long fmeaId, String nofityType) { public void notifyFmeaFromUpdate(String toke, String product, String appKey, Long fmeaId, String nofityType) {
Fmea fmea = fmeaMapper.getById(fmeaId); Fmea fmea = fmeaMapper.getById(fmeaId);
if (fmea == null) { if (fmea == null) {
return; return;
...@@ -1451,8 +1046,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1451,8 +1046,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
BigDecimal oidValue = new BigDecimal(fmea.getOidValue()); BigDecimal oidValue = new BigDecimal(fmea.getOidValue());
BigDecimal sidValue = new BigDecimal(fmea.getSidValue()); BigDecimal sidValue = new BigDecimal(fmea.getSidValue());
BigDecimal didValue = new BigDecimal(fmea.getDidValue()); BigDecimal didValue = new BigDecimal(fmea.getDidValue());
//1.1计算rpni
BigDecimal rpni = oidValue.multiply(sidValue).multiply(didValue); BigDecimal rpni = oidValue.multiply(sidValue).multiply(didValue);
BigDecimal rpn; BigDecimal rpn;
//1.2计算rpn:为空则rpni = rpn;不为空则重新计算s*d*newo
if (fmea.getNewEvaluationOid() == null) { if (fmea.getNewEvaluationOid() == null) {
fmea.setNewEvaluationOid(fmea.getEvaluationOid()); fmea.setNewEvaluationOid(fmea.getEvaluationOid());
rpn = rpni; rpn = rpni;
...@@ -1461,47 +1058,60 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1461,47 +1058,60 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
rpn = newOidValue.multiply(sidValue).multiply(didValue); rpn = newOidValue.multiply(sidValue).multiply(didValue);
} }
List<RiskLevel> levels = riskLevelDao.findAll(); List<RiskLevel> levels = riskLevelDao.findAll();
RiskLevel newLevel = getBetweenLevel(rpn, levels); RiskLevel newLevel = RpnUtils.getBetweenLevel(rpn, levels);
String jpushTarget = null; Set<String> jpushTargets = new LinkedHashSet<>();
fmea.setRpni(rpni); fmea.setRpni(rpni);
fmea.setRpn(rpn); fmea.setRpn(rpn);
if (newLevel != null) { if (newLevel != null) {
fmea.setRiskLevelId(newLevel.getId()); fmea.setRiskLevelId(newLevel.getId());
jpushTarget = getJpushTarget( toke, product, appKey,fmea, newLevel.getLevel()); getJpushTarget(toke, product, appKey, fmea, newLevel.getManageLevel());
} }
//1.3更新fmea
fmeaMapper.updateRpn(fmea); fmeaMapper.updateRpn(fmea);
saveRpnLog(fmea.getRiskSourceId(), fmeaId, rpn, rpni); //2.计算上级风险值(风险点及父节点)
this.notifyRiskSource(fmea.getRiskSourceId(), nofityType, jpushTarget); this.notifyRiskSource(fmeaId, fmea.getRiskSourceId(), nofityType, jpushTargets);
} }
} }
private String getJpushTarget(String toke,String product,String appKey,Fmea fmea, Integer level) { private Set<String> getJpushTarget(String toke, String product, String appKey, Fmea fmea, Integer managerLevel) {
String jpushTarget = null; Set<String> targets = new LinkedHashSet<>();
String userId = null; Set<String> userIds = this.getUsersByLevel(managerLevel, fmea);
userIds.forEach(userId -> {
AgencyUserModel user = remoteSecurityService.getUserById(toke, product, appKey, userId);
if (user != null) {
String target = user.getMobile();
targets.add(target);
}
});
return targets;
}
private Set<String> getUsersByLevel(Integer level, Fmea fmea) {
Set<String> userIds = new HashSet<>();
if (level.equals(1)) { if (level.equals(1)) {
userId = fmea.getCompanyLeader(); userIds.add(fmea.getCompanyLeader());
userIds.add(fmea.getDepartmentLeader());
userIds.add(fmea.getGroupLeader());
userIds.add(fmea.getPersonLeader());
} else if (level.equals(2)) { } else if (level.equals(2)) {
userId = fmea.getDepartmentLeader(); userIds.add(fmea.getDepartmentLeader());
userIds.add(fmea.getGroupLeader());
userIds.add(fmea.getPersonLeader());
} else if (level.equals(3)) { } else if (level.equals(3)) {
userId = fmea.getGroupLeader(); userIds.add(fmea.getGroupLeader());
userIds.add(fmea.getPersonLeader());
} else if (level.equals(4)) { } else if (level.equals(4)) {
userId = fmea.getPersonLeader(); userIds.add(fmea.getPersonLeader());
} }
if (userId != null) { userIds.remove(null);
AgencyUserModel user = remoteSecurityService.getUserById( toke, product, appKey, userId); return userIds;
if (user != null) {
jpushTarget = user.getMobile();
}
}
return jpushTarget;
} }
/** /**
* 告警或者不合格项导致fmea的rpn、new_evaluation_oid改变 * 告警或者不合格项导致fmea的rpn、new_evaluation_oid改变
*/ */
@Override @Override
public void notifyFmeaFromAbnormal(String toke,String product,String appKey,Long fmeaId, String notifyType) { public void notifyFmeaFromAbnormal(String toke, String product, String appKey, Long fmeaId, String notifyType) {
Fmea fmea = fmeaMapper.getById(fmeaId); Fmea fmea = fmeaMapper.getById(fmeaId);
if (fmea == null) { if (fmea == null) {
return; return;
...@@ -1509,8 +1119,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1509,8 +1119,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (fmea.getEvaluationOid() != null && fmea.getEvaluationSid() != null && fmea.getEvaluationDid() != null) { if (fmea.getEvaluationOid() != null && fmea.getEvaluationSid() != null && fmea.getEvaluationDid() != null) {
List<FmeaEquipmentPoint> equipmentPoints = fmeaEquipmentPointMapper.listFmeaByFmeaId(fmeaId); List<FmeaEquipmentPoint> equipmentPoints = fmeaEquipmentPointMapper.listFmeaByFmeaId(fmeaId);
List<FmeaPointInputitem> pointInputitems = fmeaPointInputitemMapper.listFmeaByFmeaId(fmeaId); List<FmeaPointInputitem> pointInputitems = fmeaPointInputitemMapper.listFmeaByFmeaId(fmeaId);
Double maxRate = getMaxRate(equipmentPoints, pointInputitems); //1.准备更新数据
Double maxRate = RpnUtils.getMaxRate(equipmentPoints, pointInputitems);
if (maxRate != null) { if (maxRate != null) {
//1.1根据设备和巡检数据获取高的故障率
List<EvaluationModel> oModels = iEvaluationModelDao.findAllByType("O"); List<EvaluationModel> oModels = iEvaluationModelDao.findAllByType("O");
EvaluationModel oEvaluationModel = getBetweenModel(maxRate, oModels); EvaluationModel oEvaluationModel = getBetweenModel(maxRate, oModels);
if (oEvaluationModel != null) { if (oEvaluationModel != null) {
...@@ -1519,17 +1131,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1519,17 +1131,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
BigDecimal didValue = new BigDecimal(fmea.getDidValue()); BigDecimal didValue = new BigDecimal(fmea.getDidValue());
BigDecimal rpn = newOidValue.multiply(sidValue).multiply(didValue); BigDecimal rpn = newOidValue.multiply(sidValue).multiply(didValue);
List<RiskLevel> levels = riskLevelDao.findAll(); List<RiskLevel> levels = riskLevelDao.findAll();
RiskLevel newLevel = getBetweenLevel(rpn, levels); RiskLevel newLevel = RpnUtils.getBetweenLevel(rpn, levels);
fmea.setRpn(rpn); fmea.setRpn(rpn);
fmea.setNewEvaluationOid(oEvaluationModel.getId()); fmea.setNewEvaluationOid(oEvaluationModel.getId());
String jpushTarget = null; Set<String> jpushTargets = new LinkedHashSet<>();
if (newLevel != null) { if (newLevel != null) {
jpushTarget = getJpushTarget( toke, product, appKey,fmea, newLevel.getLevel()); //1.2根据风险等级对应的责任等级获取责任人
jpushTargets = getJpushTarget(toke, product, appKey, fmea, newLevel.getManageLevel());
fmea.setRiskLevelId(newLevel.getId()); fmea.setRiskLevelId(newLevel.getId());
} }
//1.3.更新fmea的rpn、风险等级及newOid
fmeaMapper.updateRpn(fmea); fmeaMapper.updateRpn(fmea);
saveRpnLog(fmea.getRiskSourceId(), fmeaId, rpn, fmea.getRpni()); //2.计算风险点rpn、rpni、riskLevelId
this.notifyRiskSource(fmea.getRiskSourceId(), notifyType, jpushTarget); this.notifyRiskSource(fmeaId, fmea.getRiskSourceId(), notifyType, jpushTargets);
} }
} }
} }
...@@ -1538,9 +1152,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1538,9 +1152,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private void saveRpnLog(Long riskSourceId, Long fmeaId, BigDecimal rpn, BigDecimal rpni) { private void saveRpnLog(Long riskSourceId, Long fmeaId, BigDecimal rpn, BigDecimal rpni) {
RpnChangeLog rpnChangeLog = new RpnChangeLog(); RpnChangeLog rpnChangeLog = new RpnChangeLog();
rpnChangeLog.setRiskSourceId(riskSourceId); rpnChangeLog.setRiskSourceId(riskSourceId);
rpnChangeLog.setFmeaId(fmeaId);
rpnChangeLog.setRpn(rpn); rpnChangeLog.setRpn(rpn);
rpnChangeLog.setRpni(rpni); rpnChangeLog.setRpni(rpni);
rpnChangeLog.setType(RpnUtils.getChangeType(rpn, rpni));
rpnChangeLog.setTriggerBy(fmeaId);
rpnChangeLog.setFmeaId(fmeaId);
iRpnChangeLogDao.save(rpnChangeLog); iRpnChangeLogDao.save(rpnChangeLog);
} }
...@@ -1554,114 +1170,133 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1554,114 +1170,133 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return null; return null;
} }
private Double getMaxRate(List<FmeaEquipmentPoint> equipmentPoints, List<FmeaPointInputitem> pointInputitems) {
Double pointInputitemRate = null;
if (!CollectionUtils.isEmpty(pointInputitems)) {
int totalPointInputitem = pointInputitems.size();
int pointInputitemUnNormal = 0;
for (FmeaPointInputitem pointInputitem : pointInputitems) {
if (pointInputitem.getState() == 1) {
pointInputitemUnNormal++;
}
}
pointInputitemRate = pointInputitemUnNormal * 1.0 / totalPointInputitem;
}
Double equipmentPointRate = null;
if (!CollectionUtils.isEmpty(equipmentPoints)) {
int totalEquipmentPoint = equipmentPoints.size();
int equipmentPointUnNormal = 0;
for (FmeaEquipmentPoint equipmentPoint : equipmentPoints) {
if (equipmentPoint.getState() == 1) {
equipmentPointUnNormal++;
}
}
equipmentPointRate = equipmentPointUnNormal * 1.0 / totalEquipmentPoint;
}
if (equipmentPointRate == null) {
if (pointInputitemRate == null) {
return null;
} else {
return pointInputitemRate;
}
} else {
if (pointInputitemRate == null) {
return equipmentPointRate;
} else {
if (pointInputitemRate < equipmentPointRate) {
return equipmentPointRate;
} else {
return pointInputitemRate;
}
}
}
}
/** /**
* fmea的更新导致rpn、rpni的值改变 * fmea的更新导致rpn、rpni的值改变
*/ */
@Override @Override
public void notifyRiskSource(Long riskSourceId, String notifyType, String jpushTarget) { public void notifyRiskSource(Long fmeaId, Long riskSourceId, String notifyType, Set<String> jpushTargets) {
Optional<RiskSource> riskSource1 = iRiskSourceDao.findById(riskSourceId); Optional<RiskSource> riskSource1 = iRiskSourceDao.findById(riskSourceId);
RiskSource riskSource =null; RiskSource riskSource = null;
if(riskSource1.isPresent()){ if (riskSource1.isPresent()) {
riskSource =riskSource1.get(); riskSource = riskSource1.get();
} } else {
if (riskSource == null) {
return; return;
} }
List<Fmea> fmeas = fmeaMapper.listByRiskSourceId(riskSourceId); List<Fmea> fmeas = fmeaMapper.listByRiskSourceId(riskSourceId);
if (CollectionUtils.isEmpty(fmeas)) { if (CollectionUtils.isEmpty(fmeas)) {//fema删除
BigDecimal resetValue = new BigDecimal("0"); BigDecimal resetValue = new BigDecimal("0");
riskSource.setRpn(resetValue); riskSource.setRpn(null);
riskSource.setRpni(resetValue); riskSource.setRpni(null);
riskSource.setRiskLevelId(0L); riskSource.setRiskLevelId(null);
//1.更新fmea对应风险点rpn、rpni、level
riskSourceMapper.updateRpn(riskSource); riskSourceMapper.updateRpn(riskSource);
//2.记录风险点rpn变化流水
this.saveRpnLog(riskSource.getId(), fmeaId, resetValue, resetValue);
//3.更新父节点rpn、rpni、风险等级
this.updateParentRpn(riskSource.getParentId());
} else {//fmea评价、巡检、告警
RpnCalculationBo rpnValueBo = RpnUtils.calRpnAndRpni(fmeas);
if (rpnValueBo.isEmpty()) {
return;
}
BigDecimal rpn = rpnValueBo.getRpn();
BigDecimal rpni = rpnValueBo.getRpni();
List<RiskLevel> levels = riskLevelDao.findAll();
RiskLevel newRiskLevel = RpnUtils.getBetweenLevel(rpn, levels);
RiskLevel oldRiskLevel = RpnUtils.getBetweenLevel(rpni, levels);
if (newRiskLevel != null && oldRiskLevel != null) {
riskSource.setRpn(rpn);
riskSource.setRpni(rpni);
riskSource.setRiskLevelId(newRiskLevel.getId());
//1.更新fmea对应风险点rpn、rpni、level
riskSourceMapper.updateRpn(riskSource);
//2.记录风险点rpn变化流水
this.saveRpnLog(riskSource.getId(), fmeaId, rpn, rpni);
//3.更新父节点rpn、rpni、风险等级
this.updateParentRpn(riskSource.getParentId());
//4.极光推送给手机客户端
jpushRiskSourceMessage("风险预警", jpushTargets);
//5.规则告警(消息)TODO
notifyRule(riskSourceId, rpn, rpni, oldRiskLevel.getLevel(), newRiskLevel.getLevel(), notifyType);
}
} }
BigDecimal maxSidValue = new BigDecimal("0"); }
BigDecimal maxDidValue = new BigDecimal("0");
BigDecimal totalOidValue = new BigDecimal("0"); @Override
BigDecimal totalNewOidValue = new BigDecimal("0"); public void notifyFmeaFromDelete(Long riskSourceId, String from) {
long count = 0L; //1.计算风险点风险值信息
for (Fmea fmea : fmeas) { this.notifyRiskSource(0L, riskSourceId, from, null);
if (fmea.getEvaluationDid() != null && fmea.getEvaluationSid() != null && fmea.getEvaluationOid() != null && fmea.getNewEvaluationOid() != null) { }
BigDecimal didValue = new BigDecimal(fmea.getDidValue());
BigDecimal sidValue = new BigDecimal(fmea.getSidValue()); @Override
BigDecimal oidValue = new BigDecimal(fmea.getOidValue()); public void notifyRiskSourceDelete(Long parentId) {
BigDecimal newOidValue = new BigDecimal(fmea.getNewOidValue()); //1.风险点删除触发更新父节点rpn、rpni、风险等级
if (didValue.compareTo(maxDidValue) == 1) { this.updateParentRpn(parentId);
maxDidValue = didValue; }
private void updateParentRpn(long parentId) {
Optional<RiskSource> riskSource1 = iRiskSourceDao.findById(parentId);
RiskSource riskSource = null;
if (riskSource1.isPresent()) {
riskSource = riskSource1.get();
}
if (riskSource != null) {
List<RiskSource> riskSourceList = new ArrayList<>();
List<Long> ids = new ArrayList<>();
riskSourceList = iRiskSourceDao.findByParentId(riskSource.getId());
//递归获取区域(含子区域)所有点
this.getAllRiskPoint(ids, riskSourceList);
if (CollectionUtils.isEmpty(ids)) {//没有风险点,则赋初始值null
riskSource.setRpn(null);
riskSource.setRpni(null);
riskSource.setRiskLevelId(null);
} else {
List<Fmea> fmeas = fmeaMapper.listByRiskSourceIds(ids);
RpnCalculationBo rpnValueBo = RpnUtils.calRpnAndRpni(fmeas);
if (rpnValueBo.isEmpty()) {
return;
} }
if (sidValue.compareTo(maxSidValue) == 1) { BigDecimal rpn = rpnValueBo.getRpn();
maxSidValue = sidValue; BigDecimal rpni = rpnValueBo.getRpni();
List<RiskLevel> levels = riskLevelDao.findAll();
RiskLevel newRiskLevel = RpnUtils.getBetweenLevel(rpn, levels);
if (newRiskLevel != null) {
riskSource.setRpn(rpn);
riskSource.setRpni(rpni);
riskSource.setRiskLevelId(newRiskLevel.getId());
} }
totalOidValue = totalOidValue.add(oidValue);
totalNewOidValue = totalNewOidValue.add(newOidValue);
count++;
} }
iRiskSourceDao.save(riskSource);
this.updateParentRpn(riskSource.getParentId());
} }
if (count == 0) { }
return;
} /**
BigDecimal averageOidValue = totalOidValue.divide(BigDecimal.valueOf(count)); * 获得子节点:巡检点
BigDecimal averageNewOidValue = totalNewOidValue.divide(BigDecimal.valueOf(count)); *
BigDecimal rpn = maxDidValue.multiply(maxSidValue).multiply(averageNewOidValue); * @param ids 返回
BigDecimal rpni = maxDidValue.multiply(maxSidValue).multiply(averageOidValue); * @param riskSourceList 风险点区域列表
List<RiskLevel> levels = riskLevelDao.findAll(); */
RiskLevel newRiskLevel = getBetweenLevel(rpn, levels); private void getAllRiskPoint(List<Long> ids, List<RiskSource> riskSourceList) {
RiskLevel oldRiskLevel = getBetweenLevel(rpni, levels); //TODO 递归
if (newRiskLevel != null) { for (RiskSource riskSource : riskSourceList) {
riskSource.setRpn(rpn); if (riskSource.getIsRegion().equalsIgnoreCase("TRUE")) {
riskSource.setRpni(rpni); List<RiskSource> list = iRiskSourceDao.findByParentId(riskSource.getId());
riskSource.setRiskLevelId(newRiskLevel.getId()); if (list != null) {
riskSourceMapper.updateRpn(riskSource); this.getAllRiskPoint(ids, list);
jpushRiskSourceMessage("风险点告警", jpushTarget); }
notifyRule(riskSourceId, rpn, rpni, oldRiskLevel.getLevel(), newRiskLevel.getLevel(), notifyType); } else {
ids.add(riskSource.getId());
}
} }
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
} }
private void jpushRiskSourceMessage(String content, String jpushTarget) { /**
if (StringUtils.isEmpty(jpushTarget)) { * 极光推送
*/
private void jpushRiskSourceMessage(String content, Set<String> jpushTarget) {
if (CollectionUtils.isEmpty(jpushTarget)) {
return; return;
} }
PushMsgParam pushMsgParam = new PushMsgParam(); PushMsgParam pushMsgParam = new PushMsgParam();
...@@ -1672,7 +1307,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1672,7 +1307,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
appMessagePushService.sendMessage(pushMsgParam); appMessagePushService.sendMessage(pushMsgParam);
} }
private void notifyRule(Long id, BigDecimal rpnr, BigDecimal rpni, Integer oldLevel, Integer newLevel, String notifyType) { /**
* 规则告警
*/
private void notifyRule(Long id, BigDecimal rpnr, BigDecimal rpni, Integer oldLevel, Integer newLevel, String
notifyType) {
int level = oldLevel - newLevel; int level = oldLevel - newLevel;
String changeType; String changeType;
if (level > 0) { if (level > 0) {
...@@ -1703,64 +1342,49 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1703,64 +1342,49 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
} }
private RiskLevel getBetweenLevel(BigDecimal rpni, List<RiskLevel> levels) { @Override
if (CollectionUtils.isEmpty(levels)) { public List<RegionTreeResponse> findRegionTree(String channelType, String orgCode) {
return null; List<RegionTreeResponse> regionList = riskSourceMapper.getRegionList(channelType, orgCode);
} return getRiskRegionTree(regionList);
for (RiskLevel level : levels) {
int downResult = level.getDownLimit().compareTo(rpni);
int topResult = level.getTopLimit().compareTo(rpni);
if (downResult == -1 && topResult != -1) {
return level;
}
}
return null;
} }
@Override //区域列表转树
public List<RegionTreeResponse> findRegionTree(String channelType,String orgCode) { private static List<RegionTreeResponse> getRiskRegionTree(List<RegionTreeResponse> list) {
List<RegionTreeResponse> regionList = riskSourceMapper.getRegionList(channelType,orgCode); HashMap<Long, RegionTreeResponse> hashMap = new HashMap<>();
return getRiskRegionTree(regionList); list.forEach(e -> hashMap.put(e.getId(), e));
} List<RegionTreeResponse> treeList = new ArrayList<RegionTreeResponse>();
list.forEach(r -> {
//区域列表转树 Long parentId = r.getParentId();
private static List<RegionTreeResponse> getRiskRegionTree(List<RegionTreeResponse> list) { if (parentId != null) {
HashMap<Long, RegionTreeResponse> hashMap = new HashMap<>(); RegionTreeResponse pRegion = hashMap.get(parentId);
list.forEach( e -> hashMap.put(e.getId(), e)); if (pRegion != null) {
List<RegionTreeResponse> treeList = new ArrayList<RegionTreeResponse>(); pRegion.getChildren().add(r);
list.forEach( r -> { } else {
Long parentId = r.getParentId(); treeList.add(r);
if(parentId != null) { }
RegionTreeResponse pRegion = hashMap.get(parentId); }
if(pRegion != null) {
pRegion.getChildren().add(r);
}else {
treeList.add(r);
}
}
}); });
return treeList; return treeList;
} }
@Override @Override
public HashMap<String, Object> findRegionById(Long id,String orgCode,String channelType) { public HashMap<String, Object> findRegionById(Long id, String orgCode, String channelType) {
HashMap<String, Object> regionDetail = riskSourceMapper.findRegionById(id,orgCode,channelType); HashMap<String, Object> regionDetail = riskSourceMapper.findRegionById(id, orgCode, channelType);
if(regionDetail != null) { if (regionDetail != null) {
Long isBind = (Long) regionDetail.get("isBind"); Long isBind = (Long) regionDetail.get("isBind");
regionDetail.put("isBind", isBind == 0 ? false : true); regionDetail.put("isBind", isBind == 0 ? false : true);
String ue4Location = (String)regionDetail.get("ue4Location"); String ue4Location = (String) regionDetail.get("ue4Location");
regionDetail.put("ue4Location", ue4Location == null ? new JSONArray() : JSON.parseArray(ue4Location)); regionDetail.put("ue4Location", ue4Location == null ? new JSONArray() : JSON.parseArray(ue4Location));
String ue4Rotation = (String)regionDetail.get("ue4Rotation"); String ue4Rotation = (String) regionDetail.get("ue4Rotation");
regionDetail.put("ue4Rotation", ue4Rotation == null ? new JSONArray() : JSON.parseArray(ue4Rotation)); regionDetail.put("ue4Rotation", ue4Rotation == null ? new JSONArray() : JSON.parseArray(ue4Rotation));
String ue4Extent = (String)regionDetail.get("ue4Extent"); String ue4Extent = (String) regionDetail.get("ue4Extent");
regionDetail.put("ue4Extent", ue4Extent == null ? new JSONArray() : JSON.parseArray(ue4Extent)); regionDetail.put("ue4Extent", ue4Extent == null ? new JSONArray() : JSON.parseArray(ue4Extent));
} }
return regionDetail; return regionDetail;
} }
@Override @Override
public void batchSaveRegionUe4(List<BindRegionBo> regionBoList) { public void batchSaveRegionUe4(List<BindRegionBo> regionBoList) {
riskSourceMapper.batchSaveRegionUe4(regionBoList); riskSourceMapper.batchSaveRegionUe4(regionBoList);
} }
} }
...@@ -4,7 +4,6 @@ import com.yeejoin.amos.fas.business.vo.TreeSubjectVo; ...@@ -4,7 +4,6 @@ import com.yeejoin.amos.fas.business.vo.TreeSubjectVo;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.dao.entity.TextPlan; import com.yeejoin.amos.fas.dao.entity.TextPlan;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -35,4 +34,10 @@ public interface IPlanVisual3dService { ...@@ -35,4 +34,10 @@ public interface IPlanVisual3dService {
CommonResponse getResourceListByType(String type); CommonResponse getResourceListByType(String type);
List<Map<String,Object>> getResourceById(String type,Long id); List<Map<String,Object>> getResourceById(String type,Long id);
List<Map<String,Object>> getResourceTypeList();
List<TreeSubjectVo> getTextPlanBySubjectId(String appId);
void deleteTextPlanFile(Long id);
} }
package com.yeejoin.amos.fas.business.service.intfc; package com.yeejoin.amos.fas.business.service.intfc;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.data.domain.Page;
import com.yeejoin.amos.fas.business.bo.BindRegionBo; import com.yeejoin.amos.fas.business.bo.BindRegionBo;
import com.yeejoin.amos.fas.business.param.AlarmParam; import com.yeejoin.amos.fas.business.param.AlarmParam;
import com.yeejoin.amos.fas.business.param.CommonPageInfoParam; import com.yeejoin.amos.fas.business.param.CommonPageInfoParam;
...@@ -19,6 +13,12 @@ import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse; ...@@ -19,6 +13,12 @@ import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse;
import com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint; import com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint;
import com.yeejoin.amos.fas.dao.entity.FmeaPointInputitem; import com.yeejoin.amos.fas.dao.entity.FmeaPointInputitem;
import com.yeejoin.amos.fas.dao.entity.RiskSource; import com.yeejoin.amos.fas.dao.entity.RiskSource;
import org.springframework.data.domain.Page;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface IRiskSourceService { public interface IRiskSourceService {
...@@ -86,8 +86,6 @@ public interface IRiskSourceService { ...@@ -86,8 +86,6 @@ public interface IRiskSourceService {
Map earlyWarning(Long riskSourceId); Map earlyWarning(Long riskSourceId);
// BigDecimal updateRiskSourceRpni(Long riskSourceId) throws Exception;
List<HashMap<String, Object>> queryRiskAreaRpn(); List<HashMap<String, Object>> queryRiskAreaRpn();
String processFireEqumtData(AlarmParam deviceData) throws Exception; String processFireEqumtData(AlarmParam deviceData) throws Exception;
...@@ -114,8 +112,6 @@ public interface IRiskSourceService { ...@@ -114,8 +112,6 @@ public interface IRiskSourceService {
void notifyFmeaFromUpdate(String toke,String product,String appKey,Long fmeaId, String nofityType); void notifyFmeaFromUpdate(String toke,String product,String appKey,Long fmeaId, String nofityType);
void notifyRiskSource(Long riskSourceId, String notifyType, String jpushTarget);
/** /**
* 按照机构重新区域树 * 按照机构重新区域树
* @param orgCode 机构 * @param orgCode 机构
...@@ -137,4 +133,9 @@ public interface IRiskSourceService { ...@@ -137,4 +133,9 @@ public interface IRiskSourceService {
*/ */
void batchSaveRegionUe4(List<BindRegionBo> regionBoList); void batchSaveRegionUe4(List<BindRegionBo> regionBoList);
void notifyRiskSource(Long fmeaId, Long riskSourceId, String notifyType, Set<String> jpushTargets);
void notifyFmeaFromDelete(Long handId, String from);
void notifyRiskSourceDelete(Long handId);
} }
...@@ -6,10 +6,12 @@ import com.yeejoin.amos.fas.dao.entity.TopographyLine; ...@@ -6,10 +6,12 @@ import com.yeejoin.amos.fas.dao.entity.TopographyLine;
public interface ITopographyLineService { public interface ITopographyLineService {
public List<TopographyLine> getLinksByAppId(String appId); public List<TopographyLine> getLinesByAppIdAndType(String appId,String type);
public void saveLines(List<TopographyLine> lineData); public void saveLines(List<TopographyLine> lineData);
public void deleteLine(String id); public void deleteLine(String id);
public List<TopographyLine> getLinesByType(String type);
} }
...@@ -2,13 +2,12 @@ package com.yeejoin.amos.fas.business.service.intfc; ...@@ -2,13 +2,12 @@ package com.yeejoin.amos.fas.business.service.intfc;
import java.util.List; import java.util.List;
import com.yeejoin.amos.fas.dao.entity.TopographyLine;
import com.yeejoin.amos.fas.dao.entity.TopographyNode; import com.yeejoin.amos.fas.dao.entity.TopographyNode;
import com.yeejoin.amos.fas.dao.entity.TopographyNodeDetail; import com.yeejoin.amos.fas.dao.entity.TopographyNodeDetail;
public interface ITopographyNodeService { public interface ITopographyNodeService {
public List<TopographyNode> getNodesByAppId(String appId); public List<TopographyNode> getNodesByAppIdAndType(String appId,String type);
public void saveNodes(List<TopographyNode> nodeData); public void saveNodes(List<TopographyNode> nodeData);
...@@ -16,10 +15,14 @@ public interface ITopographyNodeService { ...@@ -16,10 +15,14 @@ public interface ITopographyNodeService {
public TopographyNodeDetail saveNodeDetail(TopographyNodeDetail nodeDetail); public TopographyNodeDetail saveNodeDetail(TopographyNodeDetail nodeDetail);
public void deleteNode(String id); public void deleteNode(TopographyNode node);
public TopographyNode queryByKeyAndAppId(String nodekey, String appId); public TopographyNode queryByKeyAndAppIdAndType(String nodekey, String appId,String type);
public int queryMaxKeyByAppId(String appId); public int queryMaxKeyByAppIdAndType(String appId,String type);
public TopographyNode queryById(String id);
public List<TopographyNode> getNodesByType(String type);
} }
package com.yeejoin.amos.fas.business.util;
import com.yeejoin.amos.fas.business.bo.RpnCalculationBo;
import com.yeejoin.amos.fas.common.enums.RpnChangeLogTypeEum;
import com.yeejoin.amos.fas.dao.entity.Fmea;
import com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint;
import com.yeejoin.amos.fas.dao.entity.FmeaPointInputitem;
import com.yeejoin.amos.fas.dao.entity.RiskLevel;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.List;
/**
* @author DELL
*/
public class RpnUtils {
/**
* 计算风险值
* @param fmeas
* @return RpnCalculationBo
*/
public static RpnCalculationBo calRpnAndRpni(List<Fmea> fmeas){
BigDecimal maxSidValue = new BigDecimal("0");
BigDecimal maxDidValue = new BigDecimal("0");
BigDecimal totalOidValue = new BigDecimal("0");
BigDecimal totalNewOidValue = new BigDecimal("0");
long count = 0L;
for (Fmea fmea : fmeas) {
if (fmea.getEvaluationDid() != null && fmea.getEvaluationSid() != null && fmea.getEvaluationOid() != null && fmea.getNewEvaluationOid() != null) {
BigDecimal didValue = new BigDecimal(fmea.getDidValue());
BigDecimal sidValue = new BigDecimal(fmea.getSidValue());
BigDecimal oidValue = new BigDecimal(fmea.getOidValue());
BigDecimal newOidValue = new BigDecimal(fmea.getNewOidValue());
if (didValue.compareTo(maxDidValue) == 1) {
maxDidValue = didValue;
}
if (sidValue.compareTo(maxSidValue) == 1) {
maxSidValue = sidValue;
}
totalOidValue = totalOidValue.add(oidValue);
totalNewOidValue = totalNewOidValue.add(newOidValue);
count++;
}
}
RpnCalculationBo rpnValue = new RpnCalculationBo();
rpnValue.setSize(count);
if (count == 0) {
return rpnValue;
}
BigDecimal averageOidValue = totalOidValue.divide(BigDecimal.valueOf(count),2,BigDecimal.ROUND_HALF_UP);
BigDecimal averageNewOidValue = totalNewOidValue.divide(BigDecimal.valueOf(count),2,BigDecimal.ROUND_HALF_UP);
BigDecimal rpn = maxDidValue.multiply(maxSidValue).multiply(averageNewOidValue).setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal rpni = maxDidValue.multiply(maxSidValue).multiply(averageOidValue).setScale(2,BigDecimal.ROUND_HALF_UP);
rpnValue.setRpn(rpn);
rpnValue.setRpni(rpni);
return rpnValue;
}
/**
* 计算最大故障率
* @param equipmentPoints
* @param pointInputitems
* @return
*/
public static Double getMaxRate(List<FmeaEquipmentPoint> equipmentPoints, List<FmeaPointInputitem> pointInputitems) {
Double pointInputitemRate = null;
if (!CollectionUtils.isEmpty(pointInputitems)) {
int totalPointInputitem = pointInputitems.size();
int pointInputitemUnNormal = 0;
for (FmeaPointInputitem pointInputitem : pointInputitems) {
if (pointInputitem.getState() == 1) {
pointInputitemUnNormal++;
}
}
pointInputitemRate = pointInputitemUnNormal * 1.0 / totalPointInputitem;
}
Double equipmentPointRate = null;
if (!CollectionUtils.isEmpty(equipmentPoints)) {
int totalEquipmentPoint = equipmentPoints.size();
int equipmentPointUnNormal = 0;
for (FmeaEquipmentPoint equipmentPoint : equipmentPoints) {
if (equipmentPoint.getState() == 1) {
equipmentPointUnNormal++;
}
}
equipmentPointRate = equipmentPointUnNormal * 1.0 / totalEquipmentPoint;
}
if (equipmentPointRate == null) {
if (pointInputitemRate == null) {
return null;
} else {
return pointInputitemRate;
}
} else {
if (pointInputitemRate == null) {
return equipmentPointRate;
} else {
if (pointInputitemRate < equipmentPointRate) {
return equipmentPointRate;
} else {
return pointInputitemRate;
}
}
}
}
/**
* 获得风险等级
* @param rpni
* @param levels
* @return
*/
public static RiskLevel getBetweenLevel(BigDecimal rpni, List<RiskLevel> levels) {
if (CollectionUtils.isEmpty(levels)) {
return null;
}
for (RiskLevel level : levels) {
int downResult = level.getDownLimit().compareTo(rpni);
int topResult = level.getTopLimit().compareTo(rpni);
if (downResult == -1 && topResult != -1) {
return level;
}
}
return null;
}
/**
* 获取风险变化类型
* @param rpn
* @param rpni
* @return
*/
public static int getChangeType(BigDecimal rpn, BigDecimal rpni) {
if(rpn.subtract(rpni).doubleValue() > 0){
return RpnChangeLogTypeEum.upper.getCode();
} else if(rpn.subtract(rpni).doubleValue() < 0){
return RpnChangeLogTypeEum.down.getCode();
} else {
return RpnChangeLogTypeEum.unChange.getCode();
}
}
}
...@@ -5,11 +5,11 @@ import java.util.List; ...@@ -5,11 +5,11 @@ import java.util.List;
public class TreeSubjectVo { public class TreeSubjectVo {
private Integer id; private String id;
private String treeName; private String treeName;
private Integer parentId; private String parentId;
private Integer maxSubjectNumber; private Integer maxSubjectNumber;
...@@ -17,7 +17,7 @@ public class TreeSubjectVo { ...@@ -17,7 +17,7 @@ public class TreeSubjectVo {
private List<TreeSubjectVo> children = new ArrayList<>(); private List<TreeSubjectVo> children = new ArrayList<>();
private Long createTime; private String createTime;
private Integer creator; private Integer creator;
...@@ -33,17 +33,17 @@ public class TreeSubjectVo { ...@@ -33,17 +33,17 @@ public class TreeSubjectVo {
private int publishState; private int publishState;
private int belongTreeId; private String belongTreeId;
private String scenes; private String scenes;
List<TreeSubjectVo> subjectChildren = new ArrayList<>(); List<TreeSubjectVo> subjectChildren = new ArrayList<>();
public Integer getId() { public String getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(String id) {
this.id = id; this.id = id;
} }
...@@ -55,11 +55,11 @@ public class TreeSubjectVo { ...@@ -55,11 +55,11 @@ public class TreeSubjectVo {
this.treeName = treeName; this.treeName = treeName;
} }
public Integer getParentId() { public String getParentId() {
return parentId; return parentId;
} }
public void setParentId(Integer parentId) { public void setParentId(String parentId) {
this.parentId = parentId; this.parentId = parentId;
} }
...@@ -79,11 +79,11 @@ public class TreeSubjectVo { ...@@ -79,11 +79,11 @@ public class TreeSubjectVo {
this.children = children; this.children = children;
} }
public Long getCreateTime() { public String getCreateTime() {
return createTime; return createTime;
} }
public void setCreateTime(Long createTime) { public void setCreateTime(String createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
...@@ -143,11 +143,11 @@ public class TreeSubjectVo { ...@@ -143,11 +143,11 @@ public class TreeSubjectVo {
this.publishState = publishState; this.publishState = publishState;
} }
public int getBelongTreeId() { public String getBelongTreeId() {
return belongTreeId; return belongTreeId;
} }
public void setBelongTreeId(int belongTreeId) { public void setBelongTreeId(String belongTreeId) {
this.belongTreeId = belongTreeId; this.belongTreeId = belongTreeId;
} }
......
...@@ -5,9 +5,8 @@ import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService; ...@@ -5,9 +5,8 @@ import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
import com.yeejoin.amos.fas.business.util.CacheFactory; import com.yeejoin.amos.fas.business.util.CacheFactory;
import com.yeejoin.amos.fas.business.util.CacheMap; import com.yeejoin.amos.fas.business.util.CacheMap;
import com.yeejoin.amos.fas.business.vo.Toke; import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.common.enums.TriggerRpnChangeTypeEum;
import com.yeejoin.amos.fas.context.IotContext; import com.yeejoin.amos.fas.context.IotContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -27,14 +26,19 @@ public class RsDataQueue { ...@@ -27,14 +26,19 @@ public class RsDataQueue {
private IRiskSourceService riskSourceService; private IRiskSourceService riskSourceService;
private volatile static RsDataQueue instance = null; private volatile static RsDataQueue instance = null;
private static final String TOKE = "TOKE"; private static final String TOKE = "TOKE";
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
private RsDataQueue() { private RsDataQueue() {
riskSourceService = (IRiskSourceService) IotContext.getInstance().getBean(IRiskSourceService.class); riskSourceService = (IRiskSourceService) IotContext.getInstance().getBean(IRiskSourceService.class);
} }
//获取RsDataQueue 的实例 /**
* 获取RsDataQueue 的实例
*
* @return 获RsDataQueue
*/
public static RsDataQueue getInstance() { public static RsDataQueue getInstance() {
//先检查实例是否存在,如果不存在才进入下面的同步块 //先检查实例是否存在,如果不存在才进入下面的同步块
if (instance == null) { if (instance == null) {
...@@ -59,55 +63,65 @@ public class RsDataQueue { ...@@ -59,55 +63,65 @@ public class RsDataQueue {
} }
public void addUpdateMessage(Long fmeaId) { public void addUpdateMessage(Long fmeaId) {
blockingQueue.add(new FmeaMessage(fmeaId, "update")); blockingQueue.add(new FmeaMessage(fmeaId, TriggerRpnChangeTypeEum.fmeaUpdate.getCode()));
} }
public void addPatrolMessage(Long fmeaId) { public void addPatrolMessage(Long fmeaId) {
blockingQueue.add(new FmeaMessage(fmeaId, "patrol")); blockingQueue.add(new FmeaMessage(fmeaId, TriggerRpnChangeTypeEum.patrol.getCode()));
} }
public void addEquipmentMessage(Long fmeaId) { public void addEquipmentMessage(Long fmeaId) {
blockingQueue.add(new FmeaMessage(fmeaId, "equipment")); blockingQueue.add(new FmeaMessage(fmeaId, TriggerRpnChangeTypeEum.equipment.getCode()));
} }
public void addDeleteMessage(Long riskSourceId) { public void addDeleteMessage(Long riskSourceId) {
blockingQueue.add(new FmeaMessage(riskSourceId, "delete")); blockingQueue.add(new FmeaMessage(riskSourceId, TriggerRpnChangeTypeEum.fmeaDelete.getCode()));
} }
Runnable task_runnable = new Runnable() { public void addRiskSourcePointDeleteMessage(Long parentId) {
blockingQueue.add(new FmeaMessage(parentId, TriggerRpnChangeTypeEum.riskDelete.getCode()));
}
private Runnable task_runnable = new Runnable() {
@Override
public void run() { public void run() {
while (true) { while (true) {
try { try {
FmeaMessage fmeaMessage = blockingQueue.take(); FmeaMessage fmeaMessage = blockingQueue.take();
if (riskSourceService != null) { if (riskSourceService != null) {
//获取缓存 //获取缓存
CacheMap cacheMap= CacheFactory.newChacheMap(); CacheMap cacheMap = CacheFactory.newChacheMap();
Toke toke= cacheMap.getValue(TOKE); Toke toke = cacheMap.getValue(TOKE);
if(toke==null){ if (toke == null) {
toke= remoteSecurityService.come(); toke = remoteSecurityService.come();
Long times= (long) (20*24*60*60); Long times = (long) (20 * 24 * 60 * 60);
cacheMap.setex(TOKE, toke, times); cacheMap.setex(TOKE, toke, times);
} }
String from = fmeaMessage.getNorifyFrom(); String from = fmeaMessage.getNorifyFrom();
Long handId = fmeaMessage.getHandId(); Long handId = fmeaMessage.getHandId();
if (from.equals("patrol")) { if (from.equals(TriggerRpnChangeTypeEum.patrol.getCode())) {
riskSourceService.notifyFmeaFromAbnormal(toke.getToke(),toke.getProduct(),toke.getAppKey(),handId, from); //巡检不合格通知
} else if (from.equals("equipment")) { riskSourceService.notifyFmeaFromAbnormal(toke.getToke(), toke.getProduct(), toke.getAppKey(), handId, from);
riskSourceService.notifyFmeaFromAbnormal(toke.getToke(),toke.getProduct(),toke.getAppKey(),handId, from); } else if (from.equals(TriggerRpnChangeTypeEum.equipment.getCode())) {
} else if (from.equals("update")) { //设备告警
riskSourceService.notifyFmeaFromUpdate(toke.getToke(),toke.getProduct(),toke.getAppKey(),handId, from); riskSourceService.notifyFmeaFromAbnormal(toke.getToke(), toke.getProduct(), toke.getAppKey(), handId, from);
} else if (from.equals("delete")) { } else if (from.equals(TriggerRpnChangeTypeEum.fmeaUpdate.getCode())) {
riskSourceService.notifyRiskSource(handId, from, null); //危险因素评价修改通知
riskSourceService.notifyFmeaFromUpdate(toke.getToke(), toke.getProduct(), toke.getAppKey(), handId, from);
} else if (from.equals(TriggerRpnChangeTypeEum.fmeaDelete.getCode())) {
//危险因素删除通知
riskSourceService.notifyFmeaFromDelete(handId, from);
} else if (from.equals(TriggerRpnChangeTypeEum.riskDelete.getCode())) {
//风险点删除通知
riskSourceService.notifyRiskSourceDelete(handId);
} }
} }
} catch (Exception e) { } catch (Exception e) {
LoggerFactory.getLogger(this.getClass()).error(e.getMessage()); LoggerFactory.getLogger(this.getClass()).error(e.getMessage());
e.printStackTrace();
} }
}
} }
}; }
};
} }
...@@ -182,8 +182,6 @@ ...@@ -182,8 +182,6 @@
<column name="type"/> <column name="type"/>
</createIndex> </createIndex>
</changeSet> </changeSet>
<changeSet author="shanqiyun" id="1588067351000-1"> <changeSet author="shanqiyun" id="1588067351000-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
...@@ -195,7 +193,6 @@ ...@@ -195,7 +193,6 @@
alter table f_risk_source add column `route_path` varchar(2000) DEFAULT NULL COMMENT '路径坐标' after `position3d`; alter table f_risk_source add column `route_path` varchar(2000) DEFAULT NULL COMMENT '路径坐标' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1588140925893-1"> <changeSet author="suhuiguang" id="1588140925893-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
...@@ -207,4 +204,14 @@ ...@@ -207,4 +204,14 @@
alter table `f_safety_index_change_log` add column `create_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间'; alter table `f_safety_index_change_log` add column `create_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1588990926789-1">
<preConditions onFail="MARK_RAN">
<columnExists tableName="f_risk_level " columnName="manage_level"/>
</preConditions>
<comment>f_risk_level add column manage_level 管控级别</comment>
<sql>
ALTER TABLE `f_risk_level`
add COLUMN `manage_level` tinyint(4) DEFAULT NULL COMMENT '管控级别';
</sql>
</changeSet>
</databaseChangeLog> </databaseChangeLog>
\ No newline at end of file
...@@ -5,7 +5,11 @@ ...@@ -5,7 +5,11 @@
<!--查询--> <!--查询-->
<select id="getResourceListByType" resultType="java.util.HashMap"> <select id="getResourceListByType" resultType="java.util.HashMap">
SELECT SELECT
rs.id,rs.name,rs.code rs.id as `key` ,
rs.id AS `value`,
rs.name as label,
rs.code ,
'id' as dataType
from from
<choose> <choose>
<when test="type=='fireCar'"> <when test="type=='fireCar'">
......
...@@ -132,12 +132,14 @@ ...@@ -132,12 +132,14 @@
a.unit, a.unit,
a.org_code as orgCode, a.org_code as orgCode,
a.alarm_type as alarmType, a.alarm_type as alarmType,
fd.dict_name as alarmTypeName,
b.name as fireEquipmentName, b.name as fireEquipmentName,
b.code as fireEquipmentCode b.code as fireEquipmentCode
from from
f_fire_equipment_point as a f_fire_equipment_point as a
left join left join
f_fire_equipment as b on a.fire_equipment_id = b.id f_fire_equipment as b on a.fire_equipment_id = b.id
left join f_dict fd on fd.id = a.alarm_type
<where> <where>
<if test="searchValue!=null and searchValue.trim() != ''"> <if test="searchValue!=null and searchValue.trim() != ''">
and (a.name like concat('%',#{searchValue},'%') or a.code like concat('%',#{searchValue},'%')) and (a.name like concat('%',#{searchValue},'%') or a.code like concat('%',#{searchValue},'%'))
......
...@@ -154,4 +154,27 @@ ...@@ -154,4 +154,27 @@
</set> </set>
where id = #{id} where id = #{id}
</update> </update>
<select id="listByRiskSourceIds" resultType="com.yeejoin.amos.fas.dao.entity.Fmea">
select
a.id,
a.risk_source_id as riskSourceId,
a.risk_factors_id as riskFactorsId,
a.evaluation_sid as evaluationSid,
a.evaluation_oid as evaluationOid,
a.evaluation_did as evaluationDid,
a.new_evaluation_oid as newEvaluationOid,
a.rpni,
a.rpn,
(select coefficient from f_evaluation_model where id = a.evaluation_sid) as sidValue,
(select coefficient from f_evaluation_model where id = a.evaluation_oid) as oidValue,
(select coefficient from f_evaluation_model where id = a.evaluation_did) as didValue,
(select coefficient from f_evaluation_model where id = a.new_evaluation_oid) as newOidValue
from
f_fmea as a
where
a.risk_source_id in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -119,7 +119,8 @@ ...@@ -119,7 +119,8 @@
null data_level, null data_level,
fe.`code` data_code, fe.`code` data_code,
(select GROUP_CONCAT(cast(eq.`name` as char(50)) SEPARATOR ',') from f_equipment_fire_equipment fre join f_equipment eq on fre.equipment_id = eq.id where fre.fire_equipment_id = fe.id) protect_obj_name, (select GROUP_CONCAT(cast(eq.`name` as char(50)) SEPARATOR ',') from f_equipment_fire_equipment fre join f_equipment eq on fre.equipment_id = eq.id where fre.fire_equipment_id = fe.id) protect_obj_name,
null route_name null route_name,
0 frequency
from f_fire_equipment fe from f_fire_equipment fe
where where
<choose> <choose>
...@@ -249,7 +250,8 @@ ...@@ -249,7 +250,8 @@
null data_level, null data_level,
e.`code` data_code, e.`code` data_code,
null protect_obj_name, null protect_obj_name,
null route_name null route_name,
0 frequency
from f_equipment e from f_equipment e
where where
<choose> <choose>
...@@ -346,7 +348,8 @@ ...@@ -346,7 +348,8 @@
null data_level, null data_level,
fc.car_num data_code, fc.car_num data_code,
null protect_obj_name, null protect_obj_name,
null route_name null route_name,
0 frequency
from f_fire_car fc from f_fire_car fc
where where
...@@ -445,7 +448,8 @@ ...@@ -445,7 +448,8 @@
null data_level, null data_level,
fs.`code` data_code, fs.`code` data_code,
null protect_obj_name, null protect_obj_name,
null route_name null route_name ,
0 frequency
from f_fire_station fs from f_fire_station fs
where where
<choose> <choose>
...@@ -544,7 +548,8 @@ ...@@ -544,7 +548,8 @@
null data_level, null data_level,
wr.`code` data_code, wr.`code` data_code,
null protect_obj_name, null protect_obj_name,
null route_name null route_name ,
0 frequency
from f_water_resource wr from f_water_resource wr
where where
<choose> <choose>
......
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
</dependencyManagement> </dependencyManagement>
<repositories> <repositories>
<repository> <repository>
<id>public</id> <id>public</id>
<name>Public Repositories</name> <name>Public Repositories</name>
...@@ -218,7 +218,16 @@ ...@@ -218,7 +218,16 @@
<name>maven-public</name> <name>maven-public</name>
<url>http://172.16.1.6:8081/nexus/content/repositories/maven-public/</url> <url>http://172.16.1.6:8081/nexus/content/repositories/maven-public/</url>
</repository> </repository>
<repository>
<id>maven-public</id>
<name>maven-public</name>
<url>http://repo.typroject.org:8081/repository/maven-public/</url>
</repository>
<repository>
<id>maven-snapshot</id>
<name>maven-snapshot</name>
<url>http://repo.typroject.org:8081/repository/maven-snapshots/</url>
</repository>
</repositories> </repositories>
<pluginRepositories> <pluginRepositories>
......
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