Commit 0246c446 authored by 李成龙's avatar 李成龙

合并安全风险代码到新框架

parent 9732230f
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>amos-boot-module-biz</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-fas-biz</artifactId>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-fas-api</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>xdocreport</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.itextpdf/itext-asian -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>com.itextpdf.tool</groupId>
<artifactId>xmlworker</artifactId>
<version>5.5.9</version>
</dependency>
</dependencies>
</project>
package com.yeejoin.amos.fas.business.action;
import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.action.result.BubbleTipResult;
import com.yeejoin.amos.fas.business.action.result.message.ActionResultMessage;
import org.springframework.stereotype.Component;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
/**
*
* <pre>
* 气泡提示动作
* </pre>
*
* @author amos
* @version $Id: BubbleTipAction.java, v 0.1 2019年5月16日 上午10:42:32 amos Exp $
*/
@Component
@RuleActionBean(beanLabel = "气泡提示" )
public class BubbleTipAction implements CustomerAction
{
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
//@ExposeAction("气泡提示")
@RuleMethod(methodLabel = "气泡提示", project = "风险管控")
public void sendBubbleTip(Object bizobj, Boolean showInfo, Object title, String type)
{
BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("bizobj", bizobj);
result.add(tempmap1);
//是否显示气泡
Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("showInfo", showInfo);
result.add(tempmap2);
//显示title提示
Map<String, Object> tempmap3 = new HashMap<>();
tempmap3.put("title", title);
result.add(tempmap3);
//节点类型
Map<String, Object> tempmap4 = new HashMap<>();
tempmap4.put("type", type);
result.add(tempmap4);
Constructor<?> constructor;
try
{
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
ActionResultMessage<?> action = (ActionResultMessage<?>) constructor.newInstance(result);
String msgType = "message";
Object obj = action.execute(msgType, null);
// result.setToipResponse((ToipResponse) obj);
}
catch (Exception e)
{
e.printStackTrace();
}
}
@Override
public void intreeuptPlan(String batchNo) {
}
}
package com.yeejoin.amos.fas.business.action;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentHandlerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
import com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService;
@Component
public class ContingencyLogListener implements ApplicationListener<ContingencyEvent>{
@Autowired
IRuleRunningSnapshotService ruleRunningSnapshotService;
@Override
public void onApplicationEvent(ContingencyEvent event) {
ruleRunningSnapshotService.reacordPlan(event.getTopic(), event.getMsgType(), event.getMsgBody(), event.getContingency());
}
}
package com.yeejoin.amos.fas.business.action;
public interface CustomerAction {
/**
*数字预案中断
*/
void intreeuptPlan(String batchNo);
}
package com.yeejoin.amos.fas.business.action;
import com.yeejoin.amos.component.rule.MethodParam;
import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.action.result.BubbleTipResult;
import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
/**
*
* <pre>
* 风险态势图动作
* </pre>
*
* @author amos
* @version $Id: RiskSituationAction.java, v 0.1 2019年5月16日 下午5:26:27 amos Exp $
*/
@Component
@RuleActionBean(beanLabel = "动态预案")
public class RiskSituationAction implements CustomerAction
{
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
@Autowired
private WebMqttComponent webMqttComponent;
@Value("${auto-sys.push.type}")
private String pushType;
@Value("${spring.application.name}")
private String serviceName;
@Value("${station.name}")
private String stationName;
@RuleMethod(methodLabel = "气泡提示", project = "换流站消防专项预案")
public void sendBubbleTip(@MethodParam(paramLabel = "bizobj对象") Object bizobj,
@MethodParam(paramLabel = "是否显示名称") Boolean showInfo,
@MethodParam(paramLabel = "标题") String title)
{
BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("bizobj", bizobj);
result.add(tempmap1);
//是否显示气泡
Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("showInfo", showInfo);
result.add(tempmap2);
//显示title提示
Map<String, Object> tempmap3 = new HashMap<>();
tempmap3.put("title", title);
result.add(tempmap3);
Constructor<?> constructor;
try
{
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
String msgType = "bubbleTip";
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result);
String topic = String.format("/%s/%s/%s", serviceName, stationName,"rule");
webMqttComponent.publish(topic, toipResponse.toJsonStr());
} else {
Object obj = action.execute(msgType, bizobj);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
@RuleMethod(methodLabel = "区域颜色改变", project = "换流站消防专项预案")
public void regionChange(@MethodParam(paramLabel = "bizobj对象") Object bizobj, @MethodParam(paramLabel = "颜色") String colour)
{
BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("bizobj", bizobj);
result.add(tempmap1);
//更改颜色
Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("colour", colour);
result.add(tempmap2);
Constructor<?> constructor;
try
{
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
String msgType = "changeColor";
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result);
webMqttComponent.publish("", toipResponse.toJsonStr());
} else {
action.execute(msgType, bizobj);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
//@ExposeAction(value = "区域闪烁",snapshot = false)
@RuleMethod(methodLabel = "区域闪烁", project = "换流站消防专项预案")
public void regionFlicker(@MethodParam(paramLabel = "bizobj对象") Object bizobj, @MethodParam(paramLabel = "闪烁频率") Integer frequency)
{
BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>();
result.add(tempmap1);
//更改颜色
Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("frequency", frequency);
result.add(tempmap2);
Constructor<?> constructor;
try
{
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
String msgType = "message";
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result);
webMqttComponent.publish("", toipResponse.toJsonStr());
} else {
action.execute(msgType, null);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
@Override
public void intreeuptPlan(String batchNo) {
}
}
package com.yeejoin.amos.fas.business.action;
import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.action.result.TipResult;
import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage;
import com.yeejoin.amos.fas.business.action.util.DataItemUtil;
import com.yeejoin.amos.fas.business.service.intfc.IMessageService;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
/**
*
* <pre>
* 消息提示动作
* </pre>
*
* @author amos
* @version $Id: SimpleTipAction.java, v 0.1 2019年4月24日 下午2:47:37 amos Exp $
*/
@Component
public class SimpleTipAction implements CustomerAction
{
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
@Autowired
private IMessageService messageService;
@Autowired
private WebMqttComponent webMqttComponent;
@Value("${auto-sys.push.type}")
private String pushType;
@Value("${spring.application.name}")
private String serviceName;
@Value("${station.name}")
private String stationName;
//@ExposeAction("消息提示")
public void sendMessageTip(Object bizobj, String title, String content, String type)
{
try
{
ELEvaluationContext.setVariable("bizobj",bizobj);
TipResult result = new TipResult();
result.add(bizobj);
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("title", title);
result.add(tempmap1);
Map<String, Object> tempmap2 = new HashMap<>();
content =DataItemUtil.getNative(content);
tempmap2.put("content", content);
result.add(tempmap2);
Constructor<?> constructor;
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
String msgType = "message";
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result);
String topic = String.format("/%s/%s/%s", serviceName, stationName,"rule");
webMqttComponent.publish(topic, toipResponse.toJsonStr());
} else {
action.execute(msgType, bizobj);
}
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void intreeuptPlan(String batchNo) {
}
// @SuppressWarnings("unchecked")
// private void saveMessageAction(AbstractActionResult abstractActionResult,String type)
// {
// Message message = new Message();
// List<Map<String, Object>> list = (List<Map<String, Object>>) abstractActionResult.getData();
// for(Map<String, Object> map : list) {
// for(String str: map.keySet()) {
// if(str.equals("content")) {
// message.setContent(map.get("content").toString());
// }else
// if (str.equals("title"))
// {
// message.setTitle(map.get("title").toString());
// }
// }
// if(!StringUtil.isNotEmpty(message.getContent())){
// continue;
// }
// if (abstractActionResult.getToipResponse().getBizObj() instanceof MessageRo) {
// MessageRo messageRo = (MessageRo)abstractActionResult.getToipResponse().getBizObj();
// message.setTime(messageRo.getDateTime());
// message.setBizId(messageRo.getId());
// }
// if (abstractActionResult.getToipResponse().getBizObj() instanceof RiskSourceRuleRo) {
// RiskSourceRuleRo riskSourceRuleRo = (RiskSourceRuleRo) abstractActionResult.getToipResponse().getBizObj();
// message.setTime(DateUtil.getNow());
// message.setBizId(StringUtil.isNotEmpty(riskSourceRuleRo.getId()) ?
// String.valueOf(riskSourceRuleRo.getId()) : "");
// }
// if (abstractActionResult.getToipResponse().getBizObj() instanceof ProtalDataRo) {
// ProtalDataRo protalDataRo = (ProtalDataRo) abstractActionResult.getToipResponse().getBizObj();
// message.setTime(DateUtil.getNow());
// message.setBizId(StringUtil.isNotEmpty(protalDataRo.getId()) ? String.valueOf(protalDataRo.getId()) : "");
// }
// if (abstractActionResult.getToipResponse().getBizObj() instanceof FireEquimentDataRo) {
// FireEquimentDataRo fireEquimentDataRo = (FireEquimentDataRo) abstractActionResult.getToipResponse().getBizObj();
// message.setTime(DateUtil.getNow());
// message.setBizId(StringUtil.isNotEmpty(fireEquimentDataRo.getId()) ? String.valueOf(fireEquimentDataRo.getId()) : "");
// }
// message.setBizclassName(abstractActionResult.getToipResponse().getBizObj().getClass().toString());
// message.setType(type);
// message.setId(UUID.randomUUID().toString());
// messageService.save(message);
// }
// }
}
package com.yeejoin.amos.fas.business.action.el;
import java.util.Map;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
public class ELEvaluationContext
{
private static EvaluationContext instance = new StandardEvaluationContext();
private static ExpressionParser parser = new SpelExpressionParser();
public static EvaluationContext getInstance()
{
return instance;
}
public static void setVariable(String name, Object value)
{
instance.setVariable(name, value);
}
public static void setVariable(Map<String, Object> vars)
{
for (Map.Entry<String, Object> entry : vars.entrySet())
{
instance.setVariable(entry.getKey(), entry.getValue());
}
}
public static Object getValue(String Expression){
return parser.parseExpression(Expression).getValue(instance);
}
}
package com.yeejoin.amos.fas.business.action.model;
import com.yeejoin.amos.fas.dao.entity.BusinessEntity;
import java.io.Serializable;
public class BasicsRo extends BusinessEntity implements Serializable {
private String batchNo;
public String getBatchNo() {
return batchNo;
}
public void setBatchNo(String batchNo) {
this.batchNo = batchNo;
}
}
package com.yeejoin.amos.fas.business.action.model;
import java.io.Serializable;
import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data;
/**
* @author DELL
*/
@RuleFact(value = "检查项",project = "风险管控")
@Data
public class CheckInputItemRo implements Serializable {
/**
* 检查项id
*/
private Long pointInputitemId;
/**
* 检查项状态
*/
private String status;
/**
* 检查项名称
*/
private String pointInputitemName;
/**
* 检查项检查id
*/
private Long checkInputitemId;
}
package com.yeejoin.amos.fas.business.action.model;
import org.springframework.context.ApplicationEvent;
import lombok.Data;
@Data
public class ContingencyEvent extends ApplicationEvent{
public ContingencyEvent(Object source) {
super(source);
}
/**
*
*/
private static final long serialVersionUID = -5239150129698935970L;
private String topic;
private String msgType;
private String msgBody;
private Object contingency;
}
package com.yeejoin.amos.fas.business.action.model;
import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
@RuleFact(value = "动态预案",project = "换流站消防专项预案")
@Data
public class ContingencyRo implements Serializable {
@Label("批次号")
private String batchNo;
/**
*
*/
private static final long serialVersionUID = -6721135143373410586L;
@Label("消防设备名称")
private String fireEquipmentName;//消防设备名称
@Label("消防设备id")
private String fireEquipmentId;//消防设备id
private Integer layer=0;//显示图层
//当前探测器
@Label("当前探测器图层")
private Integer fireEquipmentLayer=0;//当前探测器图层
@Label("消防设备位置")
private String fireEquipmentPosition;//消防设备位置
//重点设备信息
//负责人名称,手机号
@Label("重点设备id")
private String equipmentId;//重点设备id
@Label("重点设备组织编码")
private String equipmentOrgCode="10";//重点设备组织编码
@Label("重点设备名称")
private String equipmentName;
@Label("重点设备坐标")
private String equipmentPosition3d;
@Label("负责人手机号")
private String mobile; //负责人手机号
@Label("负责人名称")
private String adminName;//负责人名称
//摄像头
@Label("摄像头编号")
private String cameraCodes;//摄像头编号
@Label("摄像头id")
private String cameraIds;//摄像头id
@Label("火情数量")
private Integer fireCount = 1; //火情数量
@Label("操作状态")
private String confirm = "NONE";//是否确认火情,确认 CONFIRM,取消CANCEL,未操作 NONE
private String picture1;
private String picture2;
private String picture3;
private String picture4;
@Label("路线")
private String fireTruckRoute;
@Label("是否已执行到下一步")
private Boolean runstep; //是否已经执行流程
// @Label("步骤")
@Label("预案步骤")
private String step;//当前步骤
@Label("按钮编码")
private String buttonCode;
private String buttonState;
@Label("步骤状态")
private String stepState;//步骤操作状态
@Label("重点设备编码")
private String equipmentCode;
private Date createDate = new Date();
@Label("遥测数据")
private Map<String, Double> telemetryMap;
@Label("遥信数据")
private Map<String, Integer> telesignallingMap;
//消防炮
@Label("消防炮编号")
private String fireMonitorCodes;
@Label("消防炮id")
private String fireMonitorIds;
}
package com.yeejoin.amos.fas.business.action.model;
import java.io.Serializable;
import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data;
@RuleFact(value = "设备数据",project = "换流站消防专项预案")
@Data
public class DeviceRo implements Serializable{
/**
*
*/
private static final long serialVersionUID = 299646964348882067L;
@Label("点编码")
private String pointCode;
@Label("值")
private String value;
@Label("重点装备ID")
private Long equipmentId;
}
package com.yeejoin.amos.fas.business.action.model;
import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data;
import java.security.acl.LastOwnerException;
@RuleFact(value = "消防设备",project = "风险管控")
@Data
public class FireEquimentDataRo extends BasicsRo
{
/**
*
*/
private static final long serialVersionUID = 5243181171363622140L;
private Long fireEquimentId;
private String fireEqumentName;
@Label("设备id")
private Long id;//监测点id
private String name;//名称
private String unit;//单位
private String value;//值 0 / 1
private String dataType;//值类型
/**
* 设备编号
*/
@Label("设备编码")
private String code;
/**
* 监测对象 名称
*/
@Label("监测对象")
private String monitor;
private String equimentId;
/**
* 状态
*/
@Label("设备状态")
private String nodeState;
private String alarmType;
@Label("当前时间")
private String currTime;
}
\ No newline at end of file
package com.yeejoin.amos.fas.business.action.model;
import java.util.List;
import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data;
@RuleFact(value = "巡检点",project = "风险管控")
@Data
public class ProtalDataRo extends BasicsRo {
private static final long serialVersionUID = -1029442967802232959L;
@Label("巡检点id")
private Long id;//巡检点id
@Label("巡检点名称")
private String name; //名称
@Label("状态")
private String nodeState;//实时状态
@Label("上一次状态")
private String originalNodeState;//记录状态状态
private String level;//巡检点级别
/**
* 巡检点编号
*/
@Label("巡检点编号")
private String pointNo;
/**
* 责任人
*/
@Label("责任人")
private String userName;
/**
* 巡检人员
*/
private String checkUser;
/**
* 任务编号,如果无任务,则填充0
*/
@Label("任务id")
private Long taskId= 0L;
/**
* 任务状态
*/
@Label("任务状态")
private Integer taskState;
/**
* 上一次任务状态
*/
@Label("上一次任务状态")
private String originalTaskState;
private String taskName;//任务名称
private String content;//内容
private String pointName;//巡检点名称
@Label("当前时间")
private String currTime;//当前时间
private List<CheckInputItemRo> items;
private List<CheckInputItemRo> pointInputitems;
}
\ No newline at end of file
package com.yeejoin.amos.fas.business.action.model;
import java.math.BigDecimal;
import java.util.List;
import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data;
@RuleFact(value = "风险点",project = "风险管控")
@Data
public class RiskSourceRo extends BasicsRo {
private static final long serialVersionUID = 1L;
@Label("风险点id")
private String id;
/**
* 风险点名称
*/
private String name;
/**
* 风险点编号
*/
@Label("风险点编号")
private String code;
/**
* 风险点来源(ProtalDataRo、FireEquimentDataRo、child)
*/
@Label("风险点来源")
private String from;
/**
* 状态
*/
@Label("风险源状态(巡检点/设备)")
private String nodeState;//风险源状态
/**
* 上一次状态
*/
private String originalNodeState;
/**
* 风险点级别
*/
@Label("级别")
private Integer riskLevel;
/**
* RPNr值
*/
@Label("rpn")
private BigDecimal rpn;
/**
* RPNi值
*/
@Label("rpni")
private BigDecimal rpni;
/**
* 风险因素,多条换行
*/
@Label("风险因素")
private String riskFactor;
/**
* 是否区域节点
*/
@Label("是否区域节点")
private String isRegion;
@Label("区域下已触发风险点最高级别")
private Integer regionMaxLevel;
/**
* 计算RPNi值,保存所有风险因素得i值,key统一为:rpni
*/
@Label("RPNiSum")
private List<BigDecimal> RPNiSum;
/**
* 计算RPNr值
*/
@Label("风险点状态")
private String riskState;//风险点状态
private BigDecimal rg;
/**
* up、down、no
*/
@Label("等级变化类型")
private String levelChangeType;
}
package com.yeejoin.amos.fas.business.action.model;
import java.math.BigDecimal;
import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data;
@RuleFact(value = "风险点-关联巡检点",project = "风险管控")
@Data
public class RiskSourceRuleRo extends BasicsRo {
private static final long serialVersionUID = -1029442967802232957L;
/**
* patrol、equipment、update、delete
*/
@Label("触发来源")
private String type;
@Label("序号")
private Long id;
@Label("rpnr")
private BigDecimal rpnr;
@Label("rpni")
private BigDecimal rpni;
/**
* 风险增益
*/
@Label("风险增益")
private String rg;
/**
* up、down、no
*/
@Label("等级变更类型")
private String levelChangeType;
/**
* 消息内容
*/
@Label("消息内容")
private String content;
/**
* 消息标题
*/
@Label("消息标题")
private String title;
}
package com.yeejoin.amos.fas.business.action.model;
public enum SetpEnum {
STEP0("0", "确认火灾", 0),
STEP1("1", "停运换流阀、拨打报警电话", 1),
STEP2("2", "开启水喷雾系统", 2),
STEP3("3", "断开上级电源", 3),
STEP4("4", "开启油枕排油系统", 4),
STEP5("5", "消防炮“一键启动”", 5),
// STEP6("6", "消防供水", 6),
STEP7("7", "阀厅防护", 7),
STEP8("8", "本体排油", 8),
STEP9("9", "停运空调和水冷系统", 9),
STEP10("10", "驻站消防指挥权准备交接", 10),
STEP11("11", "驻站消防指挥权交接", 11),
STEP12("12", "电缆沟封堵", 12),
STEP13("13", "灭火指挥权交接", 13),
STEP14("14", "应急处置结束", 14);
private String stepCode;
private String stepName;
private int order;
SetpEnum(String stepCode, String stepName, int order) {
this.stepCode = stepCode;
this.stepName = stepName;
this.order = order;
}
public String getValue() {
return stepCode;
}
public String getTitle() {
return stepName;
}
public int getOrder() {
return order;
}
public static SetpEnum getStepByCode(String stepCode) {
for (SetpEnum setp : SetpEnum.values()) {
if (setp.stepCode.equals(stepCode)) {
return setp;
}
}
return null;
}
}
package com.yeejoin.amos.fas.business.action.mq;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttPersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;
@Component
public class WebMqttComponent {
@Autowired
private EmqKeeper emqKeeper;
public void publish(String topic, String jsonStr) {
try {
this.emqKeeper.getMqttClient().publish(topic, jsonStr.getBytes(), 2, false);
} catch (MqttPersistenceException e) {
e.printStackTrace();
} catch (MqttException e) {
e.printStackTrace();
}
}
}
package com.yeejoin.amos.fas.business.action.mq;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentHandlerService;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
/**
* @author keyong
* @title: WebMqttSubscribe
* <pre>
* @description: Mqtt订阅消息类
* </pre>
* @date 2020/11/9 17:50
*/
@Configuration
@IntegrationComponentScan
public class WebMqttSubscribe {
@Value("${emqx.user-name}")
private String userName;
@Value("${emqx.password}")
private String password;
@Value("${emqx.broker}")
private String hostUrl;
@Value("${emqx.client-id}")
private String clientId;
@Value("${emqx.defaultTopic}")
private String defaultTopic;
public MqttPahoMessageDrivenChannelAdapter adapter;
@Autowired @Lazy
IEquipmentHandlerService equipmentHandlerService;
@Bean
public MqttConnectOptions getMqttConnectOptions() {
MqttConnectOptions mqttConnectOptions = new MqttConnectOptions();
mqttConnectOptions.setUserName(userName);
mqttConnectOptions.setPassword(password.toCharArray());
mqttConnectOptions.setServerURIs(new String[]{hostUrl});
mqttConnectOptions.setKeepAliveInterval(2);
mqttConnectOptions.setAutomaticReconnect(true);
return mqttConnectOptions;
}
@Bean
public MqttPahoClientFactory mqttPahoClientFactory() {
DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
factory.setConnectionOptions(getMqttConnectOptions());
return factory;
}
@Bean
public MessageChannel mqttInputChannel() {
return new DirectChannel();
}
@Bean
public MessageProducer inbound() {
adapter = new MqttPahoMessageDrivenChannelAdapter(clientId, mqttPahoClientFactory(), defaultTopic);
adapter.setConverter(new DefaultPahoMessageConverter());
adapter.setQos(0);
adapter.setOutputChannel(mqttInputChannel());
return adapter;
}
@Bean
@ServiceActivator(inputChannel = "mqttInputChannel")
public MessageHandler handler() {
return new MessageHandler() {
@Override
public void handleMessage(Message<?> message) {
String topic = message.getHeaders().get("mqtt_receivedTopic").toString();
String msg = message.getPayload().toString();
// 订阅之后的处理逻辑
equipmentHandlerService.handlerMqttMessage(topic, msg);
}
};
}
}
package com.yeejoin.amos.fas.business.action.result;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.dao.entity.BusinessEntity;
public abstract class AbstractActionResult implements ActionResult{
public ToipResponse toipResponse;
/**
* 智能体业务对象
*/
private BusinessEntity bizObj;
public ToipResponse getToipResponse() {
return toipResponse;
}
public void setToipResponse(ToipResponse toipResponse) {
this.toipResponse = toipResponse;
}
public BusinessEntity getBizObj() {
return bizObj;
}
public void setBizObj(BusinessEntity bizObj) {
this.bizObj = bizObj;
}
}
package com.yeejoin.amos.fas.business.action.result;
import java.util.List;
import com.alibaba.fastjson.JSON;
public interface ActionResult
{
public JSON toJson();
public void addAll(List<Object> data);
public void add(Object data);
public List<?> getData();
}
package com.yeejoin.amos.fas.business.action.result;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
public class BubbleTipResult extends SimpleResult{
@Override
public JSON toJson() {
// TODO Auto-generated method stub
Map<String, Object> results = new HashMap<>();
for (Map<String, Object> tempMap : data)
{
for (Map.Entry<String, Object> entry : tempMap.entrySet())
{
results.put(entry.getKey(), entry.getValue());
}
}
return (JSON) JSON.toJSON(results);
}
}
package com.yeejoin.amos.fas.business.action.result;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
public class RiskSituationResult extends SimpleResult{
@Override
public JSON toJson() {
// TODO Auto-generated method stub
Map<String, Object> results = new HashMap<>();
for (Map<String, Object> tempMap : data)
{
for (Map.Entry<String, Object> entry : tempMap.entrySet())
{
results.put(entry.getKey(), entry.getValue());
}
}
return (JSON) JSON.toJSON(results);
}
}
package com.yeejoin.amos.fas.business.action.result;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
public class SafteyPlanResult implements ActionResult{
Map<String, Object> data = new HashMap<>();
@Override
public JSON toJson() {
return (JSON) JSON.toJSON(data);
}
@Override
public void addAll(List<Object> data) {
}
@Override
public void add(Object data) {
this.data.putAll((Map)data);
}
@Override
public List<?> getData() {
return null;
}
}
package com.yeejoin.amos.fas.business.action.result;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.fas.business.util.JSONUtil;
public class SimpleResult extends AbstractActionResult implements ActionResult
{
List<Map<String, Object>> data = new ArrayList<>();
@Override
public JSON toJson()
{
List<Map<String, Object>> results = new ArrayList<>();
for (Map<String, Object> tempMap : data)
{
for (Map.Entry<String, Object> entry : tempMap.entrySet())
{
Map<String,Object> result = new HashMap<>();
result.put("label", entry.getKey());
result.put("value", entry.getValue());
results.add(result);
}
}
return (JSON) JSON.toJSON(results);
}
@Override
public void addAll(List<Object> datas)
{
for (Object o : datas) {
this.data.add(JSONUtil.toMap(JSONUtil.toJson(o)));
}
}
@Override
public void add(Object data)
{
this.data.add(JSONUtil.toMap(JSONUtil.toJson(data)));
}
public void add(String key,Object value)
{
Map<String, Object> map = new HashMap<>();
map.put(key, value);
this.data.add(map);
}
@Override
public List<Map<String, Object>> getData() {
// TODO Auto-generated method stub
return data;
}
}
package com.yeejoin.amos.fas.business.action.result;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
public class TipResult extends SimpleResult{
@Override
public JSON toJson() {
// TODO Auto-generated method stub
Map<String, Object> results = new HashMap<>();
for (Map<String, Object> tempMap : data)
{
for (Map.Entry<String, Object> entry : tempMap.entrySet())
{
results.put(entry.getKey(), entry.getValue());
}
}
return (JSON) JSON.toJSON(results);
}
}
package com.yeejoin.amos.fas.business.action.result.message;
import java.io.IOException;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.fas.business.action.result.AbstractActionResult;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.action.websocket.RuleWebSocket;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.business.util.Constants;
import com.yeejoin.amos.fas.core.util.CommonResponse;
public abstract class AbstractActionResultMessage<R extends ToipResponse>
implements ActionResultMessage<ToipResponse>
{
protected ActionResult actionResult;
@Override
public ToipResponse execute(String msgType,
Object contingency) throws IOException, Exception
{
ToipResponse response = buildResponse(msgType, contingency,
actionResult);
if (!actionResult.getData().isEmpty())
{
sendResponse(response);
}
return response;
}
protected abstract Object getActionResultByDataFormat();
/**
*
* <pre>
* 构建对象
* </pre>
*
* @param viewTemp
* @param obj
* @return
*/
public ToipResponse buildResponse(String msgType, Object contingency, ActionResult msgContext)
{
ToipResponse toipResponse = new ToipResponse();
toipResponse.setMsgType(msgType);
toipResponse.setMsgContext(msgContext);
toipResponse.setContingency(contingency);
return toipResponse;
}
public ToipResponse buildResponse(String msgType, Object contingency, JSON msgContext)
{
ToipResponse toipResponse = new ToipResponse();
toipResponse.setMsgType(msgType);
toipResponse.setMsgContext(msgContext);
toipResponse.setContingency(contingency);
return toipResponse;
}
/**
*
* <pre>
* 发送数据
* </pre>
*
* @param response
* @throws IOException
* @throws Exception
*/
protected void sendResponse(ToipResponse response)
throws IOException, Exception
{
RuleWebSocket.sendInfo(response.toJsonStr());
System.out.println("数据发送成功>>>>>>>>" + response.toJsonStr());
}
}
package com.yeejoin.amos.fas.business.action.result.message;
import java.io.IOException;
public interface ActionResultMessage<T> {
/**
*
* <pre>
*
* </pre>
*
* @param firstStr 一级界面域
* @param secondStr 二级界面域
* @param thirdStr 三级界面域
* @return
* @throws IOException
* @throws Exception
*/
T execute(String msgType, Object contingency) throws IOException, Exception ;
}
package com.yeejoin.amos.fas.business.action.result.message;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
/**
*
* <pre>
* 气泡消息提示
* </pre>
*
* @author amos
* @version $Id: BubbleTipResultMessage.java, v 0.1 2019年5月16日 下午1:52:36 amos Exp $
*/
public class BubbleTipResultMessage extends SimpleResultMessage{
public BubbleTipResultMessage(ActionResult actionResult) {
super(actionResult);
// TODO Auto-generated constructor stub
}
}
package com.yeejoin.amos.fas.business.action.result.message;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
/**
*
* <pre>
* 气泡消息提示
* </pre>
*
* @author amos
* @version $Id: BubbleTipResultMessage.java, v 0.1 2019年5月16日 下午1:52:36 amos Exp $
*/
public class RiskSituationResultMessage extends SimpleResultMessage{
public RiskSituationResultMessage(ActionResult actionResult) {
super(actionResult);
// TODO Auto-generated constructor stub
}
}
package com.yeejoin.amos.fas.business.action.result.message;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
public class SafteyPlanResultMessage extends AbstractActionResultMessage<ToipResponse>{
public SafteyPlanResultMessage(ActionResult actionResult) {
this.actionResult = actionResult;
}
@Override
protected Object getActionResultByDataFormat() {
return actionResult.toJson();
}
}
package com.yeejoin.amos.fas.business.action.result.message;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
/**
*
* <pre>
* 简单文本输入
* </pre>
*
* @author amos
* @version $Id: SimpleResultMessage.java, v 0.1 2019年4月25日 下午1:57:33 amos Exp $
*/
public class SimpleResultMessage extends AbstractActionResultMessage<ToipResponse>
{
public SimpleResultMessage(ActionResult actionResult) {
this.actionResult = actionResult;
}
@Override
protected Object getActionResultByDataFormat() {
return actionResult.toJson();
}
}
package com.yeejoin.amos.fas.business.action.result.message;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
/**
*
* <pre>
* 消息提示
* </pre>
*
* @author amos
* @version $Id: TipResultMessage.java, v 0.1 2019年4月25日 上午11:47:13 amos Exp $
*/
public class TipResultMessage extends SimpleResultMessage{
public TipResultMessage(ActionResult actionResult) {
super(actionResult);
// TODO Auto-generated constructor stub
}
}
package com.yeejoin.amos.fas.business.action.util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
@Component
public class ContingencyLogPublisher {
@Autowired
//注入ApplicationContext用来发布事件
ApplicationContext applicationContext;
//使用ApplicationContext的publishEvent方法来发布
public void publish(ContingencyEvent msg){
applicationContext.publishEvent(msg);
}
}
package com.yeejoin.amos.fas.business.action.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext;
public class DataItemUtil
{
public static boolean getEnable(JSONObject jsonObject)
{
try
{
return jsonObject.getBooleanValue("enable");
}
catch (Exception e)
{
return false;
}
}
public static String getDisplayName(JSONObject jsonObject)
{
try
{
return jsonObject.get("displayname").toString();
}
catch (Exception e)
{
return null;
}
}
public static String getValue(JSONObject jsonObject)
{
try
{
return jsonObject.get("value").toString();
}
catch (Exception e)
{
return null;
}
}
public static String getName(JSONObject jsonObject)
{
try
{
return jsonObject.get("name").toString();
}
catch (Exception e)
{
return null;
}
}
public static String getNative(String str)
{
Pattern p = Pattern.compile("\\{(.*?)\\}");
Matcher m = p.matcher(str);
while (m.find())
{
String parameter = m.group();
Object parametervalue = ELEvaluationContext
.getValue(parameter.substring(1, parameter.length() - 1));
if(parametervalue != null)
str = str.replace(parameter,
parametervalue != null ? parametervalue.toString() : null);
}
return str;
}
}
package com.yeejoin.amos.fas.business.action.util;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* <pre>
* 反射工具类
* </pre>
*
* @author HK
* @version $Id: ReflectUtil.java, v 0.1 2017年12月25日 下午8:05:45 HK Exp $
*/
public class ReflectUtil
{
private final static Logger logger = LoggerFactory
.getLogger(ReflectUtil.class);
/**
*
* <pre>
* 设置属性值
* </pre>
*
* @param target
* 目标对象
* @param fname
* 字段名称
* @param ftype
* 字典类型
* @param fvalue
* 字段值
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void setFieldValue(Object target, String fname, Class ftype,
Object fvalue)
{ // 设置字段值 如:username 字段,setUsername(String username)
if (target == null || fname == null || "".equals(fname)
|| (fvalue != null
&& !ftype.isAssignableFrom(fvalue.getClass())))
{// 如果类型不匹配,直接退出
return;
}
Class clazz = target.getClass();
try
{ // 先通过setXxx()方法设置类属性值
String methodname = "set" + Character.toUpperCase(fname.charAt(0))
+ fname.substring(1);
// System.out.println(methodname);
Method method = clazz.getDeclaredMethod(methodname, ftype); // 获取定义的方法
if (!Modifier.isPublic(method.getModifiers()))
{ // 设置非共有方法权限
method.setAccessible(true);
}
method.invoke(target, fvalue); // 执行方法回调
}
catch (Exception me)
{// 如果set方法不存在,则直接设置类属性值
try
{
Field field = clazz.getDeclaredField(fname); // 获取定义的类属性
if (!Modifier.isPublic(field.getModifiers()))
{ // 设置非共有类属性权限
field.setAccessible(true);
}
field.set(target, fvalue); // 设置类属性值
}
catch (Exception fe)
{
if (logger.isDebugEnabled())
{
logger.debug(fe.getMessage());
}
}
}
}
/**
*
* <pre>
* 获取属性值
* </pre>
*
* @param target
* 目标对象
* @param fname
* 字段名称
* @param ftype
* 字段类型
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Object getFieldValue(Object target, String fname, Class ftype)
{// 获取字段值 如:username 字段,getUsername()
if (target == null || fname == null || "".equals(fname))
{
return null;
}
Class clazz = target.getClass();
try
{ // 先通过getXxx()方法获取类属性值
String methodname = "get" + Character.toUpperCase(fname.charAt(0))
+ fname.substring(1);
// System.out.println(methodname);
Method method = clazz.getDeclaredMethod(methodname); // 获取定义的方法
if (!Modifier.isPublic(method.getModifiers()))
{ // 设置非共有方法权限
method.setAccessible(true);
}
return method.invoke(target); // 方法回调,返回值
}
catch (Exception me)
{// 如果get方法不存在,则直接获取类属性值
if (logger.isDebugEnabled())
{
logger.debug(me.getMessage());
}
try
{
Field field = clazz.getDeclaredField(fname); // 获取定义的类属性
if (!Modifier.isPublic(field.getModifiers()))
{ // 设置非共有类属性权限
field.setAccessible(true);
}
return field.get(target);// 返回类属性值
}
catch (Exception fe)
{
if (logger.isDebugEnabled())
{
logger.debug(fe.getMessage());
}
}
}
return null;
}
public static <E> E newInstance(final Class<? extends E> clazz)
{
try
{
return clazz.newInstance();
}
catch (final Exception e)
{
logger.warn("Could not instantiate {}: {}", clazz, e);
if (e instanceof RuntimeException)
{
throw (RuntimeException) e;
}
throw new IllegalStateException(e);
}
}
public static <A extends Annotation> A getAnnotation(
final Enum<?> enumConstant, final Class<A> annotationClass)
{
try
{
final Field field = enumConstant.getClass()
.getDeclaredField(enumConstant.name());
return getAnnotation(field, annotationClass);
}
catch (final Exception e)
{
throw new IllegalStateException(e);
}
}
public static <A extends Annotation> A getAnnotation(
final AnnotatedElement element, final Class<A> annotationClass)
{
final A annotation = element.getAnnotation(annotationClass);
if (annotation == null && element instanceof Method)
{
// check for annotations on overridden methods. Since Java 8
// those are not returned by .getAnnotation(...)
final Method m = (Method) element;
final Class<?> declaringClass = m.getDeclaringClass();
final Class<?> superClass = declaringClass.getSuperclass();
final String methodName = m.getName();
final Class<?>[] methodParameterTypes = m.getParameterTypes();
if (superClass != null)
{
try
{
final Method overriddenMethod = superClass
.getMethod(methodName, methodParameterTypes);
return getAnnotation(overriddenMethod, annotationClass);
}
catch (final NoSuchMethodException e)
{
logger.debug("Failed to get overridden method '{}' from {}",
methodName, superClass);
}
}
// check for annotations on interface methods too.
final Class<?>[] interfaces = declaringClass.getInterfaces();
for (final Class<?> interfaceClass : interfaces)
{
try
{
final Method overriddenMethod = interfaceClass
.getMethod(methodName, methodParameterTypes);
return getAnnotation(overriddenMethod, annotationClass);
}
catch (final NoSuchMethodException e)
{
logger.debug("Failed to get overridden method '{}' from {}",
methodName, interfaceClass);
}
}
}
if(annotation == null && element instanceof Class<?>){
final Class<?> clazz = (Class<?>) element;
// final Class<?> declaringClass = clazz.getDeclaringClass();
final Class<?> superClass = clazz.getSuperclass();
if (superClass != null)
{
return getAnnotation(superClass, annotationClass);
}
}
return annotation;
}
public static boolean isAnnotationPresent(final Enum<?> enumConstant,
final Class<? extends Annotation> annotationClass)
{
try
{
final Field field = enumConstant.getClass()
.getDeclaredField(enumConstant.name());
return isAnnotationPresent(field, annotationClass);
}
catch (final Exception e)
{
throw new IllegalStateException(e);
}
}
public static boolean isAnnotationPresent(final AnnotatedElement element,
final Class<? extends Annotation> annotationClass)
{
return getAnnotation(element, annotationClass) != null;
}
public static Field[] getAllFields(String clazzName,
final Class<? extends Annotation> withAnnotation) throws ClassNotFoundException
{
final List<Field> result = new ArrayList<>();
final Field[] fields = getAllFields(Class.forName(clazzName));
for (final Field field : fields)
{
if (isAnnotationPresent(field, withAnnotation))
{
result.add(field);
}
}
return result.toArray(new Field[result.size()]);
}
public static Field[] getAllFields(final Class<?> clazz,
final Class<? extends Annotation> withAnnotation)
{
final List<Field> result = new ArrayList<>();
final Field[] fields = getAllFields(clazz);
for (final Field field : fields)
{
if (isAnnotationPresent(field, withAnnotation))
{
result.add(field);
}
}
return result.toArray(new Field[result.size()]);
}
public static Field[] getAllFields(final Class<?> clazz)
{
final List<Field> allFields = new ArrayList<>();
addFields(allFields, clazz);
return allFields.toArray(new Field[allFields.size()]);
}
private static void addFields(final List<Field> allFields,
final Class<?> clazz)
{
addFields(allFields, clazz, false);
}
private static void addFields(final List<Field> allFields,
final Class<?> clazz, final boolean excludeSynthetic)
{
if (clazz == Object.class)
{
return;
}
final Field[] f = clazz.getDeclaredFields();
for (final Field field : f)
{
if (excludeSynthetic && field.isSynthetic())
{
continue;
}
allFields.add(field);
}
final Class<?> superclass = clazz.getSuperclass();
addFields(allFields, superclass, excludeSynthetic);
}
public static Method[] getMethods(final Class<?> clazz, final Class<? extends Annotation> withAnnotation) {
final List<Method> result = new ArrayList<>();
final Method[] methods = getMethods(clazz);
for (final Method method : methods) {
if (isAnnotationPresent(method, withAnnotation)) {
result.add(method);
}
}
return result.toArray(new Method[result.size()]);
}
public static Method[] getMethods(final Class<?> clazz) {
final List<Method> allMethods = new ArrayList<>();
addMethods(allMethods, clazz);
return allMethods.toArray(new Method[allMethods.size()]);
}
private static void addMethods(final List<Method> allMethods, final Class<?> clazz) {
if (clazz == Object.class || clazz == null) {
return;
}
final Method[] methods = clazz.getMethods();
for (final Method method : methods) {
final Class<?> declaringClass = method.getDeclaringClass();
if (declaringClass != Object.class) {
allMethods.add(method);
}
}
}
}
package com.yeejoin.amos.fas.business.action.websocket;
import java.io.IOException;
import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
*
* <pre>
* rule webSocket定义
* </pre>
*
* @author amos
* @version $Id: RuleWebSocket.java, v 0.1 2019年5月20日 下午4:59:50 amos Exp $
*/
@Component
@ServerEndpoint(value = "/rule.ws")
public class RuleWebSocket implements Observer
{
private final static Logger log = LoggerFactory.getLogger(RuleWebSocket.class);
// 静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
private static int onlineCount = 0;
// concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
private static CopyOnWriteArraySet<RuleWebSocket> webSocketSet = new CopyOnWriteArraySet<RuleWebSocket>();
// 与某个客户端的连接会话,需要通过它来给客户端发送数据
private Session session;
private Observable ob;
private String name;
/**
* 连接建立成功调用的方法
*/
@OnOpen
public void onOpen(Session session)
{
this.session = session;
webSocketSet.add(this); // 加入set中
addOnlineCount(); // 在线数加1
log.debug("有新连接加入!当前在线人数为" + getOnlineCount());
subscribeTopics(session);
}
/**
*
* <pre>
* 订阅指挥
* </pre>
*
*/
public void subscribeTopics(Session session)
{
// this.ob = GlobalDispatch.getInstance();
// GlobalDispatch.getInstance().addObserver(this);
log.info("成功加入规则主题");
}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose()
{
webSocketSet.remove(this); // 从set中删除
subOnlineCount(); // 在线数减1
log.debug("有一连接关闭!当前在线人数为" + getOnlineCount());
if (ob != null)
{
ob.deleteObserver(this);
}
}
/**
* 收到客户端消息后调用的方法
*
* @param message
* 客户端发送过来的消息
*/
@OnMessage
public void onMessage(String message, Session session)
{
log.info("来自客户端的消息:" + message);
}
@OnError
public void onError(Session session, Throwable error)
{
log.error("发生错误", error);
}
public void sendMessage(String message) throws IOException
{
this.session.getBasicRemote().sendText(message);
// this.session.getAsyncRemote().sendText(message);
}
/**
* 群发自定义消息
*/
public static void sendInfo(String message) throws IOException
{
log.debug("——----RuleWebSocket开始群发消息------");
log.debug("消息内容为:" + message);
for (RuleWebSocket item : webSocketSet)
{
try
{
item.sendMessage(message);
}
catch (IOException e)
{
log.error(item.session.getId() + "消息发送失败", e);
continue;
}
}
log.debug("——----RuleWebSocket结束群发消息------");
}
public static synchronized int getOnlineCount()
{
return onlineCount;
}
public static synchronized void addOnlineCount()
{
RuleWebSocket.onlineCount++;
}
public static synchronized void subOnlineCount()
{
RuleWebSocket.onlineCount--;
}
@Override
public void update(Observable o, Object arg)
{
try
{
if (session.isOpen())
{
sendMessage(arg.toString());
log.debug("session" + name + "消息发送成功");
}
else
{
o.deleteObserver(this);
log.debug("session" + name + "消息发送失败:" + "session已经失去连接");
}
}
catch (Exception e)
{
log.error("session" + name + "消息发送失败:" + e.getMessage());
}
}
}
package com.yeejoin.amos.fas.business.action.websocket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}
package com.yeejoin.amos.fas.business.bo;
import com.alibaba.fastjson.JSONArray;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @author suhg
*/
@ApiModel(description = "坐标实体(ue4及非ue4)")
public class BasePointPositionBo {
/**
* ue4点坐标
*/
@ApiModelProperty("ue4坐标")
private String ue4Location;
/**
* ue4旋转
*/
@ApiModelProperty("ue4旋转")
private String ue4Rotation;
@ApiModelProperty("ue4缩放")
private String ue4Extent;
/**
* 平台3维模型坐标
*/
@ApiModelProperty("3d点坐标,非ue4用")
private String position3d;
@ApiModelProperty("区域坐标,非ue4用")
private String routePath;
public String getUe4Location() {
return ue4Location;
}
public void setUe4Location(JSONArray ue4Location) {
this.ue4Location = ue4Location.toString();
}
public String getUe4Rotation() {
return ue4Rotation;
}
public void setUe4Rotation(JSONArray ue4Rotation) {
this.ue4Rotation = ue4Rotation.toString();
}
public String getUe4Extent() {
return ue4Extent;
}
public void setUe4Extent(JSONArray ue4Extent) {
this.ue4Extent = ue4Extent.toString();
}
public String getPosition3d() {
return position3d;
}
public void setPosition3d(String position3d) {
this.position3d = position3d;
}
/**
* @return the routePath
*/
public String getRoutePath() {
return routePath;
}
/**
* @param routePath the routePath to set
*/
public void setRoutePath(String routePath) {
this.routePath = routePath;
}
}
package com.yeejoin.amos.fas.business.bo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
/**
* @author suhg
*/
@ApiModel(description = "绑定点参数实体")
public class BindPointBo extends BasePointPositionBo{
/**
* 点id
*/
@NotNull
@ApiModelProperty("巡检点id")
private Long pointId;
/**
* 点类型枚举
*/
@NotNull
@ApiModelProperty("点类型")
private String pointType;
public Long getPointId() {
return pointId;
}
public void setPointId(Long pointId) {
this.pointId = pointId;
}
public String getPointType() {
return pointType;
}
public void setPointType(String pointType) {
this.pointType = pointType;
}
}
package com.yeejoin.amos.fas.business.bo;
import javax.validation.constraints.NotNull;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel(description = "绑定区域参数实体")
public class BindRegionBo extends BasePointPositionBo{
/**
* 区域id
*/
@NotNull
@ApiModelProperty("区域id")
private Long riskSourceId;
public Long getRiskSourceId() {
return riskSourceId;
}
public void setRiskSourceId(Long riskSourceId) {
this.riskSourceId = riskSourceId;
}
}
package com.yeejoin.amos.fas.business.bo;
/**
* @author suhg
*/
public class CheckErrorBo {
private String status;
private String changeDate;
private Long id;
private String name;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getChangeDate() {
return changeDate;
}
public void setChangeDate(String changeDate) {
this.changeDate = changeDate;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.yeejoin.amos.fas.business.bo;
import lombok.Data;
/**
* @author keyong
* @title: DangerResultBo
* <pre>
* @description: TODO
* </pre>
* @date 2021/2/1 20:19
*/
@Data
public class DangerResultBo {
private int state;
private String orgCode;
private String userName;
private Long inputItemId;
}
package com.yeejoin.amos.fas.business.bo;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* The persistent class for the fire_equipment database table.
*
*/
@Data
public class FireEquipmentBo {
private static final long serialVersionUID = 1L;
/**
* id
*/
private long id;
private Date createDate;
private String brand;
private String code;
/**
* 3维坐标
*/
private String position3d;
/**
* 3维楼层
*/
private String floor3d;
/**
* 是否室内 0-否 1-是
*/
private Boolean isIndoor;
private String createBy;
private Date effectiveDate;
private int maintenanceCycle;
/**
* 装备分类:0-设备类;1-耗材类
*/
private int equipClassify;
private String manufacturer;
private String model;
private String name;
private int number;
private String orgCode;
private String productionArea;
private Date productionDate;
private String remark;
private String room;
/**
* 装备编码
*/
private String equipCode;
/**
* 装备类型
*/
private String equipType;
/**
* 监测设备状态
*/
private Integer equipStatus;
private String unit;
private String protectObjNames;
/**
* 重量
*/
private BigDecimal weight;
/**
* 动作状态
*/
private String actionState;
/**
* 喷发状态
*/
private String eruptionState;
/**
* 所属风险区域id
*/
private Long riskSourceId;
/**
* ue4位置
*/
private String ue4Location;
/**
* ue4旋转
*/
private String ue4Rotation;
}
\ No newline at end of file
package com.yeejoin.amos.fas.business.bo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(description = "消防整改 消防要求实体类")
public class FireInfoBo {
/**
* 风险类型
*/
private String type;
/**
* 实际完成数量
*/
private int realNum;
/**
* 阈值
*/
private int threshold;
public FireInfoBo(int realNum, int threshold) {
this.realNum = realNum;
this.threshold = threshold;
}
public FireInfoBo() {
}
}
package com.yeejoin.amos.fas.business.bo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(description = "消防整改 整改数据实体")
public class FireMoreDataBo {
/**
* req 主键
*/
private String req;
/**
* 类型或登记
*/
private String lvl;
/**
* 设备名称
*/
private String name;
/**
* 描述
*/
private String persent;
/**
* 影响
*/
private String affect;
/**
* 处理结果
*/
private String doneResult;
/**
* 反馈
*/
private String backResult;
/**
* 反馈
*/
private String filePath;
}
package com.yeejoin.amos.fas.business.bo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(description = "消防整改 单据修改实体类")
public class FireParamBo {
private List<FireMoreDataBo> warnningData;
private List<FireMoreDataBo> hiddenData;
private List<FireMoreDataBo> dangerData;
private String backResult;
private String refResult;
private String billNo;
}
package com.yeejoin.amos.fas.business.bo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(description = "消防整改数据展示实体")
public class FireRectificationBo {
/**
* 登记单号
*/
private String billno;
/**
* 站编号
*/
private String stationNum;
/**
* 站名称
*/
private String stationName;
/**
* 需处理告警
*/
private Integer warnning;
/**
* 需关注风险
*/
private Integer danger;
/**
* 需处理隐患
*/
private Integer hiddenTrouble;
/**
* 需加强消防管理
*/
private Integer adminOfFire;
/**
* 安全负责人
*/
private String chargePerson;
/**
* 联系人电话
*/
private String chargePersonTel;
/**
* 治理完成日期
*/
private String completionDate;
/**
* 实际完成日期
*/
private String reCompletionDate;
/**
* 状态
*/
private String status;
/**
* 状态code
*/
private String statuscode;
/**
* 整改下发人员
*/
private String disUser;
/**
* 整改下发登记日期
*/
private String disDate;
/**
* 环流站复制人员
*/
private String stationUser;
/**
* 整改下发人员联系电话
*/
private String stationUserTel;
/**
* 安全负责人
*/
private String safeUser;
/**
* 安全负责人电话
*/
private String safeUserTel;
/**
* 要求完成日
*/
private String reqDate;
/**
* 实际完成日
*/
private String finishDate;
/**
* 整改结果
*/
private String refResult;
/**
* 意见及建议
*/
private String viewsAndSuggestions;
/**
* 反馈结果
*/
private String backResult;
}
package com.yeejoin.amos.fas.business.bo;
import java.util.Set;
/**
* 手机消息对象
*/
public class JpushMsgBo {
/**
* 接收人集合
*/
Set<String> target;
/**
* 消息体
*/
JpushMsgContentBo msg;
public Set<String> getTarget() {
return target;
}
public void setTarget(Set<String> target) {
this.target = target;
}
public JpushMsgContentBo getMsg() {
return msg;
}
public void setMsg(JpushMsgContentBo msg) {
this.msg = msg;
}
}
package com.yeejoin.amos.fas.business.bo;
import com.yeejoin.amos.fas.common.enums.TriggerRpnChangeTypeEum;
import com.yeejoin.amos.fas.core.util.DateUtil;
import java.math.BigDecimal;
/**
* 手机消息推送内容
*/
public class JpushMsgContentBo {
/**
* 危险因素名称
*/
private String fmeaName;
/**
* 触发类型
*/
private String notifyType;
/**
* 巡检状态
*/
private String checkStatus;
public String getCheckStatus() {
return checkStatus;
}
public void setCheckStatus(String checkStatus) {
this.checkStatus = checkStatus;
}
/**
* 执行日期
*/
private String executeDate = DateUtil.getLongCurrentDate();
/**
* 执行人
*/
private String execute;
/**
* 等级变化范围
*/
private int levelIsChange;
/**
* 当前rpn
*/
private BigDecimal rpn;
/**
*风险等级
*/
private String level;
/**
*标题
*/
private String subject;
/**
* 关联名称
*/
private String relationName;
/**
* 是否需要发送
*/
private Boolean isSend;
public JpushMsgContentBo(String fmeaName, String notifyType){
this.fmeaName = fmeaName;
this.notifyType = notifyType;
this.setSubject(notifyType);
}
public Boolean getSend() {
return isSend;
}
private void setSubject(String notifyType){
if(notifyType.equals(TriggerRpnChangeTypeEum.patrol.getCode())){
//巡检
this.subject = "风险预警";
this.isSend = true;
} else if(notifyType.equals(TriggerRpnChangeTypeEum.alarm.getCode())){
//设备告警
this.subject = "风险预警";
this.isSend = true;
} else if(notifyType.equals(TriggerRpnChangeTypeEum.alarmRecovery.getCode())){
//告警恢复
this.subject = "告警恢复";
this.isSend = true;
} else if(notifyType.equals(TriggerRpnChangeTypeEum.fmeaUpdate.getCode())){
//风险评价
this.subject = "风险评价";
this.isSend = true;
}
}
public String genMessage(){
StringBuilder message = new StringBuilder();
if(notifyType.equals(TriggerRpnChangeTypeEum.patrol.getCode())){
//巡检
message.append("执行人:").append(execute).append("\n");
message.append("执行时间:").append(executeDate).append("\n");
message.append("危险因素名称:").append(fmeaName).append("\n");
message.append("描述:").append("当前风险值上升到").append(rpn).append(",风险等级").append(getLevelChangeType()).append(level).append("\n");
message.append("触发原因:").append("关联巡检点").append(relationName).append("检查").append(checkStatus);
} else if(notifyType.equals(TriggerRpnChangeTypeEum.alarm.getCode())){
//设备告警
message.append("执行时间:").append(executeDate).append("\n");
message.append("危险因素名称:").append(fmeaName).append("\n");
message.append("描述:").append("当前风险值上升到").append(rpn).append(",风险等级").append(getLevelChangeType()).append(level).append("\n");
message.append("触发原因:").append("关联设备").append(relationName).append("指标项报警");
} else if(notifyType.equals(TriggerRpnChangeTypeEum.alarmRecovery.getCode())){
//告警恢复
message.append(relationName).append("设备告警解除");
} else if(notifyType.equals(TriggerRpnChangeTypeEum.fmeaUpdate.getCode())){
//风险评价
message.append("评价人:").append(execute).append("\n");;
message.append("评价时间:").append(executeDate).append("\n");
message.append("评价内容:").append(fmeaName).append("\n");
message.append("评价等级:").append(level);
}
return message.toString();
}
private String getLevelChangeType(){
String changeType = "";
if(levelIsChange > 0){
changeType = "上升到";
}else if(levelIsChange == 0){
changeType = "不变";
} else {
changeType = "下降到";
}
return changeType;
}
public String getExecute() {
return execute;
}
public void setExecute(String execute) {
this.execute = execute;
}
public int getLevelIsChange() {
return levelIsChange;
}
public void setLevelIsChange(int levelIsChange) {
this.levelIsChange = levelIsChange;
}
public BigDecimal getRpn() {
return rpn;
}
public void setRpn(BigDecimal rpn) {
this.rpn = rpn;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public String getRelationName() {
return relationName;
}
public String getSubject() {
return subject;
}
public void setRelationName(String relationName) {
this.relationName = relationName;
}
}
package com.yeejoin.amos.fas.business.bo;
import com.yeejoin.amos.fas.dao.entity.Fmea;
import java.math.BigDecimal;
/**
* 参数对象
*/
public class MsgParamBo {
private String toke;
private String product;
private String appKey;
private Fmea fmea;
private Integer managerLevel;
private String notifyType;
private String userName;
private int levelIsChange;
private BigDecimal rpn;
private String level;
private String relationName;
private String checkStatus;
public String getCheckStatus() {
return checkStatus;
}
public void setCheckStatus(String checkStatus) {
this.checkStatus = checkStatus;
}
public String getToke() {
return toke;
}
public void setToke(String toke) {
this.toke = toke;
}
public String getProduct() {
return product;
}
public void setProduct(String product) {
this.product = product;
}
public String getAppKey() {
return appKey;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
}
public Fmea getFmea() {
return fmea;
}
public void setFmea(Fmea fmea) {
this.fmea = fmea;
}
public Integer getManagerLevel() {
return managerLevel;
}
public void setManagerLevel(Integer managerLevel) {
this.managerLevel = managerLevel;
}
public String getNotifyType() {
return notifyType;
}
public void setNotifyType(String notifyType) {
this.notifyType = notifyType;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public int getLevelIsChange() {
return levelIsChange;
}
public void setLevelIsChange(int levelIsChange) {
this.levelIsChange = levelIsChange;
}
public BigDecimal getRpn() {
return rpn;
}
public void setRpn(BigDecimal rpn) {
this.rpn = rpn;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public String getRelationName() {
return relationName;
}
public void setRelationName(String relationName) {
this.relationName = relationName;
}
}
package com.yeejoin.amos.fas.business.bo;
/**
* @author suhg
*/
public class RiskPointRpnChangeBo {
private Long id;
private String name;
private Long riskLevelId;
private String changeDate;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getRiskLevelId() {
return riskLevelId;
}
public void setRiskLevelId(Long riskLevelId) {
this.riskLevelId = riskLevelId;
}
public String getChangeDate() {
return changeDate;
}
public void setChangeDate(String changeDate) {
this.changeDate = changeDate;
}
}
package com.yeejoin.amos.fas.business.bo;
import lombok.Data;
import java.util.List;
@Data
public class RiskSourceSynBo {
/**
* 源id
*/
private Long id;
/**
* 编号
*/
private String code;
/**
* 名称
*/
private String name;
/**
* 上级id
*/
private Long parentId;
/**
* 子节点
*/
List<RiskSourceSynBo> children;
}
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;
}
}
package com.yeejoin.amos.fas.business.bo;
public class SafetyExecuteBo {
private Long id;
private String code;
private String label;
private String pointId;
private String type;
private String status;//指标状态
private String changeDate;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getPointId() {
return pointId;
}
public void setPointId(String pointId) {
this.pointId = pointId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getChangeDate() {
return changeDate;
}
public void setChangeDate(String changeDate) {
this.changeDate = changeDate;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
/**
*
*/
package com.yeejoin.amos.fas.business.constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 常量
*/
public class FasConstant {
/**
* 构造方法
*/
private FasConstant() {
LoggerFactory.getLogger(this.getClass()).debug(FasConstant.CONSTRUCTOR);
}
/**
* amos线程池数量
*/
public static final int AMOS_THREAD_NUM = 20;
/**
* 构造方法字符串
*/
public static final String CONSTRUCTOR = "constructor...";
/**
* 风险评价
*
*/
public static final String EVA_MODEL_S = "S"; //风险评价模型 危险程度(S)评分标准
public static final String EVA_MODEL_O = "O"; //故障频数(O)评分标准
public static final String EVA_MODEL_D = "D"; //探测度(D)评分标准
public static final String UPLOAD_ROOT_PATH = "upload";//图片上传根路径
public static final String UPLOAD_CAR_PATH = "fireCar";//消防车图片路径
public static final String UPLOAD_EQUIPMENT_PATH = "fireEquipment";
public static final String UPLOAD_FIRESTATION_PATH = "fireStation";//消防小室图片路径
public static final String RISK_SOURCE_STATUS_NORMAL = "NORMAL";//风险点状态-正常
public static final String RISK_SOURCE_STATUS_ANOMALY = "ANOMALY";//风险点状态-正常
public static final String PLAN_SOURCE_TYPE = "plan_source_type";//预案资源类型
public static final String ALL_POINT = "all";
public static String appKey = "";
public static String product = "";
public static String token = "";
public static String staticOrgCode = "";
}
package com.yeejoin.amos.fas.business.controller;
import java.util.HashMap;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.fas.business.param.CommonPageInfoParam;
import com.yeejoin.amos.fas.business.service.intfc.IAccidentTypeService;
import com.yeejoin.amos.fas.business.util.CommonPageParamUtil;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.request.CommonRequest;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.dao.entity.AccidentType;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping("/api/accidentType")
@Api("事故类型api")
public class AccidentTypeController extends AbstractBaseController {
private final Logger log = LoggerFactory.getLogger(AccidentTypeController.class);
@Autowired
IAccidentTypeService iAccidentTypeService;
/**
* 事故类型分页查询
*
* @param id
* @return
*/
@Permission
@ApiOperation(httpMethod = "POST",value = "事故类型查询", notes = "事故类型查询")
@RequestMapping(value = "/pagelist", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse queryRiskLevelPage(@ApiParam(value = "查询条件", required = false) @RequestBody(required = false) List<CommonRequest> queryRequests,
@ApiParam(value = "分页参数", required = true) CommonPageable commonPageable) {
CommonPageInfoParam param = CommonPageParamUtil.fillCommonPageInfoParam(queryRequests, commonPageable);
ReginParams reginParams =getSelectedOrgInfo();
String orgCode = this.getOrgCode(reginParams);
param.setOrgCode(orgCode);
Page<HashMap<String, Object>> list = iAccidentTypeService.queryAccidentTypePage(getToken(),getProduct(),getAppKey(),param);
return CommonResponseUtil.success(list);
}
/**
* 事故类型查询,不分页
*
* @param id
* @return
*/
@Permission
@ApiOperation(httpMethod = "GET",value = "事故类型查询不分页", notes = "事故类型查询不分页")
@RequestMapping(value = "/all-list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryRiskLevel() {
ReginParams reginParams =getSelectedOrgInfo();
String compCode=getOrgCode(reginParams);
List<HashMap<String,Object>> list = iAccidentTypeService.queryAccidentType(compCode);
return CommonResponseUtil.success(list);
}
/**
* 事故类型新增及维护
* @param param
* @return
*/
@Permission
@ApiOperation(httpMethod = "POST", value = "事故类型新增及维护", notes = "事故类型新增及维护")
@RequestMapping(value = "/editAccidentType", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse checkPlanAdd(@ApiParam(value = "事故类型对象", required = true) @RequestBody AccidentType param) {
try {
AgencyUserModel user = getUserInfo();
ReginParams reginParams =getSelectedOrgInfo();
String dep=getDepartmentId(reginParams);
String compCode=getOrgCode(reginParams);
HashMap<String,Object> map = new HashMap<String,Object>();
map.put("dept_id", dep);
map.put("org_code", compCode);
map.put("user_id", user.getUserId());
map.put("param", param);
iAccidentTypeService.editAccidentType(map);
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(),e);
return CommonResponseUtil.failure("事故类型编辑失败" + e.getMessage());
}
}
/**
* 事故类型删除(支持批量)
* @param param
* @return
*/
@Permission
@ApiOperation(httpMethod = "POST", value = "删除事故类型", notes = "删除事故类型")
@RequestMapping(value = "/deleteAccidentTypeById", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse deletePlanById(@ApiParam(value = "事故类型ID", required = true) @RequestBody Long[] param) {
try {
iAccidentTypeService.detAccidentType(param);
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(),e);
return CommonResponseUtil.failure(e.getMessage()+",事故类型删除失败");
}
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.fas.business.param.CommonPageInfoParam;
import com.yeejoin.amos.fas.business.service.intfc.IAlarmService;
import com.yeejoin.amos.fas.business.util.CommonPageParamUtil;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.request.CommonRequest;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping("/api/alarm")
@Api("报警信息api")
public class AlarmController extends AbstractBaseController {
@Autowired
IAlarmService iAlarmService;
/**
* 风险等级分页查询
*
* @param queryRequests
* @return
*/
@Permission
@ApiOperation(httpMethod = "POST",value = "报警信息查分页询", notes = "报警信息查询")
@RequestMapping(value = "/pagelist", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse queryAlarmPage(
@ApiParam(value = "查询条件", required = false) @RequestBody(required = false) List<CommonRequest> queryRequests,
@ApiParam(value = "分页参数", required = true) CommonPageable commonPageable) {
CommonPageInfoParam param = CommonPageParamUtil.fillCommonPageInfoParam(queryRequests, commonPageable);
Page<HashMap<String, Object>> list = iAlarmService.queryAlarmPage(param);
return CommonResponseUtil.success(list);
}
}
package com.yeejoin.amos.fas.business.controller;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.fas.business.param.MessageParam;
import com.yeejoin.amos.fas.business.service.intfc.IBizMessageService;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping(value = "/api/message")
@Api(tags="水资源API")
public class BizMessageController extends AbstractBaseController{
@Autowired
IBizMessageService iBizMessageService;
@Permission
//@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET",value = "分页查询消息", notes = "分页查询消息")
@RequestMapping(value = "/page", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse forPage(
@ApiParam(value = "日期") @RequestParam(required = false)String time,
@ApiParam(value = "类型") @RequestParam(required = false)String type,
@ApiParam(value = "标题") @RequestParam(required = false)String title,
@RequestParam int pageNumber,
@RequestParam int pageSize
) {
ReginParams reginParams =getSelectedOrgInfo();
String compCode=getOrgCode(reginParams);
CommonPageable commonPageable = new CommonPageable(pageNumber,pageSize);
return CommonResponseUtil.success(iBizMessageService.queryForPage(StringUtils.trimToNull(time), StringUtils.trimToNull(type), StringUtils.trimToNull(title),StringUtils.trimToNull( compCode), commonPageable));
}
@Permission
@ApiOperation(httpMethod = "POST",value = "分页查询消息", notes = "分页查询消息")
@RequestMapping(value = "/page", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse forPagePOST(
@RequestBody MessageParam params
) {
ReginParams reginParams =getSelectedOrgInfo();
String compCode=getOrgCode(reginParams);
CommonPageable commonPageable = new CommonPageable(params.getPageNumber(),params.getPageSize());
return CommonResponseUtil.success(iBizMessageService.queryForPage(StringUtils.trimToNull(params.getTime()), StringUtils.trimToNull(params.getType()), StringUtils.trimToNull(params.getTitle()),StringUtils.trimToNull( compCode), commonPageable));
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.fas.business.param.PointListParam;
import com.yeejoin.amos.fas.business.param.QueryParamUtil;
import com.yeejoin.amos.fas.business.service.intfc.ICommonService;
import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.request.CommonRequest;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping(value = "/api/common")
@Api(tags = "公共资源api")
public class CommonController extends AbstractBaseController {
private final Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired
private ICommonService commonService;
@Autowired
private IRiskSourceService iRiskSourceService;
/**
* 根据当前用户获取公司下部门信息
*
* @return
*/
@Permission
@ApiOperation(httpMethod = "GET", value = "根据当前用户获取公司下部门信息", notes = "根据当前用户获取公司下部门信息")
@RequestMapping(value = "/deptment/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getDeptments() {
ReginParams reginParams =getSelectedOrgInfo();
String companyId =getCompanyId(reginParams);
if (companyId == null) {
return CommonResponseUtil.failure("公司信息获取失败!");
}
List<DepartmentModel> deps = commonService.getDepartment(getToken(),getProduct(),getAppKey(), companyId);
return CommonResponseUtil.success(objectsToMaps(deps));
}
public static <T> Map<String, Object> beanToMap(T bean) {
Map<String, Object> map = Maps.newHashMap();
if (bean != null) {
BeanMap beanMap = BeanMap.create(bean);
for (Object key : beanMap.keySet()) {
if("sequenceNbr".equals(key+"")){
map.put(key+"", beanMap.get(key)+"");
}else{
map.put(key+"", beanMap.get(key));
}
}
}
return map;
}
public static <T> List<Map<String, Object>> objectsToMaps(List<T> objList) {
List<Map<String, Object>> list = Lists.newArrayList();
if (objList != null && objList.size() > 0) {
Map<String, Object> map = null;
T bean = null;
for (int i = 0,size = objList.size(); i < size; i++) {
bean = objList.get(i);
map = beanToMap(bean);
list.add(map);
}
}
return list;
}
/**
* 查询巡检点信息
*
* @param
* @return
*/
@Permission
@ApiOperation(value = "查询巡检点信息", notes = "查询巡检点信息")
@PostMapping(value = "/pointList", produces = "application/json;charset=UTF-8")
public CommonResponse getPoints(
@ApiParam(value = "查询条件", required = false) @RequestBody(required = false) List<CommonRequest> queryRequests,
@ApiParam(value = "分页参数", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable commonPageable) {
try {
PointListParam params = new PointListParam();
QueryParamUtil.fillPointListParam(queryRequests, commonPageable, params);
Page<HashMap<String, Object>> pointList = commonService.getPointList(params);
return CommonResponseUtil.success(pointList);
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("查询巡检点信息失败");
}
}
/**
* 根据巡检点查询巡检项
*
* @param
* @return
*/
//@Authorization(ingore = true)
@Permission
@ApiOperation(value = "查询巡检点项信息", notes = "查询巡检点项信息")
@PostMapping(value = "/pointInputlist", produces = "application/json;charset=UTF-8")
public CommonResponse getPointInputs(
@ApiParam(value = "查询条件", required = false) @RequestBody(required = false) List<CommonRequest> queryRequests,
@ApiParam(value = "分页参数", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable commonPageable) {
try {
PointListParam params = new PointListParam();
// params.setOrgCode(getUserInfo().getOrgCode());
QueryParamUtil.fillPointListParam(queryRequests, commonPageable, params);
Page<HashMap<String, Object>> pointInputList = commonService.getPointInputList(params);
return CommonResponseUtil.success(pointInputList);
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("查询巡检点信息失败");
}
}
/**
* 根据部门获取部门人员信息
*
* @return
*/
@Permission
@ApiOperation(httpMethod = "GET", value = "根据部门获取部门人员信息", notes = "根据部门获取部门人员信息")
@RequestMapping(value = "/{departmentId}/user/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getUsers(@ApiParam(value = "部门ID", required = true) @PathVariable String departmentId) {
if (departmentId == null) {
return CommonResponseUtil.failure("部门信息获取失败!");
}
List<AgencyUserModel> users = commonService.getUsers(getToken(),getProduct(),getAppKey(),departmentId);
return CommonResponseUtil.success(users);
}
@Permission
@ApiOperation(httpMethod = "GET", value = "获取公司下人员列表", notes = "获取公司下人员列表")
@GetMapping(value = "/user/list", produces = "application/json;charset=UTF-8")
public CommonResponse getAllUser() {
ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams);
List<AgencyUserModel> users = commonService.getAllUser(getToken(),getProduct(),getAppKey(), compCode);
return CommonResponseUtil.success(users);
}
@ApiOperation(value = "查询公司下的风险模型(厂区、区域、风险点)")
@GetMapping(value = "/riskSource/list/{orgCode}",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public CommonResponse getRiskSourceList(@PathVariable String orgCode){
return CommonResponseUtil.success(iRiskSourceService.findRiskSourceTrees(orgCode));
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.HashMap;
import java.util.Map;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/api/region")
@Api("获取当前用户信息api")
public class CurCompanyController extends AbstractBaseController {
@Permission
@ApiOperation(httpMethod = "GET",value = "获取当前用户信息", notes = "获取当前用户信息")
@RequestMapping(value = "/current", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse current() {
Map< String, Object> map=new HashMap<>();
map.put("nickName", getUserInfo().getRealName());
map.put("company", getSelectedOrgInfo().getCompany());
map.put("department", getSelectedOrgInfo().getDepartment());
map.put("role", getSelectedOrgInfo().getRole());
return CommonResponseUtil.success(map);
}
}
package com.yeejoin.amos.fas.business.controller;
import com.yeejoin.amos.fas.business.service.intfc.IDataRefreshService;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author suhg
*/
@RestController
@RequestMapping("/api/data")
@Api(tags = "三维屏数据刷新api")
public class DataRefreshController extends AbstractBaseController{
@Autowired
private IDataRefreshService dataRefreshService;
/**
* 全景监控执行数据刷新
* @return success
*/
@Permission
@ApiOperation(value = "全景监控执行数据刷新",notes = "check-巡检记录,planTask-执行数据")
@GetMapping(value = "refresh/{dataType}")
public CommonResponse checkDataRefresh(@PathVariable String dataType){
dataRefreshService.refreshViewData(dataType);
return CommonResponseUtil.success();
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.fas.business.service.intfc.IDictService;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.dao.entity.Dict;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping(value = "/api")
@Api(tags="数据字典api")
public class DictController extends AbstractBaseController{
@Autowired
private IDictService dictService;
private final Logger log = LoggerFactory.getLogger(DictController.class);
/**
* 根据查询条件列出字典列表
* @return
*/
@Permission
@ApiOperation(httpMethod = "GET",value = "根据查询条件列出字典列表", notes = "根据查询条件列出字典列表")
@RequestMapping(value = "/dict/page", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
//@Authorization(ingore=true)
public CommonResponse page(Dict dict,
@ApiParam(value = "分页参数", defaultValue = "pageNumber=0&pageSize=10") CommonPageable commonPageable){
try {
Page<Dict> dictList = dictService.getDictPage(dict, commonPageable);
return CommonResponseUtil.success(dictList);
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("查询字典信息失败");
}
}
/**
* 根据查询条件列出字典列表
* @return
*/
@Permission
@ApiOperation(httpMethod = "GET",value = "根据查询条件列出字典列表", notes = "根据查询条件列出字典列表")
@RequestMapping(value = "/dict/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
//@Authorization(ingore=true)
public CommonResponse list(Dict dict){
try {
List<Dict> dictList = dictService.getDictList(dict);
return CommonResponseUtil.success(dictList);
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("查询字典信息失败");
}
}
/**
* 根据IDs查询字典详情
* @return
*/
@Permission
@ApiOperation(httpMethod = "GET",value = "根据IDs查询字典详情", notes = "根据IDs查询字典详情")
@RequestMapping(value = "/dict/list/{ids}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
//@Authorization(ingore=true)
public CommonResponse list(Long[] ids){
List<Dict> dictList = dictService.getDictListByIds(ids);
return CommonResponseUtil.success(dictList);
}
/**
* 根据ID查询字典详情
* @return
*/
@Permission
@ApiOperation(httpMethod = "GET",value = "根据ID查询字典详情", notes = "根据ID查询字典详情")
@RequestMapping(value = "/dict/list/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
//@Authorization(ingore=true)
public CommonResponse list(long id){
Dict dict = dictService.getDictById(id);
return CommonResponseUtil.success(dict);
}
/**
* 根据ID删除字典
* @return
*/
@Permission
@ApiOperation(httpMethod = "DELETE",value = "根据ID删除字典", notes = "根据ID删除字典")
@RequestMapping(value = "/dict/delete/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.DELETE)
//@Authorization(ingore=true)
public CommonResponse delete(long id){
dictService.deleteDictById(id);
return CommonResponseUtil.success();
}
/**
* 根据IDs删除字典
* @return
*/
@Permission
@ApiOperation(httpMethod = "DELETE",value = "根据IDs删除字典", notes = "根据IDs删除字典")
@RequestMapping(value = "/dict/delete/{ids}", produces = "application/json;charset=UTF-8", method = RequestMethod.DELETE)
//@Authorization(ingore=true)
public CommonResponse deletes(long[] ids){
dictService.deleteDictByIds(ids);
return CommonResponseUtil.success();
}
/**
* 新增字典
* @return
*/
@Permission
@ApiOperation(httpMethod = "POST",value = "新增字典", notes = "新增字典")
@RequestMapping(value = "/dict/add", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
//@Authorization(ingore=true)
public CommonResponse add(@RequestBody Dict dict){
dictService.saveDict(dict);
return CommonResponseUtil.success();
}
/**
* 编辑字典信息
* @return
*/
@Permission
@ApiOperation(httpMethod = "PUT",value = "编辑字典信息", notes = "编辑字典信息")
@RequestMapping(value = "/dict/edit", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
//@Authorization(ingore=true)
public CommonResponse edit(@RequestBody Dict dict){
dictService.saveDict(dict);
return CommonResponseUtil.success();
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.fas.business.param.FmeaBindParam;
import com.yeejoin.amos.fas.business.service.intfc.EquipmentSpecificService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentCategoryService;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* @author zjw
* @date 2020-11-04
*/
@RestController
@RequestMapping(value = "/api/equipment")
@Api(tags = "重点设备配套设施调整Api")
public class EquipmentSpecificController extends AbstractBaseController{
@Autowired
private EquipmentSpecificService equipmentSpecificService;
@Autowired
private IEquipmentCategoryService iEquipmentCategoryService;
@ApiOperation(value = "绑定消防设备指标", notes = "绑定消防设备指标")
@PostMapping(value = "/upDateEquimentPoint")
public CommonResponse upDateEquimentPoint(@RequestBody FmeaBindParam fmeaBindParam) {
return CommonResponseUtil.success(equipmentSpecificService.upDateEquimentPoint(fmeaBindParam));
}
@ApiOperation(httpMethod = "GET", value = "查询指定风险点绑定关系", notes = "查询指定风险点绑定关系")
@RequestMapping(value = "/getAssoEquips", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getAssoEquips(
@RequestParam Long fmeaId,
@RequestParam int pageNumber,
@RequestParam int pageSize) {
return CommonResponseUtil.success(equipmentSpecificService.getAssoEquips(fmeaId, pageNumber, pageSize));
}
@ApiOperation(value = "查询设备指标", notes = "查询设备指标")
@GetMapping(value = "/getBindEquipment")
public CommonResponse getBindEquipment(@RequestParam Long fmeaId,
@RequestParam Long importantEquipId,
@RequestParam Long equimentId,
@RequestParam(required = false) String equipmentPointName) {
return CommonResponseUtil.success(equipmentSpecificService.getBindEquipment(fmeaId, importantEquipId, equimentId, equipmentPointName));
}
@GetMapping(value = "/fireequiment")
@ApiOperation(httpMethod = "GET", value = "查询绑定关系设备", notes = "查询绑定关系设备")
public CommonResponse getFireEquiments(
@RequestParam(value = "equipmentId") String equipmentId,
@RequestParam(value = "fname",required = false) String fname) {
return CommonResponseUtil.success(equipmentSpecificService.getFireEquiments( equipmentId, fname));
}
@GetMapping(value = "/getEquipmentBySpe")
@ApiOperation(httpMethod = "GET", value = "获取装备台账信息", notes = "获取装备台账信息")
public CommonResponse getEquipmentBySpe(
@RequestParam(value = "name",required = false) String name,
@RequestParam(value = "code",required = false) String code,
@RequestParam(value = "pageNumber",required = false) int pageNumber,
@RequestParam(value = "pageSize",required = false) int pageSize,
@RequestParam(value = "equipmentId",required = false) String equipmentId ) {
return CommonResponseUtil.success(equipmentSpecificService.getEquipmentBySpe(name, code, pageNumber, pageSize,equipmentId));
}
@GetMapping(value = "/getEquipmentBySpeV2")
@ApiOperation(httpMethod = "GET", value = "获取装备台账信息", notes = "获取装备台账信息")
public CommonResponse getEquipmentBySpeV2(
@RequestParam(value = "name",required = false) String name,
@RequestParam(value = "pageNumber",required = false) int pageNumber,
@RequestParam(value = "pageSize",required = false) int pageSize,
@RequestParam(value = "equipmentId",required = false) String equipmentId ) {
Long aLong = null;
if (!"null".equals(equipmentId) && equipmentId != null && !"".equals(equipmentId.trim())){
aLong = Long.valueOf(equipmentId);
}
return CommonResponseUtil.success(equipmentSpecificService.getEquipmentBySpeV2(name, pageNumber, pageSize,aLong));
}
@GetMapping(value = "/list-tree", produces = "application/json;charset=UTF-8")
@ApiOperation(httpMethod = "GET", value = "全量数据树形结构返回", notes = "全量数据树形结构返回")
public CommonResponse getTreelist() {
List<EquipmentCategory> equipmentCategorys = iEquipmentCategoryService.list();
List<EquipmentCategory> list = new ArrayList<>();
Map<String, List<EquipmentCategory>> tmpMap = new HashMap<String, List<EquipmentCategory>>();
equipmentCategorys.forEach(action -> {
if (action.getParentId() == null) {
list.add(action);
} else {
if (tmpMap.get(action.getParentId().toString()) == null) {
ArrayList<EquipmentCategory> tmplist = new ArrayList<EquipmentCategory>();
tmplist.add(action);
tmpMap.put(action.getParentId().toString(), tmplist);
} else {
if (!tmpMap.get(action.getParentId().toString()).contains(action)) {
tmpMap.get(action.getParentId().toString()).add(action);
}
}
}
});
getChildren(list, tmpMap);
return CommonResponseUtil.success(list);
}
private void getChildren(List<EquipmentCategory> list, Map<String, List<EquipmentCategory>> tmpMap) {
for (EquipmentCategory equipmentCategory : list) {
if (tmpMap.get(equipmentCategory.getId().toString()) != null
&& tmpMap.get(equipmentCategory.getId().toString()).size() > 0) {
List<EquipmentCategory> equipcliss = tmpMap.get(equipmentCategory.getId().toString());
equipmentCategory.setHasLowerClassification(true);
equipmentCategory.setChildren(equipcliss);
getChildren(equipcliss, tmpMap);
}
}
}
}
package com.yeejoin.amos.fas.business.controller;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.fas.business.service.intfc.EquipmentSpecificIndexService;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
* @ProjectName: YeeAmosFireAutoSysRoot
* @Package: com.yeejoin.amos.fas.business.controller
* @ClassName: EquipmentSpecificIndexController
* @Author: Jianqiang Gao
* @Description: EquipmentSpecificIndexController
* @Date: 2021/1/18 16:32
* @Version: 1.0
*/
@RestController
@RequestMapping(value = "/api/equipSpecificIndex")
@Api(tags = "装备性能指标Api")
public class EquipmentSpecificIndexController extends AbstractBaseController {
@Value("${autoSys.alarm.nameKeys}")
private String nameKeys;
@Value("${autoSys.alarm.status}")
private String status;
@Value("${autoSys.alarm.value}")
private String value;
@Autowired
private EquipmentSpecificIndexService equipmentSpecificIndexService;
@Permission
@ApiOperation(httpMethod = "GET", value = "获取最新告警状态", notes = "获取最新告警状态")
@RequestMapping(value = "/queryInitAlarm", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryInitAlerm(@ApiParam(value = "物联采集属性值", required = true) @RequestParam String value,
@ApiParam(value = "多nameKey,中间英文逗号隔开", required = true) @RequestParam String nameKeys,
@ApiParam(value = "多status,中间英文逗号隔开", required = true) @RequestParam String status) {
return CommonResponseUtil.success(equipmentSpecificIndexService.queryInitAlarm(value, nameKeys, status));
}
@Permission
@ApiOperation(httpMethod = "GET", value = "获取三维初始化告警信息", notes = "获取三维初始化告警信息")
@RequestMapping(value = "/getInitAlarm", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getInitAlarm(@ApiParam(value = "物联采集属性值") @RequestParam(required = false) String value,
@ApiParam(value = "多nameKey,中间英文逗号隔开") @RequestParam(required = false) String nameKeys,
@ApiParam(value = "多status,中间英文逗号隔开") @RequestParam(required = false) String status) {
if (!StringUtils.isNotBlank(value) && !StringUtils.isNotBlank(nameKeys) && !StringUtils.isNotBlank(status)) {
value = this.value;
nameKeys = this.nameKeys;
status = this.status;
}
return CommonResponseUtil.success(equipmentSpecificIndexService.getInitAlarm(value, nameKeys, status));
}
}
\ No newline at end of file
package com.yeejoin.amos.fas.business.controller;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.fas.business.service.intfc.IEvaModelService;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping("/api/fmeaEvaluate")
@Api("fmea评价模型api")
public class EvaModelController extends AbstractBaseController {
@Autowired
IEvaModelService iEvaModelService;
/**
* 评价模型查询
* @param id
* @return
*/
@Permission
@ApiOperation(httpMethod = "GET",value = "fmea评价模型查询", notes = "fmea评价模型查询")
@RequestMapping(value = "/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryEvaModel(@ApiParam(value = "查询条件", required = false) @RequestParam(value = "type",required =false) String type) {
HashMap<String,Object> list = iEvaModelService.findFmeaByType(type);
return CommonResponseUtil.success(list);
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.fas.business.param.FireEquipmentParam;
import com.yeejoin.amos.fas.business.param.FireEquipmentPointParam;
import com.yeejoin.amos.fas.business.param.WaterResourceParam;
import com.yeejoin.amos.fas.business.service.intfc.IExcelService;
import com.yeejoin.amos.fas.business.util.FileHelper;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.exception.YeeException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping(value = "/api/excel")
@Api(tags = "导入导出excel")
public class ExcelController extends AbstractBaseController {
private final Logger logger = LoggerFactory.getLogger(ExcelController.class);
@Autowired
private IExcelService iExcelService;
@Permission
@ApiOperation(value = "导入消防装备数据", notes = "导入消防装备数据")
@PostMapping(value = "/import/fireEquipment")
public CommonResponse importFireEquipment(@RequestPart("file") MultipartFile file) {
String fileName = file.getOriginalFilename();
if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) {
try {
List<FireEquipmentParam> list = FileHelper.importExcel(file, 1, 1, FireEquipmentParam.class);
iExcelService.importFireEquipment(list);
return CommonResponseUtil.success();
} catch (Exception e) {
logger.info("导入消防装备数据异常", e);
return CommonResponseUtil.failure("导入失败");
}
} else {
return CommonResponseUtil.failure("文件格式错误");
}
}
@Permission
@ApiOperation(value = "导入装备监测点数据", notes = "导入装备监测点数据")
@PostMapping(value = "/import/fireEquipmentPoint")
public CommonResponse importFireEquipmentPoint(@RequestPart("file") MultipartFile file) {
String fileName = file.getOriginalFilename();
if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) {
try {
List<FireEquipmentPointParam> list = FileHelper.importExcel(file, 1, 1, FireEquipmentPointParam.class);
ReginParams reginParams =getSelectedOrgInfo();
String orgCode=getOrgCode(reginParams);
iExcelService.importFireEquipmentPoint(list, orgCode,getUserId());
return CommonResponseUtil.success();
} catch (Exception e) {
logger.info("导入装备监测点数据", e);
return CommonResponseUtil.failure("导入失败");
}
} else {
return CommonResponseUtil.failure("文件格式错误");
}
}
@Permission
@ApiOperation(value = "导出数据", notes = "导出数据")
@PostMapping(value = "/export")
//@Authorization(ingore = true)
public void export(HttpServletResponse response,
@ApiParam(value = "data:导出数据;model:导出模板", required = true) @RequestParam String exportType,
@ApiParam(value = "point:监测点;equipment:设备", required = true) @RequestParam String modelName,
@ApiParam(value = "查询条件") @RequestBody(required = false) Map<String, Object> paramsMap) {
ReginParams reginParams =getSelectedOrgInfo();
String orgCode = getOrgCode(reginParams);
paramsMap.put("compCode", orgCode);
String fileName = UUID.randomUUID().toString() + ".xls";
String title = "监测点";
Class cls = null;
if ("point".equals(modelName)) {
title = "消防点位";
cls = FireEquipmentPointParam.class;
} else if ("equipment".equals(modelName)) {
title = "消防资源";
cls = FireEquipmentParam.class;
} else if ("water".equals(modelName)) {
title = "水资源";
cls = WaterResourceParam.class;
}
if (cls != null) {
List<?> list = Lists.newArrayList();
if ("data".equals(exportType)) {
list = iExcelService.exportPointData(paramsMap);
}
FileHelper.exportExcel(list, title, title, cls, fileName, response);
}
}
@Permission
@ApiOperation(value = "导入数据", notes = "导入数据")
@PostMapping(value = "/import/data/excel/{type}")
public CommonResponse importExcelData(@RequestPart("file") MultipartFile file, @ApiParam(value = "导入资源类型", required = true) @PathVariable String type) {
String fileName = file.getOriginalFilename();
if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) {
try {
if ("fireResource".equals(type)) {//导入消防装备
List<FireEquipmentParam> list = FileHelper.importExcel(file, 1, 1, FireEquipmentParam.class);
iExcelService.importFireEquipment(list);
}
// else if ("water".equals(type)) {//导入水资源
// List<WaterResourceParam> list = FileHelper.importExcel(file, 1, 1, WaterResourceParam.class);
// iExcelService.importWaterResource(list);
// }
return CommonResponseUtil.success();
} catch (YeeException e) {
logger.info("导入数据异常", e);
return CommonResponseUtil.failure(e.getMessage());
} catch (Exception e) {
logger.info("导入数据异常", e);
return CommonResponseUtil.failure("导入失败");
}
} else {
return CommonResponseUtil.failure("文件格式错误");
}
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.fas.business.service.intfc.IFireEquipPontService;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping(value = "/api/firequment/point")
@Api(tags = "消防设备风险点")
public class FireEquimtPointController extends AbstractBaseController {
@Autowired
private IFireEquipPontService fireEquipPontService;
@Permission
@ApiOperation(httpMethod = "GET", value = "指定消防设备的风险点列表", notes = "指定消防设备的风险点列表")
@RequestMapping(value = "/fireequipment/{fireEqumtId}/page", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse pointList(@PathVariable Long fireEqumtId,
@RequestParam(required = false) String name,
@RequestParam int pageNumber,
@RequestParam int pageSize
) {
CommonPageable commonPageable = new CommonPageable(pageNumber, pageSize);
return CommonResponseUtil.success(fireEquipPontService.queryByFireEquimt(fireEqumtId, name, commonPageable));
}
@Permission
@ApiOperation(value = "指定消防设备的风险点列表", notes = "指定消防设备的风险点列表")
@GetMapping(value = "/page")
public CommonResponse page(@ApiParam(value = "起始记录", required = true) @RequestParam Integer pageNumber,
@ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize,
@ApiParam(value = "是否绑定设备(0:否;1:是)") @RequestParam(required = false) Integer isBindDevice,
@ApiParam(value = "监测点编号或者监测点名称模糊匹配") @RequestParam(required = false) String searchValue,
@ApiParam(value = "类型(模拟量:ANALOGUE;开关量:SWITCH)") @RequestParam(required = false) String type) {
Map<String, Object> queryMap = Maps.newHashMap();
ReginParams reginParams =getSelectedOrgInfo();
String compCode=getOrgCode(reginParams);
queryMap.put("pageNumber", pageNumber);
queryMap.put("pageSize", pageSize);
if (isBindDevice != null && isBindDevice == 0) {
queryMap.put("fireEquipmentId", 0);
}
queryMap.put("searchValue", searchValue);
queryMap.put("type", type);
queryMap.put("compCode", compCode);
return fireEquipPontService.queryByMap(queryMap);
}
@Permission
@ApiOperation(value = "批量绑定", notes = "批量绑定")
@GetMapping(value = "/batch/bindToEquipment")
public CommonResponse batchBindToEquipment(@ApiParam(value = "设备编号", required = true) @RequestParam Long deviceId,
@ApiParam(value = "监测点编号(多个逗号隔开)", required = true) @RequestParam String pointIds) {
if (StringUtils.isEmpty(pointIds)) {
return CommonResponseUtil.failure("监测点编号必填");
}
List<Long> ids = Arrays.stream(pointIds.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
return fireEquipPontService.batchBindToEquipment(deviceId, ids);
}
@Permission
@ApiOperation(value = "批量解绑", notes = "批量解绑")
@GetMapping(value = "/batch/unbindToEquipment")
public CommonResponse batchUnbindToEquipment(@ApiParam(value = "监测点编号(多个逗号隔开)", required = true) @RequestParam String pointIds) {
if (StringUtils.isEmpty(pointIds)) {
return CommonResponseUtil.failure("监测点编号必填");
}
List<Long> ids = Arrays.stream(pointIds.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
return fireEquipPontService.batchUnbindToEquipment(ids);
}
//
// @Permission
// @ApiOperation(value = "添加监测点", notes = "添加监测点")
// @PostMapping(value = "/save")
// public CommonResponse save(@ApiParam(value = "监测点对象", required = true) @RequestBody FireEquipmentPointEntity fireEquipmentPointEntity) {
// if (fireEquipmentPointEntity.getFireEquipmentId() == null) {
// fireEquipmentPointEntity.setFireEquipmentId(0L);
// }
//
//
//
//
// return fireEquipPontService.save(fireEquipmentPointEntity);
// }
// @Permission
// @ApiOperation(value = "修改监测点", notes = "修改监测点")
// @PostMapping(value = "/update")
// public CommonResponse update(@ApiParam(value = "监测点对象", required = true) @RequestBody FireEquipmentPointEntity fireEquipmentPointEntity) {
// FireEquipmentPoint old = fireEquipPontService.queryOne(fireEquipmentPointEntity.getId());
//
// if(old.getId() != 0 ) {
// String[] idArray = new String[] { String.valueOf(old.getId()) };
// if(fireEquipPontService.countImpEquipment(idArray) > 0) {
// String riskSourceNames = fireEquipPontService.findBindRiskSourceStrByPointIds(idArray);
// return CommonResponseUtil.failure("该设备已被风险区域 [" + riskSourceNames + "] 绑定,请先删除绑定关系");
// }
// }
// return fireEquipPontService.update(fireEquipmentPointEntity);
// }
// @Permission
// @ApiOperation(value = "批量删除监测点", notes = "批量删除监测点")
// @GetMapping(value = "/batch/delete")
// public CommonResponse batchDelete(@ApiParam(value = "监测点编号(多个逗号隔开)", required = true) @RequestParam String pointIds) {
// if (StringUtils.isEmpty(pointIds)) {
// return CommonResponseUtil.failure("监测点编号必填");
// }
// String[] idArray = pointIds.split(",");
// if(fireEquipPontService.countImpEquipment(idArray) > 0) {
// String riskSourceNames = fireEquipPontService.findBindRiskSourceStrByPointIds(idArray);
// return CommonResponseUtil.failure("该点位已被风险区域 [" + riskSourceNames + "] 绑定,请先删除绑定关系");
// }
// List<Long> ids = Arrays.stream(pointIds.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
// return fireEquipPontService.batchDelete(ids);
// }
@Permission
@ApiOperation(value = "根据设备类型查询设备", notes = "批量删除监测点")
@GetMapping(value = "/listByType")
public CommonResponse listByType(@ApiParam(value = "装备分类:0-设备类;1-耗材类;2-视频监控;3-灭火器材") @RequestParam(required = false) Integer equipClassify) {
return fireEquipPontService.listByType(equipClassify);
}
}
package com.yeejoin.amos.fas.business.controller;
import com.yeejoin.amos.fas.business.bo.FireParamBo;
import com.yeejoin.amos.fas.business.service.intfc.FireRectificationService;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 安全执行-消防整改 控制器
*
* @author 郑嘉伟
*/
@RestController
@RequestMapping(value = "/api/fireRectification")
@Api(tags = "消防整改")
public class FireRectificationController extends AbstractBaseController {
@Autowired
private FireRectificationService fireRectificationService;
@Permission
@ApiOperation(httpMethod = "GET", value = "按条件查询消防整改列表信息", notes = "按条件查询消防整改列表信息")
@GetMapping(value = "/list")
public CommonResponse queryFireList(
@RequestParam(value = "nameLike") String nameLike,
@RequestParam(value = "sDate") String sDate,
@RequestParam(value = "eDate") String eDate,
@RequestParam(value = "states") int states,
@RequestParam(value = "pageNum") int pageNum,
@RequestParam(value = "pageSize") int pageSize) {
return CommonResponseUtil.success(fireRectificationService.queryFiresAndCount(nameLike,sDate,eDate,states,pageNum,pageSize));
}
@Permission
@ApiOperation(httpMethod = "GET", value = "获取单个单据详细数据", notes = "获取单个单据详细数据")
@GetMapping(value = "/getMoreData")
public CommonResponse seleteOne(@RequestParam(value = "billNo") String billNo){
return CommonResponseUtil.success(fireRectificationService.selectOneById(billNo));
}
@Permission
@ApiOperation(httpMethod = "POST", value = "下载附件", notes = "下载附件")
@PostMapping(value = "/downLoad")
public void downLoad(@RequestBody List<String> path, HttpServletResponse response){
fireRectificationService.downLoadFilesByUrll(path.get(0),response);
}
@Permission
@ApiOperation(httpMethod = "POST", value = "修改表单数据", notes = "修改表单数据")
@PostMapping(value = "/update")
public CommonResponse update(@RequestBody FireParamBo paramBo){
return CommonResponseUtil.success(fireRectificationService.updateByid(paramBo));
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.fas.business.param.CommonPageInfoParam;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.fas.business.service.intfc.IFireCarService;
import com.yeejoin.amos.fas.business.service.intfc.IFireEquipService;
//import com.yeejoin.amos.fas.business.service.intfc.IWaterResourceService;
import com.yeejoin.amos.fas.business.util.CommonPageParamUtil;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.request.CommonRequest;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping(value = "/api/fireSource")
@Api(tags = "消防资源api")
public class FireSourceController extends AbstractBaseController {
@Autowired
private IFireCarService fireCarService;
@Autowired
private IFireEquipService iFireEquipService;
@Autowired
private IEquipmentService iEquipService;
private final Logger log = LoggerFactory.getLogger(FireSourceController.class);
@Permission
@ApiOperation(httpMethod = "DELETE", value = "删除消防装备", notes = "查询单个消防装备")
@RequestMapping(value = "/{ids}", produces = "application/json;charset=UTF-8", method = RequestMethod.DELETE)
public CommonResponse delete(@PathVariable String ids) throws Exception {
String[] idArray = ids.split(",");
if (iEquipService.countImpEquipByIds(idArray) > 0) {
return CommonResponseUtil.failure("该设备已被重点设备绑定,请先删除绑定关系");
}
return CommonResponseUtil.success(iFireEquipService.delete(idArray));
}
/**
* 消防车查询
*
* @return
*/
@Permission
@ApiOperation(httpMethod = "POST", value = "查询消防车", notes = "查询消防车")
@RequestMapping(value = "/fire-car/list", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse queryFireCar(
@ApiParam(value = "查询条件", required = false) @RequestBody(required = false) List<CommonRequest> queryRequests,
@ApiParam(value = "分页参数", required = true) CommonPageable commonPageable) {
CommonPageInfoParam param = CommonPageParamUtil.fillCommonPageInfoParam(queryRequests, commonPageable);
Page<HashMap<String, Object>> carList = fireCarService.queryFireCar(getToken(), getProduct(), getAppKey(), param);
return CommonResponseUtil.success(carList);
}
/**
* 消防车详情查询
*
* @param id
* @return
*/
@Permission
@ApiOperation(httpMethod = "GET", value = "查询消防车", notes = "查询消防车")
@RequestMapping(value = "/fire-car/det/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryFireCar(@ApiParam(value = "查询条件", required = true) @PathVariable Long id) {
// FireCarDetailVo car = fireCarService.findFireCarById(getToken(), getProduct(), getAppKey(), id);
return CommonResponseUtil.success();
}
/**
* 消防装备查询-查询消防装备及视频监控
*
* @return
*/
@Permission
@ApiOperation(httpMethod = "POST", value = "消防装备查询", notes = "消防装备查询")
@RequestMapping(value = "/fire-equip/list", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse queryFireEquipment(
@ApiParam(value = "查询条件", required = false) @RequestBody(required = false) List<CommonRequest> queryRequests,
@ApiParam(value = "分页参数", required = true) CommonPageable commonPageable) {
CommonPageInfoParam param = CommonPageParamUtil.fillCommonPageInfoParam(queryRequests, commonPageable);
Page<HashMap<String, Object>> carList = iFireEquipService.queryFireEquip(param);
return CommonResponseUtil.success(carList);
}
/**
* 配套设备查询
*
* @return
*/
@Permission
@ApiOperation(httpMethod = "POST", value = "配套设备查询", notes = "配套设备查询")
@RequestMapping(value = "/matching-equip/list", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse queryFireEquipmentByProId(
@ApiParam(value = "查询条件", required = false) @RequestBody(required = true) List<CommonRequest> queryRequests,
@ApiParam(value = "分页参数", required = true) CommonPageable commonPageable) {
CommonPageInfoParam param = CommonPageParamUtil.fillCommonPageInfoParam(queryRequests, commonPageable);
Page<HashMap<String, Object>> carList = iFireEquipService.queryFireEquipByProId(param);
return CommonResponseUtil.success(carList);
}
/**
* 生产区域查询查询
*
* @return
*/
@Permission
@ApiOperation(httpMethod = "GET", value = "生产区域查询", notes = "生产区域查询")
@RequestMapping(value = "/fire-equip/area", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryProArea() {
List<String> car = iFireEquipService.findFireEquipArea();
return CommonResponseUtil.success(car);
}
// @Authorization(ingore = true)
@Permission
@ApiOperation(httpMethod = "GET", value = "查询消防设备历史数据", notes = "查询消防设备历史数据")
@RequestMapping(value = "/data/history", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryForFireEquipmentHistory(
@ApiParam(value = "设备名称", required = false) @RequestParam(required = false) String fireEquipmentName,
@ApiParam(value = "按保护对象名称", required = false) @RequestParam(required = false) String equipmentName,
@ApiParam(value = "开始日期", required = false) @RequestParam(required = false) String startTime,
@ApiParam(value = "结束日期", required = false) @RequestParam(required = false) String endTime, int pageNumber,
int pageSize) {
CommonPageable commonPageable = new CommonPageable(pageNumber, pageSize);
return CommonResponseUtil.success(iFireEquipService.queryForFireEquipmentHistory(
StringUtils.trimToNull(fireEquipmentName), StringUtils.trimToNull(equipmentName),
StringUtils.trimToNull(startTime), StringUtils.trimToNull(endTime), commonPageable));
}
@Permission
@ApiOperation(httpMethod = "GET", value = "查询消防设备列表", notes = "查询消防设备列表")
@RequestMapping(value = "/info/page", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryForEquipmentList(
@ApiParam(value = "设备名称", required = false) @RequestParam(required = false) String name,
@ApiParam(value = "设备编号", required = false) @RequestParam(required = false) String code,
@ApiParam(value = "设备类型", required = false) @RequestParam(required = false) String equipClassify,
@ApiParam(value = "是否绑定配套设备", required = false) @RequestParam(required = false) String bindStation,
int pageNumber, int pageSize) {
CommonPageable commonPageable = new CommonPageable(pageNumber, pageSize);
return CommonResponseUtil.success(iFireEquipService.queryForEquipmentList(StringUtils.trimToNull(name),
StringUtils.trimToNull(code), StringUtils.trimToNull(equipClassify), commonPageable,StringUtils.trimToNull(bindStation)));
}
@Permission
@ApiOperation(httpMethod = "GET", value = "消防状态明细信息", notes = "消防状态明细信息")
@RequestMapping(value = "/info/detail", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryForEquipmentList(@ApiParam(value = "设备名称", required = true) @RequestParam String id,
@ApiParam(value = "设备编号", required = true) @RequestParam String type) throws Exception {
try{
return CommonResponseUtil.success(iFireEquipService.queryForDetail(type, Long.valueOf(id)));
}catch (Exception e) {
log.error(e.getMessage(),e);
return CommonResponseUtil.failure("消防装备明细查询失败" + e.getMessage());
}
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.DepartmentBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.bo.RoleBo;
import com.yeejoin.amos.fas.business.feign.PrivilegeFeign;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* @author zjw
* @date 2020-03-30
*/
@RestController
@RequestMapping(value = "/api/loginBytoken")
@Api(tags = "通过userName登录Api")
public class LoginController extends AbstractBaseController{
private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
@Autowired
private PrivilegeFeign privilegeFeign;
@Autowired
private RedisTemplate<String, String> redisTemplate;
@Autowired
private RemoteSecurityService remoteSecurityService;
@Value("${outSystem.user.password}")
private String password;
@Value("${security.productWeb}")
private String product;
@Value("${security.appKey}")
private String appKey;
@ApiOperation(value = "通过userId登录", notes = "查询设备指标")
@GetMapping(value = "/{userId}")
synchronized public ReginParams getBindEquipment(@PathVariable("userId") String userId) throws Exception {
if (ObjectUtils.isEmpty(userId)){
throw new Exception("用户信息不存在");
}
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest();
String token = (String) request.getHeader("token");
ReginParams reginParams;
reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userId, token)), ReginParams.class);
if(reginParams == null){
reginParams = new ReginParams();
Map<String, String> param = new HashMap<>();
param.put("loginId", userId);
param.put("password", password);
Object result = privilegeFeign.login(appKey, product, param).getResult();
if (ObjectUtils.isEmpty(result)){
throw new Exception("缺失登录信息");
}
Map<String ,String > re = (Map<String ,String >) result;
String amosToken = re.get("token");
privilegeFeign.warrant(appKey, product, amosToken);
RequestContext.setToken(amosToken);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
AgencyUserModel userModel = (AgencyUserModel) Privilege.agencyUserClient.getme().getResult();
CompanyModel companyModel = userModel.getCompanys().get(0);
List<DepartmentModel> deptList = remoteSecurityService.getDepartmentTreeByCompanyId(amosToken, product, appKey, companyModel.getSequenceNbr().toString());
if(deptList.size() > 0){
CompanyBo companyBo = convertCompanyModelToBo(companyModel);
DepartmentBo departmentBo = convertDepartmentModelToBo(deptList.get(0));
reginParams.setDepartment(departmentBo);
reginParams.setCompany(companyBo);
}
reginParams.setToken(amosToken);
reginParams.setUserModel(userModel);
redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(reginParams));
redisTemplate.opsForValue().set(buildKey(userId, amosToken), JSONObject.toJSONString(reginParams));
}
return reginParams;
}
private DepartmentBo convertDepartmentModelToBo(DepartmentModel departmentModel){
DepartmentBo departmentBo = new DepartmentBo();
if(departmentModel != null) {
departmentBo.setCompanySeq(departmentModel.getCompanySeq());
departmentBo.setDepartmentDesc(departmentModel.getDepartmentDesc());
departmentBo.setDepartmentName(departmentModel.getDepartmentName());
departmentBo.setLevel(departmentModel.getLevel());
departmentBo.setOrgCode(departmentModel.getOrgCode());
departmentBo.setParentId(departmentModel.getParentId());
departmentBo.setDeptOrgCode(departmentModel.getDeptOrgCode().toString());
departmentBo.setSequenceNbr(departmentModel.getSequenceNbr());
}
return departmentBo;
}
/**
* Model 转 Bo
*/
private CompanyBo convertCompanyModelToBo(CompanyModel companyModel){
CompanyBo companyBo = new CompanyBo();
if(companyModel != null) {
companyBo.setAddress(companyModel.getAddress());
companyBo.setCompanyName(companyModel.getCompanyName());
companyBo.setCompanyOrgCode(companyModel.getCompanyOrgCode());
companyBo.setEmail(companyModel.getEmail());
companyBo.setLandlinePhone(companyModel.getLandlinePhone());
companyBo.setLongitude(companyModel.getLongitude());
companyBo.setLatitude(companyModel.getLatitude());
companyBo.setLevel(companyModel.getLevel());
companyBo.setOrgCode(companyModel.getOrgCode());
companyBo.setSequenceNbr(companyModel.getSequenceNbr());
companyBo.setParentId(companyModel.getParentId());
}
return companyBo;
}
private RoleBo convertRoleModelToBo(RoleModel roleModel) {
RoleBo roleBo = new RoleBo();
if(roleModel != null){
roleBo.setRoleName(roleModel.getRoleName());
roleBo.setRoleType(roleModel.getRoleType());
roleBo.setSequenceNbr(roleModel.getSequenceNbr());
}
return roleBo;
}
private String buildKey(String userId, String token) {
return "region_" + userId + "_" + token;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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