初始化项目

This commit is contained in:
2024-04-01 09:20:31 +08:00
commit fefd704e6e
4694 changed files with 1869737 additions and 0 deletions

View File

@@ -0,0 +1,161 @@
package com.pqs9900.controller.DataInfo;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.pqs9900.pojo.DataInfo.AlarmInfo;
import com.pqs9900.service.DataInfo.AlarmInfoService;
/** @Author denghuajun
* @Description //TODO 告警信息
* @Date 2019/3/15 14:25
**/
@Controller
@RequestMapping(value ="/alarm")
public class AlarmInfoController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(AlarmInfoController.class);
@Autowired
private AlarmInfoService alarmInfoService;
@Autowired
UserLogDetailService userLog;
@RequestMapping(value="alarmTip",method=RequestMethod.GET)
@ResponseBody
public void alarmTip(HttpServletRequest request,String alarmIndex){
alarmInfoService.alarmTip(alarmIndex);
}
/**
* 发送严重告警事件给指定用户
* @author cdf
* @date 2021/8/17
*/
@RequestMapping(value="alarmForSeverity",method=RequestMethod.GET)
@ResponseBody
public void alarmForSeverity(@RequestParam("alarmIndex") String alarmIndex){
alarmInfoService.alarmForSeverity(alarmIndex);
}
@PostMapping( "getAlarmInfo")
@ResponseBody
public HttpResult getAlarmInfo(String startTime, String endTime,String state,String type,Integer alarmLevel,Integer lineGrade,HttpServletRequest request) {
HttpResult result= new HttpResult();
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "getAlarmInfo");
if(!StringUtils.isEmpty(datePojo.getMsg())){
result=PubUtils.assignmentResult(null,500,datePojo.getMsg());
return result;
}
List<AlarmInfo> alarmInfo;
try {
alarmInfo = alarmInfoService.getAlarmInfo(datePojo.getStartTime(), datePojo.getEndTime(),state,type,alarmLevel,lineGrade);
if (null == alarmInfo) {
result.setCode(500);
result.setMessage("告警列表数据为空");
userLog.getLog("查询告警列表", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} else {
result.setCode(200);
result.setBody(alarmInfo);
userLog.getLog("查询告警列表", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
}
} catch (Exception e) {
result.setCode(500);
result.setMessage("获取告警列表失败");
logger.error("后台获取数据出错方法名为getAlarmInfo异常为" + e);
userLog.getLog("查询告警列表", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
}
return result;
}
@PostMapping( "getAlarmInfoDetail")
@ResponseBody
public HttpResult getAlarmInfoDetail(String state,String type,Integer typeIndex,Integer devLineType,String processTime, HttpServletRequest request) {
HttpResult result= new HttpResult();
List<AlarmInfo> alarmInfo;
try {
alarmInfo = alarmInfoService.getAlarmInfoDetail(state,type,typeIndex,devLineType,processTime);
if (null == alarmInfo) {
result.setCode(500);
result.setMessage("告警列表数据为空");
userLog.getLog("查询告警列表", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} else {
result.setCode(200);
result.setBody(alarmInfo);
userLog.getLog("查询告警列表", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
}
} catch (Exception e) {
result.setCode(500);
result.setMessage("获取告警列表失败");
logger.error("后台获取数据出错方法名为getAlarmInfoDetail异常为" + e);
userLog.getLog("查询告警列表", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
}
return result;
}
@PostMapping( "unAlarmInfo")
@ResponseBody
public HttpResult unAlarmInfo(HttpServletRequest request) {
HttpResult result= new HttpResult();
List<AlarmInfo> alarmInfo;
try {
alarmInfo = alarmInfoService.unAlarmInfo();
if (null == alarmInfo) {
result.setCode(500);
result.setMessage("告警列表数据为空");
userLog.getLog("查询告警列表", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} else {
result.setCode(200);
result.setBody(alarmInfo);
userLog.getLog("查询告警列表", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
}
} catch (Exception e) {
result.setCode(500);
result.setMessage("获取告警列表失败");
logger.error("后台获取数据出错方法名为unAlarmInfo异常为" + e.toString());
userLog.getLog("查询告警列表", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
}
return result;
}
@PostMapping( "updateAlarmInfo")
@ResponseBody
public HttpResult updateAlarmInfo(String type,Integer typeIndex,Integer devLineType,HttpServletRequest request) {
HttpResult result= new HttpResult();
try {
alarmInfoService.updateAlarmInfo(type,typeIndex,devLineType);
result.setCode(200);
result.setMessage("处理告警事件成功");
userLog.getLog("处理告警事件", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} catch (Exception e) {
// TODO: handle exception
result.setCode(500);
result.setMessage("处理告警事件失败");
logger.error("处理告警事件失败方法名为updateAlarmInfo异常为" + e);
userLog.getLog("处理告警事件", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
}
return result;
}
}

View File

@@ -0,0 +1,95 @@
package com.pqs9900.controller.DataInfo;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.DeviceType;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UserUtil;
import com.pqs9900.pojo.DataInfo.DevState;
import com.pqs9900.pojo.DataInfo.DevStateDetail;
import com.pqs9900.pojo.DataInfo.FlowDetail;
import com.pqs9900.service.DataInfo.DevStateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
/**
* @Author denghuajun
* @Description //TODO 终端状态
* @Date 2019/3/15 15:40
**/
@Controller
@RequestMapping("devstate")
public class DevStateController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(DevStateController.class);
@Autowired
private DevStateService devStateService;
@Autowired
UserUtil userUtil;
@RequestMapping(value = "getDevStateDetail", method = RequestMethod.POST)
@ResponseBody
public HttpResult getDevStateDetail(HttpServletRequest request, HttpSession session, String startTime, String
endTime) {
HttpResult result;
List<DevStateDetail> devStateDetails = new ArrayList<>();
try {
DeviceType deviceType = userUtil.getOnLineDeviceType();
devStateDetails = devStateService.getDevStateDetail(deviceType.getDataType());
result = PubUtils.assignmentResult(devStateDetails, 200, "获取终端状态成功");
} catch (Exception e) {
logger.error("查询所有终端状态异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取中终端状态错误");
}
return result;
}
@RequestMapping(value = "getDevStateInfo", method = RequestMethod.POST)
@ResponseBody
public HttpResult getDevStateInfo(HttpServletRequest request, HttpSession session, Long devIndex, String startTime, String
endTime) {
HttpResult result;
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "getDevStateInfo");
List<DevStateDetail> devStateDetails = new ArrayList<>();
try {
DeviceType deviceType = userUtil.getOnLineDeviceType();
devStateDetails = devStateService.getDevStateInfo(devIndex, datePojo.getStartTime(), datePojo.getEndTime());
result = PubUtils.assignmentResult(devStateDetails, 200, "获取终端状态统计成功");
} catch (Exception e) {
logger.error("查询所有终端状态统计异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取终端状态统计错误");
}
return result;
}
@RequestMapping(value = "getDeviceDetail", method = RequestMethod.POST)
@ResponseBody
public HttpResult getDeviceDetail(HttpServletRequest request, HttpSession session, Long devIndex) {
HttpResult result;
DevStateDetail devStateDetails;
try {
devStateDetails = devStateService.getDeviceDetail(devIndex);
result = PubUtils.assignmentResult(devStateDetails, 200, "获取终端详情成功");
} catch (Exception e) {
logger.error("查询所有终端详情异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取终端详情错误");
}
return result;
}
}

View File

@@ -0,0 +1,73 @@
package com.pqs9900.controller.DataInfo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.terminal.DeviceUnitPO;
import com.njcn.pojo.terminal.DeviceUnitVO;
import com.njcn.utils.PubUtils;
import com.pqs9900.service.DataInfo.DeviceUnitService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* system
* 装置层单位管理
* @author cdf
* @date 2023/8/17
*/
@RestController
@RequestMapping("deviceUnit")
public class DeviceUnitController {
@Resource
private DeviceUnitService deviceUnitService;
/**
* 新增装置单位
* @author cdf
* @date 2023/8/17
*/
@PostMapping("addUnit")
public HttpResult addUnit(@RequestBody DeviceUnitPO deviceUnitPO){
deviceUnitService.addUnit(deviceUnitPO);
return PubUtils.assignmentResult(null,200,"装置单位配置成功");
}
/**
* 装置单位主列表
* @author cdf
* @date 2023/8/17
*/
@GetMapping("unitTable")
public HttpResult unitTable(@RequestParam("devFlag")Integer devFlag){
List<DeviceUnitVO> deviceUnitVOList = deviceUnitService.unitTable(devFlag);
return PubUtils.assignmentResult(deviceUnitVOList,200,"装置单位配置成功");
}
/**
* 根据监测点获取监测点的单位信息
* @author cdf
* @date 2023/8/17
*/
@GetMapping("lineUnitDetail")
public HttpResult lineUnitDetail(@RequestParam("lineId")Integer lineId){
DeviceUnitVO deviceUnitVO = deviceUnitService.lineUnitDetail(lineId);
return PubUtils.assignmentResult(deviceUnitVO,200,"获取单位成功");
}
/**
* 根据监测点获取监测点的单位信息
* @author cdf
* @date 2023/8/17
*/
@GetMapping("devUnitDetail")
public HttpResult devUnitDetail(@RequestParam("devId")Integer devId){
DeviceUnitPO deviceUnitPO = deviceUnitService.devUnitDetail(devId);
return PubUtils.assignmentResult(deviceUnitPO,200,"获取单位成功");
}
}

View File

@@ -0,0 +1,81 @@
package com.pqs9900.controller.DataInfo;
/**
* @Author denghuajun
* @Description //TODO 终端流量
* @Date 2019/3/15 16:28
**/
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.PatternRegex;
import com.njcn.utils.PubUtils;
import com.pqs9900.mapper.DataInfo.FlowDetailMapper;
import com.pqs9900.pojo.DataInfo.FlowDetail;
import com.pqs9900.pojo.State.MonthYearDayFlow;
import com.pqs9900.service.DataInfo.FlowService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping("flow")
public class FlowController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(FlowController.class);
@Autowired
private FlowDetailMapper flowDetailMapper;
@Autowired
private FlowService flowService;
@RequestMapping(value = "getFlowDetail", method = RequestMethod.POST)
@ResponseBody
public HttpResult getFlowDetail(HttpServletRequest request, HttpSession session, String startTime, String
endTime) {
HttpResult result;
List<FlowDetail> flowDetails=new ArrayList<>();
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "getShow");
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return result;
}
try {
flowDetails = flowDetailMapper.getFlowDetail(datePojo.getStartTime(),datePojo.getEndTime());
result = PubUtils.assignmentResult(flowDetails, 200, "获取终端流量成功");
} catch (Exception e) {
logger.error("查询所有终端流量异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取中终端流量错误");
}
return result;
}
@RequestMapping(value = "getFlowDayDetail", method = RequestMethod.POST)
@ResponseBody
public HttpResult getFlowDayDetail(HttpServletRequest request, HttpSession session, String startTime, Long
devIndex) {
HttpResult result;
List<MonthYearDayFlow> monthYearDayFlows=new ArrayList<>();
try {
monthYearDayFlows = flowService.getFlowDayDetail(devIndex,startTime);
result = PubUtils.assignmentResult(monthYearDayFlows, 200, "获取月份日均流量成功");
} catch (Exception e) {
logger.error("查询所有终端流量异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取中终端流量错误");
}
return result;
}
}

View File

@@ -0,0 +1,197 @@
package com.pqs9900.controller.DataInfo;
import com.njcn.mapper.user.UserMapper;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.sso.pojo.user.User;
import com.njcn.utils.PubUtils;
import com.njcn.utils.XssFilterUtil;
import com.pqs9900.pojo.DataInfo.MiddRun;
import com.pqs9900.pojo.DataInfo.MiddRunState;
import com.pqs9900.pojo.DataInfo.MiddRunTree;
import com.pqs9900.service.DataInfo.MiddRunService;
import com.pqs9900.service.DataInfo.MiddRunStateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @Author denghuajun
* @Description //TODO 中间件表
* @Date 2019/3/15 14:24
**/
@Controller
@RequestMapping("middRun")
public class MiddRunController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(MiddRunController.class);
@Autowired
MiddRunService runService;
@Autowired
MiddRunStateService runStateService;
@Autowired
UserLogDetailService logDetailService;
@Autowired
UserMapper u;
@RequestMapping(value = "getTree", method = RequestMethod.POST)
@ResponseBody
public List<MiddRunTree> getTree(HttpServletRequest request, HttpSession session) {
List<MiddRunTree> result = new ArrayList();
try {
result = runService.getTreeType();
} catch (Exception e) {
logger.error("查询所有中间件信息异常,异常是" + e.toString());
}
return result;
}
@RequestMapping(value = "getShow", method = RequestMethod.POST)
@ResponseBody
public HttpResult getShow(HttpServletRequest request, HttpSession session, String middIndex, String startTime, String
endTime) {
HttpResult result;
DatePojo datePojo;
List<MiddRunState> middRunStates = new ArrayList<>();
datePojo = PubUtils.validateDate(startTime, endTime, "getShow");
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return result;
}
try {
middRunStates = runStateService.getMiddRunState(middIndex, datePojo.getStartTime(), datePojo.getEndTime());
result = PubUtils.assignmentResult(middRunStates, 200, "获取中间件列表成功");
} catch (Exception e) {
logger.error("查询所有中间件信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取中间件列表错误");
}
return result;
}
@RequestMapping(value = "getMiddRunDetail", method = RequestMethod.POST)
@ResponseBody
public HttpResult getMiddRunDetail(HttpServletRequest request, HttpSession session, String middIndex) {
HttpResult result;
List<MiddRun> middRuns=new ArrayList<>();
try {
middRuns = runService.getMiddRun(middIndex);
result = PubUtils.assignmentResult(middRuns, 200, "获取中间件列表成功");
} catch (Exception e) {
logger.error("查询所有中间件信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取中间件列表错误");
}
return result;
}
@RequestMapping(value = "getMiddRunDetails", method = RequestMethod.POST)
@ResponseBody
public HttpResult getMiddRunDetails(HttpServletRequest request, HttpSession session) {
HttpResult result;
List<MiddRun> middRuns=new ArrayList<>();
try {
middRuns = runService.getMiddRuns();
result = PubUtils.assignmentResult(middRuns, 200, "获取中间件列表成功");
} catch (Exception e) {
logger.error("查询所有中间件信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取中间件列表错误");
}
return result;
}
/**
* 新增
*/
@RequestMapping(value = "saveMiddRun", method = RequestMethod.POST)
@ResponseBody
public HttpResult saveMiddRun(String middRunName,String ip,int port) {
HttpResult result;
middRunName = XssFilterUtil.dealString(middRunName);
ip = XssFilterUtil.dealString(ip);
try {
String middRunMessge = runService.saveMiddRun(middRunName,ip,port);
if(middRunMessge.equals("新增成功")){
result = PubUtils.assignmentResult("success", 200, middRunMessge);
}else {
result = PubUtils.assignmentResult("fall", 500, middRunMessge);
}
} catch (Exception e) {
logger.error("新增中间件异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "新增中间件错误");
}
return result;
}
/**
* 修改
*/
@RequestMapping(value = "updateMiddRun", method = RequestMethod.POST)
@ResponseBody
public HttpResult updateMiddRun(String middIndex,String middRunName,String ip,int port) {
HttpResult result;
middRunName = XssFilterUtil.dealString(middRunName);
ip = XssFilterUtil.dealString(ip);
try {
String middRunMessge = runService.updateMiddRun(middIndex,middRunName,ip,port);
if(middRunMessge.equals("修改成功")){
result = PubUtils.assignmentResult("success", 200, middRunMessge);
}else {
result = PubUtils.assignmentResult("fall", 500, middRunMessge);
}
} catch (Exception e) {
logger.error("修改中间件异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "修改中间件错误");
}
return result;
}
/**
* 删除
*/
@RequestMapping(value = "deleteMiddRun", method = RequestMethod.POST)
@ResponseBody
public HttpResult deleteMiddRun(String middIndex) {
HttpResult result;
middIndex = XssFilterUtil.dealString(middIndex);
try {
String middRunMessge = runService.deleteMiddRun(middIndex);
if(middRunMessge.equals("删除成功")){
result = PubUtils.assignmentResult("success", 200, middRunMessge);
}else {
result = PubUtils.assignmentResult("fall", 500, middRunMessge);
}
} catch (Exception e) {
logger.error("删除中间件异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "删除中间件错误");
}
return result;
}
/**
* 根据id查询
*/
@ResponseBody
@PostMapping(value = "selectMiddRun")
public MiddRun selectMiddRun(String middIndex) {
return runService.selectMiddRun(middIndex);
}
}

View File

@@ -0,0 +1,219 @@
package com.pqs9900.controller.DataInfo;
import com.njcn.mapper.user.UserMapper;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UserUtil;
import com.njcn.utils.XssFilterUtil;
import com.pqs9900.controller.business.DeviceController;
import com.pqs9900.pojo.DataInfo.MiddRun;
import com.pqs9900.pojo.DataInfo.Server;
import com.pqs9900.pojo.DataInfo.ServerState;
import com.pqs9900.pojo.DataInfo.ServerTree;
import com.pqs9900.service.DataInfo.ServerService;
import com.pqs9900.service.DataInfo.ServerStateService;
import org.apache.kafka.common.protocol.types.Field;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
* @Author denghuajun
* @Description //TODO 服务器表controller
* @Date 2019/3/15 14:14
**/
@Controller
@RequestMapping("serverstate")
public class ServerController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(ServerController.class);
@Autowired
UserLogDetailService logDetailService;
@Autowired
UserMapper userMapper;
@Autowired
ServerService serverService;
@Autowired
ServerStateService serverStateService;
@Autowired
UserUtil userUtil;
@Autowired
UserMapper u;
/**
* 查询服务器信息
*/
@RequestMapping(value = "getShow", method = RequestMethod.POST)
@ResponseBody
public HttpResult getShow(HttpServletRequest request, HttpSession session, String sevIndex, String startTime,
String endTime) {
HttpResult result;
DatePojo datePojo;
List<ServerState> serverStates = new ArrayList<>();
datePojo = PubUtils.validateDate(startTime, endTime, "getShow");
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return result;
}
try {
serverStates = serverStateService.getServerState(sevIndex, datePojo.getStartTime(), datePojo.getEndTime());
result = PubUtils.assignmentResult(serverStates, 200, "获取服务器信息成功");
} catch (Exception e) {
logger.error("查询所有服务器信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取服务器信息错误");
}
return result;
}
@RequestMapping(value = "getServerDetail", method = RequestMethod.POST)
@ResponseBody
public HttpResult getServerDetail(HttpServletRequest request, HttpSession session, String sevIndex) {
HttpResult result;
List<Server> server=new ArrayList<>();
try {
server = serverService.getServer(sevIndex);
result = PubUtils.assignmentResult(server, 200, "获取服务器信息成功");
} catch (Exception e) {
logger.error("查询所有服务器信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取服务器信息错误");
}
return result;
}
@RequestMapping(value = "getTree", method = RequestMethod.POST)
@ResponseBody
public List<ServerTree> getTree(HttpServletRequest request, HttpSession session) {
List<ServerTree> result = new ArrayList();
try {
result = serverService.getTreeType();
} catch (Exception e) {
logger.error("查询所有服务器信息异常,异常是" + e.toString());
}
return result;
}
@RequestMapping(value = "getServerDetails", method = RequestMethod.POST)
@ResponseBody
public HttpResult getServerDetails(HttpServletRequest request, HttpSession session) {
HttpResult result;
List<Server> server=new ArrayList<>();
try {
server = serverService.getServerDetails();
result = PubUtils.assignmentResult(server, 200, "获取服务器信息成功");
} catch (Exception e) {
logger.error("查询所有服务器信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取服务器信息错误");
}
return result;
}
/**
* 新增
*/
@RequestMapping(value = "saveServer", method = RequestMethod.POST)
@ResponseBody
public HttpResult saveServer(String serverName, String type, String version,String hardware,
String userName,String password,String ip ) {
HttpResult result;
serverName = XssFilterUtil.dealString(serverName);
type = XssFilterUtil.dealString(type);
version = XssFilterUtil.dealString(version);
hardware = XssFilterUtil.dealString(hardware);
userName = XssFilterUtil.dealString(userName);
password = XssFilterUtil.dealString(password);
ip = XssFilterUtil.dealString(ip);
try {
String middRunMessge = serverService.saveServer(serverName,type,version,hardware,userName,password,ip);
if(middRunMessge.equals("新增成功")){
result = PubUtils.assignmentResult("success", 200, middRunMessge);
}else {
result = PubUtils.assignmentResult("fall", 500, middRunMessge);
}
} catch (Exception e) {
logger.error("新增中间件异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "新增中间件错误");
}
return result;
}
/**
* 修改
*/
@RequestMapping(value = "updateServer", method = RequestMethod.POST)
@ResponseBody
public HttpResult updateServer(String sevIndex,String serverName, String type, String version,String hardware,
String userName,String password,String ip ) {
HttpResult result;
serverName = XssFilterUtil.dealString(serverName);
type = XssFilterUtil.dealString(type);
version = XssFilterUtil.dealString(version);
hardware = XssFilterUtil.dealString(hardware);
userName = XssFilterUtil.dealString(userName);
password = XssFilterUtil.dealString(password);
ip = XssFilterUtil.dealString(ip);
try {
String middRunMessge = serverService.updateServer(sevIndex,serverName,type,version,hardware,userName,password,ip);
if(middRunMessge.equals("修改成功")){
result = PubUtils.assignmentResult("success", 200, middRunMessge);
}else {
result = PubUtils.assignmentResult("fall", 500, middRunMessge);
}
} catch (Exception e) {
logger.error("新增中间件异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "新增中间件错误");
}
return result;
}
/**
* 删除
*/
@RequestMapping(value = "deleteServer", method = RequestMethod.POST)
@ResponseBody
public HttpResult deleteServer(String sevIndex) {
HttpResult result;
sevIndex = XssFilterUtil.dealString(sevIndex);
try {
String middRunMessge = serverService.deleteServer(sevIndex);
if(middRunMessge.equals("删除成功")){
result = PubUtils.assignmentResult("success", 200, middRunMessge);
}else {
result = PubUtils.assignmentResult("fall", 500, middRunMessge);
}
} catch (Exception e) {
logger.error("删除中间件异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "删除中间件错误");
}
return result;
}
/**
* 根据id查询
*/
@ResponseBody
@PostMapping(value = "selectServer")
public Server selectServer(String sevIndex) {
return serverService.selectServer(sevIndex);
}
}

View File

@@ -0,0 +1,46 @@
package com.pqs9900.controller.HisData;
import com.njcn.pojo.commons.HttpResult;
import com.pqs9900.util.Homeostasis;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @Author denghuajun
* @Description //TODO 数据的导入
* @Date 2019/3/6 9:16
**/
@Controller
@RequestMapping(value = "hisdata")
public class HisDataDaoController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(HisDataDaoController.class);
@Autowired
private Homeostasis homeostasis;
@RequestMapping(value = "/hisdatadao", method = RequestMethod.POST)
@ResponseBody
public HttpResult hisdatadao(@RequestParam(value = "file", required = false) MultipartFile multipartFile){
HttpResult result = new HttpResult();
try {
String path;
//获取选取文件的路径
}catch (Exception e){
}
return result;
}
}

View File

@@ -0,0 +1,83 @@
package com.pqs9900.controller.business;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.data.EventDetail;
import com.njcn.pojo.data.VdListQueryVO;
import com.njcn.service.data.EventDetailService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
/**
* 区域业务的controller
*/
@Controller
@RequestMapping("/area")
public class AreaController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(AreaController.class);
@Autowired
private EventDetailService eventDetailService;
@Autowired
private UserLogDetailService userLog;
/**
*暂降列表查询
*/
@RequestMapping(value = "getVoltageDetail", method = RequestMethod.POST)
@ResponseBody
public HttpResult getVoltageDetail(@RequestBody VdListQueryVO vdListQueryVO, HttpServletRequest request) {
HttpResult result;
DatePojo datePojo;
datePojo = PubUtils.validateDate(vdListQueryVO.getStartTime(), vdListQueryVO.getEndTime(), "getVoltageDetail");
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return result;
}
String area = vdListQueryVO.getArea();
String type = vdListQueryVO.getType();
BigDecimal minfuzhi = vdListQueryVO.getMinfuzhi();
BigDecimal maxfuzhi = vdListQueryVO.getMaxfuzhi();
BigDecimal mintime = vdListQueryVO.getMintime();
BigDecimal maxtime = vdListQueryVO.getMaxtime();
BigDecimal minseverity = vdListQueryVO.getMinseverity();
BigDecimal maxseverity = vdListQueryVO.getMaxseverity();
List eventType =vdListQueryVO.getEventType();
List eventReason =vdListQueryVO.getEventReason();
List triggerType =vdListQueryVO.getTriggerType();
Integer fileflag = vdListQueryVO.getFileflag();
// 统计时间段内的暂降原因次数、暂降类型次数
List<EventDetail> voltageList;
try {
voltageList = eventDetailService.getVolList(datePojo.getStartTime(), datePojo.getEndTime(), area,type,minfuzhi,maxfuzhi,mintime,maxtime,minseverity,maxseverity,eventType,eventReason,triggerType,fileflag);
if (null == voltageList) {
result = PubUtils.assignmentResult(null, 500, "没有暂降列表的数据");
} else {
result = PubUtils.assignmentResult(voltageList, 200, "获取暂降数据成功");
}
userLog.getLog("查询电压暂降列表", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} catch (Exception e) {
result = PubUtils.assignmentResult(null, 500, "获取暂降数据异常");
userLog.getLog("查询电压暂降列表", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
logger.error("后台获取数据出错方法名为getVoltageDetail异常为" + e);
}
return result;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,124 @@
package com.pqs9900.controller.business;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.data.DataLoss;
import com.njcn.service.data.DataLossService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping(value = "dataloss")
public class DataLossController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(DataLoss.class);
@Autowired
DataLossService dataLossService;
@Autowired
UserLogDetailService logDetailService;
ObjectMapper objectMapper = new ObjectMapper();
/**
* 获取数据缺失情况
*
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
@RequestMapping(value = "getDataLoss", method = RequestMethod.POST)
@ResponseBody
public HttpResult getDataLoss(HttpServletRequest request, @Param(value = "startTime") String startTime, @Param(value =
"endTime") String endTime) throws
JsonProcessingException, AccountException {
HttpResult result = new HttpResult();
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "getDataLoss");
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "校验前台传递时间参数报错");
return result;
}
List<DataLoss> dataLosses = new ArrayList<>();
List<List> list = new ArrayList<>();
int i = 0;
try {
dataLosses = dataLossService.getDataLoss();
if (dataLosses.isEmpty()) {
result = PubUtils.assignmentResult(null, 500, "没有获取到数据缺失情况");
logger.error("获取数据缺失情况失败");
logDetailService.getLog("查询数据缺失", "失败",PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
} else {
for (DataLoss dataLoss : dataLosses) {
List<String> str = new ArrayList<String>();
str.add(String.valueOf(i += 1));
str.add(String.valueOf(dataLoss.getLineIndex()));
str.add(dataLoss.getGdName());
str.add(dataLoss.getSubName());
str.add(dataLoss.getScale());
str.add(dataLoss.getLineName());
List<DataLoss> result1 = dataLossService.getTj(startTime, endTime, dataLoss.getLineIndex());
float avg = 0;
if (result1.isEmpty()) {
avg = 0;
} else {
avg = result1.get(0).getAvg();
}
str.add(String.valueOf((float) (Math.round(avg * 100 * 100)) / 100));
if (avg * 100 > 90) {
str.add("合格");
} else if (avg * 100 < 60) {
str.add("警告");
} else {
str.add("注意");
}
list.add(str);
}
result = PubUtils.assignmentResult(list, 200, "获取数据缺失情况成功");
logger.info("获取数据缺失情况成功");
logDetailService.getLog("查询数据缺失", "成功",PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
}
} catch (Exception e) {
result = PubUtils.assignmentResult(null, 500, "没有获取到数据缺失情况");
logDetailService.getLog("查询数据缺失", "失败",PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
logger.error("获取数据缺失情况失败,异常是" + e.toString());
}
return result;
}
/**
* 获取数据缺失情况
*
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
@RequestMapping(value = "getTj", method = RequestMethod.POST)
@ResponseBody
public List<DataLoss> getTj(HttpServletRequest request, @Param(value = "startTime") String startTime, @Param(value =
"endTime") String endTime, @Param(value = "lineIndex") Long lineIndex) {
List<DataLoss> dataLoss = new ArrayList<DataLoss>();
try {
dataLoss = dataLossService.getDataAll(startTime, endTime, lineIndex);
} catch (Exception e) {
logger.error("获取数据缺失情况异常,异常是" + e.toString());
}
return dataLoss;
}
}

View File

@@ -0,0 +1,68 @@
package com.pqs9900.controller.business;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.data.DatabaseRunning;
import com.njcn.service.data.DatabaseRunningService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping(value = "database")
public class DatabaseRunningController {
@Autowired
DatabaseRunningService databaseRunningService;
@Autowired
UserLogDetailService userLogDetailService;
ObjectMapper objectMapper = new ObjectMapper();
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(DatabaseRunning.class);
/**
* 获取数据库表空间等
*
* @return
* @throws JsonProcessingException
*/
@RequestMapping(value = "getDatabaseRunning", method = RequestMethod.POST)
@ResponseBody
public String getDatabaseRunning(HttpServletRequest request) throws JsonProcessingException {
List<DatabaseRunning> result = new ArrayList<>();
List<List> s = new ArrayList<>();
try {
result = databaseRunningService.getDatabaseRunning();
if (!result.isEmpty()) {
for (DatabaseRunning databaseRunning : result) {
List<String> str = new ArrayList<String>();
str.add(databaseRunning.getTablespacename());
str.add(databaseRunning.getConten());
str.add(String.valueOf(databaseRunning.getTotals()));
str.add(String.valueOf(databaseRunning.getUses()));
str.add(String.valueOf(databaseRunning.getFrees()));
str.add(String.valueOf(databaseRunning.getPonts()));
s.add(str);
}
}
userLogDetailService.getLog("查询数据库运行情况", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
} catch (Exception e) {
userLogDetailService.getLog("查询数据库运行情况", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.error("获取数据表空间异常,异常是" + e.toString());
}
return objectMapper.writeValueAsString(s);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,104 @@
package com.pqs9900.controller.business;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.njcn.enums.LogTypeEnum;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.njcn.mapper.data.GridTopMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.data.IImportGirdTopService;
@Controller
@RequestMapping("/importGridTop")
public class importGridTopController {
GridTopMapper gtm;
@Resource
IImportGirdTopService igridTop;
@Autowired
UserLogDetailService userLogDetailService;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(importGridTopController.class);
//获取所有的拓扑图信息
@RequestMapping(value = "getGirdTop", method = RequestMethod.POST)
@ResponseBody
public HttpResult getGirdTop(HttpServletRequest request, @Param(value = "vollevel") String vollevel) {
HttpResult result = new HttpResult();
try {
List<List> gridTop = igridTop.getGirdTop(vollevel);
if (gridTop.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到拓扑图信息列表");
logger.error("获取拓扑图信息失败");
} else {
result.setCode(200);
result.setBody(gridTop);
result.setMessage("获取拓扑图信息列表成功");
logger.info("获取拓扑图信息成功");
}
} catch (Exception e) {
logger.error("获取拓扑图异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取拓扑图失败");
}
return result;
}
//将excle表中的数据取出来
@RequestMapping(value = "/importGirdTop", method = RequestMethod.POST)
@ResponseBody
public int upload(@RequestParam(value = "file", required = false) MultipartFile file, @Param(value = "volLevel") Integer volLevel, HttpServletRequest request, HttpServletResponse response) {
int result = 0;
/**
* ---------------------------------------------------------------------------------------------------
* xuyang 2020.08.27
* 修改:对上传文件做判断
* 1.文件类型 2.文件大小
*/
//获取文件名
String fileName = file.getOriginalFilename();
//文件大小(此大小为kb)
Long fileSize = file.getSize()/1024;
//文件大小判断
if (fileSize > 3072){
result = 2;
return result;
}
//文件类型判断
if (!fileName.matches("^.+\\.(?i)(xls)$")) {
result = 3;
return result;
}
/**
* over
* ---------------------------------------------------------------------------------------------------
*/
try {
result = igridTop.readExcelFile(file, volLevel);
userLogDetailService.getLog("导入拓扑数据", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
} catch (Exception e) {
logger.error("数据读取异常,异常是" + e.toString());
userLogDetailService.getLog("导入拓扑数据", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result = 0;
}
return result;
}
}

View File

@@ -0,0 +1,279 @@
package com.pqs9900.controller.configuration;
import com.njcn.enums.LogTypeEnum;
import com.njcn.mapper.configuration.ConstantValueMapper;
import com.njcn.mapper.configuration.ProtectControlWordMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.configuration.ConstantValue;
import com.njcn.pojo.configuration.ProtectControlWord;
import com.njcn.service.configuration.ConstantValueService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.njcn.utils.XssFilterUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* @Author denghuajun
* @Description //TODO 定值管理
* @Date 2018/10/15 21:50
**/
@Controller
@RequestMapping(value = "constant")
public class ConstantValueController {
@Autowired
private ConstantValueService cvs;
@Autowired
private ConstantValueMapper cvsm;
@Autowired
private ProtectControlWordMapper pcwm;
@Resource
UserLogDetailService userLog;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(ConstantValueController.class);
@RequestMapping(value = "quarryOutValue", method = RequestMethod.POST)
@ResponseBody
public HttpResult quarryOutValue(HttpServletRequest request, String devtype, String tltName, String isOutIn, long lineIndex) throws AccountException {
HttpResult result = new HttpResult();
List<ConstantValue> quarryOutValue = new ArrayList<>();//简谐波
List<ConstantValue> quarryOutValue1 = new ArrayList<>();//谐波电压
List<ConstantValue> quarryOutValue2 = new ArrayList<>();//谐波电流
List<ConstantValue> quarryOutValue3 = new ArrayList<>();//基本定值
List<List> quarryValue = new ArrayList<>();
//后台Xss攻击处理、包括html/js/sql
devtype = XssFilterUtil.dealString(devtype);
try {
if (isOutIn.equals("out")) { //外部定值
List<ConstantValue> constantValues = cvs.quarryOutValueBase(lineIndex);
if (constantValues.size() != 0 || !constantValues.isEmpty()) {
for (int i = 0; i < constantValues.size(); i++) {
if (constantValues.get(i).getDzType() == 1) {
quarryOutValue3.add(constantValues.get(i));
} else if (constantValues.get(i).getDzType() == 2) {
quarryOutValue2.add(constantValues.get(i));
} else if (constantValues.get(i).getDzType() == 3) {
quarryOutValue1.add(constantValues.get(i));
} else if (constantValues.get(i).getDzType() == 4) {
quarryOutValue.add(constantValues.get(i));
}
}
quarryValue.add(quarryOutValue3);
quarryValue.add(quarryOutValue2);
quarryValue.add(quarryOutValue1);
quarryValue.add(quarryOutValue);
result.setCode(200);
result.setMessage("获取定值信息成功");
userLog.getLog("查询定值信息", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result.setBody(quarryValue);
} else {
result.setCode(500);
result.setMessage("获取定值信息失败");
userLog.getLog("查询定值信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result.setBody(null);
}
} else if (isOutIn.equals("in")) { //内部定值
List<ConstantValue> constantValues = cvs.quarryInValueBase(lineIndex);
if (constantValues.isEmpty()) {
result.setCode(500);
userLog.getLog("查询定值信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result.setMessage("没有配置信息");
} else {
result.setCode(200);
result.setMessage("获取定值信息成功");
userLog.getLog("查询定值信息", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result.setBody(constantValues);
}
}
} catch (Exception e) {
logger.error("获取定值异常,异常是" + e.toString());
userLog.getLog("查询定值信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result = PubUtils.assignmentResult(null, 500, "获取定值失败");
}
return result;
}
//定值更新数据库
@RequestMapping(value = "updateDatabaseValue", method = RequestMethod.POST)
@ResponseBody
public int updateDatabaseValue(HttpServletRequest request, String json) throws AccountException {
int result = 0;
List<Integer> inoutVaule = new ArrayList<>();
try {
JSONObject jsonObject = JSONObject.fromObject(json); //使用net.sf.json.JSONObject对象来解析json
//区分内/外定值
String type = jsonObject.getString("type");
if (type.equals("80")) {//外部定值
int cpuNo = jsonObject.getInt("cpu_no");
inoutVaule = jsonObject.getJSONArray("data");
for (int i = 0; i < inoutVaule.size(); i++) {
Float value = (float) ((JSONArray) inoutVaule).getDouble(i);
//进行外部定值的更正
cvs.updateOut(cpuNo, '%' + type + '%', i + 1, value);
}
result = 1;
} else if (type.equals("90")) {//内部定值
String devtype = jsonObject.getString("dev_type");
int devIndex = jsonObject.getInt("devindex");
inoutVaule = jsonObject.getJSONArray("data");
for (int i = 0; i < inoutVaule.size(); i++) {
int value = inoutVaule.get(i);
try {
if (i == inoutVaule.size() - 1 || i == inoutVaule.size() - 2) {
value = value / 100;
//进行内部定值的更正
cvs.updateIn(devIndex, '%' + type + '%', i + 1, value);
} else {
//进行内部定值的更正
cvs.updateIn(devIndex, '%' + type + '%', i + 1, value);
ConstantValue constantValue = cvs.getConvId(devIndex, type, i + 1);
String property = "";
//根据装置类型和sort进行查询
String pvIndex = constantValue.getPvIndex();
property = Integer.toBinaryString(value);
int strLen = property.length();
if (strLen < 16) {
while (strLen < 16) {
StringBuffer sb = new StringBuffer();
sb.append("0").append(property);//左补0
property = sb.toString();
strLen = property.length();
}
}
char[] ar = property.toCharArray();
for (int j = 0; j < ar.length; j++) {
int flag = ar[j] - 48;
pcwm.updateWord(pvIndex, flag, (ar.length - 1) - j);
}
}
result = 1;
} catch (Exception e) {
result = 0;
}
}
}
} catch (Exception e) {
logger.error("定值存库异常,异常是" + e.toString());
userLog.getLog("配置定值信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 2);
result = 0;
}
return result;
}
//定值描述更新数据库
@RequestMapping(value = "updateDatabase", method = RequestMethod.POST)
@ResponseBody
public int updateDatabase(HttpServletRequest request, int hander, int type, String json1) throws AccountException {
int result = 0;
try {
JSONObject json = JSONObject.fromObject(json1); //使用net.sf.json.JSONObject对象来解析json
//获取方法类型methodname
String methodname = json.getString("methodname");
List<ConstantValue> inoutVaule = new ArrayList<>();
//hander 用于匹配 0 定值 1 定值描述
int handers = json.getInt("hander");
//用于判断内外定值 80外部定值 90内部定值
if (handers == handers) {
int devIndex = json.getInt("devindex");//终端id
inoutVaule = json.getJSONArray("data");
JSONObject json_test1 = JSONObject.fromObject(inoutVaule.get(0));
int isint = 0;//用于判断时候删除子表数据
String devtype1 = json_test1.getString("dev_type");
String type2 = json_test1.getString("type");
if (type == 90) {
//cvsm.deleteWord(devtype1);
cvsm.deleteValue(devIndex, '%' + type2 + '%');
isint = 1;
} else if (type == 80) {
int lineIndex = Integer.parseInt(json.getString("lineindex"));
isint = 0;
cvsm.deleteOutValue(lineIndex, '%' + type2 + '%');
}
for (int i = 0; i < inoutVaule.size(); i++) {
String pvIndex = UUID.randomUUID().toString();
List<ProtectControlWord> property = new ArrayList<>();
JSONObject json_test = JSONObject.fromObject(inoutVaule.get(i));
//获取监测点序号、终端类型、定值类型、单位、最大值、最小值、默认值、设定值、描述
int cpuNo = json_test.getInt("cpu_no");
String devType = json_test.getString("dev_type");
int type1 = json_test.getInt("type");
int dzType = 0;
if(type == 80){
dzType = json_test.getInt("dz_type");
}
String unit = json_test.getString("unit");
Float maxValue = (float) json_test.getDouble("maxvalue");
Float minValue = (float) json_test.getDouble("minvalue");
Float defaultvalue = (float) json_test.getDouble("defaultvalue");
Float value = (float) json_test.getDouble("value");
String describe = json_test.getString("describe");
int sort = json_test.getInt("sort");
if (isint == 1) {
property = json_test.getJSONArray("property");
}
ConstantValue constantValue = new ConstantValue();
constantValue.setPvIndex(pvIndex);
constantValue.setCpuNo(cpuNo);
constantValue.setDevType(devType);
constantValue.setType(type1);
constantValue.setDzType(dzType);
constantValue.setUnit(unit);
constantValue.setMaxValue(maxValue);
constantValue.setMinValue(minValue);
constantValue.setDefaultValue(defaultvalue);
constantValue.setValue(value);
constantValue.setDescribe(describe);
constantValue.setSort(sort);
//存库
cvsm.insert(constantValue);
//获取内部定值控制字
if (isint == 1) {
if (property.size() > 1) {
for (int j = 0; j < property.size(); j++) {
JSONObject json_test2 = JSONObject.fromObject(property.get(j));
int typeNum = json_test2.getInt("type_num");
String bit0 = json_test2.getString("bit0");
String bit1 = json_test2.getString("bit1");
String describe1 = json_test2.getString("describe");
int flag = json_test2.getInt("flag");
ProtectControlWord protectControlWord = new ProtectControlWord();
protectControlWord.setPvIndex(pvIndex);
protectControlWord.setTypeNum(typeNum);
protectControlWord.setBit0(bit0);
protectControlWord.setBit1(bit1);
protectControlWord.setDescribe(describe1);
protectControlWord.setFlag(flag);
pcwm.insert(protectControlWord);
}
}
}
}
userLog.getLog("配置定值信息", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = 1;
} else {
userLog.getLog("配置定值信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 2);
result = 0;
}
} catch (Exception e) {
userLog.getLog("配置定值信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 2);
logger.error("定值存库异常,异常是" + e.toString());
result = 0;
}
return result;
}
}

View File

@@ -0,0 +1,393 @@
package com.pqs9900.controller.configuration;
import com.njcn.enums.LogTypeEnum;
import com.njcn.mapper.configuration.DicDataMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.configuration.DicData;
import com.njcn.pojo.configuration.DicType;
import com.njcn.service.configuration.DicDataService;
import com.njcn.service.configuration.DicDataTypeService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.njcn.utils.SerializeUtil;
import com.njcn.utils.UserUtil;
import com.njcn.utils.XssFilterUtil;
import com.njcn.utils.redis.JedisManager;
import net.sf.json.JSONArray;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping(value = "/dic")
public class DicDataTypeController {
@Resource
DicDataTypeService ddts;
@Resource
DicDataService dds;
@Resource
UserLogDetailService userLog;
@Autowired
JedisManager jedisManager;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(DicDataTypeController.class);
/**
* 新增数据字典
*/
@RequestMapping(value = "saveData", method = RequestMethod.POST)
@ResponseBody
public HttpResult saveData(HttpServletRequest request, String dicName, String dicType, int leave, int triphase) throws AccountException {
HttpResult result = new HttpResult();
//后台Xss攻击处理、包括html/js/sql
dicName = XssFilterUtil.dealString(dicName);
dicType = XssFilterUtil.dealString(dicType);
try {
String message = dds.saveData(dicName, dicType, leave, triphase);
if (message.equalsIgnoreCase("新增字典成功!")) {
result.setCode(200);
result.setMessage(message);
result.setBody("success");
userLog.getLog("新增数据字典", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.info("新增数据字典成功");
} else if(message.equalsIgnoreCase("字典名称不可为空")){
result.setCode(501);
result.setMessage(message);
userLog.getLog("新增数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("新增数据字典失败");
} else if(message.equalsIgnoreCase("字典名称包括中文、数字、字母、括号以及点号")){
result.setCode(502);
result.setMessage(message);
userLog.getLog("新增数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("新增数据字典失败");
} else {
result.setCode(500);
result.setMessage(message);
userLog.getLog("新增数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("新增数据字典失败");
}
} catch (Exception e) {
userLog.getLog("新增数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
result = PubUtils.assignmentResult(null, 500, "新增数据字典失败");
}
return result;
}
@ResponseBody
@RequestMapping(value = "setArea", method = RequestMethod.POST)
public List<DicData> setArea() {
List<DicData> list = new ArrayList<>();
try {
list = dds.setArea();
} catch (Exception e) {
logger.error("查询区域信息异常,异常是" + e.toString());
}
return list;
}
// 查询所有数据类型
@ResponseBody
@RequestMapping(value = "All", method = RequestMethod.POST)
public List<DicType> selectAll(@Param(value = "typeId") String typeId) {
List<DicType> list = new ArrayList<>();
try {
list = ddts.All(typeId);
} catch (Exception e) {
logger.error("查询数据类型信息异常,异常是" + e.toString());
}
return list;
}
// 查询所有数据类型
@ResponseBody
@RequestMapping(value = "selectAll", method = RequestMethod.POST)
public List<DicType> selectAll() {
List<DicType> list = new ArrayList<>();
try {
list = ddts.selectAll();
} catch (Exception e) {
logger.error("查询数据类型信息异常,异常是" + e.toString());
}
return list;
}
// 查询所有数据类型
@ResponseBody
@RequestMapping(value = "selectTypeName", method = RequestMethod.POST)
public DicType selectTypeName(@Param(value = "typeId") String typeId) {
DicType list = new DicType();
try {
list = ddts.selectTypeName(typeId);
} catch (Exception e) {
logger.error("查询数据类型异常,异常是" + e.toString());
}
return list;
}
// 查询所有
@ResponseBody
@RequestMapping(value = "seleAll", method = RequestMethod.POST)
public HttpResult seleAll(HttpServletRequest request,String name) throws AccountException {
HttpResult result = new HttpResult();
try {
List<List> deviceList = dds.seleAll(name);
if (deviceList.isEmpty()) {
result.setCode(500);
userLog.getLog("查询数据字典", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result.setMessage("没有配置信息");
} else {
result.setCode(200);
result.setMessage("获取配置信息成功");
userLog.getLog("查询数据字典", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result.setBody(deviceList);
}
} catch (Exception e) {
logger.error("查询所有数据字典异常,异常是" + e.toString());
userLog.getLog("查询数据字典", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result = PubUtils.assignmentResult(null, 500, "没有配置信息");
}
return result;
}
// 根据类型ID查询所有字典数据详情
@ResponseBody
@RequestMapping(value = "selAll", method = RequestMethod.POST)
public HttpResult selAll(HttpServletRequest request,String typeId) throws AccountException {
HttpResult result = new HttpResult();
List<List> deviceList = new ArrayList<>();
try {
if (typeId.equals("0")) {
deviceList = dds.seleAll("");
} else {
deviceList = dds.selAll(typeId);
}
if (deviceList.isEmpty()) {
result.setCode(500);
userLog.getLog("查询数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result.setMessage("没有配置信息");
} else {
result.setCode(200);
userLog.getLog("查询数据字典", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result.setMessage("获取配置信息成功");
result.setBody(deviceList);
}
} catch (Exception e) {
userLog.getLog("查询数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.error("查询所有数据字典异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "没有配置信息");
}
return result;
}
//根據ID查詢所有
@RequestMapping(value = "/selAllId", method = RequestMethod.POST)
@ResponseBody
public List<DicData> selAllId(String typeId) {
List<DicData> dicData = new ArrayList<>();
try {
dicData = dds.selAllId(typeId);
} catch (Exception e) {
logger.error("查询数据字典异常,异常是" + e.toString());
}
return dicData;
}
//根據ID查詢所有
@RequestMapping(value = "/selAllType", method = RequestMethod.POST)
@ResponseBody
public List<DicData> selAllType(String typeId) {
List<DicData> dicData = new ArrayList<>();
JSONArray jsonArray = JSONArray.fromObject(typeId);
String types = (String) jsonArray.getJSONObject(0).get("type");
String[] pointid = types.split(",");
try {
List<String> tmp = new ArrayList<>();
if(pointid.length>0){
for(String type : pointid){
tmp.add(type);
}
}
dicData = dds.selAllType(tmp);
} catch (Exception e) {
logger.error("查询数据字典异常,异常是" + e.toString());
}
return dicData;
}
//根據ID查詢所有
@RequestMapping(value = "/selectId", method = RequestMethod.POST)
@ResponseBody
public DicData selectId(String dicIndex) {
DicData dicData = new DicData();
try {
dicData = dds.selectId(dicIndex);
} catch (Exception e) {
logger.error("查询所有数据字典异常,异常是" + e.toString());
}
return dds.selectId(dicIndex);
}
/**
* 根据字典索引删除字典
*/
@RequestMapping(value = "deleteDataByIndex", method = RequestMethod.POST)
@ResponseBody
public HttpResult deleteDataByIndex(HttpServletRequest request, String index) throws AccountException {
HttpResult result = new HttpResult();
try {
String ip = PubUtils.getIpAddr(request);
String username = TokenManager.getToken().getLoginName();
byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
String key = SerializeUtil.deserialize(value, String.class);
if(key.equals("success")){
String message = dds.deleteDataByIndex(index);
if (message.equalsIgnoreCase("删除字典成功!")) {
result.setCode(200);
result.setMessage(message);
result.setBody("success");
userLog.getLog("删除数据字典", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.info("删除字典成功");
} else {
result.setCode(500);
result.setMessage(message);
userLog.getLog("删除数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("删除字典失败");
}
}else{
result.setCode(500);
result.setMessage("删除字典失败,密码验证失败!");
userLog.getLog("删除数据字典,密码验证失败!", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("删除字典失败");
}
} catch (Exception e) {
logger.error("删除数据字典异常,异常是" + e.toString());
userLog.getLog("删除数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
result = PubUtils.assignmentResult(null, 500, "删除数据字典失败");
}
return result;
}
// 修改字典
@ResponseBody
@RequestMapping(value = "/updateData", method = RequestMethod.POST)
public int update(HttpServletRequest request,@Param(value = "dicName") String dicName, @Param(value = "updateTime") Date updateTime, @Param(value = "dicIndex") String dicIndex, @Param(value = "dicType") String dicType, @Param(value = "dicLeave") Integer dicLeave) throws AccountException {
int flag = 1;
//后台Xss攻击处理、包括html/js/sql
dicName = XssFilterUtil.dealString(dicName);
dicType = XssFilterUtil.dealString(dicType);
if(!StringUtils.isBlank(dicName)) {
if(PubUtils.patternDic(dicName)) {
try {
List<DicData> list = dds.selectName(dicIndex, dicType);
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getDicName().equals(dicName)) {
flag = 0;
}
}
if (flag != 0) {
DicData dic = new DicData();
dic.setDicIndex(dicIndex);
dic.setDicName(dicName);
updateTime = new Date();
DicType dt = new DicType();
dt.setDicTypeIndex(dicType);
dic.setDicType(dt.getDicTypeIndex());
dic.setUpdateTime(updateTime);
dic.setDicLeave(dicLeave);
int state = 1;
dic.setState(state);
dds.updateData(dic);
flag = 1;
userLog.getLog("修改数据字典", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.info("修改数据字典成功");
} else {
flag = 0;
userLog.getLog("修改数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("修改数据字典失败,原因是该数据字典名称已存在");
}
} catch (Exception e) {
// TODO: handle exception
e.getMessage();
}
}else {
userLog.getLog("修改数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("修改数据字典失败,原因是数据字典名称不匹配");
flag = 3;
}
}else {
userLog.getLog("修改数据字典", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("修改数据字典失败,原因是数据字典名称为空");
flag = 2;
}
return flag;
}
@ResponseBody
@RequestMapping(value = "getMangType", method = RequestMethod.POST)
public List<DicData> getMangType() {
List<DicData> dicData = new ArrayList<>();
try {
dicData = dds.getMangType();
} catch (Exception e) {
logger.error("查询所有数据类型异常,异常是" + e.toString());
}
return dicData;
}
@ResponseBody
@RequestMapping(value = "getDicName", method = RequestMethod.POST)
public String getDicName(String devtype) {
String dicName="";
try {
dicName = dds.getDicName(devtype);
} catch (Exception e) {
logger.error("查询所有数据类型异常,异常是" + e.toString());
}
return dicName;
}
@ResponseBody
@RequestMapping(value = "getType", method = RequestMethod.POST)
public List<DicData> getType() {
List<DicData> dicData = new ArrayList<>();
try {
dicData = dds.getType();
} catch (Exception e) {
logger.error("查询所有数据类型异常,异常是" + e.toString());
}
return dicData;
}
@ResponseBody
@RequestMapping(value = "getSystemType", method = RequestMethod.POST)
public List<DicData> getSystemType() {
List<DicData> dicData = new ArrayList<>();
try {
dicData = dds.getSystemType();
} catch (Exception e) {
logger.error("查询所有数据类型异常,异常是" + e.toString());
}
return dicData;
}
}

View File

@@ -0,0 +1,239 @@
package com.pqs9900.controller.configuration;
import com.njcn.enums.DicDataTypeEnum;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.configuration.DicType;
import com.njcn.pojo.configuration.DicTypeTree;
import com.njcn.service.configuration.DicDataService;
import com.njcn.service.configuration.DicDataTypeService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.njcn.utils.SerializeUtil;
import com.njcn.utils.UserUtil;
import com.njcn.utils.XssFilterUtil;
import com.njcn.utils.redis.JedisManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping(value = "/type")
public class DicTypeController {
@Resource
DicDataTypeService ddts;
@Autowired
UserUtil uu;
@Resource
UserLogDetailService userLog;
@Autowired
JedisManager jedisManager;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(DicTypeController.class);
//根据Id查询所有
@RequestMapping(value = "selType", method = RequestMethod.POST)
@ResponseBody
public List<DicType> selType(@Param(value = "dicTypeIndex") String dicTypeIndex) {
List<DicType> dt = new ArrayList<>();
try {
dt = ddts.selTypeId(dicTypeIndex);
} catch (Exception e) {
logger.error("查询所有数据字典异常,异常是" + e.toString());
}
return dt;
}
/**
* 资源列表树
*
* @param request
* @param session
* @return
*/
@RequestMapping(value = "getTree", method = RequestMethod.POST)
@ResponseBody
public List<DicTypeTree> getTree(HttpServletRequest request, HttpSession session) {
List<DicTypeTree> result = new ArrayList();
try {
result = ddts.getTreeType();
} catch (Exception e) {
logger.error("查询所有数据字典异常,异常是" + e.toString());
}
return result;
}
@ResponseBody
@RequestMapping(value = "getLog", method = RequestMethod.POST)
public List<DicType> getLog() {
List<DicType> dicTypes = new ArrayList<>();
List<String> list = new ArrayList<>();
try {
list.add(DicDataTypeEnum.serviceEnum.getName());
list.add(DicDataTypeEnum.systemEnum.getName());
dicTypes = ddts.getLog(list);
} catch (Exception e) {
logger.error("查询日志异常,异常是" + e.toString());
}
return dicTypes;
}
/**
* 新增通用字典
*/
@RequestMapping(value = "saveType", method = RequestMethod.POST)
@ResponseBody
public HttpResult saveType(HttpServletRequest request, String dicTypeName, String dicTypeDescription) {
HttpResult result = new HttpResult();
//后台Xss攻击处理、包括html/js/sql
dicTypeName = XssFilterUtil.dealString(dicTypeName);
dicTypeDescription = XssFilterUtil.dealString(dicTypeDescription);
try {
if(!StringUtils.isBlank(dicTypeName)) {
if(PubUtils.patternTyPe(dicTypeName)) {
if(PubUtils.patternDes500(dicTypeDescription)) {
String message = ddts.saveType(dicTypeName, dicTypeDescription);
if (message.equalsIgnoreCase("新增字典类型成功!")) {
result.setCode(200);
result.setMessage(message);
result.setBody("success");
userLog.getLog("新增字典类型", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.info("新增字典类型成功");
} else if (message.equalsIgnoreCase("字典类型不可为空")) {
result = PubUtils.assignmentResult(null, 501, message);
userLog.getLog("新增字典类型", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("新增字典类型失败");
} else if (message.equalsIgnoreCase("字典类型由中文组成")) {
userLog.getLog("新增字典类型", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 502, message);
logger.error("新增字典类型失败");
} else {
result.setCode(500);
result.setMessage(message);
userLog.getLog("新增字典类型", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("新增字典类型失败");
}
}else {
result.setCode(500);
result.setMessage("描述长度为500内");
userLog.getLog("新增字典类型", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("新增字典类型失败");
}
}else {
result.setCode(500);
result.setMessage("字典类型名称非法");
userLog.getLog("新增字典类型", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("新增字典类型失败");
}
}else {
result.setCode(500);
result.setMessage("字典类型为空");
userLog.getLog("新增字典类型", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("新增字典类型失败");
}
} catch (Exception e) {
logger.error("新增数据字典类型异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "新增字典类型失败");
}
return result;
}
//删除
@ResponseBody
@RequestMapping("/delete")
public int delete(HttpServletRequest request,@Param(value = "dicTypeIndex") String dicTypeIndex) throws AccountException {
DicType dt = new DicType();
int flag = 0;
try {
String ip = PubUtils.getIpAddr(request);
String username = TokenManager.getToken().getLoginName();
byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
String key = SerializeUtil.deserialize(value, String.class);
if(key.equals("success")){
dt.setDicTypeIndex(dicTypeIndex);
flag = ddts.deleteType(dt);
userLog.getLog("删除字典类型", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.info("删除字典类型成功");
}else{
userLog.getLog("删除字典类型", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("删除字典失败");
}
} catch (Exception e) {
userLog.getLog("删除字典类型", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("删除字典失败");
}
return flag;
}
// 修改字典
@ResponseBody
@RequestMapping(value = "/updateType", method = RequestMethod.POST)
public int updateType(HttpServletRequest request,@Param(value = "dicTypeName") String dicTypeName, @Param(value = "updateTime") Date updateTime, @Param(value = "dicTypeIndex") String dicTypeIndex, @Param(value = "dicTypeDiscribe") String dicTypeDiscribe) throws AccountException {
//后台Xss攻击处理、包括html/js/sql
dicTypeName = XssFilterUtil.dealString(dicTypeName);
dicTypeDiscribe = XssFilterUtil.dealString(dicTypeDiscribe);
DicType dt = new DicType();
int flag = 1;
if(!StringUtils.isBlank(dicTypeName)) {
if(PubUtils.patternTyPe(dicTypeName)) {
try {
List<DicType> list = ddts.selectName(dicTypeIndex);
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getDicTypeName().equals(dicTypeName)) {
flag = 0;
logger.error("修改字典类型失败,原因是该字典名称已存在");
userLog.getLog("修改字典类型", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
}
}
if (flag != 0) {
dt.setDicTypeIndex(dicTypeIndex);
dt.setDicTypeName(dicTypeName);
updateTime = new Date();
dt.setUpdateTime(updateTime);
dt.setDicTypeDiscribe(dicTypeDiscribe);
ddts.updateType(dt);
userLog.getLog("修改字典类型", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.info("修改字典类型成功");
}
} catch (Exception e) {
logger.error("修改字典类型异常,异常是"+e.getMessage());
flag = 0;
}
}else {
flag = 3;
userLog.getLog("修改字典类型", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("修改字典类型失败,原因是字典名称非法");
}
}else{
flag = 2;
userLog.getLog("修改字典类型", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("修改字典类型失败,原因是字典名称为空");
}
return flag;
}
}

View File

@@ -0,0 +1,541 @@
package com.pqs9900.controller.configuration;
import cn.hutool.core.io.FileUtil;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.commons.WaveData;
import com.njcn.pojo.configuration.Line;
import com.njcn.service.commons.IWaveService;
import com.njcn.service.configuration.DeviceService;
import com.njcn.service.configuration.LineService;
import com.njcn.service.data.EventDetailService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.shiro.cache.VCache;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.AppConfig;
import com.njcn.utils.PubUtils;
import com.njcn.utils.ZipUtils;
import com.njcn.utils.redis.JedisManager;
import com.pqs9900.service.DataInfo.DownEventService;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.ZipOutputStream;
/**
* @author hongawen
* @Date: 2018/11/5 19:32
*/
@Controller
@RequestMapping("offdata")
public class OffDataController {
private static final Logger logger = LoggerFactory.getLogger(OffDataController.class);
@Autowired
private EventDetailService eventDetailService;
@Autowired
private JedisManager jedisManager;
static VCache cache;
@Autowired
private AppConfig appConfig;
@Autowired
private DeviceService deviceService;
@Autowired
private LineService lineService;
@Autowired
private IWaveService waveService;
@Autowired
private DownEventService downEventService;
@Autowired
private UserLogDetailService userLog;
/**
* 准备离线数据,包括基础配置数据以及日志数据、波形文件数据
*
* @param startTime 起始时间
* @param endTime 截止时间
* @param area 区域
*/
@PostMapping("/waveData")
@ResponseBody
public HttpResult waveData(String startTime, String endTime, String area) {
HttpResult result;
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "waveData");
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return result;
}
try {
//下载前,清空备份的两个文件夹
String item = "njcntemp" + File.separator + "waveTemp9900";
String itemExcel = "njcntemp" + File.separator + "excel9900";
FileUtil.clean(new File(appConfig.getTmppath() + item));
FileUtil.clean(new File(appConfig.getTmppath() + itemExcel));
//表格数据
Boolean flag = eventDetailService.getEventDetailList(area, datePojo.getStartTime(), datePojo.getEndTime());
if (!flag) {
result = PubUtils.assignmentResult(null, 500, "准备配置信息出错");
} else {
Map<String, List<String>> indexList = eventDetailService.getEventDetailIndexList(area, datePojo.getStartTime(), datePojo.getEndTime());
if (CollectionUtils.isEmpty(indexList)) {
result = PubUtils.assignmentResult(null, 500, "没有波形数据");
} else {
result = PubUtils.assignmentResult(indexList, 200, "波形数据准备完毕");
cache.set(TokenManager.getUserId() + TokenManager.getSysType() + "waveFiles", indexList);
}
}
} catch (Exception e) {
logger.error("后台获取数据出错方法名为waveData异常为" + e);
result = PubUtils.assignmentResult(null, 500, "获取暂降事件数据出错,请联系管理员");
}
return result;
}
/**
* 下载波形文件
*/
@RequestMapping("downWaveZip")
public void downZIPFile(HttpServletResponse response) throws Exception {
Map<String, List<String>> files = cache.get(TokenManager.getUserId() + TokenManager.getSysType() + "waveFiles");
if (CollectionUtils.isEmpty(files)) {
return;
}
String key = TokenManager.getUserId() + TokenManager.getSysType();
String excelPath = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, key);
//清除缓存
jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, key);
String zipName = "Comtrade.zip";
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition", "attachment; filename=" + zipName);
ZipOutputStream out = new ZipOutputStream(response.getOutputStream());
try {
String item = "njcntemp" + File.separator + "waveTemp9900";
String itemExcel = "njcntemp" + File.separator + "excel9900";
Iterator<Map.Entry<String, List<String>>> it = files.entrySet().iterator();
File comtrade = new File(appConfig.getTmppath() + item);
FileUtil.clean(comtrade);
while (it.hasNext()) {
Map.Entry<String, List<String>> entry = it.next();
List<String> filePaths = entry.getValue();
File directoryFile = new File(appConfig.getTmppath() + item + File.separator + entry.getKey());
for (String path : filePaths) {
FileUtils.copyFileToDirectory(new File(path), directoryFile);
}
}
FileUtils.copyFileToDirectory(new File(excelPath), comtrade);
ZipUtils.doCompress(comtrade.getPath(), out);
//压缩完毕后,清除这个文件夹下的所有的文件
FileUtil.clean(comtrade);
FileUtil.clean(new File(appConfig.getTmppath() + itemExcel));
response.flushBuffer();
} catch (Exception e) {
logger.error("下载波形文件发生异常,异常是" + e.getMessage());
} finally {
out.close();
}
}
/**
* 上传表格数据,保存入库
*
* @param file 上传的表格
*/
@PostMapping("uploadExcelData")
@ResponseBody
public HttpResult uploadExcelData(@RequestParam(value = "file", required = false) MultipartFile file) throws Exception {
HttpResult result;
/**
* ---------------------------------------------------------------------------------------------------
* xuyang 2020.08.27
* 修改:对上传文件做判断
* 文件大小
*/
//文件大小(此大小为kb)
Long fileSize = file.getSize() / 1024;
//判断文件大小
if (fileSize > 3072) {
result = PubUtils.assignmentResult(null, 500, "上传失败,上传文件超过3M文件过大!");
return result;
}
/**
* over
* ---------------------------------------------------------------------------------------------------
*/
String fileName = file.getOriginalFilename();//获取文件名
if (!fileName.matches("^.+\\.(?i)(xlsx)$")) {
result = PubUtils.assignmentResult(null, 500, "文件类型不对");
return result;
}
Boolean flag;
try {
flag = eventDetailService.dealWithData(file);
if (!flag) {
result = PubUtils.assignmentResult(null, 500, "数据导入失败");
} else {
result = PubUtils.assignmentResult(null, 200, "数据导入成功");
}
} catch (Exception e) {
logger.error(e.toString());
if (e.getMessage().equalsIgnoreCase("读取数据过程有误")) {
result = PubUtils.assignmentResult(null, 500, "读取数据过程有误");
} else if (e.getMessage().equalsIgnoreCase("清洗数据过程有误")) {
result = PubUtils.assignmentResult(null, 500, "清洗数据过程有误");
} else {
result = PubUtils.assignmentResult(null, 500, "数据导入失败");
}
}
return result;
}
/**
* 上传波形数据、监测点索引,保存入库
*
* @param multfile 上传的波形CFG文件
*/
@PostMapping("uploadWaveData")
@ResponseBody
public HttpResult uploadWaveData(@RequestParam(value = "file", required = false) MultipartFile multfile, String deviceIndex, String lineIndex, HttpServletRequest request) {
HttpResult result;
//首先根据deviceIndex获取IP确定文件需要保存的文件夹路径
if (StringUtils.isEmpty(deviceIndex) || StringUtils.isEmpty(lineIndex)) {
return PubUtils.assignmentResult(null, 500, "装置或检测点索引为空");
}
String ip = deviceService.getIPByIndex(deviceIndex);
if (StringUtils.isEmpty(ip)) {
return PubUtils.assignmentResult(null, 500, "装置IP为空");
}
//拷贝文件到指定文件夹下
String path;
try {
String filePath = appConfig.getWavePath() + File.separator + ip + File.separator + multfile.getOriginalFilename();
File file = new File(filePath);
FileUtils.copyInputStreamToFile(multfile.getInputStream(), file);
path = file.getPath();
} catch (Exception e) {
logger.error("拷贝上传文件过程出错,原因:" + e.toString());
return PubUtils.assignmentResult(null, 500, "拷贝文件流出错");
}
//文件拷贝成功后,需要将路径保存起来,以便后面分析事件日志参考,注只需要CFG文件的路径
try {
if (!StringUtils.isEmpty(path) & path.toUpperCase(Locale.ENGLISH).endsWith("CFG")) {
String key = "uploadWave" + TokenManager.getUserId();
Map<String, List<String>> pathsTemp = cache.get(key);
List<String> paths;
if (pathsTemp == null) {
paths = new ArrayList<>();
pathsTemp = new HashMap<>();
} else {
paths = pathsTemp.get(key);
if (CollectionUtils.isEmpty(paths)) {
paths = new ArrayList<>();
}
}
paths.add(path);
pathsTemp.put(key, paths);
cache.set(key, pathsTemp);
}
result = PubUtils.assignmentResult(null, 200, "保存文件路径成功");
userLog.getLog("上传离线波形文件", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} catch (Exception e) {
logger.error("保存文件路径出错,原因:" + e.toString());
result = PubUtils.assignmentResult(null, 500, "保存文件路径出错");
userLog.getLog("上传离线波形文件", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
}
return result;
}
/**
* 根据上面存的路径,录入波形日志
*
* @param lineIndex 监测点索引
*/
@PostMapping("saveWaveDetail")
@ResponseBody
public HttpResult saveWaveDetail(String lineIndex) {
HttpResult result;
//首先根据deviceIndex获取IP确定文件需要保存的文件夹路径
if (StringUtils.isEmpty(lineIndex)) {
return PubUtils.assignmentResult(null, 500, "检测点索引为空");
}
String key = "uploadWave" + TokenManager.getUserId();
Map<String, List<String>> pathsTemp = cache.get(key);
List<String> paths = pathsTemp.get(key);
//用完就删
cache.set(key, new HashMap<String, List<String>>());
if (CollectionUtils.isEmpty(paths)) {
return PubUtils.assignmentResult(null, 500, "没有事件需要保存");
}
try {
eventDetailService.saveEventDetail(lineIndex, paths);
result = PubUtils.assignmentResult(null, 200, "全部保存成功");
} catch (Exception e) {
logger.error("事件存库出现异常,原因:" + e.toString());
result = PubUtils.assignmentResult(null, 500, "事件存库出现异常");
}
return result;
}
/**
* @param multfile 上传的波形CFG文件
*/
@PostMapping("viewWave")
@ResponseBody
public HttpResult viewWave(@RequestParam(value = "file", required = false) MultipartFile multfile) {
String originalFilename = multfile.getOriginalFilename();
originalFilename = originalFilename.substring(originalFilename.length() - 4);
if (!originalFilename.equalsIgnoreCase(".CFG") && !originalFilename.equalsIgnoreCase(".DAT")) {
return PubUtils.assignmentResult(null, 500, "文件类型有误");
}
HttpResult result;
//首先根据deviceIndex获取IP确定文件需要保存的文件夹路径
//拷贝文件到指定文件夹下
String path;
try {
String filePath = appConfig.getTmppath() + File.separator + "waveTemp" + File.separator + multfile.getOriginalFilename();
File file = new File(filePath);
FileUtils.copyInputStreamToFile(multfile.getInputStream(), file);
path = file.getPath();
} catch (Exception e) {
logger.error("拷贝上传文件过程出错,原因:" + e.toString());
return PubUtils.assignmentResult(null, 500, "拷贝文件流出错");
}
//文件拷贝成功后,需要将路径保存起来,以便后面分析事件日志参考,注只需要CFG文件的路径
try {
if (!StringUtils.isEmpty(path) & path.toUpperCase(Locale.ENGLISH).endsWith("CFG")) {
String key = "viewWave" + TokenManager.getUserId();
jedisManager.saveValueByKey(RedisDB.SHORT_TIME_QUERY, key, path, RedisDB.SHORT_TIME);
}
result = PubUtils.assignmentResult(null, 200, "保存文件路径成功");
} catch (Exception e) {
logger.error("保存文件路径出错,原因:" + e.toString());
result = PubUtils.assignmentResult(null, 500, "保存文件路径出错");
}
return result;
}
/**
* 根据上面存的路径,显示波形数据
*/
@PostMapping("showWave")
@ResponseBody
public HttpResult showWave(HttpServletRequest request) {
HttpResult result = PubUtils.initResult(TokenManager.getToken().getLoginName(), request, LogTypeEnum.SYSTEM.toString(), 1);
String key = "viewWave" + TokenManager.getUserId();
String path = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, key);
if (StringUtils.isEmpty(path)) {
return PubUtils.assignmentResultLog(null, 500, "没有波形展示", "离线波形查看", "失败", result);
}
WaveData waveData;
try {
waveData = waveService.getWavedataByPath(path);
if (CollectionUtils.isEmpty(waveData.getSunData())) {
result = PubUtils.assignmentResultLog(null, 500, "没有波形数据", "离线波形查看", "失败", result);
} else {
result = PubUtils.assignmentResultLog(waveData, 200, "获取波形数据成功", "离线波形查看", "成功", result);
}
} catch (Exception e) {
logger.error("获取波形数据异常,原因:" + e.toString());
result = PubUtils.assignmentResultLog(null, 500, "获取波形数据失败", "离线波形查看", "失败", result);
}
return result;
}
/**
* 新增暂降事件及上传波形文件
*
* @author cdf
* @date 2021/9/29
*/
@PostMapping("addEvent")
@ResponseBody
public HttpResult addEventAndWave(@RequestParam(value = "file") MultipartFile[] multfile, Integer lineIndex, String time, Integer ms, String describe, Integer waveType, Integer persistime,Float eventValue,String eventReason,String eventType) {
//首先根据deviceIndex获取IP确定文件需要保存的文件夹路径
if (StringUtils.isEmpty(lineIndex)) {
return PubUtils.assignmentResult(null, 500, "监测点索引为空");
}
if (StringUtils.isEmpty(time) || Objects.isNull(ms)) {
return PubUtils.assignmentResult(null, 500, "暂态发生时间不可为空");
}
if (Objects.isNull(waveType)) {
return PubUtils.assignmentResult(null, 500, "事件类型不可为空");
}
if (Objects.isNull(persistime)) {
return PubUtils.assignmentResult(null, 500, "事件持续时间不可为空");
}
if (Objects.isNull(eventValue)) {
return PubUtils.assignmentResult(null, 500, "特征幅值不可为空");
}
if(StringUtils.isEmpty(eventReason)){
return PubUtils.assignmentResult(null, 500, "暂态原因不可为空");
}
if(StringUtils.isEmpty(eventType)){
return PubUtils.assignmentResult(null, 500, "暂态类型不可为空");
}
Line line = lineService.selectLineByIndex(lineIndex.longValue());
if (Objects.isNull(line)) {
return PubUtils.assignmentResult(null, 500, "获取监测点信息失败,请联系管理员");
}
String ip = deviceService.getIPByIndex(line.getDevIndex().toString());
if (StringUtils.isEmpty(ip)) {
return PubUtils.assignmentResult(null, 500, "装置IP为空");
}
Date times;
SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
times = sdfs.parse(time);
} catch (ParseException e) {
return PubUtils.assignmentResult(null, 500, "时间格式有误");
}
for (MultipartFile multipartFile : multfile) {
//文件大小(此大小为kb)
Long fileSize = multipartFile.getSize() / 1024;
//判断文件大小
if (fileSize > 3072) {
return PubUtils.assignmentResult(null, 500, "上传失败,上传文件超过3M文件过大!");
}
String originalFilename = multipartFile.getOriginalFilename();
originalFilename = originalFilename.substring(originalFilename.length() - 4);
if (!originalFilename.equalsIgnoreCase(".CFG") && !originalFilename.equalsIgnoreCase(".DAT")) {
return PubUtils.assignmentResult(null, 500, "文件类型有误");
}
}
String res;
try {
res = downEventService.addEventAndWave(multfile, lineIndex, times, ms, describe, waveType, persistime, eventValue, eventReason, eventType, ip);
}catch (Exception e){
res = e.getMessage();
}
if ("新增成功".equals(res)) {
return PubUtils.assignmentResult(null, 200, res);
}else {
return PubUtils.assignmentResult(null, 500, res);
}
}
/**
* 新增波形文件
* @author cdf
* @date 2021/10/8
*/
@PostMapping("uploadWaveDetail")
@ResponseBody
public synchronized HttpResult uploadWaveDetail(@RequestParam("file") MultipartFile multfile,String lineIndex, HttpServletRequest request) {
HttpResult result;
//首先根据deviceIndex获取IP确定文件需要保存的文件夹路径
Line line = lineService.selectLineByIndex(Long.parseLong(lineIndex));
if (Objects.isNull(line)) {
return PubUtils.assignmentResult(null, 500, "获取监测点信息失败,请联系管理员");
}
String ip = deviceService.getIPByIndex(line.getDevIndex().toString());
if (StringUtils.isEmpty(ip)) {
return PubUtils.assignmentResult(null, 500, "装置IP为空");
}
//文件大小(此大小为kb)
Long fileSize = multfile.getSize() / 1024;
//判断文件大小
if (fileSize > 3072) {
return PubUtils.assignmentResult(null, 500, "上传失败,上传文件超过3M文件过大!");
}
String originalFilename = multfile.getOriginalFilename();
originalFilename = originalFilename.substring(originalFilename.length() - 4);
if (!originalFilename.equalsIgnoreCase(".CFG") && !originalFilename.equalsIgnoreCase(".DAT")) {
return PubUtils.assignmentResult(null, 500, "文件类型有误");
}
//拷贝文件到指定文件夹下
try {
String filePath = appConfig.getWavePath() + File.separator + ip + File.separator + multfile.getOriginalFilename();
File file = new File(filePath);
File parentFile = file.getParentFile();
if (!parentFile.exists()) {
System.out.println("父文件"+parentFile.exists());
parentFile.mkdirs();
}
if(!file.exists()){
file.createNewFile();
FileUtils.copyInputStreamToFile(multfile.getInputStream(), file);
}else{
return PubUtils.assignmentResult(null, 500, "已存在文件,请勿重复上传");
}
} catch (Exception e) {
logger.error("拷贝上传文件过程出错,原因:" + e.toString());
return PubUtils.assignmentResult(null, 500, "拷贝文件流出错");
}
result = PubUtils.assignmentResult(null, 200, "保存文件路径成功");
userLog.getLog("上传波形文件", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return result;
}
/**
* 修改数据库暂态波形标识
* @author cdf
* @date 2021/10/8
*/
@GetMapping("updateWaveFlag")
@ResponseBody
public HttpResult updateWaveFlag(String evenDetailIndex){
//首先根据deviceIndex获取IP确定文件需要保存的文件夹路径
if (StringUtils.isEmpty(evenDetailIndex)) {
return PubUtils.assignmentResult(null, 500, "事件索引不可为空");
}
Integer res = downEventService.updateWaveFlag(evenDetailIndex);
if(res == 1){
return PubUtils.assignmentResult(null, 200, null);
}else{
return PubUtils.assignmentResult(null, 500, null);
}
}
}

View File

@@ -0,0 +1,80 @@
package com.pqs9900.controller.configuration;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.configuration.ProtectControlWord;
import com.njcn.service.configuration.ProtectControlWordService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @Author denghuajun
* @Description //TODO 内部定值控制字
* @Date 2018/10/24 15:07
**/
@Controller
@RequestMapping(value = "protectcw")
public class ProtectControlWordController {
@Autowired
ProtectControlWordService pcws;
@Resource
UserLogDetailService userLog;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(ConstantValueController.class);
@RequestMapping(value = "getAll", method = RequestMethod.POST)
@ResponseBody
public HttpResult getAll(HttpServletRequest request, String pvIndex) throws AccountException {
HttpResult result = new HttpResult();
try {
List<ProtectControlWord> list = pcws.getAll(pvIndex);
if (list.isEmpty()) {
result.setCode(500);
userLog.getLog("查询定值信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
result.setBody(null);
result.setMessage("没有配置信息");
} else {
result.setCode(200);
result.setMessage("获取定值信息成功");
userLog.getLog("查询定值信息", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
result.setBody(list);
}
} catch (Exception e) {
logger.error("查询定值信息异常,异常是" + e.toString());
userLog.getLog("查询定值信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
result = PubUtils.assignmentResult(null, 500, "查询定值信息失败");
}
return result;
}
@RequestMapping(value = "getIsFT", method = RequestMethod.POST)
@ResponseBody
public int getIsFT(HttpServletRequest request, String pvIndex) throws AccountException {
int isft = 0;
try {
List<ProtectControlWord> list = pcws.getAll(pvIndex);
if (list.isEmpty()) {
isft = 0;
} else {
isft = 1;
}
} catch (Exception e) {
logger.error("查询定值信息异常,异常是" + e.toString());
userLog.getLog("查询定值信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
isft = 0;
}
return isft;
}
}

View File

@@ -0,0 +1,683 @@
package com.pqs9900.controller.configuration;
import com.njcn.enums.LogTypeEnum;
import com.njcn.mapper.configuration.SysMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.configuration.SysSet;
import com.njcn.pojo.data.FunctionPloyEntity;
import com.njcn.pojo.data.MenuEntity;
import com.njcn.pojo.data.TimerManage;
import com.njcn.sso.pojo.user.User;
import com.njcn.service.configuration.SysService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.AppConfig;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UserUtil;
import com.njcn.utils.XssFilterUtil;
import com.pqs9900.task.MyJobDetail;
import com.pqs9900.task.MySchudler;
import com.pqs9900.task.MyTrigger;
import net.sf.json.JSONArray;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@Controller
@RequestMapping(value = "/sysset")
public class SysController {
@Resource
private SysService sys;
@Resource
UserLogDetailService userLogservice;
@Autowired
AppConfig appConfig;
@Autowired
SysMapper sm;
@Autowired
UserUtil uu;
@Autowired
MySchudler mySchudler;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(SysController.class);
@ResponseBody
@RequestMapping(value = "selectSys", method = RequestMethod.POST)
public HttpResult selectAll(HttpServletRequest request) {
HttpResult result = new HttpResult();
try {
List<List> set = sys.getSysList();
if (set.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到系统配置列表");
userLogservice.getLog("查询系统配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
logger.error("获取系统配置失败");
} else {
result.setCode(200);
result.setBody(set);
result.setMessage("获取系统配置列表成功");
userLogservice.getLog("查询系统配置", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
logger.info("获取系统配置成功");
}
} catch (Exception e) {
logger.error("查询系统配置异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "查询系统配置失败");
}
return result;
}
//通过ID查询该信息
@ResponseBody
@RequestMapping(value = "selectId", method = RequestMethod.POST)
public List<List> selectId(@Param(value = "sysSetIndex") String sysSetIndex) {
List<List> list = new ArrayList<>();
try {
Example example = new Example(SysSet.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("sysSetIndex", sysSetIndex);
List<SysSet> sysSets = sm.selectByExample(example);
if (!sysSets.isEmpty()) {
for (SysSet sysSet : sysSets) {
List<String> temp = new ArrayList<>();
temp.add(sysSet.getLimitDate().toString());
temp.add(sysSet.getLimitTimes().toString());
temp.add(sysSet.getLimitNumber().toString());
temp.add(String.valueOf(sysSet.getLimitIdle()));
temp.add(String.valueOf(sysSet.getLimitLogout()));
temp.add(sysSet.getCasualUserTime().toString());
temp.add(sysSet.getLogOutTime().toString());
temp.add(sysSet.getLogSize().toString());
temp.add(sysSet.getLockTime().toString());
list.add(temp);
}
}
} catch (Exception e) {
logger.error("查询定值信息异常,异常是" + e.toString());
}
return list;
}
@ResponseBody
@RequestMapping(value = "update", method = RequestMethod.POST)
public HttpResult update(HttpServletRequest request, @Param(value = "sysSetIndex") String sysSetIndex, @Param(value = "limitDate") Integer limitDate, @Param(value = "limitTimes") Integer limitTimes, @Param(value = "limitNumber") Integer limitNumber
, @Param(value = "limitLogOut") Integer limitLogOut, @Param(value = "limitIdle") Integer limitIdle, @Param(value = "casualUserTime") Integer casualUserTime,
@Param(value = "logOutTime") Integer logOutTime, @Param(value = "logSize") Integer logSize, @Param(value = "locktime") Integer locktime) throws AccountException {
SysSet set = new SysSet();
HttpResult result ;
//正则表达
if (limitDate != null) {
if (limitTimes != null) {
if (limitNumber != null) {
if (limitLogOut != null) {
if (limitIdle != null) {
if (casualUserTime != null) {
if (logOutTime != null) {
if (logSize != null) {
if (locktime != null) {
if (PubUtils.patternPMonth(limitDate.toString())) {
if (PubUtils.patternPERROR(limitTimes.toString())) {
if (PubUtils.patternMaxNum(limitNumber.toString())) {
if (PubUtils.patternPMonth(limitIdle.toString())) {
if (PubUtils.patterPUpw(limitLogOut.toString())) {
if (PubUtils.patternPMonth(casualUserTime.toString())) {
if (PubUtils.patternFREE(logOutTime.toString())) {
if (PubUtils.patterLOG(logSize.toString())) {
if (PubUtils.patternUSERLOCK(locktime.toString())) {
//参数合法化校验
if (limitDate < 1 || limitDate > 3) {
result = PubUtils.assignmentResult(null, 500, "密码有效期值非法");
return result;
}
if (limitTimes < 1 || limitTimes > 10) {
result = PubUtils.assignmentResult(null, 500, "密码错误次数值非法");
return result;
}
if (limitNumber < 1 || limitNumber > 100) {
result = PubUtils.assignmentResult(null, 500, "最大并发数值非法");
return result;
}
if (limitIdle < 1) {
result = PubUtils.assignmentResult(null, 500, "闲置用户修改密码值非法");
return result;
}
//注销数值需要控制的比修改密码大
if (limitLogOut < 1) {
result = PubUtils.assignmentResult(null, 500, "闲置用户注销值非法");
return result;
}
if (casualUserTime < 1 || casualUserTime > 3) {
return PubUtils.assignmentResult(null, 500, "临时账号休眠值非法");
}
if (logOutTime < 1 || logOutTime > 12) {
return PubUtils.assignmentResult(null, 500, "休眠账号注销值非法");
}
if (logSize < 1 || logSize > 2) {
return PubUtils.assignmentResult(null, 500, "审计日志容量值非法");
}
if (locktime < 20 || locktime > 60) {
return PubUtils.assignmentResult(null, 500, "用户锁定时长值非法");
}
if (sysSetIndex.equals("0")) {
sysSetIndex = java.util.UUID.randomUUID().toString();
set.setSysSetIndex(sysSetIndex);//guid
set.setLimitDate(limitDate);
set.setLimitTimes(limitTimes);
set.setLimitNumber(limitNumber);
set.setLimitIdle(limitIdle);
set.setLimitLogout(limitLogOut);
User user = TokenManager.getToken();
String userIndex = user.getUserIndex();//当前登录用户
set.setUserIndex(userIndex);
set.setUpdatetime(new Date());
set.setState(1);
set.setCasualUserTime(casualUserTime);
set.setLogOutTime(logOutTime);
set.setLogSize(logSize);
set.setLockTime(locktime);
try {
sm.insert(set);
userLogservice.saveUserLog(TokenManager.getToken().getUserIndex(), TokenManager.getToken().getLoginName(), "系统配置修改", "成功", appConfig.getSystemFlag(), PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.info("成功更改系统配置");
result = PubUtils.assignmentResult(null, 200, "成功更改系统配置");
} catch (Exception e) {
userLogservice.saveUserLog(TokenManager.getToken().getUserIndex(), TokenManager.getToken().getLoginName(), "系统配置修改", "失败", appConfig.getSystemFlag(), PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("更改配置失败");
result = PubUtils.assignmentResult(null, 500, "更改配置失败");
}
} else {
set.setSysSetIndex(sysSetIndex);
set.setLimitDate(limitDate);
set.setLimitTimes(limitTimes);
set.setLimitNumber(limitNumber);
set.setLimitIdle(limitIdle);
set.setLimitLogout(limitLogOut);
User user = TokenManager.getToken();
String userIndex = user.getUserIndex();//当前登录用户
set.setUserIndex(userIndex);
set.setUpdatetime(new Date());
set.setState(1);
set.setCasualUserTime(casualUserTime);
set.setLogOutTime(logOutTime);
set.setLogSize(logSize);
set.setLockTime(locktime);
try {
String detail = userLogservice.updateSysSet(set);
userLogservice.getLogSys("系统配置修改", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1,detail);
logger.info("成功更改系统配置");
result = PubUtils.assignmentResult(null, 200, "成功更改系统配置");
} catch (Exception e) {
// TODO: handle exception
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("更改配置失败");
result = PubUtils.assignmentResult(null, 500, "更改配置失败");
}
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "用户锁定时长值非法");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "审计日志容量值非法");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "休眠账号注销值非法");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "临时账号休眠值非法");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "闲置用户注销值非法");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "闲置用户修改密码值非法");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "最大并发数值非法");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "密码错误次数值非法");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "密码有效期值非法");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "用户锁定时长值为空");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "审计日志容量值为空");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "休眠账号注销值为空");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "临时账号休眠值为空");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "闲置用户注销值为空");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "闲置用户修改密码值为空");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "最大并发数值为空");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "密码错误次数值为空");
}
} else {
userLogservice.getLog("系统配置修改", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "密码有效期值为空");
}
return result;
}
@ResponseBody
@PostMapping("menuList")
public HttpResult listMenu(HttpServletRequest request) {
HttpResult httpResult = new HttpResult();
try {
List<MenuEntity> list = sys.listMenu();
MenuEntity menuEntity = new MenuEntity();
menuEntity.setName("菜单资源");
menuEntity.setGuid("0");
menuEntity.setPath("#");
menuEntity.setMenuType("#");
menuEntity.setMenuName("");
menuEntity.setUpdateTime("");
menuEntity.setMenuDes("");
menuEntity.setParentNode("");
menuEntity.setParentNode(null);
list.add(menuEntity);
httpResult.setCode(200);
httpResult.setBody(list);
httpResult.setMessage("获取菜单列表成功.");
userLogservice.getLog("查询菜单列表", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} catch (Exception e) {
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("获取菜单列表失败.");
userLogservice.getLog("查询菜单列表", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
return httpResult;
}
@ResponseBody
@PostMapping("/menuTypeList")
public HttpResult listType() {
HttpResult httpResult = new HttpResult();
try {
List<MenuEntity> list = sys.menuTypeList();
httpResult.setCode(200);
httpResult.setBody(list);
httpResult.setMessage("获取资源类型成功.");
} catch (Exception e) {
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("获取资源类型失败.");
}
return httpResult;
}
@ResponseBody
@PostMapping("/parentMenuList")
public HttpResult parentMenuList() {
HttpResult httpResult = new HttpResult();
try {
List<MenuEntity> list = sys.parentMenuList();
httpResult.setCode(200);
httpResult.setBody(list);
httpResult.setMessage("获取上级节点成功.");
} catch (Exception e) {
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("获取上级节点失败.");
}
return httpResult;
}
@ResponseBody
@PostMapping("addConfig")
public HttpResult addConfig(HttpServletRequest request, String id, String roleId, String name, String menuIds, String des) {
HttpResult httpResult = new HttpResult();
id = XssFilterUtil.dealString(id);
roleId = XssFilterUtil.dealString(roleId);
name = XssFilterUtil.dealString(name);
menuIds = XssFilterUtil.dealString(menuIds);
des = XssFilterUtil.dealString(des);
JSONArray jsonArray = JSONArray.fromObject(menuIds);
List<String> list = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
list.add(jsonArray.get(i).toString());
}
if (id.equals("")) {
try {//新增配置数据
httpResult.setCode(200);
sys.insertRoleMenuData(UUID.randomUUID().toString(), roleId, name, list, des, new Date(), TokenManager.getToken().getUserIndex(), TokenManager.getSysType());
userLogservice.getLog("角色菜单资源配置", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} catch (Exception e) {
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("新增失败");
userLogservice.getLog("角色菜单资源配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
} else {
try { //更新配置数据
httpResult.setCode(200);
sys.updateRoleMenuData(id, roleId, name, list, des, new Date(), TokenManager.getToken().getUserIndex());
userLogservice.getLog("角色菜单资源配置", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} catch (Exception e) {
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("更新失败");
userLogservice.getLog("角色菜单资源配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
}
return httpResult;
}
@ResponseBody
@PostMapping("addMenu")
public HttpResult addMenu(HttpServletRequest request, String id, String name, String path, String parentSelect, String typeSelect, String des) {
HttpResult httpResult = new HttpResult();
//xss处理
id = XssFilterUtil.dealString(id);
name = XssFilterUtil.dealString(name);
path = XssFilterUtil.dealString(path);
parentSelect = XssFilterUtil.dealString(parentSelect);
typeSelect = XssFilterUtil.dealString(typeSelect);
des = XssFilterUtil.dealString(des);
if (judgeParam(name)) {//非空判断
if (judgeParam(path)) {
if (judgeParam(parentSelect)) {
if (judgeParam(typeSelect)) {
try {
if (PubUtils.patternTF(name)) { //正则校验
if (PubUtils.patterUrl(path)) {
try {
MenuEntity menuEntity = new MenuEntity();
menuEntity.setName(name);
menuEntity.setPath(path);
menuEntity.setParentNode(parentSelect);
menuEntity.setMenuType(typeSelect);
menuEntity.setMenuDes(des);
menuEntity.setDateUpdateTime(new Date());
String userIndex = TokenManager.getToken().getUserIndex();
String sysType = TokenManager.getSysType();
if (judgeParam(id)) { //更新
menuEntity.setGuid(id);
sys.updateData(menuEntity, userIndex);
} else { //新增
String guid = UUID.randomUUID().toString();
menuEntity.setGuid(guid);
sys.insertData(menuEntity, userIndex, sysType);
}
httpResult.setCode(200);
httpResult = PubUtils.assignmentResult(null, 200, "操作菜单资源基础项配置成功");
} catch (Exception e) {
userLogservice.getLog("菜单资源基础项配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "操作菜单资源基础项配置失败");
}
} else {
userLogservice.getLog("菜单资源基础项配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "资源路径非法");
}
} else {
userLogservice.getLog("菜单资源基础项配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "资源名称非法");
}
} catch (Exception e) {
userLogservice.getLog("菜单资源基础项配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "操作菜单资源基础项配置失败");
}
} else {
userLogservice.getLog("菜单资源基础项配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "资源类型为空");
}
} else {
userLogservice.getLog("菜单资源基础项配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "父节点为空");
}
} else {
userLogservice.getLog("菜单资源基础项配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "资源路径为空");
}
} else {
userLogservice.getLog("菜单资源基础项配置", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "资源名称为空");
}
return httpResult;
}
private boolean judgeParam(String s) {
if (!s.equals("") && s != null) {
return true;
}
return false;
}
@ResponseBody
@PostMapping("deleteMenu")
public HttpResult deleteMenu(String id,HttpServletRequest request) {
HttpResult httpResult = new HttpResult();
try {
String userIndex = TokenManager.getToken().getUserIndex();
sys.deleteMenu(id, userIndex, new Date());
httpResult.setCode(200);
httpResult.setMessage("删除成功");
userLogservice.getLog("删除菜单", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} catch (Exception e) {
httpResult.setCode(500);
httpResult.setMessage("删除失败");
userLogservice.getLog("删除菜单", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
return httpResult;
}
@ResponseBody
@PostMapping("getTimerManage")
public HttpResult getTimerManage() {
HttpResult httpResult = new HttpResult();
try {
List<TimerManage> list = sys.getTimerManage();
httpResult.setCode(200);
httpResult.setBody(list);
httpResult.setMessage("获取任务定时器状态成功.");
} catch (Exception e) {
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("获取任务定时器状态失败.");
}
return httpResult;
}
@ResponseBody
@PostMapping("setTimerState")
public HttpResult setTimerState(String guid, Integer state) {
HttpResult httpResult = new HttpResult();
Map<MyTrigger, MyJobDetail> map = mySchudler.getMap();
String str = sys.getTimerManageByGuid(guid);
Iterator<Map.Entry<MyTrigger, MyJobDetail>> iterator = map.entrySet().iterator();
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("设置任务定时器失败.");
while (iterator.hasNext()) {
Map.Entry<MyTrigger, MyJobDetail> m = iterator.next();
if (m.getKey().getCronTrigger().getKey().getGroup().equals(str)) {
if (state == 1)
mySchudler.stopJob(m.getKey());
else
mySchudler.startJob(m.getValue(), m.getKey(), state);
try {
Integer result = sys.setTimerState(guid, state);
if (result == 0) {
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("设置任务定时器失败.");
} else {
httpResult.setCode(200);
httpResult.setBody(null);
httpResult.setMessage("设置任务定时器成功.");
}
} catch (Exception e) {
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("设置任务定时器失败.");
}
}
}
return httpResult;
}
@ResponseBody
@PostMapping("menuPloyList")
public HttpResult menuPloyList(HttpServletRequest request) {
HttpResult httpResult = new HttpResult();
try {
String sysType = TokenManager.getSysType();
List<FunctionPloyEntity> list = sys.menuPloyList(sysType);
httpResult.setCode(200);
httpResult.setBody(list);
httpResult.setMessage("获取角色菜单配置模板策略成功.");
userLogservice.getLog("查询角色菜单配置模板策略", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} catch (Exception e) {
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("获取角色菜单配置模板策略失败.");
userLogservice.getLog("查询角色菜单配置模板策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
return httpResult;
}
@ResponseBody
@PostMapping("roleList")
public HttpResult roleList() {
HttpResult httpResult = new HttpResult();
try {
List<MenuEntity> list = sys.roleList();
MenuEntity menuEntity = new MenuEntity();
menuEntity.setGuid("0");
menuEntity.setName("用户角色");
menuEntity.setParentNode(null);
list.add(menuEntity);
httpResult.setCode(200);
httpResult.setBody(list);
httpResult.setMessage("获取角色成功.");
} catch (Exception e) {
httpResult.setCode(500);
httpResult.setBody(null);
httpResult.setMessage("获取角色失败.");
}
return httpResult;
}
@ResponseBody
@PostMapping("roleStateList")
public HttpResult roleStateList() {
HttpResult httpResult = new HttpResult();
try {
List<String> list = sys.roleStateList(TokenManager.getSysType());
if (list == null || list.isEmpty() || list.size() == 0) {
httpResult.setCode(500);
} else {
httpResult.setCode(200);
httpResult.setBody(list);
}
} catch (Exception e) {
httpResult.setCode(500);
}
return httpResult;
}
@ResponseBody
@PostMapping("deleteMenuPloy")
public HttpResult deleteMenuPloy(String id, String roleId) {
HttpResult httpResult = new HttpResult();
try {
httpResult.setCode(200);
sys.deleteFunctionRoleData(id, new Date(), TokenManager.getToken().getUserIndex(), roleId);
} catch (Exception e) {
httpResult.setCode(500);
}
return httpResult;
}
@ResponseBody
@PostMapping("getRoleFunction")
public HttpResult getRoleFunction(String roleId, String id) {
HttpResult httpResult = new HttpResult();
try {
List<String> list = sys.getRoleFunction(roleId, id);
if (list == null || list.isEmpty() || list.size() == 0) {
httpResult.setCode(500);
} else {
httpResult.setCode(200);
httpResult.setBody(list);
}
} catch (Exception e) {
httpResult.setCode(500);
}
return httpResult;
}
}

View File

@@ -0,0 +1,98 @@
package com.pqs9900.controller.filebackup;
import com.njcn.enums.LogTypeEnum;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.AppConfig;
import com.njcn.utils.PubUtils;
import com.pqs9900.service.filebackup.FileBackUpService;
import com.pqs9900.serviceImpl.HisData.DataFlickerServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* @author xuyang
* @date 2020/9/11 16:49
*/
@Controller
@RequestMapping(value = "fileBackUp")
public class FileBackUpController {
private static final Logger logger= LoggerFactory.getLogger(DataFlickerServiceImpl.class);
@Autowired
private UserLogDetailService userLogDetailService;
@Autowired
private AppConfig appConfig;
@Resource
private FileBackUpService fileBackUpService;
@RequestMapping(value = "writeFile",method = RequestMethod.POST)
@ResponseBody
public Map<String,Object> fileCode(ServletRequest request){
HttpServletRequest httpRequest = (HttpServletRequest) request;
Map<String,Object> map ;
try {
userLogDetailService.saveUserLog(TokenManager.getToken().getUserIndex(), TokenManager.getToken().getLoginName(),"文件备份","成功",appConfig.getSystemFlag(), PubUtils.getIpAddr(httpRequest), LogTypeEnum.SYSTEM.toString(),1);
// if ((int) map.get("code") == 0){
// } else {
// userLogDetailService.saveUserLog(TokenManager.getToken().getUserIndex(), TokenManager.getToken().getLoginName(),"查询结果为0条,备份","成功",appConfig.getSystemFlag(), PubUtils.getIpAddr(httpRequest), LogTypeEnum.SYSTEM.toString(),0);
// }
map = fileBackUpService.fileCode();
} catch (AccountException e) {
try {
userLogDetailService.saveUserLog(TokenManager.getToken().getUserIndex(), TokenManager.getToken().getLoginName(),"文件备份","失败",appConfig.getSystemFlag(), PubUtils.getIpAddr(httpRequest), LogTypeEnum.SYSTEM.toString(),1);
} catch (Exception e1) {
logger.error("用户异常登录日志入库出错," + e1.toString());
}
logger.error("备份失败,异常为:"+e.toString());
map=new HashMap<>();
map.put("code",0);
}
return map;
}
@RequestMapping(value = "deleteUserlog",method = RequestMethod.POST)
@ResponseBody
public Integer deleteUserlog(ServletRequest request){
HttpServletRequest httpRequest = (HttpServletRequest) request;
Integer code = 0;
int deleteLine = fileBackUpService.deleteUserLog();
if (deleteLine > 0){
code = 200;
}
return code;
}
@RequestMapping(value = "fileRecovery",method = RequestMethod.POST)
@ResponseBody
public Map<String,Object> fileRecovery(ServletRequest request){
HttpServletRequest httpRequest = (HttpServletRequest) request;
Map<String,Object> map = fileBackUpService.fileRecovery();
try {
if ((int)map.get("code") == 200){
userLogDetailService.saveUserLog(TokenManager.getToken().getUserIndex(), TokenManager.getToken().getLoginName(),"数据恢复","成功",appConfig.getSystemFlag(), PubUtils.getIpAddr(httpRequest), LogTypeEnum.SYSTEM.toString(),1);
} else {
userLogDetailService.saveUserLog(TokenManager.getToken().getUserIndex(), TokenManager.getToken().getLoginName(),"数据恢复","失败",appConfig.getSystemFlag(), PubUtils.getIpAddr(httpRequest), LogTypeEnum.SYSTEM.toString(),1);
}
}
catch (AccountException e) {
logger.error("恢复失败,异常为:"+e.toString());
}
return map;
}
}

View File

@@ -0,0 +1,110 @@
package com.pqs9900.controller.linedata;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.device.DeviceGeneral;
import com.njcn.service.configuration.DeviceService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.pqs9900.pojo.linedata.HalfReportRVO;
import com.pqs9900.pojo.linedata.OnlineRateCldRVO;
import com.pqs9900.service.linedata.AreaIntegralityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* system
*
* @author cdf
* @date 2021/12/6
*/
@RestController
@RequestMapping("areaData")
public class AreaIntegralityController {
@Resource
private AreaIntegralityService areaIntegralityService;
/**
* 区域统计--》数据完整性
*
* @param startTime 起始时间
* @param endTime 截止时间
*/
@PostMapping("dataIntegrality")
@ResponseBody
public HttpResult dataIntegrality(String startTime, String endTime, Integer overview,String area,
String scale, String manc, String loadtype,Integer lineGrade, HttpServletRequest request) {
HttpResult result = PubUtils.initResult(TokenManager.getToken().getLoginName(), request, LogTypeEnum.BUSSINESS.toString(), 0);
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "dataIntegrality");
if (!StringUtils.isEmpty(datePojo.getMsg())) {
result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
return result;
}
DeviceGeneral data;
try {
data = areaIntegralityService.getDataIntegrality(datePojo.getStartTime(), datePojo.getEndTime(), overview,area,scale, manc, loadtype,lineGrade);
if (null == data) {
result = PubUtils.assignmentResultLog(null, 500, "获取数据完整性数据为空", "查询数据完整性", "成功", result);
} else {
result = PubUtils.assignmentResultLog(data, 200, "获取数据完整性数据成功", "查询数据完整性", "成功", result);
}
} catch (Exception e) {
result = PubUtils.assignmentResultLog(null, 500, "获取数据完整性数据异常", "查询数据完整性", "失败", result);
}
return result;
}
/**
*区域统计--》终端状态
*/
@PostMapping("deviceStatus")
@ResponseBody
public HttpResult getDeviceStatus(Integer overview, String area,String scale,String manc,String loadtype,
HttpServletRequest request,String startTime,String endTime,Integer lineGrade) {
HttpResult result=PubUtils.initResult(TokenManager.getToken().getLoginName(),request,LogTypeEnum.BUSSINESS.toString(),0);
DeviceGeneral data ;
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "deviceStatus");
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
return result;
}
try {
data=areaIntegralityService.getDeviceSiftData(overview,area,scale,manc,loadtype,datePojo.getStartTime(),datePojo.getEndTime(),lineGrade);
if(null==data){
result = PubUtils.assignmentResultLog(null, 500, "获取终端运行数据为空","查询稳态终端状态","成功",result);
}else{
result = PubUtils.assignmentResultLog(data, 200, "获取终端运行数据成功","查询稳态终端状态","成功",result);
}
} catch (Exception e) {
e.printStackTrace();
result = PubUtils.assignmentResultLog(null, 500, "获取终端运行数据异常","查询稳态终端状态","失败",result);
}
return result;
}
/**
* 获取半月报监测点详情
* @author cdf
* @date 2022/5/7
*/
@GetMapping("getHalfReportList")
public HttpResult getHalfReportList(String startTime,String endTime,String lineGrade,Integer status,Integer devFlag) {
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getHalfReportList");
if (!StringUtils.isEmpty(datePojo.getMsg())) {
return PubUtils.assignmentResult(null, 500, datePojo.getMsg());
}
List<HalfReportRVO> list = areaIntegralityService.getHalfReportList(datePojo.getStartTime(),datePojo.getEndTime(),lineGrade,status,devFlag);
return PubUtils.assignmentResult(list, 200, "获取成功");
}
}

View File

@@ -0,0 +1,355 @@
package com.pqs9900.controller.linedata;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.pointInfo.LineLedger;
import com.njcn.utils.PubUtils;
import com.pqs9900.listener.LineMarkExcelListener;
import com.pqs9900.pojo.linedata.MarkExcel;
import com.pqs9900.service.linedata.LineMarkService;
import com.pqs9900.util.csv.GetByteEncode;
import com.pqs9900.util.csv.ReadCsvUtil;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;
/**
* system
*
* @author cdf
* @date 2021/10/27
*/
@RestController
@RequestMapping("lineMark")
public class LineMarkController {
@Resource
private LineMarkService lineMarkService;
/**
* 获取监测点台账列表
*
* @author cdf
* @date 2021/10/27
*/
@GetMapping("getLineMark")
public HttpResult getLineMark(Integer status, Integer lineGrade) {
List<LineLedger> list = lineMarkService.getLineMark(status, lineGrade);
if (CollectionUtil.isNotEmpty(list)) {
return PubUtils.assignmentResult(list, 200, "获取成功");
} else {
return PubUtils.assignmentResult(null, 500, "获取失败");
}
}
/**
* 单个新增或修改监测点等级
*
* @author cdf
* @date 2021/11/2
*/
@PostMapping("singleOperate")
public HttpResult singleOperate(Integer lineIndex, String lineGrade) {
if (Objects.isNull(lineIndex)) {
return PubUtils.assignmentResult(null, 500, "参数出错");
}
Integer res = lineMarkService.singleOperate(lineIndex, lineGrade);
if (res == 1) {
return PubUtils.assignmentResult(null, 200, "操作成功");
} else {
return PubUtils.assignmentResult(null, 500, "操作失败");
}
}
/**
* 获取监测点评级
*
* @author cdf
* @date 2021/11/2
*/
@GetMapping("getLineGrade")
public HttpResult getLineGrade(Integer lineIndex) {
LineLedger lineLedger = lineMarkService.getLineGrade(lineIndex);
if (Objects.isNull(lineLedger)) {
return PubUtils.assignmentResult(null, 500, "获取失败");
}
return PubUtils.assignmentResult(lineLedger, 200, "获取成功");
}
/**
* 批量导入监测点评分excel
*
* @author cdf
* @date 2021/10/27
*/
@PostMapping("batchImport")
public HttpResult batchExport(@RequestParam(value = "file") MultipartFile file) {
HttpResult result;
//获取文件名
String fileName = file.getOriginalFilename();
//文件大小(此大小为kb)
Long fileSize = file.getSize() / 1024;
//判断文件大小
if (fileSize > 30720) {
result = PubUtils.assignmentResult(null, 500, "上传失败,上传文件超过30M文件过大!");
return result;
}
if (!fileName.matches("^.+\\.(?i)(xlsx)$") && !fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(csv)$")) {
result = PubUtils.assignmentResult(null, 500, "上传文件类型错误!");
return result;
}
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
} catch (IOException e) {
e.printStackTrace();
return PubUtils.assignmentResult(null, 500, "文件读取异常!");
}
if (fileName.matches("^.+\\.(?i)(csv)$")) {
//解析csv文件
List<MarkExcel> csvList = new ArrayList<>();
BufferedReader bufferedReader = null;
ByteArrayInputStream fis = null;
InputStreamReader isr = null;
byte[] bate = new byte[0];
try {
bate = file.getBytes();
fis = new ByteArrayInputStream(bate);
//指定以当前文件编码读取
isr = new InputStreamReader(fis, GetByteEncode.getEncoding(bate));
bufferedReader = new BufferedReader(isr);
String csvStr;
int flag = 1;
//读取到的内容给line变量
while ((csvStr = bufferedReader.readLine()) != null) {
String msg = "";
if (flag == 1) {
msg = "表头行";
} else {
msg = "" + flag + "";
}
System.out.println(csvStr);
String[] strArr = csvStr.trim().replace("\uFEFF","").split(",");
List<String> strList = Arrays.asList(strArr);
if (CollectionUtil.isEmpty(strList)) {
return PubUtils.assignmentResult(null, 500, msg + "数据缺失!");
}
if (strList.size() != 6) {
return PubUtils.assignmentResult(null, 500, msg + "数据缺失!");
}
if (flag == 1) {
if (!"省份".equals(strList.get(0)) || !"供电公司".equals(strList.get(1)) || !"所属变电站".equals(strList.get(2))
|| !"装置名称".equals(strList.get(3)) || !"监测点名称".equals(strList.get(4)) || !"监测点评级".equals(strList.get(5))) {
return PubUtils.assignmentResult(null, 500, "csv表头出错!");
}
} else {
MarkExcel markExcel = new MarkExcel();
markExcel.setProvince(strList.get(0).trim());
markExcel.setGdName(strList.get(1).trim());
markExcel.setSubName(strList.get(2).trim());
markExcel.setDevName(strList.get(3).trim());
markExcel.setLineName(strList.get(4).trim());
markExcel.setMark(strList.get(5).trim());
csvList.add(markExcel);
}
flag++;
}
if (CollectionUtil.isEmpty(csvList)) {
return PubUtils.assignmentResult(null, 500, "导入数据为空!");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
if (isr != null) {
isr.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
String deal = lineMarkService.dealData(csvList);
if ("操作成功".equals(deal)) {
return PubUtils.assignmentResult(null, 200, deal);
} else {
return PubUtils.assignmentResult(null, 500, deal);
}
} else {
LineMarkExcelListener lineMarkExcelListener = new LineMarkExcelListener(lineMarkService);
try {
EasyExcel.read(inputStream, MarkExcel.class, lineMarkExcelListener).sheet().headRowNumber(1).doRead();
} catch (ExcelAnalysisException e) {
return PubUtils.assignmentResult(null, 500, e.getMessage());
}
}
return PubUtils.assignmentResult(null, 200, "操作成功");
}
/**
* 导出模板
*
* @author cdf
* @date 2021/11/1
*/
/* @GetMapping("exportTemplate")
public void exportTemplate(HttpServletResponse response) {
// 头的策略
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
headWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
try {
response.setContentType("application/force-download");
response.setCharacterEncoding("utf-8");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "No-cache");
response.setDateHeader("Expires", 0);
String encodeFileName = URLEncoder.encode("监测点评级批量模板", "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + encodeFileName + ".xls");
OutputStream outputStream = null;
outputStream = response.getOutputStream();
ExcelWriterBuilder builder = EasyExcel.write(outputStream, MarkExcel.class).registerWriteHandler(new SheetWriteHandler() {
@Override
public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
}
@Override
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
String[] yesOrNo = new String[]{"极重要", "重要", "普通", "不重要"};
Sheet sheet = writeSheetHolder.getSheet();
DataValidationHelper helper = sheet.getDataValidationHelper();//设置下拉框
*//***起始行、终止行、起始列、终止列**//*
CellRangeAddressList addressList = new CellRangeAddressList(1, 1000, 5, 5);
*//***设置下拉框数据**//*
DataValidationConstraint constraint = helper.createExplicitListConstraint(yesOrNo);
DataValidation dataValidation = helper.createValidation(constraint, addressList);
*//***处理Excel兼容性问题**//*
if (dataValidation instanceof XSSFDataValidation) {
dataValidation.setSuppressDropDownArrow(true);
dataValidation.setShowErrorBox(true);
} else {
dataValidation.setSuppressDropDownArrow(false);
}
sheet.addValidationData(dataValidation);
}
}).registerWriteHandler(horizontalCellStyleStrategy);
ExcelWriter excelWriter = builder.build();
WriteSheet sheet1 = EasyExcel.writerSheet(0).head(MarkExcel.class).build();
excelWriter.write(new ArrayList(0), sheet1);
excelWriter.finish();
} catch (IOException e) {
e.printStackTrace();
}
*//* wb.write(outputStream);
wb.close();
outputStream.close();*//*
}*/
/*********************************************************终端在线率*************begin*/
/**
* 获取终端在线率
*
* @author cdf
* @date 2021/11/2
*/
public HttpResult getOnlineData(String area, String begin, String end, String lineGrade) {
return null;
}
public static String getFileCharsetName(InputStream inputStream) throws IOException {
byte[] head = new byte[3];
inputStream.read(head);
String charsetName = "GBK";//或GB2312即ANSI
if (head[0] == -1 && head[1] == -2) //0xFFFE
{
charsetName = "UTF-16";
} else if (head[0] == -2 && head[1] == -1) //0xFEFF
{
charsetName = "Unicode";//包含两种编码格式UCS2-Big-Endian和UCS2-Little-Endian
} else if (head[0] == -27 && head[1] == -101 && head[2] == -98) {
charsetName = "UTF-8"; //UTF-8(不含BOM)
} else if (head[0] == -17 && head[1] == -69 && head[2] == -65) {
charsetName = "UTF-8"; //UTF-8-BOM
}
inputStream.close();
System.out.println("");
return charsetName;
}
/**
* 批量修改停运监测点评级为空
* @author cdf
* @date 2023/7/6
*/
@GetMapping("batchUpdateLineMarkStop")
public HttpResult batchUpdateLineMarkStop(){
boolean flag = lineMarkService.batchUpdateLineMarkStop();
if(flag){
return PubUtils.assignmentResult(null, 200, "操作成功");
}
return PubUtils.assignmentResult(null, 500, "不存在停运评级的监测点");
}
}

View File

@@ -0,0 +1,234 @@
package com.pqs9900.controller.linedata;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.pointInfo.LineLedger;
import com.njcn.utils.PubUtils;
import com.pqs9900.listener.LineMarkWeightExcelListener;
import com.pqs9900.listener.LineMarkWeightExcelListener;
import com.pqs9900.pojo.linedata.LineMarkWeight;
import com.pqs9900.pojo.linedata.LineMarkWeightVo;
import com.pqs9900.pojo.linedata.MarkWeightExcel;
import com.pqs9900.service.linedata.LineMarkWeightService;
import com.pqs9900.util.csv.GetByteEncode;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
* system
* 监测点评分权重
* @author cdf
* @date 2023/8/16
*/
@RestController
@RequestMapping("lineWeightMark")
public class LineMarkWeightController {
@Resource
private LineMarkWeightService lineMarkWeightService;
/**
* 获取监测点台账列表
*
* @author cdf
* @date 2021/10/27
*/
@GetMapping("getLineMarkWeight")
public HttpResult getLineMarkWeight(Integer devFlag, Integer lineGrade) {
List<LineMarkWeightVo> list = lineMarkWeightService.getLineMarkWeight(devFlag, lineGrade);
if (CollectionUtil.isNotEmpty(list)) {
return PubUtils.assignmentResult(list, 200, "获取成功");
} else {
return PubUtils.assignmentResult(null, 500, "获取失败");
}
}
/**
* 单个新增或修改监测点等级
*
* @author cdf
* @date 2021/11/2
*/
@PostMapping("singleOperate")
public HttpResult singleOperate(@RequestBody LineMarkWeight lineMarkWeight) {
Integer res = lineMarkWeightService.singleOperate(lineMarkWeight);
if (res == 1) {
return PubUtils.assignmentResult(null, 200, "操作成功");
} else {
return PubUtils.assignmentResult(null, 500, "操作失败");
}
}
/**
* 获取监测点评级
*
* @author cdf
* @date 2021/11/2
*/
@GetMapping("getLineGrade")
public HttpResult getLineGrade(Integer lineIndex) {
LineLedger lineLedger = lineMarkWeightService.getLineGrade(lineIndex);
if (Objects.isNull(lineLedger)) {
return PubUtils.assignmentResult(null, 500, "获取失败");
}
return PubUtils.assignmentResult(lineLedger, 200, "获取成功");
}
/**
* 批量导入监测点评分excel
*
* @author cdf
* @date 2021/10/27
*/
@PostMapping("batchImportLineWeight")
public HttpResult batchExport(@RequestParam(value = "file") MultipartFile file) {
HttpResult result;
//获取文件名
String fileName = file.getOriginalFilename();
//文件大小(此大小为kb)
Long fileSize = file.getSize() / 1024;
//判断文件大小
if (fileSize > 30720) {
result = PubUtils.assignmentResult(null, 500, "上传失败,上传文件超过30M文件过大!");
return result;
}
if (!fileName.matches("^.+\\.(?i)(xlsx)$") && !fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(csv)$")) {
result = PubUtils.assignmentResult(null, 500, "上传文件类型错误!");
return result;
}
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
} catch (IOException e) {
e.printStackTrace();
return PubUtils.assignmentResult(null, 500, "文件读取异常!");
}
if (fileName.matches("^.+\\.(?i)(csv)$")) {
//解析csv文件
List<MarkWeightExcel> csvList = new ArrayList<>();
BufferedReader bufferedReader = null;
ByteArrayInputStream fis = null;
InputStreamReader isr = null;
byte[] bate;
try {
bate = file.getBytes();
fis = new ByteArrayInputStream(bate);
//指定以当前文件编码读取
isr = new InputStreamReader(fis, GetByteEncode.getEncoding(bate));
bufferedReader = new BufferedReader(isr);
String csvStr;
int flag = 1;
//读取到的内容给line变量
while ((csvStr = bufferedReader.readLine()) != null) {
String msg = "";
if (flag == 1) {
msg = "表头行";
} else {
msg = "" + flag + "";
}
System.out.println(csvStr);
String[] strArr = csvStr.trim().replace("\uFEFF","").split(",");
List<String> strList = Arrays.asList(strArr);
if (CollectionUtil.isEmpty(strList)) {
return PubUtils.assignmentResult(null, 500, msg + "数据缺失!");
}
if (strList.size() != 14) {
return PubUtils.assignmentResult(null, 500, msg + "数据缺失!");
}
if (flag == 1) {
if (!"省份".equals(strList.get(1)) || !"供电公司".equals(strList.get(2)) ||!"所属变电站".equals(strList.get(3))
|| !"装置名称".equals(strList.get(4))||!"监测点名称".equals(strList.get(5))) {
return PubUtils.assignmentResult(null, 500, "csv表头出错!");
}
} else {
MarkWeightExcel MarkWeightExcel = new MarkWeightExcel();
MarkWeightExcel.setIndex(strList.get(0).trim());
MarkWeightExcel.setProvince(strList.get(1).trim());
MarkWeightExcel.setGdName(strList.get(2).trim());
MarkWeightExcel.setSubName(strList.get(3).trim());
MarkWeightExcel.setDevName(strList.get(4).trim());
MarkWeightExcel.setLineName(strList.get(5).trim());
try {
MarkWeightExcel.setCommunFeeMark(Integer.valueOf(strList.get(6)));
MarkWeightExcel.setAssetBelong(Integer.valueOf(strList.get(7)));
MarkWeightExcel.setServiceMark(Integer.valueOf(strList.get(8)));
MarkWeightExcel.setAgentMark(Integer.valueOf(strList.get(9)));
MarkWeightExcel.setCompanyMark(Integer.valueOf(strList.get(10)));
MarkWeightExcel.setUserMark(Integer.valueOf(strList.get(11)));
MarkWeightExcel.setLineTypeMark(Integer.valueOf(strList.get(12)));
MarkWeightExcel.setBusinessMark(Integer.valueOf(strList.get(13)));
} catch (NumberFormatException numberFormatException) {
return PubUtils.assignmentResult(null, 500, msg + "填写的分值格式错误!");
}
csvList.add(MarkWeightExcel);
}
flag++;
}
if (CollectionUtil.isEmpty(csvList)) {
return PubUtils.assignmentResult(null, 500, "导入数据为空!");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
if (isr != null) {
isr.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
String deal = lineMarkWeightService.dealData(csvList);
if ("操作成功".equals(deal)) {
return PubUtils.assignmentResult(null, 200, deal);
} else {
return PubUtils.assignmentResult(null, 500, deal);
}
} else {
LineMarkWeightExcelListener lineMarkWeightExcelListener = new LineMarkWeightExcelListener(lineMarkWeightService);
try {
EasyExcel.read(inputStream, MarkWeightExcel.class, lineMarkWeightExcelListener).sheet().headRowNumber(1).doRead();
} catch (ExcelAnalysisException e) {
return PubUtils.assignmentResult(null, 500, e.getMessage());
}
}
return PubUtils.assignmentResult(null, 200, "操作成功");
}
}

View File

@@ -0,0 +1,321 @@
package com.pqs9900.controller.linedata;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.runmanage.IntergralityData;
import com.njcn.pojo.commons.runmanage.OnlineRateData;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.pqs9900.pojo.linedata.*;
import com.pqs9900.service.linedata.TerminalRunService;
import com.pqs9900.service.terminal.VersionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* system
* 告警策略
* @author cdf
* @date 2021/11/3
*/
@RestController
@RequestMapping("inStrategy")
public class TopStrategyController {
private static final Logger logger = LoggerFactory.getLogger(TopStrategyController.class);
@Resource
private TerminalRunService terminalRunService;
@Autowired
UserLogDetailService userLog;
/**
* 新增
*
* @author cdf
* @date 2021/11/3
*/
@PostMapping("addForRun")
public HttpResult addForRun(@RequestBody TerminalRun terminalRun) {
Integer res = terminalRunService.addForRun(terminalRun);
if (res == 1) {
return PubUtils.assignmentResult(null, 200, "操作成功");
} else if (res == -1) {
return PubUtils.assignmentResult(null, 500, "已存在此等级策略,请勿重复操作");
} else {
return PubUtils.assignmentResult(null, 500, "操作失败");
}
}
/**
* 修改
*
* @author cdf
* @date 2021/11/3
*/
@PostMapping("updateForRun")
public HttpResult updateForRun(@RequestBody TerminalRun terminalRun) {
Integer res = terminalRunService.updateForRun(terminalRun);
if (res == 1) {
return PubUtils.assignmentResult(null, 200, "操作成功");
} else {
return PubUtils.assignmentResult(null, 500, "操作失败");
}
}
/**
* 查询
*
* @author cdf
* @date 2021/11/3
*/
@GetMapping("queryForRun")
public HttpResult queryForRun(String dicIndex) {
TerminalRun terminalRun = terminalRunService.queryForRun(dicIndex);
if (Objects.nonNull(terminalRun)) {
return PubUtils.assignmentResult(terminalRun, 200, "操作成功");
} else {
return PubUtils.assignmentResult(null, 500, "操作失败");
}
}
/**
* 获取所有等级的策略
*
* @author cdf
* @date 2021/11/3
*/
@GetMapping("queryListForRun")
public HttpResult queryListForRun() {
List<TerminalRun> interalStrategy = terminalRunService.queryListForRun();
if (CollectionUtil.isNotEmpty(interalStrategy)) {
return PubUtils.assignmentResult(interalStrategy, 200, "操作成功");
} else {
return PubUtils.assignmentResult(null, 500, "数据为空");
}
}
/**
* 删除
*
* @author cdf
* @date 2021/11/3
*/
@GetMapping("deleteForRun")
public HttpResult deleteForRun(@RequestParam("dicIndex") String dicIndex) {
Integer res = terminalRunService.deleteForRun(dicIndex);
if (res == 1) {
return PubUtils.assignmentResult(null, 200, "操作成功");
} else {
return PubUtils.assignmentResult(null, 500, "操作失败");
}
}
/**
* 运行管理中的终端在线率数据查询展示
*
* @param startTime 起始时间
* @param endTime 截止时间
* @param colorFlag 是否达标
*/
@PostMapping("getOnlineRateData")
@ResponseBody
public HttpResult getOnlineRateData(String startTime, String endTime,Integer lineGrade,Integer colorFlag, HttpServletRequest request) {
HttpResult result = PubUtils.initResult(TokenManager.getToken().getLoginName(), request, LogTypeEnum.BUSSINESS.toString(), 0);
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "getOnlineRateData");
if (!StringUtils.isEmpty(datePojo.getMsg())) {
result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
return result;
}
List<OnlineRateData> onlineRateDatas;
try {
onlineRateDatas = terminalRunService.getOnlineRate(datePojo.getStartTime(), datePojo.getEndTime(),lineGrade,colorFlag);
if (CollectionUtil.isEmpty(onlineRateDatas)) {
result = PubUtils.assignmentResultLog(null, 500, "获取终端在线率数据为空", "查询在线率列表", "成功", result);
} else {
result = PubUtils.assignmentResultLog(onlineRateDatas, 200, "获取终端在线率数据成功", "查询在线率列表", "成功", result);
}
} catch (Exception e) {
e.printStackTrace();
logger.error("获取终端运行数据异常,异常为:" + e.toString());
result = PubUtils.assignmentResultLog(null, 500, "获取终端在线率数据异常", "查询在线率列表", "失败", result);
}
return result;
}
/**
* 运行管理--》监测点数据完整性
*
* @param startTime 起始时间
* @param endTime 截止时间
*/
@PostMapping("getIntegrityData")
@ResponseBody
public HttpResult getIntegrityData(String startTime, String endTime,Integer lineGrade,Integer colorFlag, HttpServletRequest request) {
HttpResult result = PubUtils.initResult(TokenManager.getToken().getLoginName(), request, LogTypeEnum.BUSSINESS.toString(), 0);
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "getIntegrityData");
if (!StringUtils.isEmpty(datePojo.getMsg())) {
result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
return result;
}
IntergralityData intergralityData;
try {
intergralityData = terminalRunService.getDataIntegralityTable(datePojo.getStartTime(), datePojo.getEndTime(),lineGrade,colorFlag);
if (null == intergralityData) {
result = PubUtils.assignmentResultLog(null, 500, "获取监测点数据完整性数据为空", "查询完整性列表", "成功", result);
} else {
result = PubUtils.assignmentResultLog(intergralityData, 200, "获取监测点数据完整性数据成功", "查询完整性列表", "成功", result);
}
// userLog.getLog("查询监测点数据完整性", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} catch (Exception e) {
logger.error("获取终端运行数据异常,异常为:" + e.toString());
result = PubUtils.assignmentResultLog(null, 500, "获取监测点数据完整性数据异常", "查询完整性列表", "成功", result);
// userLog.getLog("查询监测点数据完整性", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
}
return result;
}
/**
* 终端运行异常页面列表初始化
* 获取每日终端异常消息
* @author cdf
* @date 2021/11/9
*/
@PostMapping("getRunExceptionList")
public HttpResult getRunExceptionList(String startTime, String endTime, Integer lineGrade) {
HttpResult result;
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getRunExceptionList");
if (!StringUtils.isEmpty(datePojo.getMsg())) {
result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
return result;
}
List<TopView> list = terminalRunService.getRunExceptionList(datePojo.getStartTime(), datePojo.getEndTime(), lineGrade);
return PubUtils.assignmentResult(list, 200, "获取成功");
}
/**
* 获取指定日期运行异常的装置
* @author cdf
* @date 2021/11/15
*/
@PostMapping("getRunExceptionDetail")
public HttpResult getRunExceptionDetail(String timeId,Integer lineGrade) {
if(StrUtil.isBlank(timeId)){
return PubUtils.assignmentResult(null, 500, "参数校验失败");
}
Date time;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
time = sdf.parse(timeId);
} catch (ParseException e) {
return PubUtils.assignmentResult(null,500,"时间格式出错");
}
List<TopException> list = terminalRunService.getRunExceptionDetail(time,lineGrade);
return PubUtils.assignmentResult(list, 200, "获取成功");
}
/**
* 通过设备id获取指定日期运行异常的装置
* @author cdf
* @date 2021/11/15
*/
@PostMapping("getRunExceptionDetailById")
public HttpResult getRunExceptionDetailById(String timeId,Integer devIndex) {
if(StrUtil.isBlank(timeId)){
return PubUtils.assignmentResult(null, 500, "参数校验失败");
}
Date time;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
time = sdf.parse(timeId);
} catch (ParseException e) {
return PubUtils.assignmentResult(null,500,"时间格式出错");
}
TopException topException= terminalRunService.getRunExceptionDetailById(time,devIndex);
return PubUtils.assignmentResult(topException, 200, "获取成功");
}
/**
* 获取指定日期数据完整性统计
* @author dhj
* @date 2021/12/07
*/
@PostMapping("getDataIntegralityStatis")
public HttpResult getDataIntegralityStatis(String startTime,String endTime,Long lineId) {
List<DataIntegralityStatis> dataIntegralityStatis = new ArrayList<>();
if(StrUtil.isBlank(startTime) && StrUtil.isBlank(endTime)){
return PubUtils.assignmentResult(null, 500, "参数校验失败");
}
try {
dataIntegralityStatis = terminalRunService.getDataIntegralityStatis(lineId,startTime,endTime);
} catch (Exception e) {
return PubUtils.assignmentResult(null,500,"获取失败");
}
return PubUtils.assignmentResult(dataIntegralityStatis, 200, "获取成功");
}
//稳态数据补招补招
@RequestMapping(value = "socketonIntegrityData", method = RequestMethod.POST)
@ResponseBody
public HttpResult socketonIntegrityData(HttpServletRequest request, String type, Long LineId, String startTime,String endTime) {
String result = "";
try {
result = terminalRunService.socketonIntegrityData(type, LineId, startTime,endTime);
if("稳态数据补招命令接收成功".equals(result)){
userLog.getLog("稳态数据补招", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return PubUtils.assignmentResult(null,200,result);
}else{
return PubUtils.assignmentResult(null,500,result);
}
} catch (Exception e) {
userLog.getLog("稳态数据补招", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
logger.error("socket异常异常是" + e.getMessage());
return PubUtils.assignmentResult(null,500,"稳态数据补招异常");
}
}
/**
* 在线率cld主页面
* @author cdf
* @date 2021/12/16
*/
@GetMapping("getOnlineRateCldList")
public HttpResult getOnlineRateCldList(String startTime,String endTime,Integer lineGrade,Integer colorFlag) {
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getOnlineRateCldList");
if (!StringUtils.isEmpty(datePojo.getMsg())) {
return PubUtils.assignmentResult(null, 500, datePojo.getMsg());
}
List<OnlineRateCldRVO> list = terminalRunService.getOnlineRateCldList(datePojo.getStartTime(),datePojo.getEndTime(),lineGrade,colorFlag);
return PubUtils.assignmentResult(list, 200, "获取成功");
}
}

View File

@@ -0,0 +1,307 @@
package com.pqs9900.controller.log;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.njcn.enums.LogTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.njcn.mapper.user.UserMapper;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.log.UserLogDetail;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
@Controller
@RequestMapping(value = "log")
public class UserLogController {
ObjectMapper objectMapper = new ObjectMapper();
@Autowired
private UserMapper userMapper;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(UserLogController.class);
@Autowired
private UserLogDetailService uls;
@RequestMapping(value = "getUserLog", method = RequestMethod.POST)
@ResponseBody
public HttpResult getUserLog(HttpServletRequest request) {
HttpResult result = new HttpResult();
try {
List<List> userLog = uls.getUserLog();
if (userLog.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到日志信息列表");
} else {
result.setCode(200);
result.setBody(userLog);
uls.getLog("查询日志信息", "成功",PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
result.setMessage("获取日志信息列表成功");
}
} catch (Exception e) {
logger.error("查询日志信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "查询日志信息失败");
uls.getLog("查询日志信息", "失败",PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
}
return result;
}
@RequestMapping(value = "getUserLogId", method = RequestMethod.POST)
@ResponseBody
public HttpResult getUserLogId(HttpServletRequest request,String username, String type, String name, String startTime, String endTime) throws JsonProcessingException {
HttpResult result = new HttpResult();
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "getUserLogId");
try {
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "校验前台传递时间参数报错");
return result;
}
List<List> userLog = uls.getUserLogId(username,type, name, datePojo.getStartTime(), datePojo.getEndTime());
if (userLog.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到日志信息列表");
} else {
result.setCode(200);
result.setBody(userLog);
uls.getLog("查询日志信息", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result.setMessage("获取日志信息列表成功");
}
} catch (Exception e) {
logger.error("查询日志信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "查询日志信息失败");
uls.getLog("查询日志信息", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
}
return result;
}
/***
* 统计事件类型
*/
@RequestMapping(value = "geteventtype", method = RequestMethod.POST)
@ResponseBody
public String geteventtype(HttpServletRequest request, String startTime, String endTime) throws JsonProcessingException {
List<UserLogDetail> result = new ArrayList<UserLogDetail>();
List<List> s = new ArrayList<List>();
startTime = startTime + " 00:00:00";
endTime = endTime + " 23:59:59";
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "geteventtype");
try {
result = uls.geteventtype(datePojo.getStartTime(), datePojo.getEndTime());
int j = 0;
for (int i = 0; i < result.size(); i++) {
List<String> a = new ArrayList<String>();
j = j + 1;
a.add(result.get(i).getType());
a.add(result.get(i).getNum().toString());
s.add(a);
}
} catch (Exception e) {
logger.error("查询统计事件异常,异常是" + e.toString());
}
return objectMapper.writeValueAsString(s);
}
/***
* 统计详细事件
*/
@RequestMapping(value = "getdetailtype", method = RequestMethod.POST)
@ResponseBody
public String getdetailtype(HttpServletRequest request, String startTime, String endTime) throws JsonProcessingException {
List<UserLogDetail> result = new ArrayList<UserLogDetail>();
List<List> s = new ArrayList<List>();
startTime = startTime + " 00:00:00";
endTime = endTime + " 23:59:59";
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "geteventtype");
try {
result = uls.getdetailtype(datePojo.getStartTime(), datePojo.getEndTime());
int j = 0;
for (int i = 0; i < result.size(); i++) {
List<String> a = new ArrayList<String>();
j = j + 1;
a.add(result.get(i).getName());
a.add(result.get(i).getNum().toString());
s.add(a);
}
} catch (Exception e) {
logger.error("统计详细事件异常,异常是" + e.toString());
}
return objectMapper.writeValueAsString(s);
}
/***
* 统计用户
*/
@RequestMapping(value = "getUserStatistics", method = RequestMethod.POST)
@ResponseBody
public String getUserStatistics(HttpServletRequest request, String startTime, String endTime) throws JsonProcessingException {
List<UserLogDetail> result = new ArrayList<UserLogDetail>();
List<List> s = new ArrayList<List>();
startTime = startTime + " 00:00:00";
endTime = endTime + " 23:59:59";
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "geteventtype");
try {
result = uls.getUserStatistics(datePojo.getStartTime(), datePojo.getEndTime());
int j = 0;
for (int i = 0; i < result.size(); i++) {
List<String> a = new ArrayList<String>();
j = j + 1;
a.add(result.get(i).getName());
a.add(result.get(i).getNum().toString());
s.add(a);
}
} catch (Exception e) {
logger.error("统计用户异常,异常是" + e.toString());
}
return objectMapper.writeValueAsString(s);
}
/***
* 统计月份
*/
@RequestMapping(value = "getdetailmonth", method = RequestMethod.POST)
@ResponseBody
public List<UserLogDetail> getdetailmonth(HttpServletRequest request, String startTime, String endTime) throws JsonProcessingException {
List<UserLogDetail> result = new ArrayList<UserLogDetail>();
List<List> s = new ArrayList<List>();
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getdetailmonth");
try {
result = uls.getdetailmonth(datePojo.getStartTime(), datePojo.getEndTime());
} catch (Exception e) {
logger.error("统计详细事件异常,异常是" + e.toString());
}
return result;
}
@ResponseBody
@RequestMapping(value = "getUsername", method = RequestMethod.POST)
public List<String> getUsername() {
List<String> names = new ArrayList<>();
try {
names = userMapper.getAllName();
} catch (Exception e) {
logger.error("查询日志异常,异常是" + e.toString());
}
return names;
}
@RequestMapping(value = "getWarnInfo", method = RequestMethod.POST)
@ResponseBody
public HttpResult getWarnInfo(HttpServletRequest request,Long type) {
HttpResult result = new HttpResult();
try {
List<List> userLog = uls.getWarnInfo(type);
if (userLog.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到日志信息列表");
} else {
result.setCode(200);
result.setBody(userLog);
result.setMessage("获取日志信息列表成功");
}
uls.getLog("查询日志信息", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
} catch (Exception e) {
logger.error("查询日志信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "查询日志信息失败");
uls.getLog("查询日志信息", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
}
return result;
}
@RequestMapping(value = "getWarnInfoCounts", method = RequestMethod.POST)
@ResponseBody
public HttpResult getWarnInfoCounts(Long type) {
HttpResult result = new HttpResult();
try {
Integer counts = uls.getWarnInfoCounts(type);
if (counts==0) {
result.setCode(500);
result.setMessage("日志列表数据为空");
} else {
result.setCode(200);
result.setBody(counts);
result.setMessage("存在日志列表数据展示");
}
} catch (Exception e) {
logger.error("查询日志信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "查询日志信息失败");
}
return result;
}
@RequestMapping(value = "getMemoInfo", method = RequestMethod.POST)
@ResponseBody
public HttpResult getMemoInfo(HttpServletRequest request) {
HttpResult result = new HttpResult();
try {
Integer userLog = uls.getMemoInfo();
if (userLog == null) {
result.setCode(500);
result.setMessage("");
} else {
result.setCode(200);
result.setBody(userLog);
result.setMessage("获取存储空间成功");
}
uls.getLog("查询存储空间", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
} catch (Exception e) {
logger.error("查询存储空间异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "查询存储空间失败");
uls.getLog("查询存储空间", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
}
return result;
}
@RequestMapping(value = "getSjtj", method = RequestMethod.POST)
@ResponseBody
public HttpResult getSjtj(HttpServletRequest request,String username, String type, String name, String startTime, String endTime) throws JsonProcessingException {
HttpResult result = new HttpResult();
startTime = startTime + " 00:00:00";
endTime = endTime + " 23:59:59";
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "getSjtj");
try {
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "校验前台传递时间参数报错");
return result;
}
List<List> userLog = uls.getSjtj(username,type, name, datePojo.getStartTime(), datePojo.getEndTime());
if (userLog.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到日志统计列表");
} else {
result.setCode(200);
result.setBody(userLog);
uls.getLog("查询日志统计", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result.setMessage("获取日志统计列表成功");
}
} catch (Exception e) {
logger.error("查询日志统计异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "查询日志统计失败");
uls.getLog("查询日志统计", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
}
return result;
}
@RequestMapping(value = "expcsv", method = RequestMethod.POST)
@ResponseBody
public void expcsv(HttpServletRequest request,String message) {
uls.getLog(message, "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
}
}

View File

@@ -0,0 +1,63 @@
package com.pqs9900.controller.log;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.log.UserLoginService;
import com.njcn.utils.PubUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.core.JsonProcessingException;
@Controller
@RequestMapping(value = "login")
public class UserLoginController {
@Autowired
UserLoginService loginService;
@Autowired
UserLogDetailService userLogDetailService;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(UserLoginController.class);
@RequestMapping(value = "getUserLogin", method = RequestMethod.POST)
@ResponseBody
public HttpResult getUserLogin(HttpServletRequest request, String startTime, String endTime) throws JsonProcessingException {
HttpResult result = new HttpResult();
startTime = startTime + " 00:00:00";
endTime = endTime + " 23:59:59";
DatePojo datePojo;
try {
datePojo = PubUtils.validateDate(startTime, endTime, "getUserLogId");
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "校验前台传递时间参数报错");
return result;
}
List<List> userLog = loginService.getUserLogin(startTime, endTime);
if (userLog.isEmpty()) {
result.setCode(500);
userLogDetailService.getLog("查询用户登录信息", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result.setMessage("没有获取到日志信息列表");
} else {
result.setCode(200);
result.setBody(userLog);
userLogDetailService.getLog("查询用户登录信息", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result.setMessage("获取日志信息列表成功");
}
} catch (Exception e) {
logger.error("查询日志信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "查询日志信息失败");
}
return result;
}
}

View File

@@ -0,0 +1,281 @@
package com.pqs9900.controller.message;
import cn.hutool.core.collection.CollectionUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.njcn.utils.SerializeUtil;
import com.njcn.utils.XssFilterUtil;
import com.njcn.utils.redis.JedisManager;
import com.pqs9900.pojo.message.MsgBaseConfDTO;
import com.pqs9900.pojo.message.MsgInfoDTO;
import com.pqs9900.pojo.message.MsgTemplateData;
import com.pqs9900.pojo.message.MsgTypeTemplateDTO;
import com.pqs9900.service.message.MessageService;
import com.pqs9900.service.message.SendMessageService;
import com.pqs9900.task.SendMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
@Controller
@RequestMapping("/message")
public class MessageController {
private static final Logger logger = LoggerFactory.getLogger(MessageController.class);
@Autowired
private MessageService messageService;
@Autowired
private SendMessageService sendMessageService;
@Autowired
private SendMessage sendMessage;
@Autowired
JedisManager jedisManager;
@PostMapping("test")
public void test() {
sendMessage.stop();
sendMessage.start(sendMessage.getTaskRegistrar());
}
@PostMapping("sendMsg")
@ResponseBody
public HttpResult sendMsg(@RequestParam("msg") String msg, @RequestParam("phone") String phone) {
HttpResult httpResult = new HttpResult();
//正则校验
if (!PubUtils.patternPhone(phone)) {
httpResult.setMessage("手机格式不正确");
httpResult.setCode(500);
httpResult.setBody(null);
return httpResult;
}
//xss处理
msg = XssFilterUtil.dealString(msg);
try {
String res = messageService.sendMsg(msg, phone, null,null,null,0,null);
if("发送成功".equals(res)){
httpResult.setBody(null);
httpResult.setCode(200);
httpResult.setMessage(res);
}else {
httpResult.setBody(null);
httpResult.setCode(500);
httpResult.setMessage(res);
}
} catch (Exception e) {
httpResult.setBody(null);
httpResult.setCode(500);
httpResult.setMessage(e.toString());
}
return httpResult;
}
/**
* @Author chendaofei
* @Description 获取短信基本配置
* @Date 9:34 2020/5/14
**/
@GetMapping("getMsgConfig")
@ResponseBody
public HttpResult getMsgConfig() {
MsgBaseConfDTO msgConfig = messageService.getMsgConfig();
if (msgConfig != null) {
return PubUtils.assignmentResult(msgConfig, 200, "获取短信基本配置成功");
}else {
return PubUtils.assignmentResult(null, 500, "暂无配置");
}
}
/**
* @Author chendaofei
* @Description 更新短信基本配置
* @Date 9:34 2020/5/14
**/
@PostMapping("updateMsgCofig")
@ResponseBody
public HttpResult updateMsgCofig(@RequestBody MsgBaseConfDTO msgBaseConfDTO) {
try{
if(msgBaseConfDTO.getIsSend()==null|| msgBaseConfDTO.getTimeInterval()==null||msgBaseConfDTO.getOffDay()==null||msgBaseConfDTO.getList()==null){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
sendMessageService.updateMsgCofig(msgBaseConfDTO);
}catch (Exception e){
return PubUtils.assignmentResult(null,500,"配置失败");
}
return PubUtils.assignmentResult(null,200,"配置成功");
}
/**
* @Author chendaofei
* @Description 获取短信类型模板及时间模板
* @Date 9:35 2020/5/14
**/
@GetMapping("getMsgDicdataList")
@ResponseBody
public HttpResult getMsgDicdataList() {
List<MsgTypeTemplateDTO> list = new ArrayList<>();
try {
list = messageService.getMsgDicdataList();
return PubUtils.assignmentResult(list, 200, "获取短信配置模板成功");
} catch (Exception e) {
return PubUtils.assignmentResult(null, 500, "获取失败");
}
}
/**
* @Author chendaofei
* @Description 删除模板
* @Date 9:36 2020/5/14
**/
@GetMapping("delMsgDicBytype")
@ResponseBody
public HttpResult delMsgDicBytype(HttpServletRequest request,String msgIndex) {
HttpResult result = new HttpResult();
if (PubUtils.isBlank(msgIndex)) {
result = PubUtils.assignmentResult(null, 500, "参数不可为空");
}
String ip = PubUtils.getIpAddr(request);
String username = TokenManager.getToken().getLoginName();
byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
String key = SerializeUtil.deserialize(value, String.class);
if(key.equals("success")){
Integer res = messageService.delMsgDicBytype(msgIndex);
if (res == 1) {
result = PubUtils.assignmentResult(null, 200, "删除成功!");
}else{
result = PubUtils.assignmentResult(null, 500, "删除失败!");
}
}else{
result = PubUtils.assignmentResult(null, 500, "删除失败!密码验证失败");
}
jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
return result;
}
/**
* @Author chendaofei
* @Description 更新短信模板是否启用
* @Date 9:36 2020/5/14
**/
@PostMapping("updateMsgDicState")
@ResponseBody
public HttpResult updateMsgDicState(List<String> list) {
HttpResult httpResult;
try{
String res = messageService.updateMsgDicState(list);
if ("配置成功".equals(res)) {
httpResult = PubUtils.assignmentResult(null, 200, res);
}else {
httpResult = PubUtils.assignmentResult(null, 500, "配置失败");
}
}catch (Exception e){
httpResult = PubUtils.assignmentResult(null, 500, "配置失败");
}
return httpResult;
}
/**
* @Author chendaofei
* @Description 添加类型时间模板
* @Date 9:37 2020/5/14
**/
@PostMapping("addMsgDicdata")
@ResponseBody
public HttpResult addMsgDicdata(Integer msgType, BigDecimal value1, BigDecimal value2, String msgName) {
if (msgType == null || value1 == null || value2 == null || PubUtils.isBlank(msgName)) {
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
if (value1.compareTo(value2) >= 0) {
return PubUtils.assignmentResult(null, 500, "最小临界值不可大于等于最终临界值");
}
if (msgType == 1) {
//时间模板
if (new BigDecimal(value1.intValue()).compareTo(value1) != 0 || new BigDecimal(value2.intValue()).compareTo(value2) != 0) {
return PubUtils.assignmentResult(null, 500, "时间格式有误");
}
}
//xss
msgName = XssFilterUtil.dealString(msgName);
MsgTypeTemplateDTO msgTypeTemplateDTO = new MsgTypeTemplateDTO();
msgTypeTemplateDTO.setMsgIndex(UUID.randomUUID().toString());
msgTypeTemplateDTO.setMsgType(msgType);
msgTypeTemplateDTO.setMsgName(msgName);
msgTypeTemplateDTO.setValue1(value1);
msgTypeTemplateDTO.setValue2(value2);
try {
String res = messageService.addMsgDicdata(msgTypeTemplateDTO);
if ("添加成功".equals(res)) {
return PubUtils.assignmentResult(null, 200, res);
} else {
return PubUtils.assignmentResult(null, 500, res);
}
} catch (Exception e) {
return PubUtils.assignmentResult(null, 500, "添加失败,请联系管理员");
}
}
/**
* @Author chendaofei
* @Description 查询短信信息列表
* @Date 9:22 2020/5/20
**/
@GetMapping("getAllMsgList")
@ResponseBody
public HttpResult getAllMsgList(@RequestParam(required = false, value = "type") Integer type, @RequestParam(value = "startTime", required = false) String startTime, @RequestParam(value = "endTime", required = false) String endTime) {
HttpResult httpResult;
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "getAllMsgList");
if (!datePojo.getValidity()) {
httpResult = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return httpResult;
}
Date be =datePojo.getStartTime();
Date en = datePojo.getEndTime();
List<MsgInfoDTO> list = messageService.getAllMsgList(type,be ,en);
return PubUtils.assignmentResult(list, 200, "获取成功");
}
/**
* @Author chendaofei
* @Description 删除已发短信
* @Date 11:50 2020/5/21
**/
@PostMapping("deleteMsgList")
@ResponseBody
public HttpResult deleteMsgList(@RequestBody List<String> list) {
if (list == null || list.size() == 0) {
return PubUtils.assignmentResult(null, 500, "id不可为空");
}
Boolean flag = messageService.deleteMsgList(list);
if (flag) {
return PubUtils.assignmentResult(null, 200, "删除成功");
}
return PubUtils.assignmentResult(null, 500, "删除失败");
}
}

View File

@@ -0,0 +1,303 @@
package com.pqs9900.controller.root;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.user.RoleGroup;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.user.RoleGroupService;
import com.njcn.service.user.UserService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.sso.pojo.user.User;
import com.njcn.utils.DesUtils;
import com.njcn.utils.PubUtils;
import com.njcn.utils.SerializeUtil;
import com.njcn.utils.XssFilterUtil;
import com.njcn.utils.redis.JedisManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.security.interfaces.RSAPrivateKey;
import java.util.List;
/**
* @author hongawen
* @date: 2019/9/26 13:26
*/
@Controller
@RequestMapping("managers")
public class ManagersController {
private static final Logger logger = LoggerFactory.getLogger(ManagersController.class);
@Resource
UserLogDetailService userLogservice;
@Resource
private UserService userService;
@Resource
private RoleGroupService roleGroupService;
@Resource
private JedisManager jedisManager;
/**
* 获取管理员列表
* @param request
* @param userState
* @return
*/
@PostMapping("allManagers")
@ResponseBody
public HttpResult allManagers(HttpServletRequest request, String userState){
HttpResult httpResult;
List<User> managers;
try{
managers=userService.getAllManagers(userState);
httpResult= PubUtils.assignmentResult(managers,200,"获取管理员列表成功");
}catch(Exception e){
httpResult= PubUtils.assignmentResult(null,500,"获取管理员列表异常");
}
return httpResult;
}
/**
* 弹出新增管理员页面
*/
@GetMapping("addManager")
public String addManager(HttpServletRequest request){
return "business/root/addManager";
}
/**
* 弹出修改管理员密码页面
*/
@GetMapping("updateManagerPassWord")
public String updateManagerPassWord(HttpServletRequest request){
return "business/root/updateManagerPassWord";
}
/**
* 获取所有管理员的角色组
*/
@PostMapping("allManagerRole")
@ResponseBody
public HttpResult allManagerRole(){
HttpResult httpResult;
List<RoleGroup> roleGroups;
try{
roleGroups=roleGroupService.getAllManagerRoleGroup();
httpResult= PubUtils.assignmentResult(roleGroups,200,"获取所有管理员角色组成功");
}catch(Exception e){
httpResult= PubUtils.assignmentResult(null,500,"获取管理员角色组异常");
}
return httpResult;
}
/**
* 保存管理员
*/
@PostMapping("saveManager")
@ResponseBody
public HttpResult saveManager(String name, String loginName,
String password, String phone, String email, String ip, String ipEnd, String time, Integer mark, String rolegpIndex, String token, HttpServletRequest request) {
HttpResult result = new HttpResult();
String sessionToken = (String) TokenManager.getSession().getAttribute("token");
if (!token.equalsIgnoreCase(sessionToken)) {
result = PubUtils.assignmentResult(null, 500, "非法访问");
return result;
}
//后台Xss攻击处理、包括html/js/sql
name = XssFilterUtil.dealString(name);
loginName = XssFilterUtil.dealString(loginName);
loginName = DesUtils.aesDecrypt(loginName);//解密操作
rolegpIndex = XssFilterUtil.dealString(rolegpIndex);
password = XssFilterUtil.dealString(password);
phone = XssFilterUtil.dealString(phone);
email = XssFilterUtil.dealString(email);
ip = XssFilterUtil.dealString(ip);
ipEnd = XssFilterUtil.dealString(ipEnd);
time = XssFilterUtil.dealString(time);
String tmpip = StringUtils.isBlank(PubUtils.getIpAddr(request)) ? "127.0.0.1" : PubUtils.getIpAddr(request);
try {
// byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(loginName + tmpip));
// RSAPrivateKey privateKey = SerializeUtil.deserialize(value, RSAPrivateKey.class);
//秘钥用完即删
// jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(loginName + tmpip));
//密码处理
String privateKey = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, loginName + tmpip);
//秘钥用完即删
jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, loginName + tmpip);
password = PubUtils.getPasswordSM2Verify(privateKey, password);
if (password == null && password.length() == 0) {
result = PubUtils.assignmentResult(null, 500, "密码传输完整性被破坏");
return result;
}
if (password.contains(loginName)) {
result = PubUtils.assignmentResult(null, 302, "用户密码包含用户名");
logger.error("新增管理员失败");
userLogservice.getLog("用户审核", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return result;
}
//新增管理员
String message = userService.saveManager(name, loginName, rolegpIndex, password, phone, email, ip, ipEnd, time, mark);
if (message.equalsIgnoreCase("新增管理员成功!")) {
result = PubUtils.assignmentResult("success", 200, message);
logger.info("新增管理员成功");
userLogservice.getLog("新增用户", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("登录名已存在")) {
result = PubUtils.assignmentResult(null, 300, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("名称已存在")) {
result = PubUtils.assignmentResult(null, 500, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("该手机号已被注册")) {
result = PubUtils.assignmentResult(null, 301, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("名称不可为空")) {
result = PubUtils.assignmentResult(null, 302, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("登录名不可为空")) {
result = PubUtils.assignmentResult(null, 303, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("密码不可为空")) {
result = PubUtils.assignmentResult(null, 304, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("手机号不可为空")) {
result = PubUtils.assignmentResult(null, 305, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("邮箱不可为空")) {
result = PubUtils.assignmentResult(null, 306, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("起始ip不可为空")) {
result = PubUtils.assignmentResult(null, 307, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("结束ip不可为空")) {
result = PubUtils.assignmentResult(null, 308, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("名称只由中文组成长度为1-20")) {
result = PubUtils.assignmentResult(null, 309, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("登录名只能由3-16的字母和数字组成")) {
result = PubUtils.assignmentResult(null, 310, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("密码格式不正确需要包含特殊字符字母数字长度为8-16")) {
result = PubUtils.assignmentResult(null, 311, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("邮箱格式不正确,应含有@ .在@后,以.com、.con结尾qq,163等")) {
result = PubUtils.assignmentResult(null, 312, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("手机号格式不正确必须有11位并且为数字是正常的手机号码开头")) {
result = PubUtils.assignmentResult(null, 313, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("起始ip地址格式不正确")) {
result = PubUtils.assignmentResult(null, 314, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("结束ip地址格式不正确")) {
result = PubUtils.assignmentResult(null, 315, message);
logger.error("新增管理员失败");
userLogservice.getLog("新增用户", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
} catch (Exception e) {
logger.error("新增管理员异常,异常为" + e);
result = PubUtils.assignmentResult(null, 500, "新增管理员失败");
}
return result;
}
/**
* 更新管理员密码
* @param username 登录名
* @param passwordX 新密码
*/
@PostMapping("updatePassword")
@ResponseBody
public HttpResult updatePassword(HttpServletRequest request,String username, String passwordX, String token) {
HttpResult result ;
String sessionToken = (String) TokenManager.getSession().getAttribute("token");
if (!token.equalsIgnoreCase(sessionToken)) {
result = PubUtils.assignmentResult(null, 500, "非法访问");
return result;
}
username = DesUtils.aesDecrypt(username);
passwordX = XssFilterUtil.dealString(passwordX);
String ip = StringUtils.isBlank(PubUtils.getIpAddr(request)) ? "127.0.0.1" : PubUtils.getIpAddr(request);
try {
String privateKey = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, username + ip);
//秘钥用完即删
jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
passwordX = PubUtils.getPasswordSM2Verify(privateKey, passwordX);
if (StringUtils.isBlank(passwordX)) {
result = PubUtils.assignmentResult(null, 500, "密码传输完整性被破坏");
userLogservice.getLog("修改管理员密码", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return result;
}
//增加判断密码是否包含用户名
if (passwordX.contains(username)) {
userLogservice.getLog("修改管理员密码", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "管理员密码包含登录名");
}
if (!(PubUtils.patternPassword(passwordX) || PubUtils.patternUsername(username))) {
userLogservice.getLog("修改管理员密码", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 500, "管理员名、密码格式不正确");
return result;
}
try {
userService.modifyPassword(username, passwordX);
userLogservice.getLog("修改管理员密码", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 200, "修改密码成功");
} catch (Exception e) {
userLogservice.getLog("修改管理员密码", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 500, e.getMessage());
logger.error("用户修改密码成功后,保存记录出错。原因:" + e.toString());
}
} catch (Exception e) {
logger.error("更新密码出错,异常为:" + e.toString());
String eMessage = e.getMessage();
if (eMessage.length() > 20) {
eMessage = "内部出错";
}
result = PubUtils.assignmentResult(null, 500, eMessage);
try {
userLogservice.getLog("修改管理员密码", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} catch (Exception u) {
logger.error("用户修改密码失败后,保存记录出错。原因:" + u.toString());
}
}
return result;
}
}

View File

@@ -0,0 +1,103 @@
package com.pqs9900.controller.root;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.system.SubSystem;
import com.njcn.service.system.SystemService;
import com.njcn.utils.PubUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
/**
* @author hongawen
* @date: 2019/10/8 10:00
*/
@Controller
@RequestMapping("manageSystem")
public class SystemController {
private static final Logger logger = LoggerFactory.getLogger(SystemController.class);
@Resource
private SystemService systemService;
/**
* 获取所有子项目系统信息
*/
@PostMapping("getSystemInfo")
@ResponseBody
public HttpResult getSystemInfo(){
HttpResult httpResult;
List<SubSystem> subSystemList;
try{
subSystemList=systemService.getSystems();
httpResult= PubUtils.assignmentResult(subSystemList,200,"获取所有系统项目成功");
}catch(Exception e){
logger.error(e.toString());
httpResult= PubUtils.assignmentResult(null,500,"获取所有系统项目失败");
}
return httpResult;
}
/**
* 隐藏当前系统
*/
@PostMapping("hideSystem")
@ResponseBody
public HttpResult hideSystem(String systemIndex){
HttpResult httpResult;
try{
systemService.hideSystem(systemIndex);
httpResult= PubUtils.assignmentResult(null,200,"隐藏系统项目成功");
}catch(Exception e){
logger.error(e.toString());
httpResult= PubUtils.assignmentResult(null,500,"隐藏系统项目失败");
}
return httpResult;
}
/**
* 显示当前系统
*/
@PostMapping("displaySystem")
@ResponseBody
public HttpResult displaySystem(String systemIndex){
HttpResult httpResult;
try{
systemService.displaySystem(systemIndex);
httpResult= PubUtils.assignmentResult(null,200,"显示系统项目成功");
}catch(Exception e){
logger.error(e.toString());
httpResult= PubUtils.assignmentResult(null,500,"显示系统项目失败");
}
return httpResult;
}
/**
* 隐藏当前系统
*/
@PostMapping("defaultSystem")
@ResponseBody
public HttpResult defaultSystem(String systemIndex){
HttpResult httpResult;
try{
systemService.defaultSystem(systemIndex);
httpResult= PubUtils.assignmentResult(null,200,"设置默认系统项目成功");
}catch(Exception e){
logger.error(e.toString());
httpResult= PubUtils.assignmentResult(null,500,"设置默认系统项目失败");
}
return httpResult;
}
}

View File

@@ -0,0 +1,371 @@
package com.pqs9900.controller.root;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.SimpleValue;
import com.njcn.pojo.system.Theme;
import com.njcn.service.system.ThemeService;
import com.njcn.utils.PubUtils;
import com.njcn.utils.XssFilterUtil;
/**
* @author hongawen
* @date: 2019/9/27 10:47
*/
@Controller
@RequestMapping("theme")
public class ThemeController {
private static final Logger logger = LoggerFactory.getLogger(ThemeController.class);
@Resource
private ThemeService themeService;
private String logoName;
private String faviconName;
/**
* 跳转修改主题页面
*/
@GetMapping("modifytheme")
public String modifyTheme() {
return "business/root/modifyTheme";
}
/**
* 获取logo图片
*/
@PostMapping("logo")
public void logo(HttpServletResponse resp, HttpSession session) {
ServletOutputStream out;
FileInputStream inStream = null;
try {
out = resp.getOutputStream();
if (null != out) {
String logPath = "/images/logo.png";
logPath = session.getServletContext().getRealPath(logPath);
inStream = new FileInputStream(logPath);
BufferedImage image = ImageIO.read(inStream);
ImageIO.write(image, "png", out);
}
} catch (IOException e) {
logger.error("获取logo异常原因为" + e.toString());
} finally {
if (inStream != null) {
try {
inStream.close();
} catch (IOException e) {
logger.error("关闭输入流异常,异常为:" + e.toString());
}
}
}
}
/**
* 获取主题色
*/
@PostMapping("getColor")
@ResponseBody
public HttpResult getColor() {
HttpResult result;
String color;
try {
color = themeService.getThemeColor();
result = PubUtils.assignmentResult(color, 200, "获取主题色成功");
} catch (Exception e) {
logger.error(e.toString());
result = PubUtils.assignmentResult("#006565", 500, "获取主题色失败");
}
return result;
}
/**
* 获取主题信息
*/
@PostMapping("getThemeInfo")
@ResponseBody
public HttpResult getThemeInfo() {
HttpResult result;
SimpleValue simpleValue;
try {
simpleValue = themeService.getThemeInfo();
result = PubUtils.assignmentResult(simpleValue, 200, "获取主题信息成功");
} catch (Exception e) {
logger.error(e.toString());
simpleValue = new SimpleValue();
simpleValue.setName("国网主题");
simpleValue.setValue("#006565");
result = PubUtils.assignmentResult(simpleValue, 500, "获取主题信息失败");
}
return result;
}
/**
* 获取主题信息
*/
@PostMapping("getThemeList")
@ResponseBody
public HttpResult getThemeList() {
HttpResult result;
List<Theme> themes = new ArrayList<>();
try {
themes = themeService.getThemeList();
result = PubUtils.assignmentResult(themes, 200, "获取主题信息成功");
} catch (Exception e) {
logger.error(e.toString());
Theme theme = new Theme();
theme.setThemeDesc("国网");
theme.setThemeColor("#006565");
theme.setLogoName("gwlogo");
theme.setFaviconName("gwfavicon");
themes.add(theme);
result = PubUtils.assignmentResult(themes, 500, "获取主题信息失败");
}
return result;
}
/**
* 删除主题
*/
@PostMapping("deleteTheme")
@ResponseBody
public HttpResult deleteTheme(String themeIndex) {
HttpResult result;
try {
themeService.deleteTheme(themeIndex);
result = PubUtils.assignmentResult(null, 200, "激活主题成功");
} catch (Exception e) {
logger.error(e.toString());
result = PubUtils.assignmentResult(null, 500, "激活主题失败");
}
return result;
}
/**
* 激活主题
*/
@PostMapping("activate")
@ResponseBody
public HttpResult activate(String themeIndex, HttpSession session) {
HttpResult result;
try {
Theme theme = themeService.activate(themeIndex);
this.logoName = theme.getLogoName();
this.faviconName = theme.getFaviconName();
//更新没问题后,替换图片流
replaceLogo(session);
replaceFavicon(session);
result = PubUtils.assignmentResult(null, 200, "激活主题成功");
} catch (Exception e) {
logger.error(e.toString());
result = PubUtils.assignmentResult(null, 500, "激活主题失败");
}
return result;
}
/**
* 上传logo
*/
@PostMapping("/uploadLogo")
@ResponseBody
public HttpResult uploadLogo(@RequestParam(value = "file", required = false) MultipartFile file, HttpSession session) throws IOException {
HttpResult result;
String contentType = file.getContentType().substring(6);
if (file.getSize() == 0) {
result = PubUtils.assignmentResult(null, 501, "logo图片为空");
return result;
}
//判断文件格式是否正确
if (contentType.equalsIgnoreCase("png") || contentType.equalsIgnoreCase("jpg") || contentType.equalsIgnoreCase("jpeg")) {
//临时logo的位置
String logPath = "/images";
logPath = session.getServletContext().getRealPath(logPath);
String filename = file.getOriginalFilename();
filename = filename.substring(filename.lastIndexOf(File.separator)+1);
String tempLogPath = logPath + File.separator + filename;
File temp = new File(tempLogPath);
if (temp.isFile() && temp.exists()) {
temp.delete();
}
file.transferTo(temp);
this.logoName=filename;
result = PubUtils.assignmentResult(filename, 200, "logo图片上传成功");
} else {
result = PubUtils.assignmentResult(null, 501, "logo图片格式非法");
}
return result;
}
/**
* 上传favicon
*/
@PostMapping("/uploadFavicon")
@ResponseBody
public HttpResult uploadFavicon(@RequestParam(value = "file", required = false) MultipartFile file, HttpSession session) throws IOException {
HttpResult result;
String contentType = file.getContentType().substring(6);
if (file.getSize() == 0) {
result = PubUtils.assignmentResult(null, 501, "图标为空");
return result;
}
//判断文件格式是否正确
if (contentType.equalsIgnoreCase("x-icon")) {
//临时logo的位置
String faviconPath = "/images";
faviconPath = session.getServletContext().getRealPath(faviconPath);
String filename = file.getOriginalFilename();
filename = filename.substring(filename.lastIndexOf(File.separator)+1);
String tempFaviconPath = faviconPath + File.separator + filename;
File temp = new File(tempFaviconPath);
if (temp.isFile() && temp.exists()) {
temp.delete();
}
file.transferTo(temp);
this.faviconName=filename;
result = PubUtils.assignmentResult(filename, 200, "图标上传成功");
} else {
result = PubUtils.assignmentResult(null, 501, "图标格式非法");
}
return result;
}
/**
* 更新主题
*/
@PostMapping("/updateTheme")
@ResponseBody
public HttpResult updateTheme(String themeDesc, String color, HttpSession session) {
HttpResult result;
themeDesc = XssFilterUtil.dealString(themeDesc);
color = XssFilterUtil.dealString(color);
if (!PubUtils.patternDes10(themeDesc)) {
result = PubUtils.assignmentResult(null, 500, "请输入1-10位的主题描述");
return result;
}
if (!PubUtils.patternDes10(color)) {
result = PubUtils.assignmentResult(null, 500, "请输入16进制颜色");
return result;
}
try {
themeService.updateTheme(themeDesc, color, this.logoName, this.faviconName);
// //更新没问题后,替换图片流
// replaceLogo(session);
// replaceFavicon(session);
result = PubUtils.assignmentResult(null, 200, "主题更新成功");
} catch (Exception e) {
logger.error("主题更新异常" + e.toString());
result = PubUtils.assignmentResult(null, 500, "主题更新异常");
}
return result;
}
/**
* 将刚刚上传的logo临时文件替换为正式logo
*/
private void replaceLogo(HttpSession session) {
//临时logo
String imagePath = "/images";
imagePath = session.getServletContext().getRealPath(imagePath);
String tempLogoPath = imagePath + File.separator + this.logoName;
FileInputStream inputStream = null;
FileOutputStream outputStream = null;
try {
inputStream = new FileInputStream(tempLogoPath);
//目标logo
String targetLogoPath = imagePath + File.separator + "logo.png";
outputStream = new FileOutputStream(targetLogoPath);
//进行复制操作
int len = 0;
byte[] byts = new byte[1024];
while ((len = inputStream.read(byts)) != -1) {
//注意:字节流会直接写入到文件当中,不用刷新缓存
outputStream.write(byts, 0, len);
}
} catch (Exception e) {
logger.error("替换logo图片流异常异常为" + e.toString());
} finally {
try {
if (null != inputStream) {
inputStream.close();
}
} catch (Exception e) {
logger.error("关闭流异常,异常为:" + e.toString());
}
try {
if (null != outputStream) {
outputStream.close();
}
} catch (Exception e) {
logger.error("关闭流异常,异常为:" + e.toString());
}
}
}
/**
* 将刚刚上传的图标临时文件替换为正式图标
*/
private void replaceFavicon(HttpSession session) {
//临时图标
String imagePath = "/images";
imagePath = session.getServletContext().getRealPath(imagePath);
String tempFaviconPath = imagePath + File.separator + this.faviconName;
//目标图标
String targetFaviconPath = imagePath + File.separator + "favicon.ico";
FileInputStream inputStream = null;
FileOutputStream outputStream = null;
try {
inputStream = new FileInputStream(tempFaviconPath);
outputStream = new FileOutputStream(targetFaviconPath);
int len;
byte[] byts = new byte[1024];
while ((len = inputStream.read(byts)) != -1) {
outputStream.write(byts, 0, len);
}
} catch (IOException e) {
logger.error("上传的图标替换为正式图标失败,原因为:" + e.toString());
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (IOException e) {
logger.error("关闭流异常,异常为:" + e.toString());
}
try {
if (outputStream != null) {
outputStream.close();
}
} catch (IOException e) {
logger.error("关闭流异常,异常为:" + e.toString());
}
}
}
}

View File

@@ -0,0 +1,124 @@
package com.pqs9900.controller.terminal;
import cn.hutool.core.collection.CollectionUtil;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.pqs9900.pojo.terminal.FlowMealDTO;
import com.pqs9900.service.terminal.FlowMealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @Description
* @Author cdf
* @Date 2020/8/7 11:12
**/
@RestController
@RequestMapping("flow")
public class FlowMealController {
@Resource
private UserLogDetailService userLog;
@Autowired
private FlowMealService flowMealService;
/**
* @Author chendaofei
* @Description 新增流量套餐
* @Date 11:33 2020/8/7
**/
@PostMapping("addFlowMeal")
public HttpResult addFlowMeal(HttpServletRequest request, @RequestBody FlowMealDTO flowMealDTO){
if(PubUtils.isBlank(flowMealDTO.getFmName())||
flowMealDTO.getFmNumber()==null ||
flowMealDTO.getType()==null ||flowMealDTO.getSecondType()==null){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
String res = flowMealService.addFlowMeal(flowMealDTO);
if("新增成功".equals(res)){
userLog.getLog("新增流量套餐", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,200,res);
}else {
userLog.getLog("新增流量套餐", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,500,res);
}
}
/**
* @Author chendaofei
* @Description 修改流量套餐
* @Date 10:41 2020/8/7
**/
@PostMapping("updateFlowMeal")
public HttpResult updateFlowMeal(HttpServletRequest request,@RequestBody FlowMealDTO flowMealDTO) {
if(PubUtils.isBlank(flowMealDTO.getFmIndex())||
PubUtils.isBlank(flowMealDTO.getFmName())||
flowMealDTO.getFmNumber()==null ||
flowMealDTO.getType()==null ||flowMealDTO.getSecondType()==null){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
String res = flowMealService.updateFlowMeal(flowMealDTO);
if("修改成功".equals(res)){
userLog.getLog("修改流量套餐", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,200,"修改成功");
}else {
userLog.getLog("修改流量套餐", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,500,res);
}
}
/**
* @Author chendaofei
* @Description 删除流量套餐
* @Date 10:41 2020/8/7
**/
@PostMapping("delFlowMeal")
public HttpResult delFlowMeal(HttpServletRequest request,String fmIndex) {
if(PubUtils.isBlank(fmIndex)){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
Integer res = flowMealService.delFlowMeal(fmIndex);
if(res == 1){
userLog.getLog("删除流量套餐", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,200,"删除成功");
}else {
userLog.getLog("删除流量套餐", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,500,"删除失败");
}
}
/**
* @Author chendaofei
* @Description 获取流量套餐列表
* @Date 10:41 2020/8/7
**/
@GetMapping("getFlowMealList")
public HttpResult getFlowMealList() {
List<FlowMealDTO> list = flowMealService.getFlowMealList();
return PubUtils.assignmentResult(list,200,"获取成功");
}
/**
* @Author chendaofei
* @Description 通过id获取流量套餐
* @Date 14:31 2020/8/7
**/
@GetMapping("getFlowMeal")
public HttpResult getFlowMeal(String fmIndex){
if(PubUtils.isBlank(fmIndex)){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
FlowMealDTO flowMealDTO = flowMealService.getFlowMeal(fmIndex);
return PubUtils.assignmentResult(flowMealDTO,200,"获取成功");
}
}

View File

@@ -0,0 +1,157 @@
package com.pqs9900.controller.terminal;
import cn.hutool.core.collection.CollectionUtil;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.configuration.DicData;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.pqs9900.pojo.terminal.FlowStrategyBindDTO;
import com.pqs9900.pojo.terminal.FlowStrategyVO;
import com.pqs9900.service.terminal.FlowStrategyService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @Description 流量策略
* @Author cdf
* @Date 2020/8/10 14:58
**/
@RestController
@RequestMapping("flowstrategy")
public class FlowStrategyController {
@Resource
private UserLogDetailService userLog;
@Autowired
private FlowStrategyService flowStrategyService;
@PostMapping("addStrategy")
public HttpResult addStrategy(HttpServletRequest request, @RequestBody FlowStrategyVO flowStrategyVO) {
if(PubUtils.isBlank(flowStrategyVO.getName())|| flowStrategyVO.getComPer()==null || flowStrategyVO.getWarnPer()==null||
flowStrategyVO.getAlertPer()==null || flowStrategyVO.getType() == null || CollectionUtil.isEmpty(flowStrategyVO.getComList())
||CollectionUtil.isEmpty(flowStrategyVO.getWarnList())||CollectionUtil.isEmpty(flowStrategyVO.getAlertList())){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
try {
String res = flowStrategyService.addStrategy(flowStrategyVO);
if("新增成功".equals(res)){
userLog.getLog("新增流量策略", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,200,res);
}else {
userLog.getLog("新增流量策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,500,res);
}
}catch (Exception e){
userLog.getLog("新增流量策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,500,"新增异常");
}
}
@PostMapping("updateStrategy")
public HttpResult updateStrategy(HttpServletRequest request, @RequestBody FlowStrategyVO flowStrategyVO) {
if(PubUtils.isBlank(flowStrategyVO.getFsIndex())||PubUtils.isBlank(flowStrategyVO.getName())||
flowStrategyVO.getComPer()==null || flowStrategyVO.getWarnPer()==null||
flowStrategyVO.getAlertPer()==null || flowStrategyVO.getType() == null ||CollectionUtil.isEmpty(flowStrategyVO.getComList())
||CollectionUtil.isEmpty(flowStrategyVO.getWarnList())||CollectionUtil.isEmpty(flowStrategyVO.getAlertList())){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
try {
String res = flowStrategyService.updateStrategy(flowStrategyVO);
if("操作成功".equals(res)){
String r = flowStrategyService.addFunTran(flowStrategyVO);
if("操作成功".equals(r)){
userLog.getLog("修改流量策略", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,200,res);
}else {
userLog.getLog("修改流量策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,500,"更新异常");
}
}else {
userLog.getLog("修改流量策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,500,res);
}
}catch (Exception e){
userLog.getLog("修改流量策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,500,"更新异常");
}
}
@GetMapping("delStrategy")
public HttpResult delStrategy(HttpServletRequest request, String fsIndex) {
if(PubUtils.isBlank(fsIndex)){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
Integer res= flowStrategyService.delStrategy(fsIndex);
if(res == 1){
userLog.getLog("删除流量策略", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,200,"删除成功");
}else {
userLog.getLog("删除流量策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,200,"删除失败");
}
}
@GetMapping("getStrategy")
public HttpResult getStrategy(String fsIndex) {
if(PubUtils.isBlank(fsIndex)){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
FlowStrategyVO flowStrategyVO = flowStrategyService.getStrategy(fsIndex);
if(flowStrategyVO == null){
return PubUtils.assignmentResult(null,500,"获取失败");
}else {
return PubUtils.assignmentResult(flowStrategyVO,200,"获取成功");
}
}
/**
* @Author chendaofei
* @Description 获取流量策略列表
* @Date 10:31 2020/10/15
**/
@GetMapping("getStrategyList")
public HttpResult getStrategyList() {
List<FlowStrategyVO> list = flowStrategyService.getStrategyList();
return PubUtils.assignmentResult(list,200,"获取成功");
}
/**
* @Author chendaofei
* @Description 获取所有装置功能
* @Date 10:14 2020/8/11
**/
@GetMapping("getDic")
public HttpResult getDic(){
List<DicData> list = flowStrategyService.getTartgetTypeForDic();
return PubUtils.assignmentResult(list,200,"获取成功");
}
/**
* @Author chendaofei
* @Description
* @Date 16:57 2020/8/20
**/
@GetMapping("getFun")
public HttpResult getFun(String fsdIndex){
if(PubUtils.isBlank(fsdIndex)){
return PubUtils.assignmentResult(null,500,"参数错误");
}
List<String> f = flowStrategyService.getFun(fsdIndex);
return PubUtils.assignmentResult(f,200,"查询成功");
}
}

View File

@@ -0,0 +1,259 @@
package com.pqs9900.controller.terminal;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.pqs9900.pojo.terminal.FlowDetailRVO;
import com.pqs9900.pojo.terminal.FlowStatisticsRVO;
import com.pqs9900.pojo.terminal.TerminalParamVO;
import com.pqs9900.pojo.terminal.TerminalRVO;
import com.pqs9900.service.terminal.TerminalStateService;
import com.pqs9900.serviceImpl.webtool.CsvDataServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
/**
* @Description 终端运行管理
* @Author cdf
* @Date 2020/8/28 15:10
**/
@RestController
@RequestMapping("terminalmanger")
public class TerminalStateController {
private static final Logger logger = LoggerFactory.getLogger(TerminalStateController.class);
@Resource
private UserLogDetailService userLog;
@Autowired
private TerminalStateService terminalStateService;
/**
* @Author chendaofei
* @Description 获取终端版本流量列表
* @Date 10:40 2020/8/31
**/
@GetMapping("getTerminalList")
public HttpResult getTerminalList(String devType, Integer status,String startTime){
List<TerminalRVO> list = terminalStateService.getTerminalList(devType,status,startTime);
return PubUtils.assignmentResult(list,200,"获取成功");
}
/**
* @Author chendaofei
* @Description 获取终端版本流量策略列表
* @Date 10:40 2020/8/31
**/
@PostMapping("getTerminalList2")
public HttpResult getTerminalList2(@RequestBody List<String>list){
List<TerminalRVO> res = terminalStateService.getTerminalList2(list);
return PubUtils.assignmentResult(res,200,"获取成功");
}
/**
* @Author chendaofei
* @Description 批量修改终端运行状态
* @Date 9:23 2020/9/2
**/
@PostMapping("updateDevFlag")
public HttpResult updateDevFlag(HttpServletRequest request,@RequestBody TerminalParamVO terminalParamVO){
if(CollectionUtil.isEmpty(terminalParamVO.getList())||terminalParamVO.getDevFlag()==null || StrUtil.isBlank(terminalParamVO.getDescribe())){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
int res = terminalStateService.updateDevFlag(terminalParamVO);
if(res==terminalParamVO.getList().size()){
userLog.getLog("修改终端运行状态", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,200,"修改状态成功");
}else {
userLog.getLog("修改终端运行状态", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null,500,"修改状态失败");
}
}
/**
* @Author chendaofei
* @Description 配置终端流量套餐
* @Date 12:26 2020/9/21
**/
@PostMapping("addDevMealAss")
public HttpResult addDevMealAss(HttpServletRequest request,@RequestBody TerminalParamVO terminalParamVO){
if(CollectionUtil.isEmpty(terminalParamVO.getList())||PubUtils.isBlank(terminalParamVO.getFmBaseIndex())){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
try {
Integer res = terminalStateService.addDevMealAss(terminalParamVO.getList(), terminalParamVO.getFmBaseIndex(), terminalParamVO.getFmReamIndex());
if (res == terminalParamVO.getList().size()) {
userLog.getLog("配置终端流量套餐", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 200, "配置成功");
} else {
userLog.getLog("配置终端流量套餐", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "配置失败");
}
}catch (Exception e){
logger.error("错误为:"+e.getMessage());
userLog.getLog("配置终端流量套餐", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "配置失败");
}
}
/**
* @Author chendaofei
* @Description 配置终端流量策略
* @Date 12:26 2020/9/21
**/
@PostMapping("addDevStrategyAss")
public HttpResult addDevStrategyAss(HttpServletRequest request,@RequestBody TerminalParamVO terminalParamVO){
if(CollectionUtil.isEmpty(terminalParamVO.getList())||PubUtils.isBlank(terminalParamVO.getFsIndex())){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
try {
Integer res = terminalStateService.addDevStrategyAss(terminalParamVO.getList(), terminalParamVO.getFsIndex());
if (res == terminalParamVO.getList().size()) {
userLog.getLog("配置终端流量策略", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 200, "配置成功");
} else {
userLog.getLog("配置终端流量策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "配置失败");
}
}catch (Exception e){
logger.error(e.getMessage());
userLog.getLog("配置终端流量策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "配置失败");
}
}
/**
* @Author chendaofei
* @Description 获取ip
* @Date 12:26 2020/9/21
**/
@PostMapping("getWebIpList")
public HttpResult getWebIpList(){
String res = terminalStateService.getWebIpList();
if("执行成功".equals(res)){
return PubUtils.assignmentResult(null, 200, res);
}else {
return PubUtils.assignmentResult(null, 500, res);
}
}
/**
* @Author chendaofei
* @Description 获取流量详情
* @Date 12:26 2020/9/21
**/
@PostMapping("getTerminalFlowDetail")
public HttpResult getTerminalFlowDetail(@RequestParam("devIndex")String devIndex,@RequestParam("startTime")String startTime){
if(PubUtils.isBlank(devIndex)||PubUtils.isBlank(startTime)){
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setLenient(false);
try {
sdf.parse(startTime);
} catch (ParseException e) {
return PubUtils.assignmentResult(null, 500, "时间格式有误");
}
FlowDetailRVO res = terminalStateService.getTerminalFlowDetail(devIndex,startTime);
if(res!=null){
return PubUtils.assignmentResult(res, 200, "获取成功");
}else {
return PubUtils.assignmentResult(null, 500, "暂无数据");
}
}
/**
* @Author chendaofei
* @Description 流量统计柱状图数据获取
* @Date 20:39 2020/10/9
**/
@PostMapping("getFlowStatiscsList")
public HttpResult getFlowStatiscsList(@RequestBody Map<String,Object> map){
if(map==null){
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
String startTime =(String)map.get("startTime");
List<String> list = (List<String>) map.get("list");
String mealBi = (String) map.get("mealBi");
String mealUse = (String)map.get("mealUse");
String mealAll = (String)map.get("mealAll");
if(PubUtils.isBlank(mealBi) && PubUtils.isBlank(mealUse) && PubUtils.isBlank(mealAll) ){
return PubUtils.assignmentResult(null, 500, "参数错误");
}
if(!PubUtils.isBlank(mealBi) && !PubUtils.isBlank(mealUse) && !PubUtils.isBlank(mealAll) ){
return PubUtils.assignmentResult(null, 500, "参数错误");
}
if(CollectionUtil.isEmpty(list)){
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setLenient(false);
try {
sdf.parse(startTime);
} catch (ParseException e) {
return PubUtils.assignmentResult(null, 500, "时间格式有误");
}
List<FlowStatisticsRVO> list1 = terminalStateService.getFlowStatiscsList(startTime,list,mealBi,mealUse,mealAll);
return PubUtils.assignmentResult(list1, 200, "获取成功");
}
/**
* @Author chendaofei
* @Description 查看终端性能展示
* @Date 9:42 2020/10/14
**/
@PostMapping("getQuailty")
public HttpResult getQuailty(@RequestParam("devIndex")String devIndex){
String res = terminalStateService.getQuailty(devIndex);
if("获取成功".equals(res)){
return PubUtils.assignmentResult(res, 200, "获取成功");
}else {
return PubUtils.assignmentResult(res, 500, "获取失败");
}
}
@PostMapping("closeSocket")
public HttpResult closeSocket(String devIndex){
String res = terminalStateService.closeSocket(devIndex);
if("执行成功".equals(res)){
return PubUtils.assignmentResult(res, 200, "执行成功");
}else {
return PubUtils.assignmentResult(res, 500, "执行失败");
}
}
@PostMapping("closeSocket2")
public void closeSocket2(String devIndex){
String res = terminalStateService.closeSocket(devIndex);
}
/**
* @Author chendaofei
* @Description 心跳机制
* @Date 12:00 2020/10/21
**/
@PostMapping("heartSocket")
public HttpResult heartSocket(String devIndex){
String res = terminalStateService.heartSocket(devIndex);
if("发送成功".equals(res)){
return PubUtils.assignmentResult(null, 200, res);
}else {
return PubUtils.assignmentResult(null, 500, res);
}
}
}

View File

@@ -0,0 +1,415 @@
package com.pqs9900.controller.terminal;
import cn.hutool.core.collection.CollectionUtil;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.configuration.DevFunction;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.njcn.utils.XssFilterUtil;
import com.pqs9900.pojo.DataInfo.TerminalPojo;
import com.pqs9900.pojo.terminal.DeviceIpRVO;
import com.pqs9900.pojo.terminal.EdData;
import com.pqs9900.pojo.terminal.UpParamPojo;
import com.pqs9900.service.terminal.VersionService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* @Description pqs9900 终端管理 版本管理
* @Author cdf
* @Date 2020/7/30 10:56
**/
@RestController
@RequestMapping("version")
public class VersionController {
@Resource
private UserLogDetailService userLog;
@Autowired
private VersionService versionService;
/**
* @Author chendaofei
* @Description 获取所有终端
* @Date 10:58 2020/7/30
**/
@GetMapping("getTerminalList")
public HttpResult getTerminalList(Integer status, String devType,String devSeries,Integer upIsNo) {
List<TerminalPojo> list = versionService.getDeviceList(status, devType,devSeries,upIsNo);
return PubUtils.assignmentResult(list, 200, "获取成功");
}
/**
* @Author chendaofei
* @Description 获取所有终端
* @Date 10:58 2020/7/30
**/
@PostMapping("getTerminalListForUp")
public HttpResult getTerminalListForUp(@RequestBody List<String> devarr) {
List<TerminalPojo> list = versionService.getTerminalListForUp(devarr);
return PubUtils.assignmentResult(list, 200, "获取成功");
}
/**
* @Author chendaofei
* @Description 添加版本
* @Date 10:58 2020/7/30
**/
@PostMapping("addVersion")
public HttpResult addVersion(HttpServletRequest request, @RequestParam("edName") String edName, @RequestParam("edProtocol") String edProtocol, @RequestParam("edDate") String edDate, @RequestParam("edDescribe") String edDescribe, @RequestParam("devType") String devType, @RequestParam(value = "type",required = false) String type, @RequestParam("file") MultipartFile file) {
if (PubUtils.isBlank(edName)||PubUtils.isBlank(edProtocol)||PubUtils.isBlank(edDate)||PubUtils.isBlank(devType)) {
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
sdf.parse(edDate);
} catch (ParseException e) {
return PubUtils.assignmentResult(null, 500, "时间格式有误");
}
if (file.isEmpty()) {
return PubUtils.assignmentResult(null, 500, "请上传升级文件");
} else {
String fileName = file.getOriginalFilename();
if(fileName.lastIndexOf(".")!=-1){
//文件后缀,判断上传文件格式
String subffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
if (!judgeFileType(subffix)) {
return PubUtils.assignmentResult(null, 500, "请上传后缀为bin的文件或无后缀文件");
}
}
}
edName = XssFilterUtil.dealString(edName);
edProtocol = XssFilterUtil.dealString(edProtocol);
edDescribe = XssFilterUtil.dealString(edDescribe);
type = XssFilterUtil.dealString(type);
String res = versionService.addVersion(edName, edDescribe,edProtocol,edDate,devType,type,file);
if ("新增成功".equals(res)) {
userLog.getLog("新增终端升级程序版本", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 200, res);
} else {
userLog.getLog("新增终端升级程序版本", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, res);
}
}
/**
* @Author chendaofei
* @Description 更新版本
* @Date 10:58 2020/7/30
**/
@PostMapping("updateVersion")
public HttpResult updateVersion(HttpServletRequest request,@RequestParam("edIndex") String edIndex, @RequestParam("edName") String edName,@RequestParam("edProtocol") String edProtocol,@RequestParam("edDate") String edDate, @RequestParam("edDescribe") String edDescribe,@RequestParam("devType") String devType,@RequestParam(value = "type",required = false) String type, @RequestParam(value = "file",required = false) MultipartFile file) {
if (PubUtils.isBlank(edName) || PubUtils.isBlank(edProtocol) || PubUtils.isBlank(edIndex) ||PubUtils.isBlank(edDate)) {
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
sdf.parse(edDate);
} catch (ParseException e) {
return PubUtils.assignmentResult(null, 500, "时间格式有误");
}
if (file!=null) {
if(!file.isEmpty()){
String fileName = file.getOriginalFilename();
if(fileName.lastIndexOf(".")!=-1){
//文件后缀,判断上传文件格式
String subffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
if (!judgeFileType(subffix)) {
return PubUtils.assignmentResult(null, 500, "请上传后缀为bin的文件或无后缀文件");
}
}
}
}
edName = XssFilterUtil.dealString(edName);
edProtocol = XssFilterUtil.dealString(edProtocol);
edDescribe = XssFilterUtil.dealString(edDescribe);
type = XssFilterUtil.dealString(type);
String res = versionService.updateVersion(edIndex, edName, edDescribe,edProtocol,edDate,devType,type,file);
if ("修改成功".equals(res)) {
userLog.getLog("修改终端升级程序版本", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 200, res);
} else {
userLog.getLog("修改终端升级程序版本", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, res);
}
}
/**
* @Author chendaofei
* @Description 删除版本
* @Date 10:58 2020/7/30
**/
@GetMapping("delVersion")
public HttpResult delVersion(HttpServletRequest request,String edIndex) {
if(PubUtils.isBlank(edIndex)){
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
Integer res = versionService.delVersion(edIndex);
if (res == 1) {
userLog.getLog("删除终端升级程序版本", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 200, "删除成功");
} else if(res == -1){
userLog.getLog("删除终端升级程序版本", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "当前版本已经绑定装置,不可删除");
} else {
userLog.getLog("删除终端升级程序版本", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "删除失败");
}
}
/**
* @Author chendaofei
* @Description 启用停用版本
* @Date 10:58 2020/7/30
**/
@PostMapping("enableDisable")
public HttpResult enableDisable(HttpServletRequest request,String edIndex,Integer status) {
if(PubUtils.isBlank(edIndex) || status == null){
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
Integer res = versionService.enableDisable(edIndex,status);
if (res == 1) {
userLog.getLog("启用停用终端升级程序版本", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 200, "切换成功");
} else {
userLog.getLog("启用停用终端升级程序版本", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return PubUtils.assignmentResult(null, 500, "操作失败");
}
}
/**
* @Author chendaofei
* @Description 根据id获取版本
* @Date 10:58 2020/7/30
**/
@GetMapping("getVersion")
public HttpResult getVersion(String edIndex) {
if(PubUtils.isBlank(edIndex)){
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
EdData edData = versionService.getVersion(edIndex);
return PubUtils.assignmentResult(edData, 200, "获取成功");
}
/**
* @Author chendaofei
* @Description 根据id获取版本存在bolb类型字段加载过慢
* @Date 10:58 2020/7/30
**/
@GetMapping("getVersionTwo")
public HttpResult getVersionTwo(String edIndex) {
if(PubUtils.isBlank(edIndex)){
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
EdData edData = versionService.getVersionTwo(edIndex);
return PubUtils.assignmentResult(edData, 200, "获取成功");
}
/**
* @Author chendaofei
* @Description 获取所有版本列表
* @Date 10:58 2020/7/30
**/
@GetMapping("getVersionList")
public HttpResult getVersionList(String blob,String devType) {
List<EdData> list = versionService.getVersionList(blob,devType);
return PubUtils.assignmentResult(list, 200, "获取成功");
}
/**
* @Author chendaofei
* @Description 获取所有版本列表过滤掉已有版本
* @Date 10:58 2020/7/30
**/
@PostMapping("getVersionListFilterDevIndex")
public HttpResult getVersionListFilterEdIndex(@RequestBody UpParamPojo upParamPojo) {
String devType = upParamPojo.getDevType();
String blob = upParamPojo.getBlob();
List<String> edList = upParamPojo.getEdList();
if (PubUtils.isBlank(devType) || PubUtils.isBlank(blob) || CollectionUtil.isEmpty(edList)) {
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
List<EdData> list = versionService.getVersionListFilterEdIndex(devType,blob,edList);
return PubUtils.assignmentResult(list, 200, "获取成功");
}
/**
* @Author chendaofei
* @Description
* @Date 14:45 2020/8/11
**/
@PostMapping("getTemplet")
public HttpResult getTemplet(@RequestBody DeviceIpRVO deviceIpRVO) {
List<String> list = deviceIpRVO.getIndexlist();
if (CollectionUtil.isEmpty(list)) {
return PubUtils.assignmentResult(null, 500, "请选择终端");
}
if (PubUtils.isBlank(deviceIpRVO.getNodeIndex())) {
return PubUtils.assignmentResult(null, 500, "请选择版本号");
}
try {
String edIndex = deviceIpRVO.getNodeIndex();
String res = versionService.getTemplet(list, edIndex);
if ("运行成功".equals(res)) {
return PubUtils.assignmentResult(null, 200, "执行成功");
} else {
return PubUtils.assignmentResult(null, 500, res);
}
} catch (Exception e) {
return PubUtils.assignmentResult(null, 500, "连接异常");
}
}
private Boolean judgeFileType(String subffix) {
boolean result = false;
if ("bin".equals(subffix)) {
result = true;
}
return result;
}
/**
* @Author chendaofei
* @Description 获取启用装置功能
* @Date 14:45 2020/8/11
**/
@GetMapping("getDevfunction")
public HttpResult getDevfunction(String devIndex) {
if(PubUtils.isBlank(devIndex)){
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
List<DevFunction> devfunction = versionService.getDevfunction(devIndex);
return PubUtils.assignmentResult(devfunction,200,"获取成功");
}
/**
* @Author chendaofei
* @Description 获取升级日志
* @Date 14:45 2020/8/11
**/
@GetMapping("getUpdetail")
public HttpResult getUpdetail(String devIndex) {
if(PubUtils.isBlank(devIndex)){
return PubUtils.assignmentResult(null, 500, "参数不可为空");
}
List<TerminalPojo> devfunction = versionService.getUpdetail(devIndex);
return PubUtils.assignmentResult(devfunction,200,"获取成功");
}
/**
* 批量单点重启装置命令
* @author cdf
* @date 2021/7/30
*/
@PostMapping("restartDev")
public HttpResult restartDev(@RequestBody List<String> devList){
if(CollectionUtil.isEmpty(devList)){
return PubUtils.assignmentResult(null,500,"重启装置命令发送失败");
}else {
//根据装置id获取前置机的ip
String res = versionService.restartDev(devList);
if("命令发送成功".equals(res)){
return PubUtils.assignmentResult(null,200,"重启装置命令发送成功");
}else {
return PubUtils.assignmentResult(null,500,res);
}
}
}
/**
* 批量单点重启装置命令
* @author dhj
* @date 2021/7/30
*/
@RequestMapping(value = "restartDevConValue", method = RequestMethod.POST)
@ResponseBody
public HttpResult restartDevConValue(HttpServletRequest request,Integer devnumber){
if(CollectionUtil.isEmpty(Collections.singleton(devnumber))){
return PubUtils.assignmentResult(null,500,"重启装置命令发送失败");
}else {
//根据装置id获取前置机的ip
String res = versionService.restartDevConValue(devnumber);
if("命令发送成功".equals(res)){
return PubUtils.assignmentResult(null,200,"重启装置命令发送成功");
}else {
return PubUtils.assignmentResult(null,500,res);
}
}
}
/**
* 取消升级命令
* @author cdf
* @date 2021/8/2
*/
@PostMapping("cancelUp")
public HttpResult cancelUp(@RequestBody List<String> devList){
if(CollectionUtil.isEmpty(devList)){
return PubUtils.assignmentResult(null,500,"取消升级命令发送失败");
}else {
//根据装置id获取前置机的ip
String res = versionService.cancelUp(devList);
if("取消命令发送成功".equals(res)){
return PubUtils.assignmentResult(null,200,"取消命令发送成功");
}else {
return PubUtils.assignmentResult(null,500,res);
}
}
}
/**
* 判断是否升级成功
* @author cdf
* @date 2021/8/30
*/
@PostMapping("upFlag")
public HttpResult upFlag(@RequestBody List<Integer> devIndex){
List<TerminalPojo> list = versionService.upFlag(devIndex);
if(CollectionUtil.isNotEmpty(list)){
return PubUtils.assignmentResult(list,200,"获取成功");
}else {
return PubUtils.assignmentResult(list,500,"获取失败");
}
}
/**
* 记录升级版本日志
* @author cdf
* @date 2021/8/30
*/
@PostMapping("logsPush")
public HttpResult logsPush(@RequestBody List<Map<String, String>> map){
try {
versionService.logsPush(map);
} catch (Exception e) {
e.printStackTrace();
}
return PubUtils.assignmentResult(null,200,"日志录入成功");
}
}

View File

@@ -0,0 +1,29 @@
package com.pqs9900.controller.user;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping(value="auth")
@Controller
public class AuthController {
/**
* 用户被踢后,跳转的页面
*/
@RequestMapping(value="kickedOut")
public String kickedOut(HttpServletRequest request){
return "auth/kickedOut";
}
/**
* 用户没有权限提示的页面
*/
@RequestMapping(value="unauthorized")
public String unauthorized(HttpServletRequest request){
return "auth/unauthorized";
}
}

View File

@@ -0,0 +1,543 @@
package com.pqs9900.controller.user;
import com.njcn.enums.LogTypeEnum;
import com.njcn.mapper.configuration.GDInforMapper;
import com.njcn.mapper.configuration.LineMapper;
import com.njcn.mapper.user.DeptsMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.configuration.GDInformation;
import com.njcn.pojo.configuration.Line;
import com.njcn.pojo.user.*;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.user.DeptsLineService;
import com.njcn.service.user.DeptsLineTreeService;
import com.njcn.service.user.DeptsService;
import com.njcn.service.user.UserService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.njcn.utils.SerializeUtil;
import com.njcn.utils.XssFilterUtil;
import com.njcn.utils.redis.JedisManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping(value = "/depts")
public class DeptsController {
@Resource
DeptsService ds;
@Resource
DeptsMapper dm;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(DeptsController.class);
@Resource
private UserService us;
@Resource
private UserLogDetailService userLog;
@Autowired
private DeptsLineService deptsLineService;
@Autowired
private LineMapper lineMapper;
@Autowired
private GDInforMapper gdInforMapper;
@Autowired
private DeptsLineTreeService deptsLineTreeService;
@Autowired
JedisManager jedisManager;
/**
* 查询数据用以新增用户如:部门、角色组
*/
@ResponseBody
@PostMapping(value = "selectAll")
public HttpResult selectAll() {
HttpResult result;
DeptsAndRoleGP deptsAndRoleGP = new DeptsAndRoleGP();
try {
List<Depts> list = dm.selectDeptAll();
List<Role> roleGroups = us.selectAll();
if (CollectionUtils.isEmpty(list)) {
deptsAndRoleGP.setDeptsList(new ArrayList<>());
} else {
deptsAndRoleGP.setDeptsList(list);
}
if (CollectionUtils.isEmpty(roleGroups)) {
deptsAndRoleGP.setRoleGroups(new ArrayList<>());
} else {
deptsAndRoleGP.setRoleGroups(roleGroups);
}
deptsAndRoleGP.setReferralCode(PubUtils.referralCode().toUpperCase());
result = PubUtils.assignmentResult(deptsAndRoleGP, 200, "获取数据成功");
} catch (Exception e) {
result = PubUtils.assignmentResult(null, 500, "获取数据失败");
}
return result;
}
/**
* 查询数据
*/
@ResponseBody
@PostMapping(value = "selectAllDept")
public HttpResult selectAllDept(HttpServletRequest request) throws AccountException {
HttpResult result = new HttpResult();
try {
List<Depts> list = ds.selectAll();
if (!list.isEmpty()) {
userLog.getLog("查询部门", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result = PubUtils.assignmentResult(list, 200, "获取数据成功");
}
} catch (Exception e) {
userLog.getLog("查询部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
logger.error("获取异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取部门失败");
}
return result;
}
/**
* 查询数据
*/
@ResponseBody
@PostMapping(value = "selectDept")
public HttpResult selectDept(HttpServletRequest request) throws AccountException {
HttpResult result = new HttpResult();
try {
List<Depts> list = ds.selectDeptAll();
if (!list.isEmpty()) {
userLog.getLog("查询部门", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result = PubUtils.assignmentResult(list, 200, "获取数据成功");
}
} catch (Exception e) {
userLog.getLog("查询部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
logger.error("获取异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取部门失败");
}
return result;
}
@ResponseBody
@RequestMapping(value = "getDepts", method = RequestMethod.POST)
public HttpResult getDepts(HttpServletRequest request) throws AccountException {
HttpResult result = new HttpResult();
try {
List<List> deviceList = ds.getDepts();
if (deviceList.isEmpty()) {
result.setCode(500);
result.setMessage("没有配置信息");
userLog.getLog("查询部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
logger.error("获取部门信息失败");
} else {
result.setCode(200);
result.setMessage("获取配置信息成功");
result.setBody(deviceList);
userLog.getLog("查询部门", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
logger.info("获取部门信息成功");
}
} catch (Exception e) {
userLog.getLog("查询部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
logger.error("获取部门异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取部门失败");
}
return result;
}
/**
* 根据选择的部门查询
*/
@RequestMapping(value = "getD", method = RequestMethod.POST)
@ResponseBody
public HttpResult getD(HttpServletRequest request, String node) throws AccountException {
HttpResult result = new HttpResult();
List<List> deviceList;
if (node.equals("0")) {
try {
deviceList = ds.getDepts();
if (deviceList.isEmpty()) {
result.setCode(500);
result.setMessage("没有配置信息");
userLog.getLog("查询部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
logger.error("获取部门信息失败");
} else {
result.setCode(200);
userLog.getLog("查询部门", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result.setMessage("获取配置信息成功");
result.setBody(deviceList);
logger.info("获取部门信息成功");
}
} catch (Exception e) {
userLog.getLog("查询部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result = PubUtils.assignmentResult(null, 500, "获取数据失败");
}
} else {
try {
deviceList = ds.getD(node);
if (deviceList.isEmpty()) {
result.setCode(500);
result.setMessage("没有配置信息");
userLog.getLog("查询部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
logger.error("获取部门信息失败");
} else {
result.setCode(200);
result.setMessage("获取配置信息成功");
result.setBody(deviceList);
userLog.getLog("查询部门", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
logger.info("获取部门信息成功");
}
} catch (Exception e) {
logger.error("获取部门信息异常,异常为" + e.toString());
userLog.getLog("查询部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result = PubUtils.assignmentResult(null, 500, "获取部门失败");
}
}
return result;
}
/**
* 新增部门
*/
@RequestMapping(value = "saveDepts", method = RequestMethod.POST)
@ResponseBody
public HttpResult saveDepts(HttpServletRequest request, String deptsName, String deptsDescription, String parentNode, String area, int customDept) throws AccountException {
HttpResult result = new HttpResult();
//后台Xss攻击处理、包括html/js/sql
deptsName = XssFilterUtil.dealString(deptsName);
deptsDescription = XssFilterUtil.dealString(deptsDescription);
area = XssFilterUtil.dealString(area);
if (!StringUtils.isBlank(deptsName)) {
if (!StringUtils.isBlank(area)) {
if (PubUtils.patternDepts(deptsName)) {
if (PubUtils.patternDes200(deptsDescription)) {
if (StringUtils.isBlank(deptsDescription)) {
deptsDescription = "暂无描述";
}
try {
String message = ds.saveDepts(deptsName, deptsDescription, parentNode, area, customDept);
if (message.equalsIgnoreCase("新增部门成功!")) {
result.setCode(200);
result.setMessage(message);
result.setBody("success");
logger.info("新增部门成功");
userLog.getLog("新增部门", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else {
result.setCode(500);
result.setMessage(message);
logger.error("新增部门失败");
userLog.getLog("新增部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
} catch (Exception e) {
logger.error("新增部门异常,异常为" + e.toString());
userLog.getLog("新增部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 500, "新增部门失败");
}
} else {
result.setCode(500);
result.setMessage("描述长度在200内");
logger.error("新增部门失败");
userLog.getLog("新增部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
} else {
result.setCode(500);
result.setMessage("部门名称非法只可输入1-20位中文");
logger.error("新增部门失败");
userLog.getLog("新增部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
} else {
result.setCode(500);
result.setMessage("区域为空,请到数据字典处新增");
logger.error("新增部门失败");
userLog.getLog("新增部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
} else {
result.setCode(500);
result.setMessage("部门名称为空");
logger.error("新增部门失败");
userLog.getLog("新增部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
return result;
}
/**
* 根据部门索引删除部门
*/
@RequestMapping(value = "deleteDeptsByIndex", method = RequestMethod.POST)
@ResponseBody
public HttpResult deleteDeptsByIndex(HttpServletRequest request, String index) {
HttpResult result = new HttpResult();
try {
String ip = PubUtils.getIpAddr(request);
String username = TokenManager.getToken().getLoginName();
byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
String key = SerializeUtil.deserialize(value, String.class);
if (key.equals("success")) {
String message = ds.deleteDeptsByIndex(index);
if (message.equalsIgnoreCase("删除部门成功!")) {
result.setCode(200);
result.setMessage(message);
result.setBody("success");
logger.info("删除部门成功");
userLog.getLog("删除部门", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else if (message.equalsIgnoreCase("该部门为省级部门,不可删除")) {
result = null;
} else {
result.setCode(500);
result.setMessage(message);
logger.error("删除部门失败");
userLog.getLog("删除部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
} else {
result.setCode(500);
result.setMessage("删除部门失败,密码验证失败!");
logger.error("删除部门失败,密码验证失败!");
userLog.getLog("删除部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
} catch (Exception e) {
logger.error("删除部门异常,异常为" + e.toString());
userLog.getLog("新增部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 500, "删除部门失败");
}
return result;
}
/**
* 根据部门索引查询所有
*/
@RequestMapping(value = "getAll", method = RequestMethod.POST)
@ResponseBody
public Depts getAll(String deptsIndex) {
return ds.getAll(deptsIndex);
}
/**
* 根据部门索引查询所有
*/
@RequestMapping(value = "getAllArea", method = RequestMethod.POST)
@ResponseBody
public Depts getAllArea(String deptsIndex) {
return ds.getAllArea(deptsIndex);
}
//父节点
@RequestMapping(value = "selectName", method = RequestMethod.POST)
@ResponseBody
public Depts selectName(String parentNode) {
Depts list = new Depts();
try {
list = ds.selectName(parentNode);
} catch (Exception e) {
logger.error("查询父节点异常,异常是" + e.toString());
}
return list;
}
//父节点
@RequestMapping(value = "selName", method = RequestMethod.POST)
@ResponseBody
public List<Depts> selName(String deptsIndex) {
List<Depts> list = new ArrayList<>();
try {
list = ds.selName(deptsIndex);
} catch (Exception e) {
logger.error("查询父节点异常,异常是" + e.toString());
}
return list;
}
//父节点
@RequestMapping(value = "selparentnode", method = RequestMethod.POST)
@ResponseBody
public List<Depts> selparentnode(String deptsIndex) {
List<Depts> list = new ArrayList<>();
try {
list = ds.selparentnode(deptsIndex);
} catch (Exception e) {
logger.error("查询父节点异常,异常是" + e.toString());
}
return list;
}
/**
* 修改部门
*/
@RequestMapping(value = "updateDepts", method = RequestMethod.POST)
@ResponseBody
public int updateDepts(HttpServletRequest request, String deptsIndex, String deptsName, String deptsDescription, Integer customDeptType, String parentNode, String area) throws AccountException {
int flag = 1;
//后台Xss攻击处理、包括html/js/sql
deptsName = XssFilterUtil.dealString(deptsName);
deptsDescription = XssFilterUtil.dealString(deptsDescription);
area = XssFilterUtil.dealString(area);
try {
List<Depts> list = dm.selName(deptsIndex);
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getDeptsName().equals(deptsName)) {
flag = 0;
}
}
if (flag != 0) {
Depts depts = new Depts();
depts.setDeptsIndex(deptsIndex);
depts.setDeptsName(deptsName);
depts.setParentNodeId(parentNode);
depts.setCustomDept(Integer.valueOf(customDeptType));
depts.setUpdateTime(new Date());
depts.setArea(area);
depts.setDeptsDescription(deptsDescription);
ds.updateDepts(depts);
flag = 1;
logger.info("修改部门成功");
userLog.getLog("修改部门", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else {
logger.error("修改部门失败,原因是部门名称已存在");
userLog.getLog("修改部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
flag = 0;
}
} catch (Exception e) {
// TODO: handle exception
userLog.getLog("修改部门", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("修改部门异常,异常为" + e.toString());
flag = 0;
}
return flag;
}
/***
* 查询当前已绑的供电公司和监测点
*/
@RequestMapping(value = "getBind", method = RequestMethod.POST)
@ResponseBody
public List<DeptsLine> getBind(HttpServletRequest request, @Param("deptsIndex") String deptsIndex) {
List<DeptsLine> deptsLines = new ArrayList<>();
try {
deptsLines = deptsLineService.getBind(deptsIndex);
List<Line> lines = new ArrayList<>();
List<GDInformation> gdInformations = new ArrayList<>();
if (!deptsLines.isEmpty()) {
for (int i = 0; i < deptsLines.size(); i++) {
Line line = new Line();
line.setLineIndex(deptsLines.get(i).getLineIndex());
lines = lineMapper.select(line);
line = lineMapper.selectOne(line);
//监测点
deptsLines.get(i).setLines(lines);
//供电公司
GDInformation gdInformation = new GDInformation();
gdInformation.setGdIndex(line.getGdIndex());
gdInformations = gdInforMapper.select(gdInformation);
deptsLines.get(i).setGdi(gdInformations);
}
return deptsLines;
} else {
deptsLines = null;
}
} catch (Exception e) {
deptsLines = null;
logger.error("查询绑定的供电公司及监测点异常,异常为" + e.toString());
return deptsLines;
}
return deptsLines;
}
/**
* 部门绑定监测点树
*
* @param request
* @param session
* @return
*/
@RequestMapping(value = "deptsLinetree", method = RequestMethod.POST)
@ResponseBody
public List<DeptslineTree> deptsLinetree(HttpServletRequest request, HttpSession session, String area, String deptsIndex, Integer customDept, Integer isother) {
if (session.getAttribute("line_index") != null || session.getAttribute("line_index") != "") {
session.removeAttribute("line_index");
}
List<DeptslineTree> result = new ArrayList();
try {
//判断是否为自定义部门
if (customDept == 1 ||customDept == 2) {
result = deptsLineTreeService.getDeptsLineTreeNo(deptsIndex, area);
} else {
//判断是未绑定的还是其他绑定的
if (isother == 0) {
//非自定义未绑定的
result = deptsLineTreeService.getDeptsLineTreeNoF(deptsIndex, area);
} else {
//非自定义其他绑定的
result = deptsLineTreeService.getDeptsLineTreeOther(deptsIndex, area);
}
}
} catch (Exception e) {
logger.error("获取监测点树异常,异常为" + e.toString());
}
return result;
}
/**
* 部门绑定监测点树
*
* @param request
* @param session
* @return
*/
@RequestMapping(value = "getmyselfTree", method = RequestMethod.POST)
@ResponseBody
public List<DeptslineTree> getmyselfTree(HttpServletRequest request, HttpSession session, String area, String deptsIndex) {
if (session.getAttribute("line_index") != null || session.getAttribute("line_index") != "") {
session.removeAttribute("line_index");
}
List<DeptslineTree> result = new ArrayList();
try {
result = deptsLineTreeService.getDeptsLineTreeMyself(deptsIndex, area);
} catch (Exception e) {
logger.error("获取监测点树异常,异常为" + e.toString());
}
return result;
}
@RequestMapping(value = "selectAreaDept", method = RequestMethod.POST)
@ResponseBody
public Depts selectAreaDept(String deptsIndex) {
Depts depts = null;
try {
depts = ds.selectAreaDept(deptsIndex);
} catch (Exception e) {
logger.error("获取监测点树异常,异常为" + e.toString());
return depts;
}
return depts;
}
}

View File

@@ -0,0 +1,114 @@
package com.pqs9900.controller.user;
import com.njcn.pojo.configuration.GDInformation;
import com.njcn.pojo.user.DeptsGd;
import com.njcn.service.configuration.IGdInfoService;
import com.njcn.service.user.DeptGDService;
import com.njcn.shiro.token.TokenManager;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
@Controller
@RequestMapping(value = "/deptsGd")
public class DeptsGdController {
@Resource
DeptGDService dgd;
@Resource
IGdInfoService ig;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(DeptsGdController.class);
@ResponseBody
@RequestMapping(value = "selectAllGd", method = RequestMethod.POST)
public List<DeptsGd> selectAllGd(@Param(value = "deptsIndex") String deptsIndex) throws Exception {
List<DeptsGd> list = dgd.selectAllGd(deptsIndex);
return list;
}
@ResponseBody
@RequestMapping(value = "selectNoGd", method = RequestMethod.POST)
public List<GDInformation> selectNoGd() {
try {
List<GDInformation> list = ig.selectNoGd(TokenManager.getSysType());
return list;
} catch (Exception e) {
List<GDInformation> listG = dgd.selectAll();
return listG;
}
}
@ResponseBody
@RequestMapping(value = "selectOthersNoGd", method = RequestMethod.POST)
public List<GDInformation> selectOthersNoGd(@Param("deptsIndex") String deptsIndex) {
List<GDInformation> list = ig.selectOthersNoGd(deptsIndex, TokenManager.getSysType());
return list;
}
@ResponseBody
@RequestMapping(value = "insertDeptGd", method = RequestMethod.POST)
public int insertDeptGd(@Param(value = "deptsIndex") String deptsIndex, @Param(value = "GDIndex") Long GDIndex) {
int falg = 0;
DeptsGd deptsGd = new DeptsGd();
try {
deptsGd.setDeptsIndex(deptsIndex);
deptsGd.setGDIndex(GDIndex);
falg = dgd.insertDeptGd(deptsGd);
logger.info("绑定供电公司成功");
} catch (Exception e) {
// TODO: handle exception
falg = 0;
logger.error("绑定供电公司失败");
}
return falg;
}
//先解绑
@ResponseBody
@RequestMapping(value = "deleteNowDeptGd", method = RequestMethod.POST)
public int deleteNowDeptGd(@Param(value = "GDIndex") Long GDIndex) {
int falg = 0;
try {
falg = dgd.deleteNowDeptGd(GDIndex,TokenManager.getSysType());
logger.info("解绑供电公司成功");
} catch (Exception e) {
// TODO: handle exception
falg = 0;
logger.error("解绑供电公司失败");
}
return falg;
}
@ResponseBody
@RequestMapping(value = "deleteDeptGd", method = RequestMethod.POST)
public int deleteDeptGd(@Param(value = "deptsIndex") String deptsIndex, @Param(value = "GDIndex") Long GDIndex) {
int falg = 0;
DeptsGd deptsGd = new DeptsGd();
try {
deptsGd.setDeptsIndex(deptsIndex);
deptsGd.setGDIndex(GDIndex);
falg = dgd.deleteDeptGd(deptsGd);
logger.info("解绑供电公司成功");
} catch (Exception e) {
// TODO: handle exception
falg = 0;
logger.error("解绑供电公司失败");
}
return falg;
}
}

View File

@@ -0,0 +1,164 @@
package com.pqs9900.controller.user;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.user.DeptsLineService;
import com.njcn.utils.PubUtils;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
@Controller
@RequestMapping(value = "/deptsline")
public class DeptsLineController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(DeptsLineController.class);
@Resource
private UserLogDetailService userLog;
@Autowired
DeptsLineService lineService;
//绑定监测点
@RequestMapping(value = "getBindLine", method = RequestMethod.POST)
@ResponseBody
public HttpResult getBindLine(HttpServletRequest request, String deptsIndex,String treecheck) throws AccountException {
HttpResult result = new HttpResult();
JSONArray jsonArray = JSONArray.fromObject(treecheck);
List<String> index = (List<String>) JSONArray.toCollection(jsonArray, String.class);
try {
String message = lineService.getBindLine(deptsIndex,index);
if (message.equalsIgnoreCase("绑定监测点成功")) {
result.setCode(200);
result.setMessage(message);
userLog.getLog("绑定监测点", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.info("绑定监测点成功!");
} else if (message.equalsIgnoreCase("绑定监测点失败")) {
result.setCode(400);
result.setMessage(message);
userLog.getLog("绑定监测点", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("绑定监测点失败!");
} else {
result.setCode(500);
result.setMessage(message);
userLog.getLog("绑定监测点", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("绑定监测点失败!");
}
} catch (Exception e) {
logger.error("绑定监测点异常,异常为" + e.toString());
userLog.getLog("绑定监测点", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 500, "绑定监测点失败");
}
return result;
}
//换绑监测点
@RequestMapping(value = "changeBindLine", method = RequestMethod.POST)
@ResponseBody
public HttpResult changeBindLine(HttpServletRequest request, String deptsIndex,String treecheck) throws AccountException {
HttpResult result = new HttpResult();
JSONArray jsonArray = JSONArray.fromObject(treecheck);
List<String> index = (List<String>) JSONArray.toCollection(jsonArray, String.class);
try {
String message = lineService.changeBindLine(deptsIndex,index);
if (message.equalsIgnoreCase("监测点换绑成功")) {
result.setCode(200);
result.setMessage(message);
userLog.getLog("监测点换绑", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.info("监测点换绑成功!");
} else if (message.equalsIgnoreCase("监测点换绑失败")) {
result.setCode(400);
result.setMessage(message);
userLog.getLog("监测点换绑", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("监测点换绑失败!");
} else {
result.setCode(500);
result.setMessage(message);
userLog.getLog("监测点换绑", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("监测点换绑失败!");
}
} catch (Exception e) {
logger.error("监测点换绑异常,异常为" + e.toString());
userLog.getLog("监测点换绑", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 500, "监测点换绑失败");
}
return result;
}
//解除绑定
@RequestMapping(value = "deleteBindLine", method = RequestMethod.POST)
@ResponseBody
public HttpResult deleteBindLine(HttpServletRequest request, String deptsIndex,String treecheck) throws AccountException {
HttpResult result = new HttpResult();
JSONArray jsonArray = JSONArray.fromObject(treecheck);
List<String> index = (List<String>) JSONArray.toCollection(jsonArray, String.class);
try {
String message = lineService.deleteBindLine(deptsIndex,index);
if (message.equalsIgnoreCase("解绑监测点成功")) {
result.setCode(200);
result.setMessage(message);
userLog.getLog("解绑监测点", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.info("解绑监测点成功!");
} else if (message.equalsIgnoreCase("解绑监测点失败")) {
result.setCode(400);
result.setMessage(message);
userLog.getLog("解绑监测点", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("解绑监测点失败!");
} else {
result.setCode(500);
result.setMessage(message);
userLog.getLog("解绑监测点", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("解绑监测点失败!");
}
} catch (Exception e) {
logger.error("解绑监测点异常,异常为" + e.toString());
userLog.getLog("解绑监测点", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 500, "解绑监测点失败");
}
return result;
}
/**
* 查询是否绑定了监测点
*/
@RequestMapping(value = "selectLine", method = RequestMethod.POST)
@ResponseBody
public int selectLine(HttpServletRequest request, String parentNode) throws AccountException {
int flag = 0;
try{
flag = lineService.selectLine(parentNode);
}catch (Exception e){
flag = 0;
return flag;
}
return flag;
}
/****
* 解除父节点的所有绑定
*/
@RequestMapping(value = "removeBind", method = RequestMethod.POST)
@ResponseBody
public int removeBind(HttpServletRequest request, String parentNode) throws AccountException {
int flag = 0;
try{
flag = lineService.removeBind(parentNode);
}catch (Exception e){
flag = 0;
return flag;
}
return flag;
}
}

View File

@@ -0,0 +1,431 @@
package com.pqs9900.controller.user;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.io.FileUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
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.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.njcn.enums.LogTypeEnum;
import com.njcn.enums.ProjectEnum;
import com.njcn.mapper.user.ManageListMapper;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.configuration.NodeInformation;
import com.njcn.pojo.user.ManageList;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.user.ManageListService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.sso.pojo.user.User;
import com.njcn.utils.AppConfig;
import com.njcn.utils.PubUtils;
import com.njcn.utils.XssFilterUtil;
import com.njcn.utils.redis.JedisManager;
import com.pqs9900.service.DataInfo.AlarmInfoService;
@Controller
@RequestMapping(value ="/manage")
public class ManageListController {
ObjectMapper objectMapper =new ObjectMapper();
@Autowired
ManageListService mService;
@Autowired
private JedisManager jedisManager;
@Autowired
ManageListMapper mlm;
@Autowired
private AppConfig appConfig;
@Autowired
UserLogDetailService userLogDetailService;
@Autowired
private AlarmInfoService alarmInfoService;
private int flag;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(ManageListController.class);
@RequestMapping(value = "getManage", method = RequestMethod.POST)
@ResponseBody
public HttpResult getManage(HttpServletRequest request) {
HttpResult result = new HttpResult();
try{
List<List> users = mService.getManage();
if (users.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到资源信息列表");
userLogDetailService.getLog("查询资源", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.error("获取资源信息失败");
} else {
result.setCode(200);
result.setBody(users);
result.setMessage("获取资源信息列表成功");
userLogDetailService.getLog("查询资源", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.info("获取资源信息成功");
}
}catch (Exception e){
logger.error("获取资源异常,异常为"+e.toString());
result=PubUtils.assignmentResult(null,500,"获取资源失败");
}
return result;
}
@ResponseBody
@RequestMapping(value = "getmange",method = RequestMethod.POST)
public ManageList getmange(@Param("resIndex")String resIndex){
return mService.selectTypeId(resIndex);
}
@ResponseBody
@RequestMapping(value = "updateManageList" ,method = RequestMethod.POST)
public int updateManageList(String resIndex,String name,String type,String description){
int i=0;
name = XssFilterUtil.dealString(name);
description = XssFilterUtil.dealString(description);
ManageList manageList=new ManageList();
manageList.setRes_Index(resIndex);
try {
List<ManageList> manageLists=mService.selectOneByIndex(resIndex);
if(!manageLists.isEmpty()) {
String url=manageLists.get(0).getRes_Url();//资源地址
File file=new File(url);
// 判断目录或文件是否存在
if (!file.exists()) { // 不存在
i=2;
} else {
mService.updateManageList(resIndex, name, type, description, TokenManager.getSysType(), TokenManager.getToken()
.getUserIndex());
i = 1;
}
}
}catch ( Exception e){
i=0; }
return i;
}
@RequestMapping(value = "getSourceManage", method = RequestMethod.POST)
@ResponseBody
public HttpResult getSourceManage(HttpServletRequest request) {
HttpResult result = new HttpResult();
try{
List<List> users = mService.getSourceManage();
if (users.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到资源信息列表");
logger.error("获取资源信息失败");
} else {
result.setCode(200);
result.setBody(users);
result.setMessage("获取资源信息列表成功");
logger.info("获取资源信息成功");
}
}catch (Exception e){
logger.error("获取资源异常,异常为"+e.toString());
result=PubUtils.assignmentResult(null,500,"获取资源失败");
}
return result;
}
@RequestMapping(value="/uploadManageList",method = RequestMethod.POST)
@ResponseBody
public HttpResult uploadManageList(@RequestParam(value="file",required = false)MultipartFile multipartFile,@Param(value="name")
String name,@Param(value="type")String type,@Param(value="description")String description,
HttpServletRequest request, HttpServletResponse response) throws IOException, AccountException {
HttpResult result = new HttpResult();
/**
* ---------------------------------------------------------------------------------------------------
* xuyang 2020.08.27
* 修改:对上传文件做判断
* 1.文件类型 2.文件大小
*/
final long fixedSize = 3072;
//获取文件名
String fileName = multipartFile.getOriginalFilename();
//文件大小(此大小为kb)
Long fileSize = multipartFile.getSize()/1024;
if (fileSize > fixedSize){
result = PubUtils.assignmentResult(null, 500, "上传失败,上传文件超过3M文件过大!");
return result;
}
if (!fileName.matches("^.+\\.(?i)(xlsx)$") && !fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(doc)$") && !fileName.matches("^.+\\.(?i)(docx)$") && !fileName.matches("^.+\\.(?i)(pdf)$") && !fileName.matches("^.+\\.(?i)(png)$") && !fileName.matches("^.+\\.(?i)(jpg)$") && !fileName.matches("^.+\\.(?i)(cvs)$") && !fileName.matches("^.+\\.(?i)(jepg)$")) {
result = PubUtils.assignmentResult(null, 500, "上传失败,上传文件类型错误!");
return result;
}
/**
* over
* ---------------------------------------------------------------------------------------------------
*/
name = XssFilterUtil.dealString(name);
description = XssFilterUtil.dealString(description);
//首先根据deviceIndex获取IP确定文件需要保存的文件夹路径
//拷贝文件到指定文件夹下
String path;
//获取当前系统作为第二个目录
String sysType=TokenManager.getSysType();
String xt;
//判断非空
if(!org.apache.commons.lang3.StringUtils.isBlank(name)) {
if(PubUtils.patternDes500(description)) {
if (sysType == ProjectEnum.PQS9000.getKey()) {
xt = "wt";
} else {
xt = "zt";
}
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式
String time = df.format(new Date());// new Date()为获取当前系统时间作为第三个目录
String fTime = time +File.separator;
try {
String filePath = appConfig.getTmppath() +File.separator+ "Resources" +File.separator+ xt +File.separator+ fTime +File.separator+ multipartFile
.getOriginalFilename();
File file = new File(filePath);
FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), file);
path = file.getPath();
} catch (Exception e) {
logger.error("拷贝上传文件过程出错,原因:" + e.toString());
return PubUtils.assignmentResult(null, 500, "拷贝文件流出错");
}
//文件拷贝成功后,需要将路径保存起来,以便后面分析事件日志参考,注只需要CFG文件的路径
try {
if (!StringUtils.isEmpty(path) & path.toUpperCase(Locale.ENGLISH).endsWith("CFG")) {
String key = "Resources" + TokenManager.getUserId();
jedisManager.saveValueByKey(RedisDB.SHORT_TIME_QUERY, key, path, RedisDB.SHORT_TIME);
}
result = PubUtils.assignmentResult(null, 200, "保存文件路径成功");
} catch (Exception e) {
logger.error("保存文件路径出错,原因:" + e.toString());
result = PubUtils.assignmentResult(null, 500, "保存文件路径出错");
}
try {
ManageList ml = new ManageList();
String res_index = UUID.randomUUID().toString();
ml.setRes_Index(res_index);
ml.setDescription(description);
ml.setName(name);
ml.setType(type);
ml.setRes_Url(path);
User user = TokenManager.getToken();
String userIndex = user.getUserIndex();//当前登录用户
ml.setUpdateUser(userIndex);
ml.setUpdateTime(new Date());
ml.setState(1);//1表示正常
ml.setSysType(TokenManager.getSysType());
mlm.insert(ml);
userLogDetailService.getLog("上传资源", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} catch (Exception e) {
logger.error("上传资源异常,异常为" + e.toString());
userLogDetailService.getLog("上传资源", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 500, "上传资源失败");
}
}else{
logger.error("上传资源错误,原因:资源描述长度超过限制");
userLogDetailService.getLog("上传资源", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
result = PubUtils.assignmentResult(null, 502, "上传资源错误,原因:资源描述长度超过限制");
}
/*File file2=new File(url);
if(!file2.exists()){
file2.mkdirs(); //判断本地是否有该路径,如果没有,就创建
}
File myPath = new File( url+fTime );
if ( !myPath.exists()){//若此目录不存在,则创建之
myPath.mkdir();
}
*/
}else {
logger.error("上传资源错误,原因:资源名称为空");
userLogDetailService.getLog("上传资源", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
result = PubUtils.assignmentResult(null, 501, "上传资源错误,原因:资源名称为空");
}
return result;
}
@RequestMapping(value="/deleteManageByIndex",method = RequestMethod.POST)
@ResponseBody
public int deleteManageByIndex(HttpServletRequest request,@Param(value="res_Index")String res_Index){
int result=0;
ManageList manageList=new ManageList();
manageList.setRes_Index(res_Index);
try {
List<ManageList> manageLists=mService.selectOneByIndex(res_Index);
if(!manageLists.isEmpty()){
String url=manageLists.get(0).getRes_Url();//资源地址
File file=new File(url);
// 判断目录或文件是否存在
if (!file.exists()) { // 不存在
result=0;
} else {
// 判断是否为文件
if (file.isFile()) { // 为文件时调用删除文件方法
if (file.isFile() && file.exists()) {
file.delete();
mService.deleteIndex(res_Index);
result = 1;
userLogDetailService.getLog("删除资源", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
}else{
result = 0;
userLogDetailService.getLog("删除资源", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
}
}
}
}
} catch (Exception e) {
logger.error("删除资源异常,异常为"+e.toString());
result=0;
}
return result;
}
/***
* 前置机管理详情
* @return
*/
@RequestMapping(value="getNodeInfo",method=RequestMethod.POST)
@ResponseBody
public String getNodeInfo(HttpSession session) throws JsonProcessingException{
List<NodeInformation> result=new ArrayList<NodeInformation>();
List<List> s=new ArrayList<List>();
int j=0;
try {
result = mService.getNodeInfo();
for (int i = 0; i < result.size(); i++) {
List<String> a = new ArrayList<String>();
a.add(String.valueOf(result.get(i).getNodeIndex()));
a.add(result.get(i).getNodeName());
a.add(result.get(i).getNodeDesc());
a.add(result.get(i).getNodeIP());
if (result.get(i).getNodeStatus() == 0) {
a.add("删除");
} else {
a.add("正常");
}
s.add(a);
}
}catch (Exception e) {
logger.error("查询前置机异常,异常是" + e.toString());
}
return objectMapper.writeValueAsString(s);
}
@RequestMapping(value="delNodeInfo",method=RequestMethod.POST)
@ResponseBody
public HttpResult delNodeInfo(HttpServletRequest request,Long nodeIndex){
HttpResult result=new HttpResult();
try {
String message = mService.delNode(nodeIndex);
if (message.equalsIgnoreCase("删除成功")) {
result.setCode(200);
result.setMessage(message);
logger.info("删除前置机成功!");
} else {
result.setCode(500);
result.setMessage(message);
logger.error("删除前置机失败!");
}
} catch (Exception e) {
result.setCode(500);
result.setMessage("删除前置机失败!");
logger.error("删除前置机失败!");
}
return result;
}
@RequestMapping(value="addNode",method=RequestMethod.POST)
@ResponseBody
public HttpResult addNode(HttpServletRequest request,HttpSession session,String nodeName,String nodeDesc,
String ip4,String ip3,String ip2,String ip1){
HttpResult result=new HttpResult();
try {
String message = mService.saveNode(nodeName, nodeDesc, ip4, ip3, ip2, ip1);
if (message.equalsIgnoreCase("添加成功")) {
result.setCode(200);
result.setMessage(message);
logger.info("新增前置机成功!");
} else if (message.equalsIgnoreCase("添加失败a")) {
result.setCode(400);
result.setMessage(message);
logger.error("新增前置机失败!名称已存在");
} else {
result.setCode(500);
result.setMessage(message);
logger.error("新增前置机失败!");
}
} catch (Exception e) {
result.setCode(500);
result.setMessage("新增前置机失败!");
logger.error("新增前置机失败!");
}
return result;
}
@RequestMapping(value="loadNode",method=RequestMethod.POST)
@ResponseBody
public List<String> loadNode(HttpServletRequest request,Long nodeIndex){
List<String> result = new ArrayList<>();
try {
result=mService.loadNode(nodeIndex);
} catch (Exception e) {
result = null;
}
return result;
}
@RequestMapping(value="modNode",method=RequestMethod.POST)
@ResponseBody
public HttpResult modNode(HttpServletRequest request,Long nodeIndex,String nodeName,String nodeDesc,
String ip4,String ip3,String ip2,String ip1){
HttpResult result=new HttpResult();
try {
String message = mService.updateNode(nodeIndex, nodeName, nodeDesc, ip4, ip3, ip2, ip1);
if (message.equalsIgnoreCase("更新成功")) {
result.setCode(200);
result.setMessage(message);
logger.info("更新前置机成功!");
} else if (message.equalsIgnoreCase("更新失败a")) {
result.setCode(400);
result.setMessage(message);
logger.error("更新前置机失败!名称已存在");
} else {
result.setCode(500);
result.setMessage(message);
logger.error("更新前置机失败!");
}
} catch (Exception e) {
result.setCode(500);
result.setMessage("更新前置机失败!");
logger.error("更新前置机失败!");
}
return result;
}
}

View File

@@ -0,0 +1,303 @@
package com.pqs9900.controller.user;
import com.njcn.mapper.user.PermissionMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.ZtreePojo;
import com.njcn.pojo.user.Permission;
import com.njcn.pojo.user.PermissionTree;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.user.IPermissionService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UserUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
@RequestMapping(value = "permission")
@Controller
public class PermissionController {
private static final Logger logger = LoggerFactory.getLogger(PermissionController.class);
@Autowired
private IPermissionService permissionService;
@Autowired
private PermissionMapper permissionMapper;
@Autowired
UserLogDetailService userLogDetailService;
/**
* 资源列表树
*
* @param request
* @param session
* @return
*/
@RequestMapping(value = "getTree", method = RequestMethod.POST)
@ResponseBody
public List<PermissionTree> getTree(HttpServletRequest request, HttpSession session) {
List<PermissionTree> result = new ArrayList();
result = permissionService.getTreeData();
return result;
}
/**
* 加载一级节点
*
* @param request
* @param session
* @return
*/
@RequestMapping(value = "getfirst", method = RequestMethod.POST)
@ResponseBody
public List<Permission> getfirst(HttpServletRequest request, HttpSession session) {
List<Permission> result = new ArrayList();
Permission tmp = new Permission();
tmp.setParentNode(0);
tmp.setSysType(TokenManager.getSysType());
result = permissionMapper.select(tmp);
return result;
}
/**
* 加载二级节点
*
* @param request
* @param session
* @return
*/
@RequestMapping(value = "getsecond", method = RequestMethod.POST)
@ResponseBody
public List<Permission> getsecond(HttpServletRequest request, HttpSession session, Integer first) {
List<Permission> result;
Permission tmp = new Permission();
try{
tmp.setParentNode(first);
tmp.setSysType(TokenManager.getSysType());
result = permissionMapper.select(tmp);
return result;
}catch(Exception e){
return new ArrayList<>();
}
}
/**
* 加载资源信息
*
* @param request
* @param session
* @return
*/
@RequestMapping(value = "getInfo", method = RequestMethod.POST)
@ResponseBody
public HttpResult getInfo(HttpServletRequest request, HttpSession session, Integer index) {
HttpResult result = new HttpResult();
List<List> datalist;
if (index == 0) {
try {
datalist = permissionService.getAllData();
if (datalist.isEmpty()) {
result.setCode(500);
result.setMessage("没有配置信息");
logger.error("获取配置项信息失败");
} else {
result.setCode(200);
result.setMessage("获取配置信息成功");
result.setBody(datalist);
logger.info("获取配置项信息成功");
}
} catch (Exception e) {
logger.error("获取数据异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取数据失败");
}
} else {
try {
datalist = permissionService.getData(index);
if (datalist.isEmpty()) {
result.setCode(500);
result.setMessage("没有配置信息");
logger.error("获取配置项信息失败");
} else {
result.setCode(200);
result.setMessage("获取配置信息成功");
result.setBody(datalist);
logger.info("获取配置项信息成功");
}
} catch (Exception e) {
logger.error("获取数据异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取数据失败");
}
}
return result;
}
/**
* 删除用户选择的资源
*/
@RequestMapping(value = "deletePermission", method = RequestMethod.POST)
@ResponseBody
public HttpResult deletePermission(HttpServletRequest request, String functionIndex) {
HttpResult result = new HttpResult();
try {
String message = permissionService.deleteByIndex(functionIndex);
if (message.equalsIgnoreCase("该资源下还有子资源,删除失败")) {
result.setCode(500);
result.setMessage(message);
} else if (message.equalsIgnoreCase("并未找到该资源,删除失败")) {
result.setCode(100);
result.setMessage(message);
} else if (message.equalsIgnoreCase("删除失败")) {
result.setCode(300);
result.setMessage(message);
} else {
result.setCode(200);
result.setMessage(message);
}
} catch (Exception e) {
logger.error("删除数据异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "删除数据失败");
}
return result;
}
/**
* 新增资源
*/
@RequestMapping(value = "addPermission", method = RequestMethod.POST)
@ResponseBody
public HttpResult addPermission(HttpServletRequest request, String description, String name, String path, Integer first, Integer second) {
HttpResult result = new HttpResult();
if (StringUtils.isBlank(description)) {
description = "暂无描述";
}
try {
String message = permissionService.savePermission(description, name, path, first, second);
if (message.equalsIgnoreCase("新增资源成功")) {
result.setCode(200);
result.setMessage(message);
} else {
result.setCode(500);
result.setMessage(message);
}
} catch (Exception e) {
logger.error("新增资源异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "新增资源失败");
}
return result;
}
/**
* 回显角色信息以及拥有的资源
*/
@RequestMapping(value = "getRolePermission", method = RequestMethod.POST)
@ResponseBody
public HttpResult getRolePermission(HttpServletRequest request) {
HttpResult result = new HttpResult();
try{
List<List> permissionList = permissionService.getRolePermission();
if (permissionList.isEmpty()) {
result.setMessage("获取角色信息失败");
result.setCode(500);
} else {
result.setCode(200);
result.setMessage("获取角色信息成功");
result.setBody(permissionList);
}
}catch (Exception e){
logger.error("回显角色信息异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "回显角色信息失败");
}
return result;
}
/**
* 根据角色获取其拥有的资源
*/
@RequestMapping(value = "getPermissions", method = RequestMethod.POST)
@ResponseBody
public HttpResult getPermissions(HttpServletRequest request, String roleIndex) {
HttpResult result = new HttpResult();
try {
List<ZtreePojo> listsZ = permissionService.getPermissions(roleIndex);
if (listsZ.isEmpty()) {
result.setMessage("获取已配置资源失败");
result.setCode(500);
} else {
result.setCode(200);
result.setMessage("获取已配置资源成功");
result.setBody(listsZ);
}
}catch (Exception e){
logger.error("获取已配置资源异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取已配置资源失败");
}
return result;
}
/**
* 根据角色获取其拥有的资源提供给用户重新分配
*/
@RequestMapping(value = "destributePermission", method = RequestMethod.POST)
@ResponseBody
public HttpResult destributePermission(HttpServletRequest request, String roleIndex) {
HttpResult result = new HttpResult();
try {
List<ZtreePojo> listsZ = permissionService.destributePermission(roleIndex);
result.setCode(200);
result.setMessage("获取已配置资源成功");
result.setBody(listsZ);
}catch (Exception e){
logger.error("获取已配置资源异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "获取已配置资源失败");
}
return result;
}
/**
* 根据角色索引,分配资源
*/
@RequestMapping(value = "disPer", method = RequestMethod.POST)
@ResponseBody
public HttpResult disPer(HttpServletRequest request, String roleIndex, String permissionIndex) {
HttpResult result = new HttpResult();
try{
String message = permissionService.disPer(roleIndex, permissionIndex);
if (message.equalsIgnoreCase("重新分配资源成功")) {
result.setCode(200);
result.setMessage("重新分配资源成功");
} else {
result.setCode(500);
result.setMessage("重新分配资源失败");
}
}catch (Exception e){
logger.error("重新分配资源异常,异常为" + e.toString());
result = PubUtils.assignmentResult(null, 500, "重新分配资源失败");
}
return result;
}
}

View File

@@ -0,0 +1,369 @@
package com.pqs9900.controller.user;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.njcn.enums.LogTypeEnum;
import com.njcn.enums.RoleGroupEnum;
import com.njcn.pojo.commons.PatternRegex;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.njcn.utils.SerializeUtil;
import com.njcn.utils.XssFilterUtil;
import com.njcn.utils.redis.JedisManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.SimpleValue;
import com.njcn.pojo.user.Role;
import com.njcn.pojo.user.RoleGroup;
import com.njcn.sso.pojo.user.User;
import com.njcn.service.user.RoleGroupService;
import com.njcn.service.user.RoleService;
import com.njcn.service.user.UserService;
@Controller
@RequestMapping(value = "/role")
public class RoleController {
@Resource
private RoleService rs;
@Resource
private RoleGroupService rgs;
@Autowired
JedisManager jedisManager;
@Autowired
UserLogDetailService userLogservice;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(RoleController.class);
//查询所有非管理角色
@ResponseBody
@RequestMapping(value = "selectAllName", method = RequestMethod.POST)
public List<RoleGroup> selectAllName(HttpServletRequest request) {
List<RoleGroup> list = new ArrayList<>();
try {
List<String> ManagerRolegroup=new ArrayList<>();
ManagerRolegroup.add(RoleGroupEnum.SYSTEM.getEname());
ManagerRolegroup.add(RoleGroupEnum.AUDIT.getEname());
ManagerRolegroup.add(RoleGroupEnum.CHECK.getEname());
ManagerRolegroup.add(RoleGroupEnum.BUSINESS.getEname());
ManagerRolegroup.add(RoleGroupEnum.CASUAL.getEname());
ManagerRolegroup.add(RoleGroupEnum.ROOT.getEname());
list = rgs.selectAllName(ManagerRolegroup);
userLogservice.getLog("查询角色", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
} catch (Exception e) {
logger.error("查询所有正式用户异常,异常为" + e.toString());
userLogservice.getLog("查询角色", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
}
return list;
}
//查询所有角色
@ResponseBody
@RequestMapping(value = "selectAll", method = RequestMethod.POST)
public List<Role> selectAll() {
List<Role> list = new ArrayList<>();
try {
list = rs.selectAll();
} catch (Exception e) {
logger.error("查询所有角色异常,异常为" + e.toString());
}
return list;
}
//根据角色名查询所有角色
@ResponseBody
@RequestMapping(value = "queryNameAll", method = RequestMethod.POST)
public List<Role> queryNameAll(@Param(value = "roleName") String roleName) {
if (roleName == null) {
roleName = "";
}
roleName = "%" + roleName + "%";
List<Role> list = new ArrayList<>();
try {
list = rs.queryNameAll(roleName);
} catch (Exception e) {
logger.error("查询所有角色异常,异常为" + e.toString());
}
return list;
}
//添加角色
@ResponseBody
@RequestMapping(value = "/insert", method = RequestMethod.POST)
public int insert(@Param(value = "roleName") String roleName, @Param(value = "updateTime") Date updateTime, @Param(value = "roleIndex") String roleIndex, @Param(value = "userIndex") String userIndex, @Param(value = "roleDescription") String roleDescription,HttpServletRequest request) {
int flag = 0;
if (rs.selName(roleName) > 0) {
flag = 2;
return flag;
} else {
Role role = new Role();
try {
roleIndex = java.util.UUID.randomUUID().toString();
role.setRoleIndex(roleIndex);
role.setRoleName(roleName);
User user = new User();
user.setUserIndex(userIndex);
role.setUserIndex(user.getUserIndex());
updateTime = new Date();
role.setUpdateTime(updateTime);
role.setRoleDescription(roleDescription);
int state = 1;
role.setState(state);
rs.insertRole(role);
flag = 1;
userLogservice.getLog("新增角色", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
} catch (Exception e) {
logger.error("新增角色异常,异常为" + e.toString());
userLogservice.getLog("新增角色", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
flag = 0;
}
return flag;
}
}
//修改角色
@ResponseBody
@RequestMapping(value = "/update", method = RequestMethod.POST)
public int updateRole(@Param(value = "roleName") String roleName, @Param(value = "updateTime") Date updateTime, @Param(value = "roleIndex") String roleIndex, @Param(value = "userIndex") String userIndex, @Param(value = "roleDescription") String roleDescription,HttpServletRequest request) {
int flag = 0;
if (rs.selName(roleName) > 0) {
flag = 2;
return flag;
} else {
Role role = new Role();
try {
role.setRoleIndex(roleIndex);
role.setRoleName(roleName);
User user = new User();
user.setUserIndex(userIndex);
role.setUserIndex(user.getUserIndex());
updateTime = new Date();
role.setUpdateTime(updateTime);
role.setRoleDescription(roleDescription);
int state = 1;
role.setState(state);
rs.updateRole(role);
flag = 1;
userLogservice.getLog("修改角色", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
} catch (Exception e) {
logger.error("修改角色异常,异常为" + e.toString());
userLogservice.getLog("修改角色", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
flag = 0;
}
return flag;
}
}
@RequestMapping("/selectId")
@ResponseBody
public Role selectRoleIndex(@Param(value = "roleIndex") String roleIndex) {
return rs.selectRoleIndex(roleIndex);
}
//删除角色
@ResponseBody
@RequestMapping("/delete")
public int delete(@Param(value = "roleIndex") String roleIndex,HttpServletRequest request) {
Role role = new Role();
int flag = 0;
try {
role.setRoleIndex(roleIndex);
rs.deleteRole(role);
flag = 1;
userLogservice.getLog("删除角色", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
} catch (Exception e) {
logger.error("删除角色异常,异常为" + e.toString());
userLogservice.getLog("删除角色", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
flag = 0;
}
return flag;
}
/**
* 获取当前所有的角色列表
*/
@RequestMapping(value = "getRoleList", method = RequestMethod.POST)
@ResponseBody
public HttpResult getRoleList(HttpServletRequest request) {
HttpResult result=PubUtils.initResult(TokenManager.getToken().getLoginName(),request,LogTypeEnum.SYSTEM.toString(),1);
try {
List<List> roleList = rs.getRoleList();
if (roleList.isEmpty()) {
result=PubUtils.assignmentResultLog(null,500,"获取角色信息为空","查询角色","成功",result);
} else {
result=PubUtils.assignmentResultLog(roleList,200,"获取角色信息成功","查询角色","成功",result);
}
userLogservice.getLog("查询角色", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
} catch (Exception e) {
logger.error("获取角色异常,异常为" + e.toString());
userLogservice.getLog("查询角色", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
result=PubUtils.assignmentResultLog(null,500,"获取角色失败","查询角色","失败",result);
}
return result;
}
/**
* 新增角色
*/
@RequestMapping(value = "addRole", method = RequestMethod.POST)
@ResponseBody
public HttpResult addRole(HttpServletRequest request, String roleName, String roleD) {
HttpResult result=PubUtils.initResult(TokenManager.getToken().getLoginName(),request,LogTypeEnum.SYSTEM.toString(),2);
//后台Xss攻击处理、包括html/js/sql
roleName = XssFilterUtil.dealString(roleName);
roleD = XssFilterUtil.dealString(roleD);
try {
if (StringUtils.isBlank(roleD)) {
roleD = "暂无描述";
}
if(StringUtils.isBlank(roleName)){
result=PubUtils.assignmentResultLog(null,500,"新增角色失败,角色名为空","新增角色","失败",result);
}else {
if(PubUtils.patternRole(roleName)){
String message = rs.saveRole(roleName, roleD);
if (message.equalsIgnoreCase("新增角色成功!")) {
result=PubUtils.assignmentResultLog("success",200,message,"新增角色","成功",result);
} else {
result=PubUtils.assignmentResultLog(null,500,message,"新增角色","成功",result);
}
}else {
result=PubUtils.assignmentResultLog(null,500,"角色名不符合由字母、数字组成,且数字不可开头","新增角色","失败",result);
}
}
userLogservice.getLog("新增角色", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
} catch (Exception e) {
logger.error("新增角色异常,异常是" + e.toString());
result=PubUtils.assignmentResultLog(null,500,"新增角色失败","新增角色","失败",result);
userLogservice.getLog("新增角色", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
}
return result;
}
/**
* 根据角色索引删除角色
*/
@RequestMapping(value = "deleteRoleByIndex", method = RequestMethod.POST)
@ResponseBody
public HttpResult deleteRoleByIndex(HttpServletRequest request, String index) {
HttpResult result=PubUtils.initResult(TokenManager.getToken().getLoginName(),request,LogTypeEnum.SYSTEM.toString(),2);
try {
String ip = PubUtils.getIpAddr(request);
String username = TokenManager.getToken().getLoginName();
byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
String key = SerializeUtil.deserialize(value, String.class);
if(key.equals("success")){
String message = rs.deleteRoleByIndex(index);
if (message.equalsIgnoreCase("删除角色成功!")) {
result=PubUtils.assignmentResultLog("success",200,message,"删除角色","成功",result);
} else {
result.setCode(500);
result.setMessage(message);
result=PubUtils.assignmentResultLog(null,500,message,"删除角色","成功",result);
}
}else{
result.setCode(400);
result.setMessage("密码验证失败!");
result=PubUtils.assignmentResultLog(null,500,"密码验证失败!","删除角色","失败",result);
}
jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
userLogservice.getLog("删除角色", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
} catch (Exception e) {
logger.error("删除角色异常,异常是" + e.toString());
result=PubUtils.assignmentResultLog(null,500,"删除角色失败","删除角色","失败",result);
userLogservice.getLog("删除角色", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 0);
}
return result;
}
/**
* 获取所有用户信息,以及用户下角色的信息
*/
@RequestMapping(value = "getUserRole", method = RequestMethod.POST)
@ResponseBody
public HttpResult getUserRole(HttpServletRequest request) {
HttpResult result = new HttpResult();
try {
List<List> roleList = rs.getUserRole();
if (roleList.isEmpty()) {
result.setMessage("获取用户角色信息失败");
result.setCode(500);
} else {
result.setCode(200);
result.setMessage("获取用户角色信息成功");
result.setBody(roleList);
}
} catch (Exception e) {
logger.error("查询角色信息异常,异常是" + e.toString());
result = PubUtils.assignmentResult(null, 500, "查询角色信息失败");
}
return result;
}
/**
* 回显用户角色,方便用户重新分配角色
*/
@RequestMapping(value = "backRole", method = RequestMethod.POST)
@ResponseBody
public HttpResult backRole(HttpServletRequest request, String roleGPIndex) {
HttpResult result=PubUtils.initResult(TokenManager.getToken().getLoginName(),request,LogTypeEnum.SYSTEM.toString(),1);
List<SimpleValue> lists;
try {
lists = rs.getBackRole(roleGPIndex);
if (lists.isEmpty()) {
result=PubUtils.assignmentResultLog(null,500,"获取用户角色信息为空","获取角色信息","成功",result);
} else {
result=PubUtils.assignmentResultLog(lists,200,"获取用户角色信息成功","获取角色信息","成功",result);
}
} catch (Exception e) {
logger.error("查询用户角色信息异常,异常是" + e.toString());
result=PubUtils.assignmentResultLog(null,500,"获取用户角色信息异常","获取角色信息","失败",result);
}
return result;
}
/**
* 根据用户选择的角色索引,以及用户索引,为该用户重新分配角色
*/
@RequestMapping(value = "disRole", method = RequestMethod.POST)
@ResponseBody
public HttpResult disRole(HttpServletRequest request, String roleGPIndex, String roleIndex) {
HttpResult result=PubUtils.initResult(TokenManager.getToken().getLoginName(),request,LogTypeEnum.SYSTEM.toString(),2);
roleGPIndex=XssFilterUtil.dealString(roleGPIndex);
roleIndex=XssFilterUtil.dealString(roleIndex);
try {
String message = rs.disRole(roleGPIndex, roleIndex);
if (message.equalsIgnoreCase("分配角色成功")) {
result=PubUtils.assignmentResultLog(null,200,message,"修改角色和角色组关系","成功",result);
} else {
result=PubUtils.assignmentResultLog(null,500,message,"修改角色和角色组关系","失败",result);
}
} catch (Exception e) {
logger.error("分配角色异常,异常是" + e.toString());
result=PubUtils.assignmentResultLog(null,500,"分配角色失败","修改角色和角色组关系","失败",result);
}
return result;
}
}

View File

@@ -0,0 +1,184 @@
package com.pqs9900.controller.user;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.user.*;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.njcn.mapper.user.TfLgPloyAssMapper;
import com.njcn.pojo.configuration.SubVoltage;
import com.njcn.service.configuration.ISubVoltageService;
import com.njcn.service.user.TfLgAssService;
import com.njcn.service.user.TransFormerService;
import com.njcn.service.user.UserService;
@Controller
@RequestMapping("tflg")
public class TfLgAssController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(TfLgAssController.class);
@Resource
private TransFormerService tfs;
@Resource
TfLgPloyAssMapper tf;
@Resource
private TfLgAssService tflg;
@Resource
private ISubVoltageService subv;
@Resource
private UserService us;
@Autowired
UserLogDetailService userLogDetailService;
@ResponseBody
@RequestMapping(value = "selectTwoName", method = RequestMethod.POST)
public List<TransFormer> selectTwoName(@Param(value = "tfIndex") String tfIndex) {
List<TransFormer> list = new ArrayList<>();
try {
list = tfs.selectTwoName(tfIndex);
} catch (Exception e) {
logger.error("产生异常,异常是" + e.toString());
}
return list;
}
//查询当前变压器的上下节点
@ResponseBody
@RequestMapping(value = "selectByMe", method = RequestMethod.POST)
public List<TfLgAssByMe> selectByMe(@Param(value = "tfIndex") String tfIndex) {
List<TfLgAssByMe> list = new ArrayList<>();
try {
list = tflg.selectByMe(tfIndex);
} catch (Exception e) {
logger.error("产生异常,异常是" + e.toString());
}
return list;
}
//查询所有的节点
@ResponseBody
@RequestMapping(value = "selectIndexAll", method = RequestMethod.POST)
public TfLgAssDetail selectIndexAll(int subIndex, String tfIndex) {
TfLgAssDetail list = new TfLgAssDetail();
try {
list = tflg.getBeforeNext(subIndex, tfIndex);
} catch (Exception e) {
logger.error("产生异常,异常是" + e.toString());
}
return list;
}
//查询所有的节点
@ResponseBody
@RequestMapping(value = "selectIndexKAll", method = RequestMethod.POST)
public TfLgAssDetail selectIndexKAll(int subIndex) {
TfLgAssDetail list = new TfLgAssDetail();
try {
list = tflg.getKBeforeNext(subIndex);
} catch (Exception e) {
logger.error("产生异常,异常是" + e.toString());
}
return list;
}
@ResponseBody
@RequestMapping(value = "getSubvIndex", method = RequestMethod.POST)
public int getSubvIndex(int subIndex) {
int num = 0;
try {
num = tflg.getSubvIndex(subIndex);
} catch (Exception e) {
logger.error("产生异常,异常是" + e.toString());
}
return num;
}
//根据subvId查询除此之外的
@ResponseBody
@RequestMapping(value = "selectExAll", method = RequestMethod.POST)
public List<LogicNext> selectExAll(@Param("subvIndex") int subvIndex, @Param("subIndex") int subIndex, @Param(value = "tfIndex") String tfIndex) {
List<LogicNext> list = new ArrayList<>();
try {
list = subv.selectExAll(subvIndex, subIndex, tfIndex);
} catch (Exception e) {
logger.error("产生异常,异常是" + e.toString());
}
return list;
}
//根据id查询所有
@ResponseBody
@RequestMapping(value = "selectIdAll", method = RequestMethod.POST)
public List<TfLgAss> selectIdAll(@Param(value = "tfIndex") String tfIndex) {
List<TfLgAss> list = new ArrayList<>();
try {
list = tflg.selectIdAll(tfIndex);
} catch (Exception e) {
logger.error("产生异常,异常是" + e.toString());
}
return list;
}
//根据userIndex查询更新人
@ResponseBody
@RequestMapping(value = "selectIdName", method = RequestMethod.POST)
public String selectIdName(@Param(value = "userIndex") String userIndex) {
String logname = "";
try {
logname = us.selectIdName(userIndex);
} catch (Exception e) {
logger.error("产生异常,异常是" + e.toString());
}
return logname;
}
//选择节点
@ResponseBody
@RequestMapping(value = "updateTfLgAss", method = RequestMethod.POST)
public int updateTfLgAss(HttpServletRequest request, @Param(value = "tfLgAss_Index") String tfLgAss_Index, @Param(value = "updatetime") Date updatetime,
@Param(value = "tfIndex") String tfIndex, @Param(value = "userIndex") String userIndex,
@Param(value = "logicBefore") int logicBefore, @Param(value = "logicNext") int logicNext, @Param(value = "state") Integer state) throws AccountException {
List<TfLgAss> list = tflg.selectIdAll(tfIndex);
int flag = 0;
if (!list.isEmpty()) {
try {
flag = tflg.updateTfLgAss(tfIndex, userIndex, logicBefore, logicNext);
userLogDetailService.getLog("节点维护", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} catch (Exception e) {
userLogDetailService.getLog("节点维护", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("产生异常,异常是" + e.toString());
}
} else {
try {
flag = tflg.insertTfLgAss(tfLgAss_Index, updatetime, tfIndex, userIndex, logicBefore, logicNext, state);
userLogDetailService.getLog("节点维护", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} catch (Exception e) {
userLogDetailService.getLog("节点维护", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("产生异常,异常是" + e.toString());
}
}
return flag;
}
}

View File

@@ -0,0 +1,254 @@
package com.pqs9900.controller.user;
import com.njcn.enums.LogTypeEnum;
import com.njcn.mapper.user.TfLgPloyAssMapper;
import com.njcn.mapper.user.TfLgPloyMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.user.TfLgPloy;
import com.njcn.pojo.user.TfLgPloyAss;
import com.njcn.pojo.user.TfLgPloyInfo;
import com.njcn.pojo.user.TfLgTree;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.user.TfLgPloyService;
import com.njcn.service.user.TfLgTreeService;
import com.njcn.utils.PubUtils;
import com.njcn.utils.XssFilterUtil;
import net.sf.json.JSONArray;
import org.apache.commons.lang3.StringUtils;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping("tflp")
public class TfLgPloyController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(TfLgPloyController.class);
@Resource
TfLgPloyService lgPloyService;
@Resource
private UserLogDetailService userLog;
@Resource
private TfLgTreeService getDeviceTree;
@Resource
private TfLgPloyMapper tflgMapper;
@Resource
private TfLgPloyAssMapper tflgAssMapper;
@Autowired
private TfLgPloyService tflgService;
@ResponseBody
@RequestMapping(value="selectAll",method=RequestMethod.POST)
public HttpResult selectAll(HttpServletRequest request) throws AccountException {
HttpResult result=new HttpResult();
try {
List<List> deviceList=lgPloyService.selectAll();
if(deviceList.isEmpty()){
result.setCode(500);
result.setMessage("没有配置信息");
userLog.getLog("查询变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.info("获取变压器策略信息失败");
}else{
result.setCode(200);
result.setMessage("获取配置信息成功");
result.setBody(deviceList);
userLog.getLog("查询变压器策略", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.info("获取变压器策略信息成功");
}
}catch (Exception e){
logger.error("获取变压器策略信息异常,异常为"+e.toString());
userLog.getLog("查询变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result=PubUtils.assignmentResult(null,500,"获取变压器策略信息失败");
}
return result;
}
/**
* 变压器策略树
* @param request
* @param session
* @return
*/
@RequestMapping(value="tflgstree",method=RequestMethod.POST)
@ResponseBody
public List<TfLgTree> tflgstree(HttpServletRequest request,HttpSession session){
if(session.getAttribute("line_index")!=null||session.getAttribute("line_index")!=""){
session.removeAttribute("line_index");
}
List<TfLgTree> result=new ArrayList();
try{
result=getDeviceTree.getTfLgTree();
}catch (Exception e){
logger.error("获取变压器策略树异常,异常为"+e.toString());
}
return result;
}
//新增策略
@RequestMapping(value = "addTfLgPloy",method=RequestMethod.POST)
@ResponseBody
public HttpResult addTfLgPloy(HttpServletRequest request,HttpSession session,String tPName,String describe,String treecheck) throws AccountException {
HttpResult result=new HttpResult();
//后台Xss攻击处理、包括html/js/sql
tPName= XssFilterUtil.dealString(tPName);
describe= XssFilterUtil.dealString(describe);
if(!StringUtils.isBlank(tPName)) {
if(PubUtils.patternTF(tPName)) {
if (PubUtils.patternDes64(describe)) {
JSONArray ja = JSONArray.fromObject(treecheck);
List<String> index = (List<String>) JSONArray.toCollection(ja, String.class);
try {
String message = lgPloyService.savePloy(tPName, describe, index);
if (message.equalsIgnoreCase("新增策略成功")) {
result.setCode(200);
result.setMessage(message);
userLog.getLog("新增变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.info("新增策略成功!");
} else if (message.equalsIgnoreCase("新增策略失败")) {
result.setCode(400);
result.setMessage(message);
userLog.getLog("新增变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("新增策略失败!名称已存在");
} else {
result.setCode(500);
result.setMessage(message);
userLog.getLog("新增变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("新增模板失败!");
}
} catch (Exception e) {
logger.error("新增变压器策略信息异常,异常为" + e.toString());
userLog.getLog("新增变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 500, "新增变压器策略信息失败");
}
}else {
userLog.getLog("新增变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
result = PubUtils.assignmentResult(null, 500, "描述长度为64内");
}
}else {
userLog.getLog("新增变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
result = PubUtils.assignmentResult(null, 500, "策略名称非法");
}
}else {
userLog.getLog("新增变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
result = PubUtils.assignmentResult(null, 500, "策略名称不可为空");
}
return result;
}
//获取节点上的树
@RequestMapping(value="loadPloy",method=RequestMethod.POST)
@ResponseBody
public TfLgPloyInfo loadPloy(HttpServletRequest request,String rpIndex){
TfLgPloyInfo result=new TfLgPloyInfo();
result = lgPloyService.loadPloy(rpIndex);
return result;
}
//修改变压器策略
@RequestMapping(value="updatePloy",method=RequestMethod.POST)
@ResponseBody
public HttpResult updatePloy(HttpServletRequest request,HttpSession session,String rpIndex,String tPName,String describe,String treecheck) throws AccountException {
HttpResult result=new HttpResult();
//后台Xss攻击处理、包括html/js/sql
tPName= XssFilterUtil.dealString(tPName);
describe= XssFilterUtil.dealString(describe);
if(!StringUtils.isBlank(tPName)) {
if(PubUtils.patternTrans(tPName)) {
JSONArray ja = JSONArray.fromObject(treecheck);
List<String> index = (List<String>) JSONArray.toCollection(ja, String.class);
try {
String message = lgPloyService.updatePloy(rpIndex, tPName, describe, index);
if (message.equalsIgnoreCase("修改变压器策略成功")) {
result.setCode(200);
result.setMessage(message);
userLog.getLog("修改变压器策略", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.info("更新变压器策略成功!");
} else if (message.equalsIgnoreCase("策略名称已存在")) {
result.setCode(400);
result.setMessage(message);
userLog.getLog("修改变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("更新变压器策略失败!名称已存在");
} else {
result.setCode(500);
result.setMessage(message);
userLog.getLog("修改变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("更新变压器策略失败!");
}
} catch (Exception e) {
logger.error("修改变压器策略信息异常,异常为" + e.toString());
userLog.getLog("修改变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
result = PubUtils.assignmentResult(null, 500, "修改变压器策略信息失败");
}
}else {
userLog.getLog("新增变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
result = PubUtils.assignmentResult(null, 500, "修改变压器策略信息失败");
}
}else {
userLog.getLog("新增变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
result = PubUtils.assignmentResult(null, 500, "修改变压器策略信息失败");
}
return result;
}
//删除变压器策略
@RequestMapping(value="deltePloy",method=RequestMethod.POST)
@ResponseBody
public HttpResult deltePloy(HttpServletRequest request,String rpIndex) throws AccountException {
HttpResult result=new HttpResult();
TfLgPloy rpp = new TfLgPloy();
rpp.settPIndex(rpIndex);
rpp.setState(1);
TfLgPloyAss ass = new TfLgPloyAss();
ass.settPIndex(rpIndex);
try{
int flag=tflgMapper.delete(rpp);
int flag1 = tflgAssMapper.delete(ass);
result.setCode(200);
userLog.getLog("删除变压器策略", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.info("删除变压器策略成功!");
}catch (Exception e) {
result.setCode(500);
userLog.getLog("删除变压器策略", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("删除变压器策略失败!");
}
return result;
}
//自检功能·
@RequestMapping(value="selfcheck",method=RequestMethod.POST)
@ResponseBody
public int selfcheck(HttpServletRequest request) throws AccountException {
int result = 0;
try {
result = tflgService.selfcheck();
userLog.getLog("自检", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
}catch (Exception e){
userLog.getLog("自检", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("自检失败,异常为"+e.toString());
}
return result;
}
}

View File

@@ -0,0 +1,266 @@
package com.pqs9900.controller.user;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.configuration.DicData;
import com.njcn.pojo.user.TransFormer;
import com.njcn.sso.pojo.user.User;
import com.njcn.service.configuration.DicDataService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.user.TransFormerService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.njcn.utils.XssFilterUtil;
import com.njcn.utils.redis.RedisCacheUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("trans")
public class TransFormerController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(TransFormerController.class);
@Resource
private TransFormerService tfs;
@Autowired
RedisCacheUtil redisCacheUtil;
@Resource
private DicDataService dds;
@Resource
private UserLogDetailService userLog;
/**
* 获取所有变压器台账
*/
@RequestMapping(value = "selectAll", method = RequestMethod.POST)
@ResponseBody
public HttpResult selectAll(HttpServletRequest request) throws AccountException {
HttpResult result = new HttpResult();
try {
List<List> transfomer = tfs.selectAll();
if (transfomer.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到所有变压器台账列表");
userLog.getLog("查询变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.error("获取所有变压器台账失败");
} else {
result.setCode(200);
result.setBody(transfomer);
result.setMessage("获取所有变压器台账列表成功");
userLog.getLog("查询变压器", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.info("获取所有变压器台账成功");
}
}catch (Exception e){
logger.error("获取变压器信息异常,异常为"+e.toString());
userLog.getLog("查询变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
result=PubUtils.assignmentResult(null,500,"获取变压器信息失败");
}
return result;
}
/**
* 根据name获取所有变压器台账
*/
@RequestMapping(value = "selectNameAll", method = RequestMethod.POST)
@ResponseBody
public HttpResult selectNameAll(HttpServletRequest request,String tfName,int node) throws AccountException {
HttpResult result = new HttpResult();
try{
List<List> transfomer = tfs.selectNameAll(tfName,node);
if (transfomer.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到所有变压器台账列表");
userLog.getLog("查询变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.error("获取所有变压器台账失败");
} else {
result.setCode(200);
result.setBody(transfomer);
result.setMessage("获取所有变压器台账列表成功");
userLog.getLog("查询变压器", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.info("获取所有变压器台账成功");
}
}catch (Exception e){
userLog.getLog("查询变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.error("获取变压器台账信息异常,异常为"+e.toString());
result=PubUtils.assignmentResult(null,500,"获取变压器台账信息失败");
}
return result;
}
//获取接线方式
@ResponseBody
@RequestMapping(value="selectWring",method=RequestMethod.POST)
public List<DicData> selectWring(){
List<DicData> list= redisCacheUtil.getWring();
return list;
}
/**
* 新增变压器
* */
@RequestMapping(value="saveTrans",method=RequestMethod.POST)
@ResponseBody
public int saveTrans(HttpServletRequest request,String tfName, int subIndex,String Wiring, String description) throws AccountException {
//后台Xss攻击处理、包括html/js/sql
tfName= XssFilterUtil.dealString(tfName);
Wiring= XssFilterUtil.dealString(Wiring);
description= XssFilterUtil.dealString(description);
int message = 0;
if(!StringUtils.isBlank(tfName)) {
if (!StringUtils.isBlank(Wiring)) {
if(PubUtils.patternTrans(tfName)) {
if(PubUtils.patternDes500(description)) {
try {
message = tfs.saveTrans(tfName, subIndex, Wiring, description);
if (message == 1) {
logger.info("新增变压器成功");
userLog.getLog("新增变压器", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
} else {
logger.error("新增变压器失败");
userLog.getLog("新增变压器", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
}
} catch (Exception e) {
logger.error("新增变压器异常,异常为" + e.toString());
message = 0;
}
}else {
message = 5;
userLog.getLog("新增变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("新增变压器失败");
}
}else {
message =4;
userLog.getLog("新增变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("新增变压器失败");
}
} else {
message = 3;
userLog.getLog("新增变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("新增变压器失败");
}
}else {
message = 2;
userLog.getLog("新增变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("新增变压器失败");
}
return message;
}
// 根据ID查询所有
@ResponseBody
@RequestMapping(value = "selectId", method = RequestMethod.POST)
public TransFormer selectId(@Param(value = "tfIndex") String tfIndex) {
return tfs.selectId(tfIndex);
}
// 根据ID查询所有
@ResponseBody
@RequestMapping(value = "selectDataName", method = RequestMethod.POST)
public List<DicData> selectDataName(@Param(value = "dicIndex") String dicIndex) {
return dds.selectDataName(dicIndex);
}
@ResponseBody
@RequestMapping(value = "selectWiring", method = RequestMethod.POST)
public List<DicData> selectWiring(@Param(value = "typeId") String typeId) {
return dds.selectWiring(typeId);
}
//修改
@ResponseBody
@RequestMapping(value = "updateTrans", method = RequestMethod.POST)
public int updateTrans(HttpServletRequest request,@Param(value="tfIndex")String tfIndex,@Param(value="tfName")String tfName,@Param(value = "subIndex")int subIndex,
@Param(value="wiring")String wiring,@Param(value="description")String description) throws AccountException {
//后台Xss攻击处理、包括html/js/sql
tfName= XssFilterUtil.dealString(tfName);
wiring= XssFilterUtil.dealString(wiring);
description= XssFilterUtil.dealString(description);
int flag = 2;
if(!StringUtils.isBlank(tfName)) {
if (PubUtils.patternTrans(tfName)) {
if(PubUtils.patternDes500(description)) {
Date updateTime = new Date();
User user = TokenManager.getToken();
String userIndex = user.getUserIndex();
TransFormer former = new TransFormer();
List<TransFormer> list = tfs.selectName(tfIndex);
try {
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getTfName().equals(tfName)) {
flag = 0;
userLog.getLog("修改变压器", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("修改变压器失败,原因是该变压器名已存在");
}
}
if (flag != 0) {
tfs.updateTrans(tfIndex, tfName, subIndex, wiring, description, updateTime, userIndex);
userLog.getLog("修改变压器", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
flag = 1;
} else {
flag = 0;
userLog.getLog("修改变压器", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("修改变压器失败,原因是该变压器名已存在");
}
} catch (Exception e) {
userLog.getLog("修改变压器", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
logger.error("修改变压器异常,异常为" + e.toString());
flag = 0;
}
}else {
flag = 5;
userLog.getLog("修改变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("修改变压器失败原因是变压器名称长度在500内");
}
}else {
flag =4;
userLog.getLog("修改变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("修改变压器失败,原因是变压器名非法");
}
}else {
flag = 3;
userLog.getLog("修改变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("修改变压器失败,原因是变压器名为空");
}
return flag;
}
/**
* 根据变压器索引删除变压器
*/
@RequestMapping(value = "deleteTransByIndex", method = RequestMethod.POST)
@ResponseBody
public HttpResult deleteTransByIndex(HttpServletRequest request, String index) throws AccountException {
HttpResult result = new HttpResult();
try {
String message = tfs.deleteTransByIndex(index);
if (message.equalsIgnoreCase("删除变压器成功!")) {
result.setCode(200);
result.setMessage(message);
result.setBody("success");
userLog.getLog("删除变压器", "成功",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.info("删除变压器成功");
} else {
result.setCode(500);
result.setMessage(message);
userLog.getLog("修改变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("删除变压器失败");
}
}catch (Exception e){
userLog.getLog("修改变压器", "失败",PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),1);
logger.error("删除变压器异常,异常为"+e.toString());
result=PubUtils.assignmentResult(null,500,"删除变压器失败");
}
return result;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
package com.pqs9900.controller.user;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("userset")
public class UserSetController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(UserSetController.class);
}

View File

@@ -0,0 +1,61 @@
package com.pqs9900.controller.user;
import com.njcn.enums.LogTypeEnum;
import com.njcn.mapper.user.WebInfoMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.user.WebInfoService;
import com.njcn.utils.AppConfig;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UserUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Controller
@RequestMapping("webinfo")
public class WebInfoController {
@Autowired
private WebInfoService infoService;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(ManageListController.class);
@Autowired
private AppConfig appConfig;
@Autowired
WebInfoMapper wim;
@Autowired
UserUtil uu;
@Autowired
UserLogDetailService userLogDetailService;
@RequestMapping(value = "getWebInfo", method = RequestMethod.POST)
@ResponseBody
public HttpResult getWebInfo(HttpServletRequest request) throws AccountException {
HttpResult result = new HttpResult();
List<List> users = infoService.getWebInfo();
if (users.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到网站信息列表");
userLogDetailService.getLog("查询网站信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.error("获取网站信息失败");
} else {
result.setCode(200);
result.setBody(users);
result.setMessage("获取网站信息列表成功");
userLogDetailService.getLog("查询网站信息", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(),0);
logger.info("获取网站信息成功");
}
return result;
}
}

View File

@@ -0,0 +1,193 @@
package com.pqs9900.controller.webtool;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.utils.PubUtils;
import com.njcn.utils.XssFilterUtil;
import com.pqs9900.service.webtool.CsvDataService;
import com.pqs9900.task.MySchudler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author cdf
* @Date 2020/6/3 15:00
**/
@Controller
@RequestMapping(value = "csv")
public class CsvDataController {
private static final Logger logger = LoggerFactory.getLogger(CsvDataController.class);
@Autowired
private CsvDataService csvDataService;
/**
* @Author chendaofei
* @Description 导出监测点详细数据
* @Date 16:22 2020/4/20
**/
@GetMapping(value = "getCsvAsSession")
@ResponseBody
public HttpResult getCsvAsSession(@RequestParam("lineid")Integer lineid, @RequestParam("beginTime")String beginTime, @RequestParam("endTime")String endTime, HttpServletResponse response, HttpServletRequest request){
if(lineid == null || PubUtils.isBlank(beginTime) || PubUtils.isBlank(endTime)){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
DatePojo datePojo;
datePojo = PubUtils.validateDate(beginTime, endTime, "getCsvAsSession");
if (!datePojo.getValidity()) {
return PubUtils.assignmentResult(null,500,datePojo.getMsg());
}
try {
String res = csvDataService.getCsvAsSession(lineid,datePojo.getStartTime(),datePojo.getEndTime(),response,request);
if("数据为空".equals(res)){
return PubUtils.assignmentResult(null,500,res);
}
} catch (IOException e) {
return PubUtils.assignmentResult(null,500,"未知错误");
}
return null;
}
/**
* @Author chendaofei
* @Description 批量导出csv
* @Date 11:15 2020/4/21
**/
@RequestMapping(value="getCsvBatch", method = RequestMethod.GET)
@ResponseBody
public HttpResult getCsvBatch(@RequestParam("list") List<Integer> list, @RequestParam("beginTime")String beginTime, @RequestParam("endTime")String endTime, HttpServletResponse response){
HttpResult httpResult = null;
if(list==null || list.size()==0 || PubUtils.isBlank(beginTime) || PubUtils.isBlank(endTime)){
PubUtils.assignmentResult(null,500,"参数不可为空");
}
DatePojo datePojo;
datePojo = PubUtils.validateDate(beginTime, endTime, "getCsvBatch");
if (!datePojo.getValidity()) {
return PubUtils.assignmentResult(null,500,datePojo.getMsg());
}
try {
String res = csvDataService.getCsvBatch(list,datePojo.getStartTime(),datePojo.getEndTime(),response);
if("存在数据".equals(res)){
httpResult = PubUtils.assignmentResult(null,200,res);
}else {
httpResult = PubUtils.assignmentResult(null,500,res);
}
} catch (IOException e) {
logger.error("导出csv发生异常异常是"+e.getMessage());
}
return httpResult;
}
/**
* 进度条刷新
*/
@GetMapping(value = "/flushProgress2")
@ResponseBody
public HttpResult flushProgress(HttpServletRequest request,HttpServletResponse response) {
Map<String,Object> map = csvDataService.flushProgress(request,response);
return PubUtils.assignmentResult(map,200,"获取成功");
}
/**
* @Author chendaofei
* @Description 分页获取所有监测信息
* @Date 15:07 2020/4/8
**/
@GetMapping(value = "/getAllInfo")
@ResponseBody
public HttpResult getAllInfo(@RequestParam("lineid") Integer lineid, @RequestParam("page")Integer page,@RequestParam("pageSize")Integer pageSize,@RequestParam("beginTime")String beginTime, @RequestParam("endTime")String endTime){
if(lineid == null || PubUtils.isBlank(beginTime) || PubUtils.isBlank(endTime) || page ==null || pageSize ==null){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
beginTime = XssFilterUtil.dealString(beginTime);
endTime = XssFilterUtil.dealString(endTime);
DatePojo datePojo;
datePojo = PubUtils.validateDate(beginTime, endTime, "getAllInfo");
if (!datePojo.getValidity()) {
return PubUtils.assignmentResult(null,500,datePojo.getMsg());
}
Map<String,Object> map = csvDataService.getAllInfo(lineid,page,pageSize,datePojo.getStartTime(),datePojo.getEndTime());
if(map!=null){
return PubUtils.assignmentResult(map,200,"获取成功");
}else {
return PubUtils.assignmentResult(null,500,"获取失败");
}
}
/*数据完成性手动操作*/
@GetMapping("startHistoryTask")
@ResponseBody
public HttpResult startHistoryTask(@RequestParam("lineNo")Integer lineNo, @RequestParam("beginTime")String beginTime, @RequestParam("endTime")String endTime){
if(lineNo == null || PubUtils.isBlank(beginTime) || PubUtils.isBlank(endTime)){
return PubUtils.assignmentResult(null,500,"参数不可为空");
}
DatePojo datePojo;
datePojo = PubUtils.validateDate(beginTime, endTime, "startHistoryTask");
if (!datePojo.getValidity()) {
return PubUtils.assignmentResult(null,500,datePojo.getMsg());
}
HttpResult httpResult = null;
String res = csvDataService.startHistoryTask(lineNo,datePojo.getStartTime(),datePojo.getEndTime());
if("执行成功".equals(res)){
httpResult = PubUtils.assignmentResult(null,200,res);
}else {
httpResult = PubUtils.assignmentResult(null,500,res);
}
return httpResult;
}
/**
* 导出暂态波形数据
* @param type 1.瞬时波形 2.rms波形
*
*/
@RequestMapping(value = "getAllWavedataToCsv", method = RequestMethod.GET)
@ResponseBody
public HttpResult getAllWavedataToCsv(String startTime,String endTime,Integer type) {
HttpResult result;
String waveData;
try {
waveData = csvDataService.getAllWavedataToCsv(startTime,endTime, 1,type);
if("成功".equals(waveData)){
result = PubUtils.assignmentResult(waveData, 200, "导出时间段波形数据成功");
}else {
result = PubUtils.assignmentResult(waveData, 500, waveData);
}
} catch (Exception e) {
e.printStackTrace();
result = PubUtils.assignmentResult(null, 500, "因为异常导致获取波形数据失败");
}
return result;
}
@GetMapping("downloadDataZip")
public void downloadDataZip(HttpServletResponse response){
csvDataService.downloadDataZip(response);
}
}

View File

@@ -0,0 +1,137 @@
package com.pqs9900.controller.webtool;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.device.Tree;
import com.njcn.pojo.configuration.Device;
import com.njcn.service.configuration.DeviceService;
import com.njcn.service.configuration.TreeService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.sso.pojo.user.User;
import com.njcn.utils.PubUtils;
import com.njcn.utils.XssFilterUtil;
import com.pqs9900.controller.business.DeviceController;
import com.pqs9900.service.webtool.CsvDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
/**
* @Description
* @Author cdf
* @Date 2020/6/3 13:25
**/
@Controller
@RequestMapping(value = "deviceTree")
public class DeviceTreeController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(DeviceController.class);
@Resource
private DeviceService getDeviceInfo;
@Resource
private TreeService getDeviceTree;
@Resource
private CsvDataService csvDataService;
/**
* 终端管理界面终端树
*
* @param request
* @param session
* @return
*/
@RequestMapping(value = "deviceTrees", method = RequestMethod.POST)
@ResponseBody
public List<Tree> getdeviceMainTree(HttpServletRequest request, HttpSession session) {
if (session.getAttribute("line_index") != null || session.getAttribute("line_index") != "") {
session.removeAttribute("line_index");
}
List<Tree> result = new ArrayList();
try {
result = getDeviceInfo.getDeviceMainTree();
} catch (Exception e) {
logger.error("获取终端树异常,异常是" + e.toString());
}
return result;
}
// 查询终端类型
@RequestMapping(value = "devNameType", method = RequestMethod.POST)
@ResponseBody
public Device devNameType(String devName) {
// 后台Xss攻击处理、包括html/js/sql
devName = XssFilterUtil.dealString(devName);
Device quarryOutValue = new Device();
try {
quarryOutValue = getDeviceInfo.devNameType(devName);
} catch (Exception e) {
logger.error("查找终端类型异常,异常是" + e.toString());
}
return quarryOutValue;
}
/**
* 终端树
*
* @param request
* @return
*/
@RequestMapping(value = "nodetree", method = RequestMethod.POST)
@ResponseBody
public HttpResult getNodeTree(HttpServletRequest request, String startTime, String endTime) {
HttpResult result;
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "tree");
if (!StringUtils.isEmpty(datePojo.getMsg())) {
result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
return result;
}
User user = TokenManager.getToken();
List<Tree> data;
try {
data = getDeviceTree.getNodeTreedata(user.getLoginName(), datePojo.getStartTime(), datePojo.getEndTime());
result = PubUtils.assignmentResult(data, 200, "获取设备树信息成功");
} catch (Exception e) {
result = PubUtils.assignmentResult(null, 200, "获取设备树信息失败");
}
return result;
}
/**
* 终端树
* cdf
*/
@RequestMapping(value = "getTree", method = RequestMethod.POST)
@ResponseBody
public HttpResult getTree() {
HttpResult result = null;
try {
List<Tree> data = csvDataService.getTree();
result = PubUtils.assignmentResult(data, 200, "获取设备树信息成功");
} catch (Exception e) {
e.printStackTrace();
result = PubUtils.assignmentResult(null, 200, "获取设备树信息失败");
}
return result;
}
}

View File

@@ -0,0 +1,59 @@
package com.pqs9900.listener;
import com.njcn.utils.Kafka.ZookeeperServerStatus;
import com.njcn.utils.PubUtils;
import com.pqs9900.controller.configuration.ConstantValueController;
import com.pqs9900.util.Kafka.JavaKafkaConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.io.InputStream;
import java.util.Properties;
public class ContextListener implements ServletContextListener {
private JavaKafkaConsumer javaKafkaConsumer = null;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(ConstantValueController.class);
@Override
public void contextInitialized(ServletContextEvent sce) {
/*try {
//读取配置文件
Properties pros = PubUtils.readProperties(getClass().getClassLoader(),"java.properties");
String zookeeper = pros.get("ZOOKEEPER").toString();
String groupId = pros.get("GROUPID").toString();
String topic = pros.get("TOPIC").toString();
String kafka_log = pros.get("KAFKA_LOG").toString();
//192.168.1.12:2181
String[] strArray=zookeeper.split(":");
if(strArray.length == 2){
String host =strArray[0];
int port =Integer.parseInt(strArray[1]);
ZookeeperServerStatus zookeeperServerStatus=new ZookeeperServerStatus();
String strModel = zookeeperServerStatus.serverStatus(host,port);
//不为空表示能获取到相对应的模式则启动Kafka监听
if(!strModel.equals("")){
int threads = 1;
javaKafkaConsumer = new JavaKafkaConsumer(topic, threads, zookeeper, groupId,kafka_log);
new Thread(javaKafkaConsumer).start();
}
}
} catch (Exception e) {
logger.error("Kafka启动失败,具体原因如下:" + e.getMessage());
}*/
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
if(javaKafkaConsumer !=null){
// 关闭
javaKafkaConsumer.shutdown();
}
}
}

View File

@@ -0,0 +1,115 @@
package com.pqs9900.listener;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.njcn.pojo.configuration.DicData;
import com.njcn.service.configuration.DeviceService;
import com.njcn.utils.UserUtil;
import com.pqs9900.controller.business.AreaController;
import com.pqs9900.controller.linedata.LineMarkController;
import com.pqs9900.pojo.linedata.MarkExcel;
import com.pqs9900.service.linedata.LineMarkService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* 监测点批量评级导入excel监听
*
* @author cdf
* @date 2021/10/27
*/
public class LineMarkExcelListener extends AnalysisEventListener<MarkExcel> {
private static final Logger logger = LoggerFactory.getLogger(LineMarkExcelListener.class);
private LineMarkService lineMarkService;
private List<String> deFlag = new ArrayList<>(Arrays.asList("极重要","重要","普通","不重要"));
private Integer ding = 0;
List<MarkExcel> list = new ArrayList<>();
@Override
public void invoke(MarkExcel object, AnalysisContext context){
ding++;
String msg =""+ding+"行,";
if(StrUtil.isBlank(object.getProvince())){
throw new ExcelAnalysisException(msg+"省份不可为空");
}
if(StrUtil.isBlank(object.getGdName())){
throw new ExcelAnalysisException(msg+"供电公司不可为空");
}
if(StrUtil.isBlank(object.getSubName())){
throw new ExcelAnalysisException(msg+"变电站不可为空");
}
if(StrUtil.isBlank(object.getDevName())){
throw new ExcelAnalysisException(msg+"设备名称不可为空");
}
if(StrUtil.isBlank(object.getLineName())){
throw new ExcelAnalysisException(msg+"监测点名称不可为空");
}
if(StrUtil.isBlank(object.getMark())){
throw new ExcelAnalysisException(msg+"监测点评级不可为空");
}
list.add(object);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
//进行
if(CollectionUtil.isNotEmpty(list)){
String res = lineMarkService.dealData(list);
if(!"操作成功".equals(res)){
throw new ExcelAnalysisException(res);
}
}else {
}
}
@Override
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
//进行表头判断
if(Objects.nonNull(headMap)){
if(headMap.size()!=6){
throw new ExcelAnalysisException("excel表头出错");
}else {
if(!"省份".equals(headMap.get(0)) || !"供电公司".equals(headMap.get(1)) ||!"所属变电站".equals(headMap.get(2))
|| !"装置名称".equals(headMap.get(3))||!"监测点名称".equals(headMap.get(4))|| !"监测点评级".equals(headMap.get(5))){
throw new ExcelAnalysisException("excel表头出错");
}
}
}else {
throw new ExcelAnalysisException("excel表头出错");
}
}
public LineMarkExcelListener(LineMarkService lineMarkService){
this.lineMarkService = lineMarkService;
//监测点等级匹配
}
}

View File

@@ -0,0 +1,118 @@
package com.pqs9900.listener;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.pqs9900.pojo.linedata.LineMarkWeight;
import com.pqs9900.pojo.linedata.MarkExcel;
import com.pqs9900.pojo.linedata.MarkWeightExcel;
import com.pqs9900.service.linedata.LineMarkService;
import com.pqs9900.service.linedata.LineMarkWeightService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
/**
* 监测点批量评级导入excel监听
*
* @author cdf
* @date 2021/10/27
*/
public class LineMarkWeightExcelListener extends AnalysisEventListener<MarkWeightExcel> {
private static final Logger logger = LoggerFactory.getLogger(LineMarkWeightExcelListener.class);
private LineMarkWeightService lineMarkWeightService;
private Integer ding = 0;
private List<MarkWeightExcel> list = new ArrayList<>();
@Override
public void invoke(MarkWeightExcel object, AnalysisContext context){
ding++;
String msg =""+ding+"行,";
if(StrUtil.isBlank(object.getProvince())){
throw new ExcelAnalysisException(msg+"省份不可为空");
}
if(StrUtil.isBlank(object.getGdName())){
throw new ExcelAnalysisException(msg+"供电公司不可为空");
}
if(StrUtil.isBlank(object.getSubName())){
throw new ExcelAnalysisException(msg+"变电站不可为空");
}
if(StrUtil.isBlank(object.getDevName())){
throw new ExcelAnalysisException(msg+"设备名称不可为空");
}
if(StrUtil.isBlank(object.getLineName())){
throw new ExcelAnalysisException(msg+"监测点名称不可为空");
}
if(Objects.isNull(object.getCommunFeeMark())){
throw new ExcelAnalysisException(msg+"通信费用评分不可为空");
}
if(Objects.isNull(object.getServiceMark())){
throw new ExcelAnalysisException(msg+"服务条款评分不可为空");
}
if(Objects.isNull(object.getAgentMark())){
throw new ExcelAnalysisException(msg+"中间户数据需求评分不可为空");
}
if(Objects.isNull(object.getCompanyMark())){
throw new ExcelAnalysisException(msg+"公司数据需求评分不可为空");
}
if(Objects.isNull(object.getUserMark())){
throw new ExcelAnalysisException(msg+"用户数据需求评分不可为空");
}
if(Objects.isNull(object.getLineTypeMark())){
throw new ExcelAnalysisException(msg+"监测点类型评分不可为空");
}
if(Objects.isNull(object.getBusinessMark())){
throw new ExcelAnalysisException(msg+"行业重要度评分不可为空");
}
list.add(object);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
//进行
if(CollectionUtil.isNotEmpty(list)){
String res = lineMarkWeightService.dealData(list);
if(!"操作成功".equals(res)){
throw new ExcelAnalysisException(res);
}
}else {
throw new ExcelAnalysisException("导入数据为空");
}
}
@Override
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
//进行表头判断
if(Objects.nonNull(headMap)){
if(headMap.size()!=15){
throw new ExcelAnalysisException("excel表头出错");
}else {
if(!"省份".equals(headMap.get(1)) || !"供电公司".equals(headMap.get(2)) ||!"所属变电站".equals(headMap.get(3))
|| !"装置名称".equals(headMap.get(4))||!"监测点名称".equals(headMap.get(5))){
throw new ExcelAnalysisException("excel表头出错");
}
}
}else {
throw new ExcelAnalysisException("excel表头出错");
}
}
public LineMarkWeightExcelListener(LineMarkWeightService lineMarkWeightService){
this.lineMarkWeightService = lineMarkWeightService;
}
}

View File

@@ -0,0 +1,74 @@
package com.pqs9900.listener;
import com.njcn.mapper.configuration.SysMapper;
import com.njcn.pojo.data.TimerManage;
import com.pqs9900.task.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.context.event.ContextStoppedEvent;
import java.util.ArrayList;
import java.util.List;
public class SchedulerListener implements ApplicationListener<ApplicationEvent> {
@Autowired
private MySchudler mySchudler;
@Autowired
private SysMapper sysMapper;
@Override
public void onApplicationEvent(ApplicationEvent event) {
if(event instanceof ContextClosedEvent){
//spring容器关闭时调用
if(mySchudler!=null){
mySchudler.destry();
}
}else if(event instanceof ContextRefreshedEvent ){
//spring容器启用时调用
if (((ContextRefreshedEvent) event).getApplicationContext().getParent() == null) {
MyJobDetail userJob = new MyJobDetail("casual", "userJob", CasualUserTask.class);
MyTrigger userTrigger = new MyTrigger("casualTrigger", "userTriggerGroup", "0 0/5 * * * ?");
MyJobDetail lockUserJob = new MyJobDetail("lockUser", "userJob", LockUserState.class);
MyTrigger lockUserTrigger = new MyTrigger("lockUserTrigger", "userTriggerGroup", "0 0/1 * * * ?");
MyJobDetail translateJob = new MyJobDetail("translate", "translateJob", JudgeTranslate.class);
MyTrigger translateTrigger = new MyTrigger("translateTrigger", "translateTriggerGroup", "0 0/5 * * * ?");
MyJobDetail topTerminalJob = new MyJobDetail("topTerminal", "topTerminalJob", TopExceptionTask.class);
MyTrigger topTerminalTrigger = new MyTrigger("topTerminalTrigger", "topTerminalTriggerGroup", "0 0 2 * * ? *");
List<TimerManage> list;
try { //防止数据库没有建表,则不开启
list = sysMapper.getTimerManage();
} catch (Exception e) {
list = new ArrayList<>();
}
for (TimerManage timerManage : list) {
switch (timerManage.getGroupName()) {
case "userTriggerGroup": {
mySchudler.startJob(userJob, userTrigger, timerManage.getState());
mySchudler.startJob(lockUserJob, lockUserTrigger, timerManage.getState());
break;
}
case "translateTriggerGroup": {
mySchudler.startJob(translateJob, translateTrigger, timerManage.getState());
break;
}
case "topTerminalTriggerGroup": {
mySchudler.startJob(topTerminalJob, topTerminalTrigger, timerManage.getState());
break;
}
}
}
}
}
}
}

View File

@@ -0,0 +1,33 @@
package com.pqs9900.listener;
import com.pqs9900.task.MyJobFactory;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
@Configuration
public class SchedulerListenerConfig {
@Autowired
private MyJobFactory myJobFactory; //自定义的factory
@Bean
public SchedulerListener applicationStartListener() {
return new SchedulerListener();
}
//获取调度器的工厂bean
@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
//修改成自己的工厂
schedulerFactoryBean.setJobFactory(myJobFactory);
return schedulerFactoryBean;
}
@Bean
public Scheduler scheduler() {
return schedulerFactoryBean().getScheduler();
}
}

View File

@@ -0,0 +1,33 @@
package com.pqs9900.mapper.DataInfo;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.pqs9900.pojo.DataInfo.AlarmInfo;
import tk.mybatis.mapper.common.Mapper;
/** @Author denghuajun
* @Description //TODO 告警信息表Mapper
* @Date 2019/3/15 11:57
**/
public interface AlarmInfoMapper extends Mapper<AlarmInfo> {
List<AlarmInfo> getAlarmInfo(@Param("startTime")Date startTime,@Param("endTime")Date endTime,@Param("state")String state,@Param("type")String type,@Param("alarmLevel") Integer alarmLevel,@Param("lineGrade") Integer lineGrade);
List<AlarmInfo> getAlarmInfoDetail(@Param("state")String state,@Param("type")String type,@Param("typeIndex")Integer typeIndex,@Param("devLineType")Integer devLineType,@Param("processTime")String processTime);
List<AlarmInfo> unAlarmInfo();
int updateAlarmInfo(@Param("type")String type,@Param("typeIndex")Integer typeIndex,@Param("devLineType")Integer devLineType,@Param("processTime")Date processTime,@Param("userIndex")String userIndex);
List<AlarmInfo> getAlarmTask(@Param("startTime")Date startTime,@Param("endTime")Date endTime);
List<AlarmInfo> getAlarmTaskByDev(@Param("startTime")Date startTime,@Param("endTime")Date endTime);
List<AlarmInfo> getAlarmDesc(@Param("devIndex")Integer devIndex,@Param("startTime")Date startTime,@Param("endTime")Date endTime);
}

View File

@@ -0,0 +1,19 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.DevStateDetail;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* @description: 终端状态详情Mapper
* @author: denghuajun
* @time: 2019-09-03 11:03:32
**/
public interface DevStateDetailMapper {
List<DevStateDetail> getDevStateDetail(@Param("dataType")List<Integer> dataType);
List<DevStateDetail> getDevStateInfo(@Param("devIndex") Long devIndex,@Param("startTime") Date startTime,@Param("endTime") Date endTime);
DevStateDetail getDeviceDetail(@Param("devIndex") Long devIndex);
}

View File

@@ -0,0 +1,11 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.DevState;
import tk.mybatis.mapper.common.Mapper;
/** @Author denghuajun
* @Description //TODO 终端状态表Mapper
* @Date 2019/3/15 11:57
**/
public interface DevStateMapper extends Mapper<DevState> {
}

View File

@@ -0,0 +1,26 @@
package com.pqs9900.mapper.DataInfo;
import com.njcn.pojo.terminal.DeviceUnitPO;
import com.njcn.pojo.terminal.DeviceUnitVO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.BaseMapper;
import java.util.List;
/**
* system
*
* @author cdf
* @date 2023/8/17
*/
public interface DeviceUnitMapper extends BaseMapper<DeviceUnitPO> {
List<DeviceUnitVO> unitTable(@Param("devFlag") Integer devFlag);
DeviceUnitVO lineUnitDetail(Integer lineId);
}

View File

@@ -0,0 +1,20 @@
package com.pqs9900.mapper.DataInfo;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/**
* system
*
* @author cdf
* @date 2021/9/29
*/
public interface DownEventMapper {
Integer addEventAndWave(@Param("eventDetailIndex") String eventDetailIndex, @Param("lineId")Integer lineId, @Param("timeid") Date timeid, @Param("ms")Integer ms, @Param("describe")String describe, @Param("wavetype")Integer wavetype, @Param("persisttime")Integer persisttime,@Param("eventValue") Float eventValue,@Param("eventReason")String eventReason,@Param("eventType")String eventType);
Integer isRight(@Param("timeid") Date timeid,@Param("lineId") Integer lineId,@Param("ms") Integer ms);
Integer updateWaveFlag(@Param("evenDetailIndex")String evenDetailIndex);
}

View File

@@ -0,0 +1,17 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.Flow;
import com.pqs9900.pojo.DataInfo.FlowDetail;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 终端流量详细表Mapper
* @Date 2019/3/27 14:58
**/
public interface FlowDetailMapper extends Mapper<FlowDetail> {
List<FlowDetail> getFlowDetail(@Param("startTime")Date startTime,@Param("endTime")Date endTime);//获取流量详情
}

View File

@@ -0,0 +1,11 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.Flow;
import tk.mybatis.mapper.common.Mapper;
/** @Author denghuajun
* @Description //TODO 终端流量表Mapper
* @Date 2019/3/15 11:58
**/
public interface FlowMapper extends Mapper<Flow> {
}

View File

@@ -0,0 +1,17 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.MiddRun;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 中间件表Mapper
* @Date 2019/3/15 11:57
**/
public interface MiddRunMapper extends Mapper<MiddRun> {
List<MiddRun> getMiddRun(@Param("middIndex")String middIndex);
List<MiddRun> getUpdateSelect(@Param("middIndex")String middIndex);
}

View File

@@ -0,0 +1,18 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.MiddRunState;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 中间件运行状态表Mapper
* @Date 2019/3/15 11:57
**/
public interface MiddRunStateMapper extends Mapper<MiddRunState> {
//查询所有历史
List<MiddRunState> getMiddRunState(@Param("middIndex")String middIndex, @Param("startTime")Date startTime, @Param
("endTime")Date endTime);
}

View File

@@ -0,0 +1,10 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.MiddRunTree;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface MiddRunTreeMapper extends Mapper<MiddRunTree> {
public List<MiddRunTree> getfirstData();
}

View File

@@ -0,0 +1,16 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.Server;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 服务器表Mapper
* @Date 2019/3/15 11:57
**/
public interface ServerMapper extends Mapper<Server> {
List<Server> getServer(@Param("sevIndex")String sevIndex);
List<Server> getUpdateServer(@Param("sevIndex")String sevIndex);
}

View File

@@ -0,0 +1,18 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.ServerState;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 服务器状态表Mapper
* @Date 2019/3/15 11:57
**/
public interface ServerStateMapper extends Mapper<ServerState> {
//查询所有历史
List<ServerState> getServerState(@Param("sevIndex")String sevIndex, @Param("startTime")Date startTime, @Param
("endTime")Date endTime);
}

View File

@@ -0,0 +1,10 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.ServerTree;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface ServerTreeMapper extends Mapper<ServerTree> {
public List<ServerTree> getfirstData();
}

View File

@@ -0,0 +1,121 @@
package com.pqs9900.mapper.DataInfo;
import com.pqs9900.pojo.DataInfo.TerminalPojo;
import com.pqs9900.pojo.terminal.DeviceIpRVO;
import com.pqs9900.pojo.terminal.EdData;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* @Description 终端版本控制
* @Author cdf
* @Date 2020/7/30 11:20
**/
public interface VersionMapper {
/**
* @Author chendaofei
* @Description 获取所有终端设备
* @Date 11:21 2020/7/30
**/
List<TerminalPojo> getDeviceList(@Param("status")Integer status,@Param("devType")String devType,@Param("devSeries")String devSeries,@Param("devarr")List<String> devarr);
/**
* @Author chendaofei
* @Description
* @Date 9:46 2020/9/14
**/
Integer getCount(@Param("edProtocol")String edProtocol,@Param("edDate")String edDate,@Param("edIndex")String edIndex);
/**
* @Author chendaofei
* @Description 新增版本
* @Date 11:49 2020/8/6
**/
Integer addVersion(EdData edData);
/**
* @Author chendaofei
* @Description 修改版本
* @Date 11:49 2020/8/6
**/
Integer updateVersion(EdData edData);
/**
* @Author chendaofei
* @Description 删除版本
* @Date 11:49 2020/8/6
**/
Integer delVersion(@Param("edIndex") String edIndex);
/**
* @Author chendaofei
* @Description 启用停用版本
* @Date 11:49 2020/8/6
**/
Integer enableDisable(@Param("edIndex") String edIndex,@Param("status") Integer status);
/**
* @Author chendaofei
* @Description 获取版本
* @Date 11:49 2020/8/6
**/
EdData getVersion(@Param("edIndex") String edIndex);
/**
* @Author chendaofei
* @Description 获取版本(区别,不带blob文件)
* @Date 11:49 2020/8/6
**/
EdData getVersionTwo(@Param("edIndex") String edIndex);
/**
* @Author chendaofei
* @Description 获取版本列表
* @Date 11:49 2020/8/6
**/
List<EdData> getVersionList(@Param("edIndex") String edIndex,@Param("edName") String edName,@Param("edProtocol") String edProtocol,@Param("edDate") String edDate,@Param("devType") String devType,@Param("type") Integer type,@Param("blob")String blob);
/**
* @Author chendaofei
* @Description 获取版本列表过滤已有版本号
* @Date 11:49 2020/8/6
**/
List<EdData> getVersionListFilterEdIndex(@Param("devType")String devType,@Param("blob")String blob,@Param("edList")List<String> edList);
/**
* @Author chendaofei
* @Description
* @Date 14:00 2020/8/11
**/
List<DeviceIpRVO> getDeviceIp(@Param("list") List<String> list);
List<DeviceIpRVO> getDeviceIps(@Param("devList") Integer devList);
/**
* @Author chendaofei
* @Description 判断设备版本号是否已经存在
* @Date 15:07 2020/8/27
**/
Integer isExitVersionForDev(@Param("edIndex")String edIndex,@Param("list")List<String> list);
/**
* @Author chendaofei
* @Description 通过字典index获取字典名
* @Date 20:07 2020/10/21
**/
String getTypeByDicId(String dicIndex);
List<TerminalPojo> getUpdetail(@Param("devIndex")String devIndex);
int isBindDev(@Param("edIndex")String edIndex);
/**
* 根据装置id获取版本号
* @author cdf
* @date 2021/8/30
*/
List<TerminalPojo> upFlag(@Param("devIndex")List<Integer> devIndex);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataFlicker;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 短时闪变
* @Date 2018/12/17 10:52
**/
public interface DataFlickerMapper extends Mapper<DataFlicker> {
int insertDataFlicker(@Param("list")List<DataFlicker> list);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataFluc;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 电压波动
* @Date 2018/12/17 10:51
**/
public interface DataFlucMapper extends Mapper<DataFluc> {
int insertDataFluc(@Param("list")List<DataFluc> list);
}

View File

@@ -0,0 +1,11 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataHarmPhasicI;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface DataHarmPhasicIMapper extends Mapper<DataHarmPhasicI> {
int insertDataHarmPhasicI(@Param("list")List<DataHarmPhasicI> list);
}

View File

@@ -0,0 +1,11 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataHarmPhasicV;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface DataHarmPhasicVMapper extends Mapper<DataHarmPhasicV> {
int insertDataHarmPhasicV(@Param("list")List<DataHarmPhasicV> list);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataHarmpowerP;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 三相有功功率
* @Date 2018/12/17 10:53
**/
public interface DataHarmpowerPMapper extends Mapper<DataHarmpowerP> {
int insertDataHarmpowerP(@Param("list")List<DataHarmpowerP> list);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataHarmpowerQ;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 三相无功功率
* @Date 2018/12/17 10:53
**/
public interface DataHarmpowerQMapper extends Mapper<DataHarmpowerQ> {
int insertDataHarmpowerQ(@Param("list")List<DataHarmpowerQ> list);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataHarmpowerS;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 三相视在功率
* @Date 2018/12/17 10:53
**/
public interface DataHarmpowerSMapper extends Mapper<DataHarmpowerS> {
int insertDataHarmpowerS(@Param("list")List<DataHarmpowerS> list);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataHarmrateI;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 谐波电流幅值
* @Date 2019/2/26 16:50
**/
public interface DataHarmrateIMapper extends Mapper<DataHarmrateI> {
int insertDataHarmrateI(@Param("list")List<DataHarmrateI> list);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataHarmrateV;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 谐波电压含有率
* @Date 2018/12/17 10:54
**/
public interface DataHarmrateVMapper extends Mapper<DataHarmrateV> {
int insertDataHarmrateV(@Param("list")List<DataHarmrateV> list);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataI;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 电流相关
* @Date 2018/12/17 10:54
**/
public interface DataIMapper extends Mapper<DataI> {
int insertDataI(@Param("list")List<DataI> list);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataInHarmI;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 电流间谐波幅值表
* @Date 2019/2/26 16:50
**/
public interface DataInHarmIMapper extends Mapper<DataInHarmI> {
int insertDataInHarmI(@Param("list")List<DataInHarmI> list);
}

View File

@@ -0,0 +1,11 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataInHarmV;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface DataInHarmVMapper extends Mapper<DataInHarmV> {
int insertDataInHarmV(@Param("list")List<DataInHarmV> list);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataPlt;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 长时闪变
* @Date 2018/12/17 10:52
**/
public interface DataPltMapper extends Mapper<DataPlt> {
int insertDataPlt(@Param("list")List<DataPlt> list);
}

View File

@@ -0,0 +1,15 @@
package com.pqs9900.mapper.HisData;
import com.pqs9900.pojo.HisData.DataV;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** @Author denghuajun
* @Description //TODO 电压相关
* @Date 2018/12/17 10:54
**/
public interface DataVMapper extends Mapper<DataV> {
int insertDataV(@Param("list")List<DataV> list);
}

View File

@@ -0,0 +1,77 @@
package com.pqs9900.mapper.HisData;
import com.njcn.pojo.data.OfflLog;
import com.pqs9900.pojo.DataInfo.TranslateState;
import com.pqs9900.util.TranslateThread.data;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface ManaDeviceMapper {
void insertOFFlog(@Param("offllog") OfflLog offlLog);
List<data> getDataInfo();
Integer delOfflog(@Param("guid")String guid);
void updateOFFlog(@Param("start") Date startTime, @Param("end") Date endTime, @Param("year") String year, @Param("state") int state, @Param("name") String name, @Param("id") int id, @Param("updateTime") Date updateTime, @Param("allCount") int allCount, @Param("realCount") int realCount, @Param("offlDescribe") String offlDescribe);
int getCount(@Param("id") int id, @Param("name") String name, @Param("state") Integer state);
List<TranslateState> getTranslateState(@Param("start") Date start, @Param("end") Date end);
List<TranslateState> judgetranslate(@Param("time") Date time);
List<String> getDepts(@Param("guid") String guid);
List<String> getDeptsInfo();
List<String> getProName();
List<String> getFacs();
List<String> getTypes();
List<String> getNodes();
List<String> getScale();
List<String> getLoadType();
TranslateState getBaseInfo(@Param("guid") String guid);
TranslateState queryimportLoading();
List<String> getVoltage();
void deleteTableDataFlicker(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataFluc(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataHAI(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataHAV(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataHAP(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataHAQ(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataHAS(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataHarmrateI(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataHarmrateV(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataI(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataV(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataINI(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataINV(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
void deleteTableDataPLT(@Param("index") Integer index, @Param("start") Date start, @Param("end") Date end);
}

View File

@@ -0,0 +1,13 @@
package com.pqs9900.mapper.State;
import com.pqs9900.pojo.State.MonthYearDayFlow;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface MonthYearDayFlowMapper extends Mapper<MonthYearDayFlow> {
List<MonthYearDayFlow> dayByMonth(@Param("devIndex")Long devIndex,@Param("yearmonth") String yearmonth);
Float getAvgFlow(@Param("devIndex")Long devIndex,@Param("yearmonth") String yearmonth);
}

View File

@@ -0,0 +1,16 @@
package com.pqs9900.mapper.filebackup;
import java.util.List;
/**
* @author 徐扬
*/
public interface FileBackUpMapper {
//获取信息
List<com.pqs9900.pojo.filebackup.FileBackUp> getFileList();
//删除表
Integer deleteUserlog();
}

View File

@@ -0,0 +1,20 @@
package com.pqs9900.mapper.linedata;
import com.pqs9900.pojo.linedata.HalfReportRVO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* system
*
* @author cdf
* @date 2021/12/6
*/
public interface AreaIntegralityMapper {
List<HalfReportRVO> getLineMoreInfo(@Param("startTime") Date startTime, @Param("endTime")Date endTime,@Param("lineGrade")String lineGrade,@Param("status")Integer status,@Param("devFlag")Integer devFlag);
}

View File

@@ -0,0 +1,70 @@
package com.pqs9900.mapper.linedata;
import com.njcn.pojo.pointInfo.LineLedger;
import com.pqs9900.pojo.linedata.MarkExcel;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
/**
* system
* 监测点打分
* @author cdf
* @date 2021/10/27
*/
public interface LineMarkMapper {
/**
* 获取监测点台账
* @author cdf
* @date 2021/10/27
*/
List<LineLedger> getLineMark(@Param("status")Integer status,@Param("lineGrade")Integer lineGrade);
/**
*
* @author cdf
* @date 2021/11/2
*/
Integer singleOperate(@Param("lineIndex") Integer lineIndex, @Param("lineGrade")String lineGrade);
/**
* 获取监测点评级
* @author cdf
* @date 2021/11/2
*/
LineLedger getLineGrade(Integer lineIndex);
/**
*
* @author cdf
* @date 2021/10/28
*/
MarkExcel getLineMarkData(@Param("gdName")String gdName,@Param("subName")String subName,@Param("devName")String devName,@Param("lineName")String lineName);
/**
* 修改监测点评级
* @author cdf
* @date 2021/10/28
*/
Integer updateMark(@Param("lineGrade") String lineGrade,@Param("lineIndex") Integer lineIndex);
/**
* 批量修改监测点评级
* @author cdf
* @date 2021/10/29
*/
Integer batchUpdateForLine(@Param("list") List<MarkExcel> list);
/**
* 批量修改装置的前置
* @author cdf
* @date 2021/10/29
*/
Integer batchUpdateNode(@Param("list")List<MarkExcel> list);
List<Integer> getStopLineIds();
}

View File

@@ -0,0 +1,73 @@
package com.pqs9900.mapper.linedata;
import com.njcn.pojo.pointInfo.LineLedger;
import com.pqs9900.pojo.linedata.LineMarkWeight;
import com.pqs9900.pojo.linedata.LineMarkWeightVo;
import com.pqs9900.pojo.linedata.MarkWeightExcel;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.BaseMapper;
import java.util.List;
/**
* system
* 监测点打分
* @author cdf
* @date 2021/10/27
*/
public interface LineMarkWeightMapper extends BaseMapper<LineMarkWeight> {
/**
* 获取监测点台账
* @author cdf
* @date 2021/10/27
*/
List<LineMarkWeightVo> getLineMarkWeight(@Param("devFalg")Integer devFalg, @Param("lineGrade")Integer lineGrade);
/**
*
* @author cdf
* @date 2021/11/2
*/
Integer singleOperate(@Param("item") LineMarkWeight item);
/**
* 获取监测点评级
* @author cdf
* @date 2021/11/2
*/
LineLedger getLineGrade(Integer lineIndex);
/**
*
* @author cdf
* @date 2021/10/28
*/
MarkWeightExcel getLineMarkData(@Param("gdName")String gdName,@Param("subName")String subName,@Param("devName")String devName,@Param("lineName")String lineName);
/**
* 批量修改监测点评分权重
* @author cdf
* @date 2021/10/29
*/
Integer batchAddLineWeight(@Param("list") List<MarkWeightExcel> list);
/**
* 批量删除监测点评分权重
* @author cdf
* @date 2023/8/16
*/
Integer batchDelLineWeight(@Param("lineIds")List<Integer> lineIds);
/**
* 批量修改装置的前置
* @author cdf
* @date 2021/10/29
*/
Integer batchUpdateNode(@Param("list")List<MarkWeightExcel> list);
List<Integer> getStopLineIds();
}

View File

@@ -0,0 +1,57 @@
package com.pqs9900.mapper.linedata;
import com.pqs9900.pojo.linedata.OnlineRateCld;
import com.pqs9900.pojo.linedata.OnlineRateCldParam;
import com.pqs9900.pojo.linedata.OnlineRateCldRVO;
import com.pqs9900.pojo.linedata.TopExceptionParam;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
/**
* system
*
* @author cdf
* @date 2021/12/16
*/
public interface OnlineRateCldMapper extends Mapper<OnlineRateCld> {
/**
* 获取所有在线终端
* @author cdf
* @date 2021/12/16
*/
List<TopExceptionParam> getRunDevList();
/**
* 查询pqs_onlinereate表在线为0的
* @author cdf
* @date 2021/12/16
*/
List<OnlineRateCldParam> getOnlineByDevIndex(@Param("timeId")Date timeId, @Param("list")List<Integer> list);
/**
* 批量新增
* @author cdf
* @date 2021/12/16
*/
Integer batchAdd(@Param("list")List<OnlineRateCld> list);
/**
* 指定日期是否存在数据
* @author cdf
* @date 2021/12/16
*/
Integer getOnlineCount(@Param("startTime")Date startTime);
/**
*
* @author cdf
* @date 2021/12/16
*/
List<OnlineRateCldRVO> getOnlineRateCldList(@Param("startTime")Date startTime, @Param("endTime")Date endTime, @Param("lineGrade")Integer lineGrade);
}

View File

@@ -0,0 +1,14 @@
package com.pqs9900.mapper.linedata;
import com.pqs9900.pojo.linedata.TopException;
import tk.mybatis.mapper.common.Mapper;
/**
* system
*
* @author cdf
* @date 2021/11/12
*/
public interface TopExceptionMapper extends Mapper<TopException> {
}

View File

@@ -0,0 +1,85 @@
package com.pqs9900.mapper.linedata;
import com.njcn.pojo.commons.runmanage.IntergralityTable;
import com.njcn.pojo.commons.runmanage.OnlineRateData;
import com.njcn.pojo.data.ComInformation;
import com.pqs9900.pojo.linedata.*;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* system
*
* @author cdf
* @date 2021/11/9
*/
public interface TopStrategyMapper extends Mapper<TerminalRun> {
List<TerminalRun> getList();
/**
* 获取每天终端异常情况
* @author cdf
* @date 2021/11/9
*/
List<OnlineRateData> selectOnlineRate( @Param("startTime")Date startTime, @Param("endTime")Date endTime,@Param("lineGrade") Integer lineGrade);
List<IntergralityTable> selectIntegrityData(@Param("startTime")Date startTime, @Param("endTime")Date endTime, @Param("lineGrade")Integer lineGrade);
List<IntergralityTable> getIntegrityTask(@Param("startTime")Date startTime);
/**
* 获取前一天装置在线率为0的装置
* @author cdf
* @date 2021/12/13
*/
List<TopExceptionParam> getDevOnlineZero(@Param("startTime")Date startTime);
List<OnlineRateCldParam> getOffTimeTask(@Param("startTime")Date startTime,@Param("endTime")Date endTime, @Param("devIndex")Integer devIndex);
List<TopExceptionParam> getOffLineTask(@Param("startTime")Date startTime, @Param("endTime")Date endTime);
List<ComInformation> devMsgInfo(@Param("devIndex")int devIndex, @Param("startTime")Date startTime, @Param("endTime")Date endTime);
List<TopExceptionParam> getFlowOutTask(@Param("startTime")Date startTime,@Param("timeId")String timeId,@Param("preValue")Integer preValue,@Param("allDay")Integer allDay,@Param("intervals")Integer intervals);
List<TopExceptionParam> getOffTimeList(@Param("devIndex")Integer devIndex,@Param("startTime")Date startTime,@Param("endTime")Date endTime,@Param("offTime")Integer offTime);
Integer addTopException(@Param("list") List<TopException> list);
Integer getTopCount(@Param("startTime")Date startTime);
List<TopView> getTopView(@Param("startTime")Date startTime,@Param("endTime")Date endTime,@Param("lineGrade")Integer lineGrade);
List<TopException> getRunExceptionDetail(@Param("timeId")Date timeId,@Param("lineGrade")Integer lineGrade);
TopException getRunExceptionDetailById(@Param("timeId")Date timeId,@Param("devIndex")Integer devIndex);
/**
* 进行流量查询
*/
List<TopExceptionParam> getDevFlow(@Param("startTime")Date startTime,@Param("timeId")String timeId);
/**
* 批量更新装置流量
* @author cdf
* @date 2021/11/18
*/
Integer batchUpdateDevFlow(@Param("list") List<TopExceptionParam> list);
/**
* 单个监测点数据完整性统计
* @author dhj
* @date 2021/12/07
*/
List<DataIntegralityStatis> getDataIntegralityStatis(@Param("lineId")Long lineId,@Param("startTime")String startTime,@Param("endTime")String endTime);
}

View File

@@ -0,0 +1,58 @@
package com.pqs9900.mapper.message;
import com.pqs9900.pojo.message.EventdetailInfo;
import com.pqs9900.pojo.message.MsgInfoDTO;
import com.pqs9900.pojo.message.UserEventDTO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface MessageMapper {
List<EventdetailInfo> getEventdetailLineId(@Param("start") Date start, @Param("end") Date end, @Param("wavetype") List<Integer> wavetype);
List<EventdetailInfo> getBaseInfo(@Param("start") Date start, @Param("end") Date end, @Param("wavetype") List<Integer> wavetype);
void insertMsgInfo(@Param("userId") String userId, @Param("insertTime") Date time, @Param("content") String content, @Param("type") Integer type, @Param("state") Integer state, @Param("msgIndex") String msgIndex);
String getUserIdByPhone(@Param("phone") String phone);
List<EventdetailInfo> getAllSendDept();
List<EventdetailInfo> getEventList(@Param("start") Date start, @Param("end") Date end, @Param("wavetype") List<Integer> wavetype,@Param("linelist")List<Integer> linelist);
/**
* @Author chendaofei
* @Description 获取最新日期
* @Date 15:39 2020/5/19
**/
MsgInfoDTO getLastTime();
/**
* @Author chendaofei
* @Description 查询短信信息列表
* @Date 9:19 2020/5/20
**/
List<MsgInfoDTO> getAllMsgList(@Param("type") Integer type, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
/**
* @Author chendaofei
* @Description 假删除已发短信
* @Date 11:48 2020/5/21
**/
Integer deleteMsgList(List<String> list);
/**
* getEvendetailList
* @author cdf
* @date 2021/3/26
*/
List<UserEventDTO> getHasSendEvent(@Param("start")Date start,@Param("end")Date end);
Integer addHasSendEvent(@Param("list") List<UserEventDTO> list);
}

View File

@@ -0,0 +1,82 @@
package com.pqs9900.mapper.message;
import com.pqs9900.pojo.message.MsgBaseConfDTO;
import com.pqs9900.pojo.message.MsgTypeTemplateDTO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* @Author chendaofei
* @Description 短信配置
* @Date 10:03 2020/5/12
**/
public interface MsgCofMapper {
/**
* @Author chendaofei
* @Description 获取短信基本配置
* @Date 10:19 2020/5/12
**/
MsgBaseConfDTO getMsgConfig();
/**
* @Author chendaofei
* @Description 添加短信配置
* @Date 10:19 2020/5/12
**/
Integer addMsgConfig(MsgBaseConfDTO msgBaseConfDTO);
/**
* @Author chendaofei
* @Description 修改短信配置
* @Date 10:19 2020/5/12
**/
Integer updateMsgCofig(MsgBaseConfDTO msgBaseConfDTO);
/**
* @Author chendaofei
* @Description 获取短信配置模板
* @Date 10:40 2020/5/12
**/
List<MsgTypeTemplateDTO> getMsgDicdataList(@Param("msgType") Integer msgType,@Param("state")Integer state);
/**
* @Author chendaofei
* @Description 检查是否存在模板
* @Date 10:40 2020/5/12
**/
Integer checkHasDicdata(@Param("msgName") String msgName, @Param("msgType") Integer msgType);
/**
* @Author chendaofei
* @Description 删除模板
* @Date 10:42 2020/5/12
**/
Integer delMsgDicBytype(@Param("msgIndex") String msgIndex);
/**
* @Author chendaofei
* @Description 修改模板状态
* @Date 10:45 2020/5/12
**/
Integer updateMsgDicState(@Param("list") List<String> list);
/**
* @Author chendaofei
* @Description 全部修改为不启用
* @Date 10:45 2020/5/12
**/
Integer updateMsgDicState2();
/**
* @Author chendaofei
* @Description 新增模板
* @Date 10:47 2020/5/12
**/
Integer addMsgDicdata(MsgTypeTemplateDTO msgTypeTemplateDTO);
Integer updateSendMsgTime(Date date);
}

View File

@@ -0,0 +1,12 @@
package com.pqs9900.mapper.terminal;
import com.pqs9900.pojo.terminal.FlowMealDTO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface FlowMealMapper extends Mapper<FlowMealDTO> {
List<FlowMealDTO> getFlowMealList(@Param("fmIndex")String fmIndex,@Param("fmName")String fmName,@Param("type")Integer type,@Param("secondType")Integer secondType);
}

View File

@@ -0,0 +1,97 @@
package com.pqs9900.mapper.terminal;
import com.pqs9900.pojo.terminal.FlowStrategyBindDTO;
import com.pqs9900.pojo.terminal.FlowStrategyVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Description 流量策略
* @Author cdf
* @Date 2020/8/10 14:58
**/
public interface FlowStrategyMapper {
/**
* @Author chendaofei
* @Description 新增流量策略字典
* @Date 15:35 2020/8/10
**/
Integer addFsdic(@Param("fsdIndex")String fsdIndex,@Param("percent")Integer percent,@Param("type")Integer type);
/**
* @Author chendaofei
* @Description 修改流量策略字典
* @Date 15:35 2020/8/10
**/
Integer updateFsdic(@Param("fsdIndex")String fsdIndex,@Param("percent")Integer percent,@Param("type")Integer type);
/**
* @Author chendaofei
* @Description 删除流量策略字典
* @Date 15:35 2020/8/10
**/
Integer delFsdic(@Param("fsdIndex") String fsdIndex);
/**
* @Author chendaofei
* @Description 新增流量策略
* @Date 15:35 2020/8/10
**/
Integer addStrategy(FlowStrategyVO flowStrategyVO);
/**
* @Author chendaofei
* @Description 修改流量策略
* @Date 15:35 2020/8/10
**/
Integer updateStrategy(FlowStrategyVO flowStrategyVO);
/**
* @Author chendaofei
* @Description 修改流量策略
* @Date 15:35 2020/8/10
**/
Integer delStrategy(@Param("fsIndex") String fsIndex);
/**
* @Author chendaofei
* @Description 获取流量策略列表
* @Date 15:35 2020/8/10
**/
List<FlowStrategyVO> getStrategyList(@Param("name")String name,@Param("type")Integer type,@Param("fsIndex")String fsIndex);
/**
* @Author chendaofei
* @Description 获取流量策略
* @Date 15:35 2020/8/10
**/
FlowStrategyVO getStrategy(@Param("fsIndex")String fsIndex);
/**
* @Author chendaofei
* @Description 新增流量策略字典绑定类型
* @Date 15:35 2020/8/10
**/
Integer addFun(@Param("list") List<FlowStrategyBindDTO> list);
/**
* @Author chendaofei
* @Description 删除流量策略字典绑定类型
* @Date 15:35 2020/8/10
**/
Integer delFun(@Param("fsdIndex")String fsdIndex);
/**
* @Author chendaofei
* @Description
* @Date 16:57 2020/8/20
**/
List<String> getFun(@Param("fsdIndex")String fsdIndex);
}

View File

@@ -0,0 +1,93 @@
package com.pqs9900.mapper.terminal;
import com.pqs9900.pojo.DataInfo.FlowDetail;
import com.pqs9900.pojo.terminal.*;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface TerminalStateMapper {
/**
* @Author chendaofei
* @Description 获取终端版本流量列表
* @Date 10:40 2020/8/31
**/
List<TerminalRVO> getTerminalList(@Param("devType")String devType, @Param("status")Integer status,@Param("startTime")String startTime);
/**
* @Author chendaofei
* @Description
* @Date 10:40 2020/8/31
**/
List<TerminalRVO> getTerminalList2(@Param("list")List<String> list);
/**
* @Author chendaofei
* @Description 批量修改终端运行状态
* @Date 9:23 2020/9/2
**/
Integer updateDevFlag(@Param("list")List<String> list,@Param("devFlag")Integer devFlag);
/**
* @Author chendaofei
* @Description 删除套餐关系表
* @Date 12:26 2020/9/21
**/
Integer delDevMealAss(@Param("list")List<String> list);
/**
* @Author chendaofei
* @Description 新增设备流量套餐关系表
* @Date 12:26 2020/9/21
**/
Integer addDevMealAss(@Param("list")List<TerminalMealAssDTO> list);
/**
* @Author chendaofei
* @Description 删除套餐关系表
* @Date 12:26 2020/9/21
**/
Integer delStrategyAss(@Param("list")List<String> list);
/**
* @Author chendaofei
* @Description 新增设备流量套餐关系表
* @Date 12:26 2020/9/21
**/
Integer addStrategyAss(@Param("list")List<TerminalStrategyAssDTO> list);
/**
* @Author chendaofei
* @Description 获取阶段时间内操作的终端guid
* @Date 12:26 2020/9/21
**/
List<String> getPushInfoList();
FlowDetailRVO getTerminalFlowDetail(@Param("devIndex")String devIndex,@Param("startTime") String startTime);
/**
* @Author chendaofei
* @Description 流量统计柱状图数据获取
* @Date 20:39 2020/10/9
**/
List<FlowStatisticsRVO> getFlowStatiscsList(@Param("startTime")String startTime,@Param("list")List<String> list,@Param("mealBi")String mealBi,@Param("mealUse")String mealUse,@Param("mealAll")String mealAll);
/**
* @Author chendaofei
* @Description 统计日流量流量图表数据
* @Date 21:34 2020/10/12
**/
List<FlowStatisticsRVO> getDayFlowList(@Param("devIndex")String devIndex,@Param("startTime") String startTime);
/**
* @Author chendaofei
* @Description 通过终端获取前置ip
* @Date 9:50 2020/10/14
**/
String getIpByTerminal(@Param("devIndex")String devIndex);
}

View File

@@ -0,0 +1,35 @@
package com.pqs9900.mapper.webtool;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface CsvDataMapper {
/**
* @Author chendaofei
* @Description //TODO Administrator
* @Date 9:40 2020/4/3
*/
List<Map<String, Object>> findAll(@Param("lineid")Integer lineid, @Param("beginTime")Date beginTime, @Param("endTime")Date endTime);
/**
* @Author chendaofei
* @Description
* @Date 11:22 2020/4/21
**/
Integer checkIsExist(@Param("lineid")Integer lineid, @Param("beginTime")Date beginTime, @Param("endTime")Date endTime);
/**
* @Author chendaofei
* @Description 数据完整性手动操作
* @Date 9:21 2020/6/5
**/
List<Map<String,Object>> startHistoryTask(@Param("LineNo") Integer LineNo, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
//根据变电站id获取变电站名称
String getSubNameById(@Param("id") Long id);
}

View File

@@ -0,0 +1,237 @@
package com.pqs9900.pojo.DataInfo;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/** @Author denghuajun
* @Description //TODO 告警信息表
* @Date 2019/3/15 9:34
**/
@Table(name = "PQS_ALARMINFO")
public class AlarmInfo {
@Id
@Column(name = "ALARM_INDEX")
private String alarmIndex;// 告警信息表Guid
@Column(name = "type")
private String type;// Varchar2 (36) Not NULL 关联表pqs_dicdata告警类型Guid
@Column(name = "OCCURREDTIME")
private Date occurredTime;//OCCURREDTIME Date Not NULL 发生告警时间
@Column(name = "DESCRPIPTION")
private String descrpiption;//DESCRPIPTION Varchar2 (200) Not NULL 发生告警的详细描述
@Column(name = "STATE")
private int state;// Number(1) Not NULL 是否处理0-未处理 1-已处理
@Column(name = "PROCESSTIME")
private Date processTime;//PROCESSTIME Date NULL 处理后的时间,未处理为空
@Column(name = "USER_INDEX")
private String userIndex;// Varchar2 (36) Not NULL 关联表PQS_User处理的用户Guid,可为空
@Column(name = "TYPE_INDEX")
private String typeIndex;
@Column(name = "DEVLINE_TYPE")
private String devLineType;
@Transient
private String timeid;
@Transient
private String alarmLevel;
@Transient
private String ptime;
@Transient
private String username;
@Transient
private String typeId;
@Transient
private String subName;
@Transient
private String devName;
@Transient
private String lineName;
@Transient
private Integer dicLeave;
@Transient
private Integer counts;
@Transient
private Integer lineGrade;
public Integer getLineGrade() {
return lineGrade;
}
public void setLineGrade(Integer lineGrade) {
this.lineGrade = lineGrade;
}
public Integer getCounts() {
return counts;
}
public void setCounts(Integer counts) {
this.counts = counts;
}
public Integer getDicLeave() {
return dicLeave;
}
public void setDicLeave(Integer dicLeave) {
this.dicLeave = dicLeave;
}
public String getLineName() {
return lineName;
}
public void setLineName(String lineName) {
this.lineName = lineName;
}
public String getDevName() {
return devName;
}
public void setDevName(String devName) {
this.devName = devName;
}
public String getSubName() {
return subName;
}
public void setSubName(String subName) {
this.subName = subName;
}
public String getTypeId() {
return typeId;
}
public void setTypeId(String typeId) {
this.typeId = typeId;
}
public String getTypeIndex() {
return typeIndex;
}
public void setTypeIndex(String typeIndex) {
this.typeIndex = typeIndex;
}
public String getDevLineType() {
return devLineType;
}
public void setDevLineType(String devLineType) {
this.devLineType = devLineType;
}
public String getAlarmIndex() {
return alarmIndex;
}
public void setAlarmIndex(String alarmIndex) {
this.alarmIndex = alarmIndex;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Date getOccurredTime() {
return occurredTime;
}
public void setOccurredTime(Date occurredTime) {
this.occurredTime = occurredTime;
}
public String getDescrpiption() {
return descrpiption;
}
public void setDescrpiption(String descrpiption) {
this.descrpiption = descrpiption;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public Date getProcessTime() {
return processTime;
}
public void setProcessTime(Date processTime) {
this.processTime = processTime;
}
public String getUserIndex() {
return userIndex;
}
public void setUserIndex(String userIndex) {
this.userIndex = userIndex;
}
public String getTimeid() {
return timeid;
}
public void setTimeid(String timeid) {
this.timeid = timeid;
}
public String getAlarmLevel() {
return alarmLevel;
}
public void setAlarmLevel(String alarmLevel) {
this.alarmLevel = alarmLevel;
}
public String getPtime() {
return ptime;
}
public void setPtime(String ptime) {
this.ptime = ptime;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Override
public String toString() {
return "AlarmInfo{" +
"alarmIndex='" + alarmIndex + '\'' +
", type='" + type + '\'' +
", occurredTime=" + occurredTime +
", descrpiption='" + descrpiption + '\'' +
", state=" + state +
", processTime=" + processTime +
", userIndex='" + userIndex + '\'' +
'}';
}
}

View File

@@ -0,0 +1,76 @@
package com.pqs9900.pojo.DataInfo;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/** @Author denghuajun
* @Description //TODO 终端状态表
* @Date 2019/3/15 10:21
**/
@Table(name = "PQS_DEVSTATE")
public class DevState {
@Id
@Column(name = "DEVSTATE_INDEX")
private String devStateIndex;//终端状态Guid
@Column(name = "DEV_INDEX")
private int devIndex;//关联表pq_device装置序号
@Column(name = "TimeID")
private Date timeId;//时间id
@Column(name = "Type")
private String type;//(关联表pqs_dicdata)装置状态类型 0CPU利用率 1内存利用率 2存储卡总空间 3存储卡未使用空间
@Column(name = "Value")
private Float value;//值
public String getDevStateIndex() {
return devStateIndex;
}
public void setDevStateIndex(String devStateIndex) {
this.devStateIndex = devStateIndex;
}
public int getDevIndex() {
return devIndex;
}
public void setDevIndex(int devIndex) {
this.devIndex = devIndex;
}
public Date getTimeId() {
return timeId;
}
public void setTimeId(Date timeId) {
this.timeId = timeId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Float getValue() {
return value;
}
public void setValue(Float value) {
this.value = value;
}
@Override
public String toString() {
return "DevState{" +
"devStateIndex='" + devStateIndex + '\'' +
", devIndex=" + devIndex +
", timeId=" + timeId +
", type='" + type + '\'' +
", value=" + value +
'}';
}
}

Some files were not shown because too many files have changed in this diff Show More