初始化项目

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,24 @@
package com.pqs9200.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class PageController {
ObjectMapper mapper=new ObjectMapper();
/** 日志记录器 */
@RequestMapping(value = "{pageName}", method = RequestMethod.GET)
public String toPage(@PathVariable("pageName") String pageName)
{
return pageName;
}
}

View File

@@ -0,0 +1,67 @@
package com.pqs9200.controller;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.SimpleValue;
import com.njcn.service.system.ThemeService;
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;
/**
* @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;
/**
* 获取主题色
*/
@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;
}
}

View File

@@ -0,0 +1,130 @@
package com.pqs9200.controller.advanced;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.balance.BalanceInfo;
import com.njcn.pojo.balance.BalanceInfo.PointInfo;
import com.njcn.pojo.commons.AreaGeneralData;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.user.Depts;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.serviceimpl.commons.WaveServiceImpl;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.*;
import com.njcn.utils.GetBalance.Sarifi;
import com.pqs9200.mapper.weeklyreport.GetAreaPointInfoMapper;
import com.pqs9200.serviceimpl.weeklyreport.WeeklyReportServiceImpl;
import com.pqs9200.serviceimpl.weeklyreport.WeeklyReportServiceImpl.Info;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@RequestMapping("balance")
@RestController
public class BalanceController {
@Autowired
private GetAreaPointInfoMapper getAreaPointInfoMapper;
@Autowired
private WeeklyReportServiceImpl weeklyReportServiceImpl;
@Autowired
private GetBalance getBalance;
@Autowired
private WaveServiceImpl waveServiceImpl;
@Autowired
private UserUtil userUtil;
@Autowired
private UserLogDetailService userLog;
@Autowired
private AppConfig appConfig;
@PostMapping("getBalanceInfo")
public HttpResult getBalanceInfo(String startTime, String endTime, String area, HttpServletRequest request) {
if (area.equals("overview")) {
area = userUtil.getDeptsIndex(TokenManager.getToken().getUserIndex());
}
List<AreaGeneralData> deptdLists = userUtil.getAreaDataByInfo(area);
List<BalanceInfo> list = new ArrayList<>();
DatePojo datePojo;
datePojo = PubUtils.validateDate(startTime, endTime, "getBalanceInfo");
if (!datePojo.getValidity()) {
return PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
}
try {
for (AreaGeneralData depts : deptdLists) {
BalanceInfo balanceInfo = new BalanceInfo();
balanceInfo.setAreaName(depts.getName());
balanceInfo.setAreaIndex(depts.getDeptIndex());
List<Depts> deptsList = userUtil.getDeptsByNode(depts.getDeptIndex());
List<String> list1 = new ArrayList<>();
list1.add(depts.getDeptIndex());
for (Depts depts1 : deptsList) {
list1.add(depts1.getDeptsIndex());
}
List<Info> listLineIndex = getAreaPointInfoMapper.getLineInfo(list1, appConfig.getSysTypeZt()); // 获取监测点ID信息
List<PointInfo> list2 = new ArrayList<>();
for (Info info : listLineIndex) {
PointInfo pointInfo = balanceInfo.new PointInfo();
Float value = getBalance.getSarfiValue(datePojo.getStartTime(), datePojo.getEndTime(),
info.getId().intValue(), 0.9f); // 计算平均值
pointInfo.getQtIdx().r_esm = (value == null ? 0f : value.floatValue());
pointInfo.getQtIdx().sarfi_90 = getBalance
.getSarfiCount(datePojo.getStartTime(), datePojo.getEndTime(), info.getId(), 0.9f)
.intValue(); // 统计小于0.9的总数
pointInfo.getQtIdx().sarifi_50 = getBalance
.getSarfiCount(datePojo.getStartTime(), datePojo.getEndTime(), info.getId(), 0.5f)
.intValue(); // 统计小于0.5的总数
List<Sarifi> listSarifi = getBalance.getSarifiList(datePojo.getStartTime(), datePojo.getEndTime(),
info.getId(), 0.9f);
if (listSarifi.size() > 0) {
float floatYzd = 0f;
float floatNl = 0f;
for (Sarifi sarifi : listSarifi) {
floatYzd += Float.parseFloat(waveServiceImpl.getYzd(sarifi.getTime().floatValue(),
sarifi.getSarifiValue().floatValue()));// 调用接口计算严重程度
floatNl += BalanceUtil.calculateNl(sarifi.getTime().floatValue() / 1000,
sarifi.getSarifiValue().floatValue()); // 调用接口计算暂降能量
}
pointInfo.getQtIdx().r_assi = floatYzd / listSarifi.size();
pointInfo.getQtIdx().r_asei = floatNl / listSarifi.size();
} else {
pointInfo.getQtIdx().r_assi = 0f;
pointInfo.getQtIdx().r_asei = 0f;
}
pointInfo.setPointName(info.getName());
pointInfo.setPointId(info.getId());
list2.add(pointInfo);
}
balanceInfo.setList(list2);
list.add(balanceInfo);
}
// 打包数据传入dll计算结果
getBalance.translateData(list);
} catch (Exception e) {
userLog.getLog("区域暂降评估", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return PubUtils.assignmentResult(list, 500, "计算失败");
}
userLog.getLog("区域暂降评估", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return PubUtils.assignmentResult(list, 200, "计算成功");
}
}

View File

@@ -0,0 +1,41 @@
package com.pqs9200.controller.advanced;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.advanced.EntityResultData;
import com.njcn.pojo.advanced.EnumCode;
import com.njcn.pojo.advanced.PicDataObj;
import com.njcn.service.advanced.DrawPicService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UtilPackageData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RequestMapping("advanced")
@RestController
public class DrawPicControl {
@Autowired
private DrawPicService drawPicService;
@Autowired
private UserLogDetailService userLog;
private static final Logger logger = LoggerFactory.getLogger(DrawPicControl.class);
@PostMapping(value = "drawPicByGuid")
public EntityResultData<List<PicDataObj>> drawPicByGuid(String arrayGuid, HttpServletRequest request) {
try {
userLog.getLog("查询波形分析", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return UtilPackageData.success(drawPicService.drawPicByGuid(arrayGuid));
} catch (Exception e) {
logger.error(e.toString(), this.getClass());
userLog.getLog("查询波形分析", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return UtilPackageData.abnormal(EnumCode.ABNORMAL.getCode(), EnumCode.ABNORMAL.getDescription(), null);
}
}
}

View File

@@ -0,0 +1,56 @@
package com.pqs9200.controller.advanced;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.advanced.EntityResultData;
import com.njcn.pojo.advanced.EnumCode;
import com.njcn.pojo.advanced.EventAssObj;
import com.njcn.service.advanced.RangeService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UtilPackageData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping("advanced")
public class RangeControl {
@Autowired
private RangeService rangeService;
@Autowired
private UserLogDetailService userLog;
private static final Logger logger = LoggerFactory.getLogger(RangeControl.class);
@PostMapping(value = "queryEventsByTime")
public EntityResultData<List<EventAssObj>> queryEventsByTime(String startTime, String endTime, HttpServletRequest request) {
try {
userLog.getLog("查询影响范围分析", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return UtilPackageData.success(rangeService.queryEventsByTime(startTime, endTime));
} catch (Exception e) {
logger.error(e.toString(), this.getClass());
userLog.getLog("查询影响范围分析", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return UtilPackageData.abnormal(EnumCode.ABNORMAL.getCode(), EnumCode.ABNORMAL.getDescription(), null);
}
}
@PostMapping(value = "rangeAnalysis")
public String updatebRangeByGUID(String indexEventAss, HttpServletRequest request) {
try {
rangeService.updatebRangeByGUID(indexEventAss);
userLog.getLog("范围分析", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} catch (Exception e) {
userLog.getLog("范围分析", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
logger.error(e.toString(), this.getClass());
}
return "business/advanced/range";
}
}

View File

@@ -0,0 +1,130 @@
package com.pqs9200.controller.advanced;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.advanced.*;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.advanced.RelevanceService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UtilPackageData;
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.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.io.DataInputStream;
import java.net.URLDecoder;
import java.util.List;
@Controller
@RequestMapping(value = "advanced")
public class RelevanceControl {
@Autowired
private RelevanceService relevanceService;
@Autowired
private UserLogDetailService userLog;
private static final Logger logger = LoggerFactory.getLogger(RelevanceControl.class);
@PostMapping(value = "querySagEvents")
@ResponseBody
//归一化暂降事件展示列表
public EntityResultData<EntityRelevance> querySagEvents(String queryCondition,String startTime, String endTime,HttpServletRequest request) {
try {
userLog.getLog("查询暂降事件", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return UtilPackageData.success(relevanceService.querySagEvents(queryCondition,startTime,endTime));
} catch (Exception e) {
userLog.getLog("查询暂降事件", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
logger.error(e.toString(), RelevanceControl.class);
return UtilPackageData.abnormal(EnumCode.ABNORMAL.getCode(), EnumCode.ABNORMAL.getDescription(), null);
}
}
@PostMapping(value = "querySagEventss")
@ResponseBody
//根据监测点id获取暂降事件展示列表
public EntityResultData<EntityRelevance> querySagEventss(String queryCondition, HttpServletRequest request) {
try {
userLog.getLog("查询暂降事件", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return UtilPackageData.success(relevanceService.querySagEventss(queryCondition));
} catch (Exception e) {
userLog.getLog("查询暂降事件", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
logger.error(e.toString(), RelevanceControl.class);
return UtilPackageData.abnormal(EnumCode.ABNORMAL.getCode(), EnumCode.ABNORMAL.getDescription(), null);
}
}
@PostMapping(value = "processEvents")
@ResponseBody
public int processEvents(String arrayList, HttpServletRequest request) {
if (arrayList == null) {
try {
DataInputStream in = new DataInputStream(request.getInputStream());
int totalbytes = request.getContentLength();
byte[] dataOrigin = new byte[totalbytes];
in.readFully(dataOrigin);
in.close();
in = null;
arrayList = URLDecoder.decode(new String(dataOrigin), "UTF-8");
arrayList = arrayList.substring(10);// 截取arrayList=
dataOrigin = null;
} catch (Exception e) {
logger.error(e.toString(), EnumCode.PARAMETERABNORMAL.getDescription());
}
}
try {
relevanceService.processEvents(arrayList);
userLog.getLog("事件关联分析", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} catch (Exception e) {
userLog.getLog("事件关联分析", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
logger.error(e.toString(), EnumCode.ABNORMAL.getDescription());
return 1;
}
return 0;
}
@PostMapping(value = "queryNormalizeData")
@ResponseBody
//展示归一化结果
public EntityResultData<List<EventAssObj>> queryNormalizeData() {
try {
return UtilPackageData.success(relevanceService.queryNormalizeData());
} catch (Exception e) {
logger.error(e.toString());
return UtilPackageData.abnormal(EnumCode.ABNORMAL.getCode(), EnumCode.ABNORMAL.getDescription(), null);
}
}
@PostMapping(value = "queryEvents")
@ResponseBody
public EntityResultData<List<EntityPqsRelevance>> queryEvents() {
try {
return UtilPackageData.success(relevanceService.queryEvents());
} catch (Exception e) {
logger.error(e.toString());
return UtilPackageData.abnormal(EnumCode.ABNORMAL.getCode(), EnumCode.ABNORMAL.getDescription(), null);
}
}
//归一化算法删除
@PostMapping(value = "deleteEvent")
@ResponseBody
public HttpResult deleteEvent(String date, HttpServletRequest request) {
HttpResult httpResult = null;
try {
relevanceService.deleteEvent(date);
userLog.getLog("回退归一化操作", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
httpResult = PubUtils.assignmentResult(null,200,"删除成功");
} catch (Exception e) {
userLog.getLog("回退归一化操作", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
logger.error(e.toString());
httpResult = PubUtils.assignmentResult(null,500,"删除失败");
}
return httpResult;
}
}

View File

@@ -0,0 +1,216 @@
package com.pqs9200.controller.advanced;
import com.njcn.enums.ResultStatusEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.utils.PubUtils;
import com.njcn.utils.sagDomain.DipZoneModel;
import com.pqs9200.pojo.data.*;
import com.pqs9200.service.advanced.SvgService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author hongawen
* @version 1.0.0
* @date 2021年12月06日 13:41
*/
@RestController
@RequestMapping("/svg")
public class SvgController {
private static final Logger logger = LoggerFactory.getLogger(SvgController.class);
@Autowired
private SvgService svgService;
/**
* 保存svg信息
* @param fileName .
* @param xml .
* @param svg .
* @return .
*/
@PostMapping("/save")
public HttpResult save(String fileName, String xml, String svg) {
HttpResult result;
try {
String saveResult = svgService.saveSvg(fileName, xml, svg);
if (saveResult.equalsIgnoreCase(ResultStatusEnum.SUCCESS.getMessage())) {
result = PubUtils.assignmentResult(null,200,ResultStatusEnum.SUCCESS.getMessage());
} else {
result = PubUtils.assignmentResult(null,500,ResultStatusEnum.SUCCESS.getMessage());
}
} catch (Exception e) {
logger.error("保存svg信息失败异常为{}",e.getMessage());
result = PubUtils.assignmentResult(null,500,"失败");
}
return result;
}
/**
* 获取svg数据
* @param index 所选svg的uuid
* @param type svg后缀
*/
@PostMapping("/loadSvg")
public HttpResult loadSvg(String index,String type) {
HttpResult result;
try {
String svgXml = svgService.loadSvg(index,type);
if (svgXml.equalsIgnoreCase(ResultStatusEnum.NO_SVG_FILE.getMessage())) {
result = PubUtils.assignmentResult(null,500,ResultStatusEnum.FAIL.getMessage());
} else {
result =PubUtils.assignmentResult(svgXml,200, ResultStatusEnum.SUCCESS.getMessage());
}
} catch (Exception e) {
logger.error("获取svg信息失败异常为{}",e.getMessage());
result = PubUtils.assignmentResult(null,500,ResultStatusEnum.FAIL.getMessage());
}
return result;
}
/**
* create by: xu yang
* description: 存储图元信息
* create time: 2021/12/13 10:59
*/
@PostMapping("/saveCell")
public HttpResult saveCell(@RequestBody SvgCells svgCells) {
HttpResult result;
try {
svgService.saveCell(svgCells);
result = PubUtils.assignmentResult("成功",200,ResultStatusEnum.SUCCESS.getMessage());
} catch (Exception e) {
logger.error("保存图元信息进数据库失败,异常为:{}",e.getMessage());
result = PubUtils.assignmentResult(null,500,"失败");
}
return result;
}
/**
* create by: xu yang
* description: 查询图元信息
* create time: 2021/12/13 10:59
*/
@PostMapping("/getCell")
public HttpResult getCell(Integer cellIndex) {
HttpResult result;
SvgCells svgCells = svgService.getCell(cellIndex);
result = PubUtils.assignmentResult(svgCells,200,ResultStatusEnum.SUCCESS.getMessage());
return result;
}
/**
* create by: xu yang
* description: 存储所有图元信息
* create time: 2021/12/14 9:00
*/
@PostMapping("/saveAllCells")
public HttpResult saveAllCells(@RequestBody SvgAllCells svgAllCells) {
HttpResult result;
try {
svgService.saveAllCells(svgAllCells);
result = PubUtils.assignmentResult("成功",200,ResultStatusEnum.SUCCESS.getMessage());
} catch (Exception e) {
logger.error("存储所有图元信息失败,异常为:{}",e.getMessage());
result = PubUtils.assignmentResult(null,500,"失败");
}
return result;
}
/**
* create by: xu yang
* description: 查询所有图元信息
* create time: 2021/12/20 10:22
*/
@PostMapping("/getAllCells")
public HttpResult getAllCells() {
HttpResult result;
List<SvgCells> list = svgService.getAllCells();
result = PubUtils.assignmentResult(list,200,ResultStatusEnum.SUCCESS.getMessage());
return result;
}
/**
* create by: yexb
* description: 暂降域算法
* create time: 2021/12/20 10:22
*/
@PostMapping("/getSagDomain")
public HttpResult getSagDomain(@RequestBody SvgSagDomain svgSagDomain) {
System.out.println(svgSagDomain.getLines_substation());
HttpResult result;
DipZoneModel[] Usag_area = svgService.getSagDomain(svgSagDomain);
result = PubUtils.assignmentResult(Usag_area,200,ResultStatusEnum.SUCCESS.getMessage());
return result;
}
/**
* 功能描述: 保存暂降敏感点发生事件
* TODO
*
* @param svgSensitivePoint
* @return com.njcn.pojo.commons.HttpResult
* @author xy
* @date 2021/12/22 21:01
*/
@PostMapping("/saveSensitivePoint")
public HttpResult saveSensitivePoint(@RequestBody SvgSensitivePoint svgSensitivePoint) {
HttpResult result;
try {
svgService.saveSensitivePoint(svgSensitivePoint);
result = PubUtils.assignmentResult("成功",200,ResultStatusEnum.SUCCESS.getMessage());
} catch (Exception e) {
logger.error("保存暂降敏感点发生事件失败,异常为:{}",e.getMessage());
result = PubUtils.assignmentResult(null,500,"失败");
}
return result;
}
/**
* 功能描述:
* TODO
*
* @param
* @return com.njcn.pojo.commons.HttpResult
* @author xy
* @date 2021/12/23 14:05
*/
@PostMapping("/getAllCalucateInfo")
public HttpResult getAllCalucateInfo() {
HttpResult result;
try {
List<SvgCalucateInfo> list = svgService.getAllCalucateInfo();
result = PubUtils.assignmentResult(list,200,ResultStatusEnum.SUCCESS.getMessage());
} catch (Exception e) {
logger.error("获取所有暂降敏感点事件失败,异常为:{}",e.getMessage());
result = PubUtils.assignmentResult(null,500,"失败");
}
return result;
}
@PostMapping("/deleteCalucateInfo")
public HttpResult deleteCalucateInfo(String index) {
HttpResult result;
try {
svgService.deleteCalucateInfo(index);
result = PubUtils.assignmentResult("成功",200,ResultStatusEnum.SUCCESS.getMessage());
} catch (Exception e) {
logger.error("删除暂降敏感点事件失败,异常为:{}",e.getMessage());
result = PubUtils.assignmentResult(null,500,"失败");
}
return result;
}
}

View File

@@ -0,0 +1,66 @@
package com.pqs9200.controller.advanced;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.advanced.EntityResultData;
import com.njcn.pojo.advanced.EnumCode;
import com.njcn.pojo.advanced.SagEvent;
import com.njcn.service.advanced.WaveformService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.serviceimpl.log.UserLogDetailServiceImpl;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UtilPackageData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping(value = "advanced")
public class WaveformControl {
@Autowired
private WaveformService waveformService;
@Autowired
private UserLogDetailService userLog;
private static final Logger logger = LoggerFactory.getLogger(WaveformControl.class);
@PostMapping(value = "queryEventsByGUID")
public EntityResultData<List<SagEvent>> queryEventsByGUID(String queryCondition) {
try {
return UtilPackageData.success(waveformService.queryEventsByGUID(queryCondition));
} catch (Exception e) {
logger.error(e.toString());
return UtilPackageData.abnormal(EnumCode.ABNORMAL.getCode(), EnumCode.ABNORMAL.getDescription(), null);
}
}
@PostMapping(value = "addNormalization")
public String addNormalization(String condition, HttpServletRequest request) {
try {
waveformService.addNormalization(condition);
userLog.getLog("新增归一化事件", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} catch (Exception e) {
userLog.getLog("新增归一化事件", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
logger.error(e.toString(), EnumCode.ABNORMAL.getDescription());
}
return "business/advanced/addwavecompare";
}
@PostMapping(value = "deleteWaveform")
public String deleteWaveform(String condition, HttpServletRequest request) {
try {
waveformService.deleteWaveform(condition);
userLog.getLog("删除归一化事件", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} catch (Exception e) {
userLog.getLog("删除归一化事件", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
logger.error(e.toString(), EnumCode.ABNORMAL.getDescription());
}
return "business/advanced/deletewaveform";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,688 @@
package com.pqs9200.controller.business;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.njcn.enums.ProjectEnum;
import com.njcn.pojo.commons.WebItem;
import com.njcn.pojo.system.SubSystem;
import com.njcn.service.system.SystemService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.AppConfig;
import com.njcn.utils.XssFilterUtil;
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 org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Controller
@RequestMapping(value = "business")
public class BusinessController {
ObjectMapper objectMapper = new ObjectMapper();
@Resource
private SystemService systemService;
@Autowired
private AppConfig appConfig;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(BusinessController.class);
/**
* 高级分析中,省级专员页面跳转
*
* @param request
* @return
*/
// 跳转高级分析事件关联分析处理页面
@RequestMapping(value = "relevance")
public String relevance(HttpServletRequest request, HttpSession session) {
session.setAttribute("line_index", null);
return "business/advanced/relevance";
}
//获取未处理暂降事件
@RequestMapping(value = "relevances")
public String relevances(HttpServletRequest request, HttpSession session,String line_index) {
line_index = XssFilterUtil.dealString(line_index);
if (line_index != null) {
session.setAttribute("line_index", line_index);
}
return "business/advanced/relevance";
}
// 跳转高级分析影响范围页面
@RequestMapping(value = "range")
public String range(HttpServletRequest request) {
return "business/advanced/range";
}
// 跳转高级分析多事件波形比较页面
@RequestMapping(value = "eventscompare")
public String events(HttpServletRequest request) {
return "business/advanced/eventsCompare";
}
//跳转归一化结果策略展示
@RequestMapping(value = "processEvent")
public String processEvent() {
return "business/advanced/processEvent";
}
// 跳转事件关联分析归一化界面
@RequestMapping(value = "eventAnalysis")
public String eventAnalysis(HttpServletRequest request) {
return "business/advanced/eventAnalysis";
}
@RequestMapping(value = "relevanceresult")
public String relevanceresult(HttpServletRequest request) {
return "business/advanced/relevanceresult";
}
@RequestMapping(value = "relevancewaveform")
public String relevancewaveform(HttpServletRequest request) {
return "business/advanced/relevancewaveform";
}
@RequestMapping(value = "rangewaveform")
public String rangewaveform(HttpServletRequest request) {
return "business/advanced/rangewaveform";
}
// 跳转到范围分析界面
@RequestMapping(value = "fwfx")
public String fwfx(HttpServletRequest request, HttpSession session,String eventass_index) {
eventass_index = XssFilterUtil.dealString(eventass_index);
session.setAttribute("eventass_index", eventass_index);
return "business/overview/fwfx";
}
// 跳转高级分析波形页面
@RequestMapping(value = "waveform")
public String waveform(HttpServletRequest request, HttpSession session) {
return "business/advanced/waveform";
}
// 波形对比
@RequestMapping(value = "wavecompare")
public String wavecompare(HttpServletRequest request) {
return "business/advanced/wavecompare";
}
// 新增波形对比文件
@RequestMapping(value = "addwave")
public String addwave(HttpServletRequest request) {
return "business/advanced/addwave";
}
// 新增波形对比
@RequestMapping(value = "addwavecompare")
public String addwavecompare(HttpServletRequest request) {
return "business/advanced/addwavecompare";
}
// 删除波形对比
@RequestMapping(value = "deletewave")
public String deletewave(HttpServletRequest request) {
return "business/advanced/deletewaveform";
}
//高级分析数据界面图形展示
@RequestMapping(value = "analysis")
public String analysis(HttpServletRequest request, HttpSession session,String maxy,String miny,String time,String pt) {
maxy = XssFilterUtil.dealString(maxy);
miny = XssFilterUtil.dealString(miny);
time = XssFilterUtil.dealString(time);
pt = XssFilterUtil.dealString(pt);
session.setAttribute("maxy", maxy);
session.setAttribute("miny", miny);
session.setAttribute("time", time);
session.setAttribute("pt", pt);
return "business/area/analysis";
}
//跳转报表
@GetMapping("weeklyreport")
public String weeklyReport() {
return "business/report/weeklyreport";
}
/**
* 普通用户就可以访问
*
* @param request
* @param session
* @return
*/
// 跳转暂降列表波形分析页面
@RequestMapping(value = "vdwaveform")
public String vdWaveform(HttpServletRequest request, HttpSession session,String eventIndex) {
eventIndex = XssFilterUtil.dealString(eventIndex);
session.setAttribute("eventIndex", eventIndex);
return "business/area/waveform";
}
// 跳转暂降列表波形对比页面
@RequestMapping(value = "waveCompare")
public ModelAndView waveCompare(String eventIndex) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("business/area/waveCompare");
modelAndView.addObject("eventIndex",eventIndex);
return modelAndView;
}
// 跳转监测点页面
@RequestMapping(value = "monitor")
public String monitor(HttpServletRequest request, HttpSession session,String line_index) {
line_index = XssFilterUtil.dealString(line_index);
if (line_index != null) {
session.setAttribute("line_index", line_index);
}
return "business/monitor/monitor";
}
// 跳转showeventdatalist页面
@RequestMapping(value = "showeventdatalist")
public String showeventdatalist(HttpServletRequest request, HttpSession session,String lineIndex) {
lineIndex = XssFilterUtil.dealString(lineIndex);
session.setAttribute("lineIndex", lineIndex);
return "business/monitor/showeventdatalist";
}
// 跳转showeventtime页面
@RequestMapping(value = "showeventtime")
public String showeventtime(HttpServletRequest request, HttpSession session,String lineIndex) {
lineIndex = XssFilterUtil.dealString(lineIndex);
session.setAttribute("lineIndex", lineIndex);
return "business/monitor/showeventtime";
}
// 跳转showeventchance页面
@RequestMapping(value = "showeventchance")
public String showeventchance(HttpServletRequest request, HttpSession session,String lineIndex) {
lineIndex = XssFilterUtil.dealString(lineIndex);
session.setAttribute("lineIndex", lineIndex);
return "business/monitor/showeventchance";
}
// 跳转showdevicedetail页面
@RequestMapping(value = "showdevicedetail")
public String showdevicedetail(HttpServletRequest request, HttpSession session,String lineIndex, String longitude,String latitude,String image) {
lineIndex = XssFilterUtil.dealString(lineIndex);
longitude = XssFilterUtil.dealString(longitude);
latitude = XssFilterUtil.dealString(latitude);
image = XssFilterUtil.dealString(image);
session.setAttribute("lineIndex", lineIndex);
session.setAttribute("longitude", longitude);
session.setAttribute("latitude", latitude);
session.setAttribute("image", image);
return "business/monitor/showdevicedetail";
}
// 跳转showeventdensity页面
@RequestMapping(value = "showeventdensity")
public String showeventdensity(HttpServletRequest request, HttpSession session,String lineIndex) {
lineIndex = XssFilterUtil.dealString(lineIndex);
session.setAttribute("lineIndex", lineIndex);
return "business/monitor/showeventdensity";
}
// 跳转densityDetail页面
@RequestMapping(value = "densityDetail")
public String densityDetail(HttpServletRequest request, HttpSession session,String lineIndex,String startTime,String endTime) {
lineIndex = XssFilterUtil.dealString(lineIndex);
startTime = XssFilterUtil.dealString(startTime);
endTime = XssFilterUtil.dealString(endTime);
session.setAttribute("lineIndex", lineIndex);
session.setAttribute("startTime", startTime);
session.setAttribute("endTime", endTime);
return "business/monitor/densityDetail";
}
// 跳转事件统计
@RequestMapping(value = "tongji")
public String tongji(HttpServletRequest request) {
return "business/monitor/tongji";
}
// 跳转事件分析
@RequestMapping(value = "analyze")
public String analyze(HttpServletRequest request) {
return "business/monitor/analyze";
}
// 跳转运行管理
@RequestMapping(value = "manage")
public String manage(HttpServletRequest request) {
return "business/monitor/manage";
}
// 跳转运行管理台账页面
@RequestMapping(value = "machine")
public String machine(HttpServletRequest request) {
return "business/manage/machineAccount";
}
// 跳转终端新增界面
@RequestMapping(value = "addDev")
public String addDev(HttpServletRequest request) {
return "business/manage/addDev";
}
// 跳转终端运行管理页面
@RequestMapping(value = "runtime")
public String runtime(HttpServletRequest request, HttpSession session,String line_index) {
return "business/manage/runtime";
}
// // 跳转到终端状态更新列表
// @GetMapping(value = "terminallog")
// public String terminallog() {
// return "business/manage/terminalLogManage";
// }
// 跳转终端运行状态页面
@RequestMapping(value = "runtimestatus")
public String runtimestatus(HttpServletRequest request) {
return "business/manage/runtimeStatus";
}
// 跳转终端运行状态页面
@RequestMapping(value = "onlinerate")
public String onlinerate(HttpServletRequest request) {
return "business/manage/onlineRate";
}
// 跳转概览首页
@RequestMapping(value = "glindex")
public String dlxxt(HttpServletRequest request) {
return "business/overview/glindex";
}
// 跳转到地图界面
@RequestMapping(value = "dlxxt")
public String indexmap(HttpServletRequest request) {
return "business/overview/dlxxt";
}
@RequestMapping(value = "balance")
public String indexbalance(HttpServletRequest request) {
return "business/overview/balance";
}
// 跳转showbximg页面
@RequestMapping(value = "showbximg")
public String showbximg(HttpServletRequest request, HttpSession session,String eventIndex) {
eventIndex = XssFilterUtil.dealString(eventIndex);
session.setAttribute("eventIndex", eventIndex);
return "business/monitor/showbximg";
}
// 跳转到终端运行信息界面
@RequestMapping(value = "sbyxzt")
public String sbyxzt(HttpServletRequest request) {
return "business/overview/sbyxzt";
}
// 跳转到区域电网信息界面
@RequestMapping(value = "qygk")
public String qygk(HttpServletRequest request) {
return "business/overview/qygk";
}
// 跳转终端统计页面
@RequestMapping(value = "statistics")
public String statistics(HttpServletRequest request) {
return "business/manage/machineStatistics";
}
// 跳转通讯测试页面
@RequestMapping(value = "communicate")
public String communicate(HttpServletRequest request) {
return "business/manage/communicate";
}
// 跳转定值管理页面
@RequestMapping(value = "valuemanage")
public String valuemanage(HttpServletRequest request) {
return "business/manage/manage";
}
// 跳转区域概览页面
@RequestMapping(value = "general")
public String general(HttpServletRequest request) {
return "business/area/general";
}
@RequestMapping(value = "balancearea")
public String balance(HttpServletRequest request) {
return "business/area/balance";
}
@RequestMapping(value = "mapmonitor")
public String mapmonitor(HttpServletRequest request) {
return "business/overview/mapMonitor";
}
@RequestMapping(value = "mapevent")
public String mapevent(HttpServletRequest request) {
return "business/overview/mapEvent";
}
@RequestMapping(value = "devmap")
public String devmap(HttpServletRequest request) {
return "business/overview/devmap";
}
@RequestMapping(value = "qypg")
public String qypg(HttpServletRequest request) {
return "business/overview/qypg";
}
@RequestMapping(value = "eventmap")
public String eventmap(HttpServletRequest request) {
return "business/overview/eventmap";
}
// 跳转区域分析页面
@RequestMapping(value = "areastatistics")
public String areaStatistics(HttpServletRequest request) {
return "business/area/areaStatistics";
}
// 跳转暂降程度页面
@RequestMapping(value = "level")
public String level(HttpServletRequest request) {
return "business/area/level";
}
// 跳转暂降列表页面
@RequestMapping(value = "vdlist")
public String vdList(HttpServletRequest request) {
return "business/area/vdList";
}
// 跳转暂降事件列表范围查看
@RequestMapping(value = "viewScope")
public String viewScope(HttpServletRequest request) {
return "business/area/viewScope";
}
@RequestMapping(value = "userhelp")
public String userHelp(HttpServletRequest request, HttpSession session,String parameter) {
parameter = XssFilterUtil.dealString(parameter);
session.setAttribute("parameter", parameter);
return "business/manage/userHelp";
}
@RequestMapping(value = "sourcemanage")
public String sourceManage(HttpServletRequest request) {
return "business/manage/sourceManage";
}
/******/
@GetMapping("/doBusiness")
public ModelAndView doBusiness() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("business/main");
//判断是否需要显示切换系统以及待切换的系统信息
List<SubSystem> subSystems = systemService.getActiveSystem();
List<WebItem> webItems=new ArrayList<>();
boolean displayFlag = false;
for (SubSystem subSystem : subSystems) {
if (!subSystem.getSystemEName().equalsIgnoreCase(ProjectEnum.PQS9200.getItem())) {
displayFlag = true;
WebItem webItem=new WebItem();
webItem.setItem(subSystem.getSystemEName());
webItem.setName(subSystem.getSystemEName().toUpperCase() + subSystem.getSystemName());
webItems.add(webItem);
}
}
// WebItem webItem=new WebItem();
// webItem.setItem("pqs9300");
// webItem.setName("PQS9800大屏展示系统");
// webItems.add(webItem);
if (Objects.equals(TokenManager.getNickname(), appConfig.getThirdName())){
displayFlag = false;
}
modelAndView.addObject("webItems",webItems);
modelAndView.addObject("displayFlag", displayFlag);
return modelAndView;
}
/**
* 跳转到终端异常
*/
@RequestMapping("sbyc")
public String sbyc(HttpServletRequest request) {
return "business/overview/sbyc";
}
/**
* 跳转到终端异常
*/
@RequestMapping("zjsj")
public String zjsj(HttpServletRequest request) {
return "business/overview/zjsj";
}
@RequestMapping(value = "chart")
public String chart(HttpServletRequest request) {
return "business/settings/userLogChart";
}
@RequestMapping(value = "loginmanage")
public String loginmanage(HttpServletRequest request) {
return "business/settings/userLoginManage";
}
//读取配置文件
@PostMapping("getWebsocketURL")
@ResponseBody
public String getWebSocketURL() {
return appConfig.getWebsocket();
}
//跳转报告界面
@RequestMapping(value = "report")
public String report(HttpServletRequest request) {
return "business/report/report";
}
//跳转报告界面
@RequestMapping(value = "areareport")
public String areareport(HttpServletRequest request) {
return "business/report/areareport";
}
//跳转报告界面
@RequestMapping(value = "eventreport")
public String eventreport(HttpServletRequest request) {
return "business/report/eventreport";
}
//跳转报告界面
@RequestMapping(value = "addrpdata")
public String addRPData(HttpServletRequest request) {
return "business/settings/addRPData";
}
//跳转报告界面
@RequestMapping(value = "modrpdata")
public String modRpData(HttpServletRequest request, HttpSession session,String rdIndex) {
rdIndex = XssFilterUtil.dealString(rdIndex);
session.setAttribute("rdIndex", rdIndex);
return "business/settings/modRPDate";
}
//跳转报告界面
@RequestMapping(value = "addrpploy")
public String addRPPloy(HttpServletRequest request) {
return "business/settings/addRPPloy";
}
//跳转报告界面
@RequestMapping(value = "modrpploy")
public String modRpPloy(HttpServletRequest request, HttpSession session,String rpIndex) {
rpIndex = XssFilterUtil.dealString(rpIndex);
session.setAttribute("rpIndex", rpIndex);
return "business/settings/modRpPloy";
}
//跳转报告界面
@RequestMapping(value = "addnode")
public String addNode(HttpServletRequest request) {
return "business/settings/addNode";
}
//跳转报告界面
@RequestMapping(value = "addploy")
public String addPloy(HttpServletRequest request) {
return "business/settings/addPloy";
}
/**
* 跳转新增前置机
*/
@RequestMapping(value = "addnodeinfo")
public String addnodeinfo(HttpServletRequest request) {
return "business/manage/addNodeInfo";
}
/**
* 跳转前置机信息
*/
@RequestMapping(value = "nodeinfo")
public String nodeinfo(HttpServletRequest request) {
return "business/manage/nodeInfo";
}
/**
* 修改前置机信息
*/
@RequestMapping(value = "modnode")
public String modnode(HttpServletRequest request, HttpSession session,String nodeIndex) {
nodeIndex = XssFilterUtil.dealString(nodeIndex);
session.setAttribute("nodeIndex", nodeIndex);
return "business/manage/modNode";
}
/**
* 导入终端
*/
@RequestMapping(value = "importdev")
public String importdev(HttpServletRequest request) {
return "business/manage/importdev";
}
/**
* 跳转404页面
*/
@RequestMapping(value = "404")
public String notFound(HttpServletRequest request) {
return "business/error/404";
}
@RequestMapping("/userDetail")
public String userDetail(HttpServletRequest request, HttpSession session,String userIndex) {
userIndex = XssFilterUtil.dealString(userIndex);
session.setAttribute("userIndex", userIndex);
return "business/userDetail";
}
/**
* 跳转到修改密码
*/
@RequestMapping("updatePassWord")
public String updatePassWord(HttpServletRequest request, HttpSession session,String userIndex) {
userIndex = XssFilterUtil.dealString(userIndex);
session.setAttribute("userIndex", userIndex);
return "business/updatePassWord";
}
/**
* 跳转到事件提示
*/
@RequestMapping("tipwindow")
public String tipwindow(HttpServletRequest request) {
return "business/overview/tipwindow";
}
/**
* 暂降列表页面多条件筛选按钮弹出页面
* @author cdf
* @date 2021/1/20
*/
@RequestMapping("vdlistquery")
public String vdlistquery(){
return "business/area/vdListQuery";
}
/**
* 跳转网络拓扑图界面
* xuyang
*/
@RequestMapping(value = "ycjxt")
public String ycjxt(HttpServletRequest request) {
return "business/line/ycjxt";
}
@GetMapping(value = "bfour")
public String bfour(HttpServletRequest request) {
return "business/svg/b4";
}
@GetMapping(value = "waterstation")
public String waterstation(HttpServletRequest request) {
return "business/svg/waterStation";
}
@GetMapping(value = "bfive")
public String bfive(HttpServletRequest request) {
return "business/svg/b5";
}
/**
* 跳转到监测点台账信息
*/
@RequestMapping("lineledger")
public String lineLedger() {
return "business/manage/lineLedger";
}
@GetMapping("sagdomainshow")
public String sagDomainShow(){
return "business/advanced/sagDomainShow";
}
@GetMapping("sagdomainedit")
public String sagDomainEdit(HttpServletRequest request, HttpSession session, String svgIndex){
svgIndex = XssFilterUtil.dealString(svgIndex);
session.setAttribute("svgIndex", svgIndex);
return "business/advanced/sagDomainEdit";
}
@GetMapping("sagDomainDiagram")
public String sagDomainDiagram(HttpServletRequest request, HttpSession session, String svgName){
svgName = XssFilterUtil.dealString(svgName);
session.setAttribute("svgName", svgName);
return "business/advanced/sagDomainDiagram";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,96 @@
package com.pqs9200.controller.business;
import cn.hutool.json.JSONArray;
import com.njcn.pojo.advanced.MessageObj;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.utils.PubUtils;
import com.njcn.utils.WebSocketUtil;
import com.pqs9200.service.data.IEventPzService;
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.*;
import javax.servlet.http.HttpServletRequest;
import javax.websocket.EncodeException;
import java.io.IOException;
import java.util.Date;
import java.util.List;
/**
* @author hongawen
* @version 1.0.0
* @date 2022年02月17日 15:06
*/
@Controller
@RequestMapping(value = "event")
public class EventController {
/*** 日志记录 */
private static final Logger logger = LoggerFactory.getLogger(EventController.class);
// 建立socket对象推送数据
private WebSocketUtil webSocketUtil = new WebSocketUtil();
@Autowired
private IEventPzService iEventPzService;
/**
* 需要展示的新事件列表
*
* @param eventInfo 暂降事件数据
*/
@GetMapping("/tips")
public void showEvents(String eventInfo) {
//System.out.println(eventInfo);
JSONObject jsonObject = JSONObject.fromObject(eventInfo);
//语言测试代码
/* JSONObject jsonObject = JSONObject.fromObject("{\"eventdetail_index\":\"d4963f8f-201f-443f-b293-dda8ef870ee6\",\"lineid\":\"71\",\"timeid\":\"2022-07-15 15:00:14\",\"ms\":\"509\",\"describe\":\"\",\"wavetype\":\"1\",\"persisttime\":\"23.000\",\"eventvalue\":\"0.35\",\"eventreason\":\"未明\",\"eventtype\":\"其他\",\"gdname\":\"上海集成电路\",\"bdname\":\"220kV总降变\",\"pointname\":\"测试监测点\"}");
if(eventInfo.equals("1")){
jsonObject = JSONObject.fromObject("{\"eventdetail_index\":\"d4963f8f-201f-443f-b293-dda8ef870ee6\",\"lineid\":\"71\",\"timeid\":\"2022-07-15 15:00:14\",\"ms\":\"509\",\"describe\":\"\",\"wavetype\":\"1\",\"persisttime\":\"23.000\",\"eventvalue\":\"0.35\",\"eventreason\":\"未明\",\"eventtype\":\"其他\",\"gdname\":\"上海集成电路\",\"bdname\":\"220kV总降变\",\"pointname\":\"测试监测点\"}");
}else if(eventInfo.equals("2")){
jsonObject = JSONObject.fromObject("{\"eventdetail_index\":\"d4963f8f-201f-443f-b293-dda8ef870ee6\",\"lineid\":\"71\",\"timeid\":\"2022-07-15 15:00:14\",\"ms\":\"509\",\"describe\":\"\",\"wavetype\":\"1\",\"persisttime\":\"23.000\",\"eventvalue\":\"0.35\",\"eventreason\":\"未明\",\"eventtype\":\"其他\",\"gdname\":\"上海集成电路\",\"bdname\":\"南京总降变\",\"pointname\":\"南京监测点\"}");
}else{
jsonObject = JSONObject.fromObject("{\"eventdetail_index\":\"d4963f8f-201f-443f-b293-dda8ef870ee6\",\"lineid\":\"71\",\"timeid\":\"2022-07-15 15:00:14\",\"ms\":\"509\",\"describe\":\"\",\"wavetype\":\"1\",\"persisttime\":\"23.000\",\"eventvalue\":\"0.35\",\"eventreason\":\"未明\",\"eventtype\":\"其他\",\"gdname\":\"上海集成电路\",\"bdname\":\"江苏总降变\",\"pointname\":\"江苏监测点\"}");
}*/
jsonObject.replace("eventvalue", PubUtils.doubleRound(2,jsonObject.getDouble("eventvalue") * 100));
JSONArray jsonArray = new JSONArray();
jsonArray.add(jsonObject);
MessageObj messageObj = new MessageObj();
messageObj.setMsgId(messageObj.getRelevance() + 1);
messageObj.setMsgBody("insert");
messageObj.setMsgbody(jsonArray);
try {
webSocketUtil.sendAll(messageObj);
} catch (IOException | EncodeException e1) {
logger.error(e1.getMessage());
}
}
/**
* 暂降消息处理
* @author cdf
* @date 2022/7/15
*/
@PostMapping("dealEventWarn")
@ResponseBody
public HttpResult dealEventWarn(@RequestBody List<String> eventIds){
boolean res = iEventPzService.dealEventWarn(eventIds);
if(res){
return PubUtils.assignmentResult(null,200,"成功");
}
return PubUtils.assignmentResult(null,500,"失败");
}
}

View File

@@ -0,0 +1,339 @@
package com.pqs9200.controller.business;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.metadata.Sheet;
import com.alibaba.excel.support.ExcelTypeEnum;
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.pojo.commons.device.DeviceValue;
import com.njcn.pojo.data.GridTop;
import com.njcn.pojo.data.LineMaps;
import com.njcn.pojo.excel.AreaRuntimeExcelBody;
import com.njcn.pojo.excel.CommonParamter;
import com.njcn.pojo.excel.CompanyRuntimeExcelBody;
import com.njcn.pojo.excel.ReasonExcelBody;
import com.njcn.service.configuration.DeviceService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.pqs9200.service.data.IOverviewServer;
import org.apache.commons.collections.CollectionUtils;
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 scala.Int;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* 概览业务的controller
* */
@Controller
@RequestMapping("/overview")
public class OverviewController {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(AreaController.class);
@Autowired
private IOverviewServer iOverviewServer;
@Autowired
UserLogDetailService userLogservice;
@Autowired
private DeviceService deviceService;
@Resource
UserLogDetailService userLog;
//操作类型
private String strMessage ="";
/********************************
* 查询监测点的经纬度及相应的信息
*******************************/
@RequestMapping(value="getLineMaps",method=RequestMethod.POST)
@ResponseBody
public HttpResult getLineMaps(HttpServletRequest request){
HttpResult result=new HttpResult();
strMessage="查询监测点的经纬度及相应的信息";
try{
List<LineMaps> levelList=iOverviewServer.getLineMaps();
if(levelList.isEmpty()){
result.setCode(500);
result.setBody(null);
result.setMessage("没有数据");
}else{
result.setCode(200);
result.setBody(levelList);
result.setMessage("获取数据成功");
}
// userLogservice.getLog("业务查询",strMessage + "成功");
userLog.getLog("查询地理信息", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
}catch(Exception e){
// userLogservice.getLog("业务查询", strMessage + "失败");
userLog.getLog("查询地理信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
logger.error(strMessage + "失败,失败原因:" + e.getMessage());
}
return result;
}
/*******************************
* 查询电网拓扑图信息
* *****************************/
@RequestMapping(value="getGridTop",method=RequestMethod.POST)
@ResponseBody
public HttpResult getGridTop(HttpServletRequest request){
HttpResult result=new HttpResult();
strMessage="查询电网拓扑图信息";
try{
List<GridTop> levelList=iOverviewServer.getGridTop();
if(levelList.isEmpty()){
result.setCode(500);
result.setBody(null);
result.setMessage("没有数据");
}else{
result.setCode(200);
result.setBody(levelList);
result.setMessage("获取数据成功");
}
// userLogservice.getLog("业务查询",strMessage + "成功");
}catch(Exception e){
// userLogservice.getLog("业务查询", strMessage + "失败");
logger.error(strMessage + "失败,失败原因:" + e.getMessage());
}
return result;
}
/*******************************
* 根据监测点ID查询对应的未处理暂降事件信息
* *****************************/
@RequestMapping(value="queryLineMapByAssID",method=RequestMethod.POST)
@ResponseBody
public HttpResult queryLineMapByAssID(HttpServletRequest request,String eventass_index){
HttpResult result=new HttpResult();
strMessage="根据监测点ID查询对应的未处理暂降事件信息";
try{
//获取区域对应的暂降次数
List<LineMaps> levelList = iOverviewServer.queryLineMapByAssID(eventass_index);
if(levelList.isEmpty()){
result.setCode(500);
result.setBody(null);
result.setMessage("没有数据");
}else{
result.setCode(200);
result.setBody(levelList);
result.setMessage("获取数据成功");
}
userLog.getLog("查询未处理暂降事件", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
}catch(Exception e){
userLog.getLog("查询未处理暂降事件", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
logger.error(strMessage + "失败,失败原因:" + e.getMessage());
}
return result;
}
/**
*概览--》终端状态
*/
@PostMapping("deviceStatus")
@ResponseBody
public HttpResult getDeviceStatus(String overview,HttpServletRequest request,String startTime,String endTime) {
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=deviceService.getDeviceData(overview,datePojo.getStartTime(),datePojo.getEndTime());
result = PubUtils.assignmentResultLog(data, 200, "获取终端运行数据成功","查询暂降概览终端状态", "成功",result);
} catch (Exception e) {
logger.error("获取终端运行数据异常,异常为:"+e.toString());
result = PubUtils.assignmentResultLog(null, 500, "获取终端运行数据异常","查询暂降概览终端状态", "失败",result);
}
return result;
}
/**
* 下载区域统计表格数据
*/
@RequestMapping(value = "downloadRuntimeStatusData", method = RequestMethod.POST)
public void downloadRuntimeStatusData(@RequestBody CommonParamter commonParamter, HttpServletResponse response,String startTime,String endTime) {
DeviceGeneral data;
BufferedOutputStream out=null;
DatePojo datePojo;
datePojo = PubUtils.validateDate(commonParamter.getStartTime(), commonParamter.getEndTime(), "deviceStatus");
if (!datePojo.getValidity()) {
return;
}
try {
out = new BufferedOutputStream(response.getOutputStream());
ExcelWriter writer = new ExcelWriter(out, ExcelTypeEnum.XLSX);
data = deviceService.getDeviceData("", commonParamter.getArea(),datePojo.getStartTime(),datePojo.getEndTime());
Sheet sheet1 = new Sheet(1, 0, AreaRuntimeExcelBody.class);
sheet1.setSheetName("区域");
writer.write(getAreaRuntimeExcel(data), sheet1);
Sheet sheet2 = new Sheet(2, 0, CompanyRuntimeExcelBody.class);
sheet2.setSheetName("厂家");
writer.write(getCompanyRuntimeExcel(data), sheet2);
writer .finish();
} catch (Exception e) {
logger.error(e.getMessage());
} finally {
try {
if(null!=out){
out.close();
}
} catch (IOException e) {
logger.error(e.getMessage());
}
}
}
private List<AreaRuntimeExcelBody> getAreaRuntimeExcel(DeviceGeneral deviceGeneral) {
List<AreaRuntimeExcelBody> areaRuntimeExcelBodies=new ArrayList<>();
if(null!=deviceGeneral){
List<DeviceValue> deviceValues = deviceGeneral.getArea();
if(!CollectionUtils.isEmpty(deviceValues)){
int totalTimes=0;
int normal=0;
int breaks=0;
int shutdown=0;
float totalOnline=-1f;
boolean onlineFlag=false;
for (DeviceValue deviceValue:deviceValues) {
AreaRuntimeExcelBody areaRuntimeExcelBody=new AreaRuntimeExcelBody();
areaRuntimeExcelBody.setName(deviceValue.getName());
areaRuntimeExcelBody.setAmounts(deviceValue.getAmounts());
areaRuntimeExcelBody.setNormal(deviceValue.getStatus().getNormalData()+"");
areaRuntimeExcelBody.setBreaks(deviceValue.getStatus().getBreaksData()+"");
areaRuntimeExcelBody.setShutdown(deviceValue.getStatus().getShutdownData()+"");
areaRuntimeExcelBody.setOnline(getOnlie(deviceValue.getOnline()));
totalTimes= Integer.parseInt(deviceValue.getAmounts())+totalTimes;
normal= deviceValue.getStatus().getNormalData()+normal;
breaks= deviceValue.getStatus().getBreaksData()+breaks;
shutdown= deviceValue.getStatus().getShutdownData()+shutdown;
areaRuntimeExcelBodies.add(areaRuntimeExcelBody);
if(!getOnlie(deviceValue.getOnline()).equalsIgnoreCase("/")&&!getOnlie(deviceValue.getOnline()).equalsIgnoreCase("暂无数据")){
onlineFlag=true;
totalOnline=totalOnline+Float.valueOf(getOnlie(deviceValue.getOnline()))*deviceValue.getStatus().getNormalData();
}
}
AreaRuntimeExcelBody areaRuntimeExcelBody=new AreaRuntimeExcelBody();
areaRuntimeExcelBody.setName("总计");
areaRuntimeExcelBody.setAmounts(totalTimes+"");
areaRuntimeExcelBody.setNormal(normal+"");
areaRuntimeExcelBody.setBreaks(breaks+"");
areaRuntimeExcelBody.setShutdown(shutdown+"");
if(onlineFlag){
totalOnline=totalOnline+1;
}
if(totalOnline==-1){
areaRuntimeExcelBody.setOnline("暂无数据");
}else{
if(normal==0){
totalOnline=0f;
}else{
totalOnline=PubUtils.floatRound(2,(totalOnline/normal));
}
}
areaRuntimeExcelBody.setOnline(totalOnline+"");
areaRuntimeExcelBodies.add(areaRuntimeExcelBody);
}
}
return areaRuntimeExcelBodies;
}
private String getOnlie(String online){
switch (online){
case "3.1415":
return "/";
case "3.14159":
return "暂无数据";
default:
return online;
}
}
private List<CompanyRuntimeExcelBody> getCompanyRuntimeExcel(DeviceGeneral deviceGeneral) {
List<CompanyRuntimeExcelBody> companyRuntimeExcelBodies=new ArrayList<>();
if(null!=deviceGeneral){
List<DeviceValue> deviceValues = deviceGeneral.getInterval();
if(!CollectionUtils.isEmpty(deviceValues)){
int totalTimes=0;
int normal=0;
int breaks=0;
int shutdown=0;
float totalOnline=-1f;
boolean onlineFlag=false;
for (DeviceValue deviceValue:deviceValues) {
CompanyRuntimeExcelBody companyRuntimeExcelBody=new CompanyRuntimeExcelBody();
companyRuntimeExcelBody.setName(deviceValue.getName());
companyRuntimeExcelBody.setAmounts(deviceValue.getAmounts());
companyRuntimeExcelBody.setNormal(deviceValue.getStatus().getNormalData()+"");
companyRuntimeExcelBody.setBreaks(deviceValue.getStatus().getBreaksData()+"");
companyRuntimeExcelBody.setShutdown(deviceValue.getStatus().getShutdownData()+"");
companyRuntimeExcelBody.setOnline(getOnlie(deviceValue.getOnline()));
totalTimes= Integer.parseInt(deviceValue.getAmounts())+totalTimes;
normal= deviceValue.getStatus().getNormalData()+normal;
breaks= deviceValue.getStatus().getBreaksData()+breaks;
shutdown= deviceValue.getStatus().getShutdownData()+shutdown;
companyRuntimeExcelBodies.add(companyRuntimeExcelBody);
if(!getOnlie(deviceValue.getOnline()).equalsIgnoreCase("/")&&!getOnlie(deviceValue.getOnline()).equalsIgnoreCase("暂无数据")){
onlineFlag=true;
totalOnline=totalOnline+Float.valueOf(getOnlie(deviceValue.getOnline()))*deviceValue.getStatus().getNormalData();
}
}
CompanyRuntimeExcelBody companyRuntimeExcelBody=new CompanyRuntimeExcelBody();
companyRuntimeExcelBody.setName("总计");
companyRuntimeExcelBody.setAmounts(totalTimes+"");
companyRuntimeExcelBody.setNormal(normal+"");
companyRuntimeExcelBody.setBreaks(breaks+"");
companyRuntimeExcelBody.setShutdown(shutdown+"");
if(onlineFlag){
totalOnline=totalOnline+1;
}
if(totalOnline==-1){
companyRuntimeExcelBody.setOnline("暂无数据");
}else{
if(normal==0){
totalOnline=0f;
}else{
totalOnline=PubUtils.floatRound(2,(totalOnline/normal));
}
}
companyRuntimeExcelBody.setOnline(totalOnline+"");
companyRuntimeExcelBodies.add(companyRuntimeExcelBody);
}
}
return companyRuntimeExcelBodies;
}
@PostMapping("getRole")
@ResponseBody
public int getRole(String url) {
return deviceService.getRole(url);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
package com.pqs9200.controller.point;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.pointInfo.LineLedger;
import com.njcn.pojo.pointInfo.LineLedgerVO;
import com.njcn.pojo.pointInfo.PointInfo;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.point.PointBaseInfoService;
import com.njcn.utils.PubUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* @Author: Sunwei 【sunW2016@163.com】
* @Description:
* @Date: Create in 13:22 2018/5/28
* @Modified By:
*/
@RestController
public class PointBaseInfoController {
@Autowired
private PointBaseInfoService pointBaseInfoService;
@Autowired
UserLogDetailService userLog;
/**
* 监测点台账信息查询
* @author cdf
* @date 2021/9/14
*/
@PostMapping("getLineLedger")
public HttpResult getLineLedger(@RequestBody LineLedgerVO lineLedgerVO){
List<LineLedger> list = pointBaseInfoService.getLineLedger(lineLedgerVO);
return PubUtils.assignmentResult(list,200,"监测点台账信息查询成功");
}
}

View File

@@ -0,0 +1,29 @@
package com.pqs9200.controller.user;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
@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,112 @@
package com.pqs9200.controller.user;
import com.njcn.enums.LogTypeEnum;
import com.njcn.mapper.user.ManageListMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.user.ManageListService;
import com.njcn.utils.AppConfig;
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.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Controller
@RequestMapping(value ="/manage")
public class ManageListController {
@Autowired
ManageListService mService;
@Autowired
ManageListMapper mlm;
@Autowired
private AppConfig appConfig;
@Autowired
UserLogDetailService userLogDetailService;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(ManageListController.class);
@RequestMapping(value = "getManage", method = RequestMethod.POST)
@ResponseBody
public HttpResult getManage(HttpServletRequest request) throws AccountException {
HttpResult result = new HttpResult();
List<List> users = mService.getManage();
if (users.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到资源信息列表");
userLogDetailService.getLog("查询资源信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
logger.error("获取资源信息失败");
} else {
result.setCode(200);
result.setBody(users);
userLogDetailService.getLog("查询资源信息", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
result.setMessage("获取资源信息列表成功");
logger.info("获取资源信息成功");
}
return result;
}
@RequestMapping(value = "getBasemang", method = RequestMethod.POST)
@ResponseBody
public HttpResult getBasemang(HttpServletRequest request) throws AccountException {
HttpResult result = new HttpResult();
List<List> users = mService.getBasemang(appConfig.getSysTypeZt());
if (users.isEmpty()) {
result.setCode(500);
userLogDetailService.getLog("查询资源信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
result.setMessage("没有获取到资源信息列表");
logger.error("获取资源信息失败");
} else {
result.setCode(200);
result.setBody(users);
userLogDetailService.getLog("查询资源信息", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
result.setMessage("获取资源信息列表成功");
logger.info("获取资源信息成功");
}
return result;
}
@RequestMapping(value = "getReport", method = RequestMethod.POST)
@ResponseBody
public HttpResult getReport(HttpServletRequest request) throws AccountException {
HttpResult result = new HttpResult();
List<List> users = mService.getReport(appConfig.getSysTypeZt());
if (users.isEmpty()) {
result.setCode(500);
userLogDetailService.getLog("查询资源信息", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
result.setMessage("没有获取到资源信息列表");
logger.error("获取资源信息失败");
} else {
result.setCode(200);
result.setBody(users);
userLogDetailService.getLog("查询资源信息", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(),0);
result.setMessage("获取资源信息列表成功");
logger.info("获取资源信息成功");
}
return result;
}
@RequestMapping(value = "getSub", method = RequestMethod.POST)
@ResponseBody
public HttpResult getSub(HttpServletRequest request) {
HttpResult result = new HttpResult();
List<List> users = mService.getSub(appConfig.getSysTypeZt());
if (users.isEmpty()) {
result.setCode(500);
result.setMessage("没有获取到资源信息列表");
logger.error("获取资源信息失败");
} else {
result.setCode(200);
result.setBody(users);
result.setMessage("获取资源信息列表成功");
logger.info("获取资源信息成功");
}
return result;
}
}

View File

@@ -0,0 +1,468 @@
package com.pqs9200.controller.user;
import com.njcn.enums.CookieKeyEnum;
import com.njcn.enums.LogTypeEnum;
import com.njcn.enums.ProjectEnum;
import com.njcn.mapper.user.ManageListMapper;
import com.njcn.mapper.user.SecretKeyMapper;
import com.njcn.mapper.user.UserMapper;
import com.njcn.pojo.commons.AreaInfo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.user.ManageList;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.service.log.UserLoginService;
import com.njcn.service.user.UserService;
import com.njcn.shiro.cache.VCache;
import com.njcn.shiro.filter.KickoutSessionFilter;
import com.njcn.shiro.session.UserShiroSessionRepository;
import com.njcn.shiro.session.impl.JedisShiroSessionRepository;
import com.njcn.shiro.token.TokenManager;
import com.njcn.sso.pojo.user.User;
import com.njcn.utils.*;
import com.njcn.utils.redis.JedisManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.shiro.subject.support.DefaultSubjectContext;
import org.apache.shiro.web.util.WebUtils;
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.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.MalformedURLException;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("user")
public class UserController {
@Autowired
private UserService us;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
@Autowired
UserLogDetailService userLogservice;
@Autowired
UserLoginService userLoginService;
@Autowired
private UserShiroSessionRepository userShiroSessionRepository;
@Autowired
private AppConfig appConfig;
@Autowired
JedisManager jedisManager;
@Autowired
ManageListMapper alm;
@Autowired
SecretKeyMapper sk;
@Autowired
UserMapper um;
@Autowired
UserUtil userUtil;
static VCache cache;
/**
* 根据当前用户获取区域选择tree
*/
@PostMapping("getAreasInfo")
@ResponseBody
public List<AreaInfo> getAreasInfo(){
List<AreaInfo> areaInfos;
try{
areaInfos=us.getAreasByUser();
if(CollectionUtils.isEmpty(areaInfos)){
areaInfos=null;
}
}catch (Exception e){
areaInfos=null;
}
return areaInfos;
}
/**
* 用户注销统一重定向到sso中心在sso中心查询该用户所有对应的sessionID进行缓存清理以达到子系统全部注销
*/
@GetMapping("loginout")
public void loginOut(HttpServletRequest request, HttpServletResponse response) throws IOException {
boolean flag = appConfig.isOneContainer();
String url;
if (flag) {
String baseUrl = request.getRequestURL().toString();
url = baseUrl.substring(0, baseUrl.indexOf("pqs9200")) + "sso/user/loginout?item=pqs9200";
} else {
url = appConfig.getSsoUrl() + "/loginout?item=pqs9200";
}
WebUtils.issueRedirect(request, response, url);
}
/**
* sso认证完成后访问子系统任然需要注册子系统包括当前用户在子系统下的权限
*/
@GetMapping("ssoRegister")
public void ssoRegister(HttpServletRequest request, HttpServletResponse response,String token) throws IOException {
if (StringUtils.isBlank(token)) {
redirectSso(request, response);
} else {
//首先根据token去redis中查询有没有对应的session
Session session = userShiroSessionRepository.getSession(token);
//没有需要的共享会话,则重定向回登录中心
if (null == session) {
redirectSso(request, response);
} else {
//判断认证中心的会话是否被T被T子系统时不允许注册的返回认证中心登录页面
Boolean marker = (Boolean) session.getAttribute(KickoutSessionFilter.KICKOUT_STATUS);
if (null != marker && marker) {
redirectSso(request, response);
}
//获取session登录信息。
Object obj = session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
if (null == obj) {
//没有用户信息,则重定向回登录中心
redirectSso(request, response);
} else {
SimplePrincipalCollection spc = (SimplePrincipalCollection) obj;
obj = spc.getPrimaryPrincipal();
if (null == obj) {
//没有用户信息,则重定向回登录中心
redirectSso(request, response);
} else {
User ssoUser = (User) obj;
//获取出共享会话中的用户信息,进行再次认证和授权处理
try {
TokenManager.login(ssoUser.getLoginName(),"",ssoUser.getPassword(),PubUtils.getIpAddr(request), ProjectEnum.PQS9200.getItem());
try {
userLoginService.insertLogin(ssoUser.getLoginName(), ProjectEnum.PQS9200.getItem());
} catch (Exception e) {
logger.error("用户登录成功后,保存记录出错。原因:" + e.toString());
}
//进行sessionID存储到redis
saveSessionByUser(session, token, TokenManager.getUserId(), TokenManager.getSession().getId().toString());
userShiroSessionRepository.activeSession(session);
TokenManager.getSession().setAttribute(CookieKeyEnum.SSOLOGIN.getCookieKey(), token);
userUtil.saveRandomToken();
//认证成功重定向到业务主界面
WebUtils.issueRedirect(request, response, "/business/doBusiness");
} catch (Exception u) {
logger.error("子系统pqs9200注册时异常异常为" + response.toString());
}
}
}
}
}
}
/**
* 重定向到sso认证中心判断用户是否已经登录过
*/
private void redirectSso(HttpServletRequest request, HttpServletResponse response) throws IOException {
boolean flag = appConfig.isOneContainer();
String url;
if (flag) {
String baseUrl = request.getRequestURL().toString();
url = baseUrl.substring(0, baseUrl.indexOf("pqs9200")) + "sso/user/judgeLogin?item=pqs9200";
} else {
url = appConfig.getSsoJudge();
}
WebUtils.issueRedirect(request, response, url);
}
/**
* 根据用户索引保存当前系统的sessionID以便注销系统时删除会话信息
*
* @param token
* @param userId 用户索引
* @param sessionId 会话ID
*/
private void saveSessionByUser(Session session, String token, String userId, String sessionId) {
String key=token+userId;
List<String> infoMap= (List<String>) session.getAttribute(key);
//如果不存在,创建一个新的
infoMap = null == infoMap ? new ArrayList<>() : infoMap;
infoMap.add(JedisShiroSessionRepository.REDIS_SHIRO_SESSION + sessionId);
session.setAttribute(key,infoMap);
}
public void write(HttpServletResponse response, Object object) throws IOException {
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.write(object.toString());
out.close();
}
/**
* 根据用户名重置密码
*
* @param username 用户名
* @param password 密码
*/
@PostMapping("modifyPwd")
@ResponseBody
public HttpResult modifyPwd(String username, String password) {
HttpResult result;
username = XssFilterUtil.dealString(username);
username = RSAUtil.decryptStringByJs(username);
password = XssFilterUtil.dealString(password);
if (!(PubUtils.patternPassword(password) || PubUtils.patternUsername(username))) {
result = PubUtils.assignmentResult(null, 500, "用户名密码有误");
return result;
}
try {
us.modifyPassword(username, password);
result = PubUtils.assignmentResult(null, 200, "修改密码成功");
} catch (Exception e) {
logger.error("更新密码出错,异常为:" + e.toString());
result = PubUtils.assignmentResult(null, 500, e.getMessage());
}
return result;
}
/**
* foundChrome
* 判断浏览器在本地是否存在
*
* @throws FileNotFoundException
*/
@RequestMapping(value = "foundChrome", method = RequestMethod.POST)
@ResponseBody
public HttpResult foundChrome(HttpServletResponse response, @Param(value = "res_Index") String res_Index) {
ManageList list = new ManageList();
list.setRes_Index(res_Index);
list.setState(1);
list.setSysType(appConfig.getSysType());
List<ManageList> manageLists = alm.select(list);
return PubUtils.foundChrome(manageLists);
}
/**
* downloadChrome
* 用户下载谷歌浏览器安装版
* 存在D盘配置文件配置源路径
*
* @throws FileNotFoundException
* @throws MalformedURLException
*/
@RequestMapping(value = "downloadChrome", method = RequestMethod.GET)
public void downloadChrome(HttpServletResponse response, @Param(value = "res_Index") String res_Index, HttpServletRequest request){
ManageList list = new ManageList();
list.setRes_Index(res_Index);
list.setState(1);
list.setSysType(appConfig.getSysType());
List<ManageList> manageLists = alm.select(list);
PubUtils.downloadChrome(response,manageLists);
}
/**
* 根据用户索引获取用户信息回显,以便修改
*
* @param userIndex 用户索引
*/
@ResponseBody
@PostMapping(value = "selectId")
public User selectId(String userIndex, int flag) {
return us.selectId(userIndex, flag);
}
/************************
* RSA
* 根据用户名生成秘钥对
* @param username 用户名
*************************/
@PostMapping("generateRSAKey")
@ResponseBody
public HttpResult generateRSAKey(String username, HttpServletRequest request) {
HttpResult result;
try {
username = DesUtils.aesDecrypt(username);
// 获取公钥和私钥
HashMap<String, Object> keys = RSAUtils.getKeys();
RSAPublicKey publicKey = (RSAPublicKey) keys.get("public");
RSAPrivateKey privateKey = (RSAPrivateKey) keys.get("private");
String ip = StringUtils.isBlank(PubUtils.getIpAddr(request)) ? "127.0.0.1" : PubUtils.getIpAddr(request);
//秘钥先删除再添加
jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
// 保存私钥到 redis也可以保存到数据库
jedisManager.saveValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip), SerializeUtil.serialize(privateKey), -1);
// 将公钥传到前端
Map<String, String> map = new HashMap<String, String>();
// 注意返回modulus和exponent以16为基数的BigInteger的字符串表示形式
map.put("modulus", publicKey.getModulus().toString(16));
map.put("exponent", publicKey.getPublicExponent().toString(16));
result = PubUtils.assignmentResult(map, 200, "生成秘钥对成功!");
} catch (Exception u) {
result = PubUtils.assignmentResult(null, 500, u.getMessage());
}
return result;
}
/************************
* SM2
* 根据用户名生成秘钥对
* @param username 用户名
*************************/
@PostMapping("generateSM2Key")
@ResponseBody
public HttpResult generateSM2Key(String username, HttpServletRequest request) {
HttpResult result;
try {
if (PubUtils.isBlank(username)) {
result = PubUtils.assignmentResult(null, 500, "用户名非法!");
return result;
}
username = DesUtils.aesDecrypt(username);
// 获取公钥和私钥
Map<String, String> keyMap =PubUtils.getSM2CipHer();
String publicKey = keyMap.get("publicKey"); //加密密钥
String privateKey = keyMap.get("privateKey"); //解密密钥
String ip = PubUtils.isBlank(PubUtils.getIpAddr(request)) ? "127.0.0.1" : PubUtils.getIpAddr(request);
//秘钥先删除再添加
jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
// 保存私钥到 redis也可以保存到数据库
jedisManager.saveValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip), SerializeUtil.serialize(privateKey), -1);
// 将公钥传到前端
result = PubUtils.assignmentResult(publicKey, 200, "生成秘钥对成功!");
} catch (Exception u) {
result = PubUtils.assignmentResult(null, 500, u.getMessage());
}
return result;
}
/**
* 确认密码
*/
@PostMapping(value = "confirmPwd")
@ResponseBody
public HttpResult confirmPwd(String password, HttpServletRequest request,HttpServletResponse response) {
String ip = PubUtils.getIpAddr(request);
String username = TokenManager.getToken().getLoginName();
password = XssFilterUtil.dealString(password);
HttpResult result=PubUtils.initResult(TokenManager.getToken().getLoginName(),request,LogTypeEnum.SYSTEM.toString(),2);
try {
//密码处理
String privateKey = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, username + ip);
//秘钥用完即删
jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, username + ip);
//对SM2解密面进行验证
password = PubUtils.getPasswordSM2Verify(privateKey, password);
if (password == null && password.length() == 0) {
return PubUtils.assignmentResultLog(null, 500, "密码传输完整性被破坏","密码确认","失败",result);
}
us.judgeUsernameAndPwd(username, password);
response.setStatus(203);
result = PubUtils.assignmentResultLog(null, 200, "密码正确","密码确认","成功",result);
//缓存验证结果
jedisManager.saveValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip), SerializeUtil.serialize("success"), -1);
} catch (Exception e) {
if(e.getMessage().length()>12){
result = PubUtils.assignmentResultLog(null, 500, "密码确认异常","密码确认","失败",result);
}else{
result = PubUtils.assignmentResultLog(null, 500, e.getMessage(),"密码确认","失败",result);
}
//缓存验证结果
jedisManager.saveValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip), SerializeUtil.serialize("fail"), -1);
}
return result;
}
//修改密码
@ResponseBody
@RequestMapping(value = "updatePassword", method = RequestMethod.POST)
public HttpResult updatePassword(HttpServletRequest request, @Param(value = "username") String username,
@Param(value = "passwordX") String passwordX,
String token) {
HttpResult result = new HttpResult();
// String sessionToken = (String) TokenManager.getSession().getAttribute("token");
// if (!token.equalsIgnoreCase(sessionToken)) {
// result = PubUtils.assignmentResult(null, 500, "非法访问");
// return result;
// }
//username = XssFilterUtil.dealString(username);
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, username + ip);
//对SM2解密面进行验证
passwordX = PubUtils.getPasswordSM2Verify(privateKey, passwordX);
if (passwordX == null && passwordX.length() == 0) {
result = PubUtils.assignmentResult(null, 500, "密码传输完整性被破坏");
userLogservice.getLog("修改用户密码", "失败", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
return result;
}
//增加判断密码是否包含用户名
if (passwordX.indexOf(username) > -1) {
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 {
us.modifyPassword(username, passwordX);
userLogservice.getLog("修改用户密码", "成功", PubUtils.getIpAddr(request), LogTypeEnum.SYSTEM.toString(), 1);
result = PubUtils.assignmentResult(null, 200, "修改密码成功");
User user = new User();
user.setLoginName(username);
user = um.selectOne(user);
if (null != user) {
user.setState(1);
um.updateByPrimaryKeyBySql(user);
}
} 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,681 @@
package com.pqs9200.controller.weeklyreport;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFDrawing;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.advanced.SagEvent;
import com.njcn.pojo.commons.device.LineInfo;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.utils.PubUtils;
import com.pqs9200.pojo.weeklyreport.AreaPointInfo;
import com.pqs9200.pojo.weeklyreport.SagRate;
import sun.misc.BASE64Decoder;
public class ExcelUtil {
public void setUserLog(UserLogDetailService userLog) {
this.userLog = userLog;
}
private UserLogDetailService userLog;
// excel工作薄对象
private XSSFWorkbook workbook;
// 表单集合
private List<XSSFSheet> listSheet;
private List<byte[]> listPic;
private XSSFCellStyle style1;
private XSSFCellStyle style2;
private XSSFCellStyle style3;
private XSSFCellStyle defaultStyle;
// 重写构造函数
public ExcelUtil(String... sheetName) {
workbook = new XSSFWorkbook();
listSheet = new ArrayList<>();
listPic = new ArrayList<>();
for (int i = 0; i < sheetName.length; i++) {
listSheet.add(workbook.createSheet(sheetName[i]));
}
// 设置单元格列宽
Map<Integer, Integer> map1 = new HashMap<>();
map1.put(0, 25);
setColumnWidth(listSheet.get(0), map1);
Map<Integer, Integer> map2 = new HashMap<>();
map2.put(1, 25);
map2.put(2, 20);
map2.put(3, 20);
map2.put(4, 20);
map2.put(5, 25);
map2.put(6, 20);
map2.put(7, 20);
setColumnWidth(listSheet.get(1), map2);
Map<Integer, Integer> map3 = new HashMap<>();
map3.put(1, 25);
map3.put(2, 20);
map3.put(3, 20);
map3.put(4, 20);
map3.put(5, 25);
map3.put(6, 20);
map3.put(7, 25);
setColumnWidth(listSheet.get(3), map3);
Map<Integer, Integer> map4 = new HashMap<>();
map4.put(1, 20);
map4.put(2, 25);
map4.put(3, 25);
map4.put(4, 20);
setColumnWidth(listSheet.get(4), map4);
Map<Integer, Integer> map5 = new HashMap<>();
map5.put(1, 20);
map5.put(2, 25);
map5.put(3, 25);
map5.put(4, 20);
setColumnWidth(listSheet.get(5), map5);
Map<Integer, Integer> map6 = new HashMap<>();
map6.put(1, 20);
map6.put(2, 25);
map6.put(3, 25);
map6.put(4, 20);
setColumnWidth(listSheet.get(6), map6);
// 设置字体默认样式
for (int i = 0; i < 4; i++) {
setStyle(i);
}
}
private XSSFCellStyle getStyle(int styleType) {
switch (styleType) {
case 0:
return style1;
case 1:
return style2;
case 3:
return style3;
default:
return defaultStyle;
}
}
private void setStyle(int styleType) {
XSSFFont font = workbook.createFont();
font.setFontName("微软雅黑");
font.setFontHeightInPoints((short) 9);
switch (styleType) {
case 0:
style1 = workbook.createCellStyle();
font.setFontHeightInPoints((short) 11);
font.setBold(true);
style1.setVerticalAlignment(VerticalAlignment.CENTER);
style1.setAlignment(HorizontalAlignment.CENTER_SELECTION);
style1.setFont(font);
break;
case 1:
style2 = workbook.createCellStyle();
font.setFontHeightInPoints((short) 10);
style2.setVerticalAlignment(VerticalAlignment.CENTER);
style2.setAlignment(HorizontalAlignment.CENTER_SELECTION);
font.setBold(true);
style2.setFont(font);
break;
case 3:
style3 = workbook.createCellStyle();
style3.setVerticalAlignment(VerticalAlignment.CENTER);
style3.setAlignment(HorizontalAlignment.CENTER_SELECTION);
style3.setFont(font);
break;
default:
defaultStyle = workbook.createCellStyle();
defaultStyle.setVerticalAlignment(VerticalAlignment.CENTER);
defaultStyle.setFont(font);
break;
}
}
public XSSFWorkbook getWorkbook() {
return workbook;
}
public void setWorkbook(XSSFWorkbook workbook) {
this.workbook = workbook;
}
public List<XSSFSheet> getListSheet() {
return listSheet;
}
public void setListSheet(List<XSSFSheet> listSheet) {
this.listSheet = listSheet;
}
// 默认构造函数
public ExcelUtil() {
}
// 设置列宽
private void setColumnWidth(XSSFSheet sheet, Map<Integer, Integer> map) {
Set<Map.Entry<Integer, Integer>> sets = map.entrySet();
for (Map.Entry<Integer, Integer> entry : sets) {
sheet.setColumnWidth(entry.getKey().intValue(), entry.getValue().intValue() * 256);
}
}
// 导出表格
public void exportFile(XSSFWorkbook workbook, HttpServletResponse response, HttpServletRequest request) {
try {
response.setContentType("application/force-download");
response.addHeader("Content-Disposition",
"attachment;fileName=" + new String(("电压暂降周报").getBytes("GB2312"), "iso8859-1") + ".xlsx");// 设置文件名
OutputStream outputStream = response.getOutputStream();
// 贴图(暂降总体概况)
for (int i = 0, j = 0; i < listPic.size() - 1; i++, j += 13) {
ByteArrayOutputStream outStreamdd = new ByteArrayOutputStream();
BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(listPic.get(i)));
ImageIO.write(bufferedImage, "PNG", outStreamdd);
XSSFDrawing xssfDrawing = listSheet.get(0).createDrawingPatriarch();
XSSFClientAnchor clientAnchor = new XSSFClientAnchor(1, 1, 1, 1, 6, j, 15, j + 12);
xssfDrawing.createPicture(clientAnchor,
workbook.addPicture(outStreamdd.toByteArray(), XSSFWorkbook.PICTURE_TYPE_PNG));
}
// 贴图(暂降原因统计)
ByteArrayOutputStream outStreamdd = new ByteArrayOutputStream();
BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(listPic.get(4)));
ImageIO.write(bufferedImage, "PNG", outStreamdd);
XSSFDrawing xssfDrawing = listSheet.get(2).createDrawingPatriarch();
XSSFClientAnchor clientAnchor = new XSSFClientAnchor(1, 1, 1, 1, 0, 5, 5, 17);
xssfDrawing.createPicture(clientAnchor,
workbook.addPicture(outStreamdd.toByteArray(), XSSFWorkbook.PICTURE_TYPE_PNG));
workbook.write(outputStream);
workbook.close();
outputStream.close();
userLog.getLog("暂态报表导出", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} catch (IOException e) {
userLog.getLog("暂态报表导出", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
}
}
@SuppressWarnings("unchecked")
public void writePointInfo(XSSFSheet sheet, List<AreaPointInfo>... list) {
int rowId = 0;
// 第一行
XSSFRow row = sheet.createRow(rowId++);
XSSFCell cell = row.createCell(0);
setValue(cell, "暂态统计");
cell.setCellStyle(this.getStyle(0));
sheet.addMergedRegion(new CellRangeAddress(rowId - 1, rowId - 1, 0, 5));
// 第二行
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, "按区域统计");
cell.setCellStyle(this.getStyle(1));
sheet.addMergedRegion(new CellRangeAddress(rowId - 1, rowId - 1, 0, 5));
// 第三行
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, "区域");
cell.setCellStyle(this.getStyle(1));
cell = row.createCell(1);
setValue(cell, "监测点数量");
cell.setCellStyle(this.getStyle(1));
sheet.addMergedRegion(new CellRangeAddress(rowId - 1, rowId - 1, 1, 2));
cell = row.createCell(3);
setValue(cell, "暂降次数");
cell.setCellStyle(this.getStyle(1));
cell = row.createCell(4);
setValue(cell, "中断次数");
cell.setCellStyle(this.getStyle(1));
cell = row.createCell(5);
setValue(cell, "暂升次数");
cell.setCellStyle(this.getStyle(1));
// 第四行
row = sheet.createRow(rowId++);
sheet.addMergedRegion(new CellRangeAddress(rowId - 2, rowId - 1, 0, 0));
sheet.addMergedRegion(new CellRangeAddress(rowId - 2, rowId - 1, 3, 3));
sheet.addMergedRegion(new CellRangeAddress(rowId - 2, rowId - 1, 4, 4));
sheet.addMergedRegion(new CellRangeAddress(rowId - 2, rowId - 1, 5, 5));
cell = row.createCell(1);
setValue(cell, "在线");
cell.setCellStyle(this.getStyle(1));
cell = row.createCell(2);
setValue(cell, "离线");
cell.setCellStyle(this.getStyle(1));
for (int i = 0; i < list[0].size(); i++) {
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, list[0].get(i).getName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(1);
setValue(cell, list[0].get(i).getOnLine());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(2);
setValue(cell, list[0].get(i).getOffLine());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(3);
setValue(cell, list[0].get(i).getEventCount());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(4);
setValue(cell, list[0].get(i).getBreakCount());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(5);
setValue(cell, list[0].get(i).getUpCount());
cell.setCellStyle(this.getStyle(3));
}
// 电压等级数据
// 第二行
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, "按电压等级统计");
cell.setCellStyle(this.getStyle(1));
sheet.addMergedRegion(new CellRangeAddress(rowId - 1, rowId - 1, 0, 5));
// 第三行
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, "电压等级");
cell.setCellStyle(this.getStyle(1));
cell = row.createCell(1);
setValue(cell, "监测点数量");
cell.setCellStyle(this.getStyle(1));
sheet.addMergedRegion(new CellRangeAddress(rowId - 1, rowId - 1, 1, 2));
cell = row.createCell(3);
setValue(cell, "暂降次数");
cell.setCellStyle(this.getStyle(1));
cell = row.createCell(4);
setValue(cell, "中断次数");
cell.setCellStyle(this.getStyle(1));
cell = row.createCell(5);
setValue(cell, "暂升次数");
cell.setCellStyle(this.getStyle(1));
// 第四行
row = sheet.createRow(rowId++);
sheet.addMergedRegion(new CellRangeAddress(rowId - 2, rowId - 1, 0, 0));
sheet.addMergedRegion(new CellRangeAddress(rowId - 2, rowId - 1, 3, 3));
sheet.addMergedRegion(new CellRangeAddress(rowId - 2, rowId - 1, 4, 4));
sheet.addMergedRegion(new CellRangeAddress(rowId - 2, rowId - 1, 5, 5));
cell = row.createCell(1);
setValue(cell, "在线");
cell.setCellStyle(this.getStyle(1));
cell = row.createCell(2);
setValue(cell, "离线");
cell.setCellStyle(this.getStyle(1));
for (int i = 0; i < list[1].size(); i++) {
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, list[1].get(i).getName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(1);
setValue(cell, list[1].get(i).getOnLine());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(2);
setValue(cell, list[1].get(i).getOffLine());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(3);
setValue(cell, list[1].get(i).getEventCount());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(4);
setValue(cell, list[1].get(i).getBreakCount());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(5);
setValue(cell, list[1].get(i).getUpCount());
cell.setCellStyle(this.getStyle(3));
}
}
public void writeSagData(XSSFSheet sheet, List<SagEvent> list, int type) {
int rowId = 0;
// 第一行
XSSFRow row = sheet.createRow(rowId++);
XSSFCell cell = row.createCell(0);
String tableName = "暂态事件严重度(前二十)";
short lastColumn = 7;
if (type == 2) {
tableName = "暂态事件列表";
}
setValue(cell, tableName);
cell.setCellStyle(this.getStyle(0));
sheet.addMergedRegion(new CellRangeAddress(rowId - 1, rowId - 1, 0, lastColumn));
String[] arr = {"序号", "暂态发生时刻", "供电公司", "变电站", "监测点", "暂降(骤升)幅值(%)", "持续时间(s)"};
if (type == 2) {
arr = Arrays.copyOf(arr, arr.length + 1);
arr[arr.length - 1] = "暂态类型(机器判断)";
} else {
arr = Arrays.copyOf(arr, arr.length + 1);
arr[arr.length - 1] = "暂态严重度";
}
// 第二行
row = sheet.createRow(rowId++);
for (int i = 0; i < arr.length; i++) {
cell = row.createCell(i);
setValue(cell, arr[i]);
cell.setCellStyle(this.getStyle(1));
}
for (int i = 0; i < list.size(); i++) {
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, i + 1);
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(1);
setValue(cell, list.get(i).getStrTime());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(2);
setValue(cell, list.get(i).getPlantInfo().getNameGD());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(3);
setValue(cell, list.get(i).getPlantInfo().getNameBD());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(4);
setValue(cell, list.get(i).getPlantInfo().getNamePoint());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(5);
setValue(cell, list.get(i).getEventValue());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(6);
setValue(cell, list.get(i).getPersistTime(), 1000);
cell.setCellStyle(this.getStyle(3));
if (type == 2) {
cell = row.createCell(7);
setValue(cell, list.get(i).getSagTypeDes());
cell.setCellStyle(this.getStyle(3));
} else {
cell = row.createCell(7);
setValue(cell, list.get(i).getSeverity(), 1000);
cell.setCellStyle(this.getStyle(3));
}
}
}
public void writeTenList(XSSFSheet sheet, List<LineInfo> list) {
int rowId = 0;
// 第一行
XSSFRow row = sheet.createRow(rowId++);
XSSFCell cell = row.createCell(0);
String tableName = "暂降次数统计";
short lastColumn = 9;
setValue(cell, tableName);
cell.setCellStyle(this.getStyle(0));
sheet.addMergedRegion(new CellRangeAddress(rowId - 1, rowId - 1, 0, lastColumn));
String[] arr = {"序号", "监测点","干扰源类型","接入电网侧变电站","监测点对象名称","监测点电压等级", "监测点所在变电站/场站名称","监测点所在变电站/场站电压等级", "供电公司", "暂降次数"};
// 第二行
row = sheet.createRow(rowId++);
for (int i = 0; i < arr.length; i++) {
cell = row.createCell(i);
setValue(cell, arr[i]);
cell.setCellStyle(this.getStyle(1));
}
for (int i = 0; i < list.size(); i++) {
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, i + 1);
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(1);
setValue(cell, list.get(i).getName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(2);
setValue(cell, list.get(i).getLoadType());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(3);
setValue(cell, list.get(i).getPowerSubstationName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(4);
setValue(cell, list.get(i).getObjName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(5);
setValue(cell, list.get(i).getScale());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(6);
setValue(cell, list.get(i).getSubName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(7);
setValue(cell, list.get(i).getSubScale());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(8);
setValue(cell, list.get(i).getGdName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(9);
setValue(cell, list.get(i).getEventcount());
cell.setCellStyle(this.getStyle(3));
}
}
public void writeTenUpList(XSSFSheet sheet, List<LineInfo> list) {
int rowId = 0;
// 第一行
XSSFRow row = sheet.createRow(rowId++);
XSSFCell cell = row.createCell(0);
String tableName = "暂升次数统计";
short lastColumn = 9;
setValue(cell, tableName);
cell.setCellStyle(this.getStyle(0));
sheet.addMergedRegion(new CellRangeAddress(rowId - 1, rowId - 1, 0, lastColumn));
String[] arr = {"序号", "监测点","干扰源类型","接入电网侧变电站","监测点对象名称","监测点电压等级", "监测点所在变电站/场站名称","监测点所在变电站/场站电压等级", "供电公司", "暂升次数"};
// 第二行
row = sheet.createRow(rowId++);
for (int i = 0; i < arr.length; i++) {
cell = row.createCell(i);
setValue(cell, arr[i]);
cell.setCellStyle(this.getStyle(1));
}
for (int i = 0; i < list.size(); i++) {
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, i + 1);
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(1);
setValue(cell, list.get(i).getName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(2);
setValue(cell, list.get(i).getLoadType());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(3);
setValue(cell, list.get(i).getPowerSubstationName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(4);
setValue(cell, list.get(i).getObjName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(5);
setValue(cell, list.get(i).getScale());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(6);
setValue(cell, list.get(i).getSubName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(7);
setValue(cell, list.get(i).getSubScale());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(8);
setValue(cell, list.get(i).getGdName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(9);
setValue(cell, list.get(i).getEventcount());
cell.setCellStyle(this.getStyle(3));
}
}
public void writeTenBreakList(XSSFSheet sheet, List<LineInfo> list) {
int rowId = 0;
// 第一行
XSSFRow row = sheet.createRow(rowId++);
XSSFCell cell = row.createCell(0);
String tableName = "短时中断次数统计";
short lastColumn = 9;
setValue(cell, tableName);
cell.setCellStyle(this.getStyle(0));
sheet.addMergedRegion(new CellRangeAddress(rowId - 1, rowId - 1, 0, lastColumn));
String[] arr = {"序号", "监测点","干扰源类型","接入电网侧变电站","监测点对象名称","监测点电压等级", "监测点所在变电站/场站名称","监测点所在变电站/场站电压等级", "供电公司", "短时中断次数"};
// 第二行
row = sheet.createRow(rowId++);
for (int i = 0; i < arr.length; i++) {
cell = row.createCell(i);
setValue(cell, arr[i]);
cell.setCellStyle(this.getStyle(1));
}
for (int i = 0; i < list.size(); i++) {
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, i + 1);
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(1);
setValue(cell, list.get(i).getName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(2);
setValue(cell, list.get(i).getLoadType());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(3);
setValue(cell, list.get(i).getPowerSubstationName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(4);
setValue(cell, list.get(i).getObjName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(5);
setValue(cell, list.get(i).getScale());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(6);
setValue(cell, list.get(i).getSubName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(7);
setValue(cell, list.get(i).getSubScale());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(8);
setValue(cell, list.get(i).getGdName());
cell.setCellStyle(this.getStyle(3));
cell = row.createCell(9);
setValue(cell, list.get(i).getEventcount());
cell.setCellStyle(this.getStyle(3));
}
}
public void writeSagReason(XSSFSheet sheet, List<SagRate> list) {
int rowId = 0;
// 第一行
XSSFRow row = sheet.createRow(rowId++);
XSSFCell cell = row.createCell(0);
setValue(cell, "暂态原因统计表");
cell.setCellStyle(this.getStyle(0));
sheet.addMergedRegion(new CellRangeAddress(rowId - 1, rowId - 1, 0, list.size()));
// 第二行
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, "暂态原因");
cell.setCellStyle(this.getStyle(1));
for (int i = 0; i < list.size(); i++) {
cell = row.createCell(i + 1);
setValue(cell, list.get(i).getName());
cell.setCellStyle(this.getStyle(1));
this.getListSheet().get(2).setColumnWidth(i + 1, 25 * 256);
}
// 第三行
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, "次数");
cell.setCellStyle(this.getStyle(1));
for (int i = 0; i < list.size(); i++) {
cell = row.createCell(i + 1);
setValue(cell, list.get(i).getCount());
cell.setCellStyle(this.getStyle(3));
}
// 第四行
row = sheet.createRow(rowId++);
cell = row.createCell(0);
setValue(cell, "占比(%)");
cell.setCellStyle(this.getStyle(1));
for (int i = 0; i < list.size(); i++) {
cell = row.createCell(i + 1);
setValue(cell, list.get(i).getRate());
cell.setCellStyle(this.getStyle(3));
}
}
// 解析图片流
public void translate(String... strPic) {
// 判断数据是否为空
BASE64Decoder decoder = new BASE64Decoder();
// 生成图片
for (int i = 0; i < strPic.length; i++) {
try {
String[] url = strPic[i].split(",");
String u = url[1];
byte[] buffer = decoder.decodeBuffer(u);
listPic.add(buffer);
} catch (Exception e) {
// log日志记录
}
}
}
private void setValue(XSSFCell cell, Object object, int... a) { //暂时处理
if (object instanceof Float) {
float f = ((Float) object).floatValue();
int k = a.length > 0 ? a[0] : 100;
float f1 = (float) (Math.round(f * k)) / k;
cell.setCellValue(Double.parseDouble(String.valueOf(f1)));
return;
} else if (object instanceof Integer) {
cell.setCellValue(((Integer) object).intValue());
return;
}
cell.setCellValue(object.toString());
}
}

View File

@@ -0,0 +1,402 @@
package com.pqs9200.controller.weeklyreport;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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 com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.advanced.SagEvent;
import com.njcn.pojo.commons.DatePojo;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.commons.device.LineInfo;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.InstantiateUtil;
import com.njcn.utils.PubUtils;
import com.njcn.utils.redis.JedisManager;
import com.pqs9200.pojo.weeklyreport.AreaPointInfo;
import com.pqs9200.pojo.weeklyreport.SagRate;
import com.pqs9200.service.weeklyreport.WeeklyReportService;
@Controller
@RequestMapping("/weeklyreport")
public class WeeklyReportController {
@Autowired
private WeeklyReportService weeklyReportService;
@Autowired
private UserLogDetailService userLog;
private Map<String, ExcelUtil> map;
private InstantiateUtil<List<AreaPointInfo>> areaPointInfoInstantiateUtil;
private InstantiateUtil<List<SagEvent>> sagEventInstantiateUtil;
private InstantiateUtil<List<SagRate>> sagRateInstantiateUtil;
private InstantiateUtil<List<LineInfo>> tenListInstantiateUtil;
private InstantiateUtil<String> stringInstantiateUtil;
byte[] pointInfo;
byte[] voltageInfo;
byte[] sag;
byte[] sagReason;
byte[] sagEvents;
byte[] tenList;
byte[] tenUpList;
byte[] tenBreakList;
@Autowired
private JedisManager jedisManager;
public WeeklyReportController() {
areaPointInfoInstantiateUtil = new InstantiateUtil<>();
sagEventInstantiateUtil = new InstantiateUtil<>();
sagRateInstantiateUtil = new InstantiateUtil<>();
tenListInstantiateUtil = new InstantiateUtil<>();
stringInstantiateUtil = new InstantiateUtil<>();
pointInfo = stringInstantiateUtil.instantiate("pointInfo");
voltageInfo = stringInstantiateUtil.instantiate("voltageInfo");
sag = stringInstantiateUtil.instantiate("sag");
sagReason = stringInstantiateUtil.instantiate("sagReason");
sagEvents = stringInstantiateUtil.instantiate("sagEvents");
tenList = stringInstantiateUtil.instantiate("tenList");
tenUpList = stringInstantiateUtil.instantiate("tenUpList");
tenBreakList = stringInstantiateUtil.instantiate("tenBreakList");
map = new HashMap<>();
}
@PostMapping(value = "getPointData")
@ResponseBody
public HttpResult getPointData(String startTime, String endTime,Boolean statFlag, HttpServletRequest request) {
HttpResult result;
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getPointData");
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
userLog.getLog("查询暂降周报", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return result;
}
List<AreaPointInfo> listPointInfo = new ArrayList<>();
String userIndex = TokenManager.getUserId();
byte[] userIndexs = stringInstantiateUtil.instantiate(userIndex);
try {
listPointInfo = weeklyReportService.getPointData(datePojo.getStartTime(), datePojo.getEndTime(),statFlag);
userLog.getLog("查询暂降周报", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
} catch (Exception e) {
userLog.getLog("查询暂降周报", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
return PubUtils.assignmentResult(null, 500, "暂降数据获取失败");
}
Collections.sort(listPointInfo);
if (null == listPointInfo) {
result = PubUtils.assignmentResult(null, 500, "无暂降数据");
} else {
result = PubUtils.assignmentResult(listPointInfo, 200, "获取暂降次数成功");
}
userLog.getLog("查询暂降周报", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndexs, pointInfo, areaPointInfoInstantiateUtil.instantiate(listPointInfo), RedisDB.SHORT_TIME);
return result;
}
@PostMapping(value = "getVoltageData")
@ResponseBody
public HttpResult getVoltageData(String startTime, String endTime,Boolean statFlag) {
HttpResult result;
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getVoltageData");
if (!datePojo.getValidity()) {
result = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return result;
}
List<AreaPointInfo> listVoltageInfo = new ArrayList<>();
String userIndex = TokenManager.getUserId();
byte[] userIndexs = stringInstantiateUtil.instantiate(userIndex);
try {
listVoltageInfo = weeklyReportService.getVoltageData(datePojo.getStartTime(), datePojo.getEndTime(),statFlag);
} catch (Exception e) {
return PubUtils.assignmentResult(null, 500, "暂降数据获取失败");
}
Collections.sort(listVoltageInfo);
if (null == listVoltageInfo) {
result = PubUtils.assignmentResult(null, 500, "无暂降数据");
} else {
result = PubUtils.assignmentResult(listVoltageInfo, 200, "获取暂降次数成功");
}
jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndexs, voltageInfo, areaPointInfoInstantiateUtil.instantiate(listVoltageInfo), RedisDB.SHORT_TIME);
return result;
}
@SuppressWarnings("unchecked")
@PostMapping("/createExcel")
@ResponseBody
public HttpResult createExcel(String deptspic, String deptsevent, String voltagepic, String voltageevent,
String sagpic) {
HttpResult httpResult = new HttpResult();
String[] sheetName = {"暂态总体概况", "暂态严重度统计", "暂态原因统计", "详细事件列表", "暂降次数统计", "暂升次数统计", "短时中断次数统计"};
ExcelUtil excelUtil = new ExcelUtil(sheetName);
excelUtil.setUserLog(userLog);
String userIndex = TokenManager.getUserId();
byte[] userIndexs = stringInstantiateUtil.instantiate(userIndex);
List<AreaPointInfo> listPointInfo = areaPointInfoInstantiateUtil.deInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndexs, pointInfo));
List<AreaPointInfo> listVoltageInfo = areaPointInfoInstantiateUtil.deInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndexs, voltageInfo));
List<SagEvent> listSag = sagEventInstantiateUtil.deInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndexs, sag));
List<SagRate> listSagReason = sagRateInstantiateUtil.deInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndexs, sagReason));
List<SagEvent> listSagEvents = sagEventInstantiateUtil.deInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndexs, sagEvents));
List<LineInfo> ListTenList = tenListInstantiateUtil.deInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndexs, tenList));
List<LineInfo> ListTenUpList = tenListInstantiateUtil.deInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndexs, tenUpList));
List<LineInfo> ListTenBreakList = tenListInstantiateUtil.deInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndexs, tenBreakList));
try {
// 解析图片流
excelUtil.translate(deptspic, voltagepic, deptsevent, voltageevent, sagpic);
// 暂态总体概况
excelUtil.writePointInfo(excelUtil.getListSheet().get(0), listPointInfo, listVoltageInfo);
// 暂态严重度统计(前五)
excelUtil.writeSagData(excelUtil.getListSheet().get(1), listSag, 1);
// 暂态原因统计
excelUtil.writeSagReason(excelUtil.getListSheet().get(2), listSagReason);
// 详细事件列表
excelUtil.writeSagData(excelUtil.getListSheet().get(3), listSagEvents, 2);
// 暂降次数统计
excelUtil.writeTenList(excelUtil.getListSheet().get(4), ListTenList);
// 暂升次数统计
excelUtil.writeTenUpList(excelUtil.getListSheet().get(5), ListTenUpList);
// 短时中断次数统计
excelUtil.writeTenBreakList(excelUtil.getListSheet().get(6), ListTenBreakList);
} catch (Exception e) {
httpResult.setCode(500);
return httpResult;
}
map.put(userIndex, excelUtil);
httpResult.setCode(200);
return httpResult;
}
@GetMapping(value = "/exportExcel")
public void exportExcel(HttpServletResponse response, HttpServletRequest request) {
String userIndex = TokenManager.getUserId();
ExcelUtil excelUtil = map.get(userIndex);
excelUtil.exportFile(excelUtil.getWorkbook(), response, request);
}
@PostMapping(value = "getSagData")
@ResponseBody
public HttpResult getSagData(String startTime, String endTime,Boolean statFlag) {
HttpResult httpResult;
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getSagData");
if (!datePojo.getValidity()) {
httpResult = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return httpResult;
}
List<SagEvent> listSag = new ArrayList<>();
String userIndex = TokenManager.getUserId();
byte[] userIndexs = stringInstantiateUtil.instantiate(userIndex);
try {
listSag = weeklyReportService.getSagData(datePojo.getStartTime(), datePojo.getEndTime(),statFlag);
} catch (Exception e) {
return PubUtils.assignmentResult(null, 500, "暂降数据获取失败");
}
if (null == listSag) {
httpResult = PubUtils.assignmentResult(null, 500, "无暂降数据");
} else {
httpResult = PubUtils.assignmentResult(listSag, 200, "获取暂降次数成功");
}
jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndexs, sag, sagEventInstantiateUtil.instantiate(listSag), RedisDB.SHORT_TIME);
return httpResult;
}
@PostMapping(value = "getSagReasonData")
@ResponseBody
public HttpResult getSagReasonData(String startTime, String endTime,Boolean statFlag) {
HttpResult httpResult;
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getSagReasonData");
if (!datePojo.getValidity()) {
httpResult = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return httpResult;
}
List<SagRate> listSagReason = new ArrayList<>();
String userIndex = TokenManager.getUserId();
byte[] userIndexs = stringInstantiateUtil.instantiate(userIndex);
try {
listSagReason = weeklyReportService.getSagReasonData(datePojo.getStartTime(), datePojo.getEndTime(),statFlag);
} catch (Exception e) {
return PubUtils.assignmentResult(null, 500, "暂降数据获取失败");
}
if (null == listSagReason) {
httpResult = PubUtils.assignmentResult(null, 500, "无暂降数据");
} else {
httpResult = PubUtils.assignmentResult(listSagReason, 200, "获取暂降次数成功");
}
jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndexs, sagReason, sagRateInstantiateUtil.instantiate(listSagReason), RedisDB.SHORT_TIME);
return httpResult;
}
@PostMapping(value = "getSagEvents")
@ResponseBody
public HttpResult getSagEvents(String startTime, String endTime,Boolean statFlag) {
HttpResult httpResult;
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getSagEvents");
if (!datePojo.getValidity()) {
httpResult = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return httpResult;
}
List<SagEvent> listSagEvents = new ArrayList<>();
String userIndex = TokenManager.getUserId();
byte[] userIndexs = stringInstantiateUtil.instantiate(userIndex);
try {
listSagEvents = weeklyReportService.getSagEvents(datePojo.getStartTime(), datePojo.getEndTime(),statFlag);
} catch (Exception e) {
return PubUtils.assignmentResult(null, 500, "暂降数据获取失败");
}
if (null == listSagEvents) {
httpResult = PubUtils.assignmentResult(null, 500, "无暂降数据");
} else {
httpResult = PubUtils.assignmentResult(listSagEvents, 200, "获取暂降次数成功");
}
jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndexs, sagEvents, sagEventInstantiateUtil.instantiate(listSagEvents), RedisDB.SHORT_TIME);
return httpResult;
}
@PostMapping(value = "getTenList")
@ResponseBody
public HttpResult getTenList(String startTime, String endTime,Boolean statFlag) {
HttpResult httpResult;
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getTenList");
if (!datePojo.getValidity()) {
httpResult = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return httpResult;
}
List<LineInfo> lineInfo = new ArrayList<>();
String userIndex = TokenManager.getUserId();
byte[] userIndexs = stringInstantiateUtil.instantiate(userIndex);
try {
lineInfo = weeklyReportService.getTenList(datePojo.getStartTime(), datePojo.getEndTime(),1,statFlag);
} catch (Exception e) {
return PubUtils.assignmentResult(null, 500, "暂降数据获取失败");
}
if (null == lineInfo) {
httpResult = PubUtils.assignmentResult(null, 500, "无暂降数据");
} else {
httpResult = PubUtils.assignmentResult(lineInfo, 200, "获取暂降次数成功");
}
jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndexs, tenList, tenListInstantiateUtil.instantiate(lineInfo), RedisDB.SHORT_TIME);
return httpResult;
}
@PostMapping(value = "getTenUpList")
@ResponseBody
public HttpResult getTenUpList(String startTime, String endTime,Boolean statFlag) {
HttpResult httpResult;
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getTenUpList");
if (!datePojo.getValidity()) {
httpResult = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return httpResult;
}
List<LineInfo> lineInfo = new ArrayList<>();
String userIndex = TokenManager.getUserId();
byte[] userIndexs = stringInstantiateUtil.instantiate(userIndex);
try {
lineInfo = weeklyReportService.getTenList(datePojo.getStartTime(), datePojo.getEndTime(),2,statFlag);
} catch (Exception e) {
return PubUtils.assignmentResult(null, 500, "暂升数据获取失败");
}
if (null == lineInfo) {
httpResult = PubUtils.assignmentResult(null, 500, "无暂降数据");
} else {
httpResult = PubUtils.assignmentResult(lineInfo, 200, "获取暂升次数成功");
}
jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndexs, tenUpList, tenListInstantiateUtil.instantiate(lineInfo), RedisDB.SHORT_TIME);
return httpResult;
}
@PostMapping(value = "getTenBreakList")
@ResponseBody
public HttpResult getTenBreakList(String startTime, String endTime,Boolean statFlag) {
HttpResult httpResult;
DatePojo datePojo = PubUtils.validateDate(startTime, endTime, "getTenBreakList");
if (!datePojo.getValidity()) {
httpResult = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误");
return httpResult;
}
List<LineInfo> lineInfo = new ArrayList<>();
String userIndex = TokenManager.getUserId();
byte[] userIndexs = stringInstantiateUtil.instantiate(userIndex);
try {
lineInfo = weeklyReportService.getTenList(datePojo.getStartTime(), datePojo.getEndTime(),3,statFlag);
} catch (Exception e) {
return PubUtils.assignmentResult(null, 500, "短时中断数据获取失败");
}
if (null == lineInfo) {
httpResult = PubUtils.assignmentResult(null, 500, "无暂降数据");
} else {
httpResult = PubUtils.assignmentResult(lineInfo, 200, "获取短时中断次数成功");
}
jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndexs, tenBreakList, tenListInstantiateUtil.instantiate(lineInfo), RedisDB.SHORT_TIME);
return httpResult;
}
}

View File

@@ -0,0 +1,58 @@
package com.pqs9200.listener;
import com.njcn.utils.PubUtils;
import com.pqs9200.utils.JavaKafkaConsumer;
import com.njcn.utils.Kafka.ZookeeperServerStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class ContextListener implements ServletContextListener {
private JavaKafkaConsumer javaKafkaConsumer = null;
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(ContextListener.class);
@Override
public void contextInitialized(ServletContextEvent sce) {
//读取配置文件
/* 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();
//启动Kafka
try {
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,29 @@
package com.pqs9200.mapper.advanced;
import com.pqs9200.pojo.data.SvgCalucateInfo;
import com.pqs9200.pojo.data.SvgCells;
import com.pqs9200.pojo.data.SvgSensitivePoint;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SvgMapper {
SvgCells getSvgCells(@Param("cellId") Integer cellId);
int saveCell(SvgCells svgCells);
int updateCell(SvgCells svgCells);
List<Integer> getAllCellsId();
void deleteCell(@Param("list") List<Integer> list);
List<SvgCells> getAllCells();
int saveSensitivePoint(SvgSensitivePoint svgSensitivePoint);
List<SvgCalucateInfo> getAllCalucateInfo();
int deleteCalucateInfo(@Param("index") String index);
}

View File

@@ -0,0 +1,26 @@
package com.pqs9200.mapper.weeklyreport;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.njcn.pojo.commons.device.LineInfo;
import com.njcn.pojo.data.LineMaps;
import com.pqs9200.serviceimpl.weeklyreport.WeeklyReportServiceImpl.Info;
public interface GetAreaPointInfoMapper {
Integer getOnline(@Param("gdIndexs") List<Integer> list); // 统计在线监测点个数(离线个数=监测点ID集合长度-在线个数)
Integer getEventCount(@Param("lineIndexs") List<Integer> list, @Param("start") Date start, @Param("end") Date end); // 统计暂降事件个数
Integer getBreakCount(@Param("lineIndexs") List<Integer> list, @Param("start") Date start, @Param("end") Date end); // 统计中断事件个数
Integer getUpCount(@Param("lineIndexs") List<Integer> list, @Param("start") Date start, @Param("end") Date end); // 统计暂升事件个数
List<Info> getLineInfo(@Param("deptIndexs") List<String> list, @Param("systype") String systype);
List<LineMaps> getMapsBylines(@Param("list") List<Integer> list);
List<LineInfo> getTenList(@Param("start") Date start, @Param("end") Date end,@Param("wavetype") Integer wavetype,@Param("list")List<Integer> list);
}

View File

@@ -0,0 +1,14 @@
package com.pqs9200.mapper.weeklyreport;
import java.util.Date;
import java.util.List;
import com.pqs9200.pojo.weeklyreport.ResultReason;
import org.apache.ibatis.annotations.Param;
public interface GetSagReasonMapper {
List<ResultReason> getReasonName();
List<ResultReason> getTotal(@Param("startTime") Date start, @Param("endTime") Date end,
@Param("lineId") List<Integer> list);
}

View File

@@ -0,0 +1,14 @@
package com.pqs9200.mapper.weeklyreport;
import com.njcn.pojo.configuration.DicData;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface GetVoltageInfoMapper {
List<DicData> getVoltageData();
List<Integer> getLineIndex(@Param("scal") String scal, @Param("gdIndex") List<Integer> list);
Integer getOnLine(@Param("LineIndexs") List<Integer> list);
}

View File

@@ -0,0 +1,26 @@
package com.pqs9200.pojo.commons.device;
import com.njcn.pojo.commons.device.DeviceValue;
import com.njcn.pojo.data.LineMaps;
import java.io.Serializable;
import java.util.List;
public class DevMapInfo implements Serializable{
private List<LineMaps> maps;
private List<DeviceValue> online;
public List<LineMaps> getMaps() {
return maps;
}
public void setMaps(List<LineMaps> maps) {
this.maps = maps;
}
public List<DeviceValue> getOnline() {
return online;
}
public void setOnline(List<DeviceValue> online) {
this.online = online;
}
}

View File

@@ -0,0 +1,76 @@
package com.pqs9200.pojo.data;
import java.io.Serializable;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2021/12/14 10:58
*/
public class SvgAllCells implements Serializable {
private List<Integer> lineArr;
private List<Integer> sensitiveArr;
private List<Integer> substationArr;
private List<Integer> powerArr;
private List<Integer> transformerArr;
public List<Integer> getLineArr() {
return lineArr;
}
public void setLineArr(List<Integer> lineArr) {
this.lineArr = lineArr;
}
public List<Integer> getSensitiveArr() {
return sensitiveArr;
}
public void setSensitiveArr(List<Integer> sensitiveArr) {
this.sensitiveArr = sensitiveArr;
}
public List<Integer> getSubstationArr() {
return substationArr;
}
public void setSubstationArr(List<Integer> substationArr) {
this.substationArr = substationArr;
}
public List<Integer> getPowerArr() {
return powerArr;
}
public void setPowerArr(List<Integer> powerArr) {
this.powerArr = powerArr;
}
public List<Integer> getTransformerArr() {
return transformerArr;
}
public void setTransformerArr(List<Integer> transformerArr) {
this.transformerArr = transformerArr;
}
@Override
public String toString() {
return "SvgAllCells{" +
"lineArr=" + lineArr +
", sensitiveArr=" + sensitiveArr +
", substationArr=" + substationArr +
", powerArr=" + powerArr +
", transformerArr=" + transformerArr +
'}';
}
}

View File

@@ -0,0 +1,78 @@
package com.pqs9200.pojo.data;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2021/12/23 14:08
*/
public class SvgCalucateInfo {
private String calucateIndex;
private String cellName;
private Float amplitude;
private String descentType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date timeId;
public String getCalucateIndex() {
return calucateIndex;
}
public void setCalucateIndex(String calucateIndex) {
this.calucateIndex = calucateIndex;
}
public String getCellName() {
return cellName;
}
public void setCellName(String cellName) {
this.cellName = cellName;
}
public Float getAmplitude() {
return amplitude;
}
public void setAmplitude(Float amplitude) {
this.amplitude = amplitude;
}
public String getDescentType() {
return descentType;
}
public void setDescentType(String descentType) {
this.descentType = descentType;
}
public Date getTimeId() {
return timeId;
}
public void setTimeId(Date timeId) {
this.timeId = timeId;
}
@Override
public String toString() {
return "SvgCalucateInfo{" +
"calucateIndex='" + calucateIndex + '\'' +
", cellName='" + cellName + '\'' +
", amplitude=" + amplitude +
", descentType='" + descentType + '\'' +
", timeId=" + timeId +
'}';
}
}

View File

@@ -0,0 +1,230 @@
package com.pqs9200.pojo.data;
import java.io.Serializable;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2021/12/13 11:18
*/
public class SvgCells implements Serializable {
//图元id
private Integer cellIndex;
//图元名称
private String cellName;
//电缆长度
private Float cableLength;
//电压等级
private Float cellLevel;
//正序电阻
private Float positiveSequenceResistance;
//正序电抗
private Float positiveSequenceReactance;
//零序电阻
private Float zeroSequenceResistance;
//零序电抗
private Float zeroSequenceReactance;
//转换系数
private Float coefficient;
//暂降敏感点关联一次接线图
private String wiringDiagram;
//图元类型 1:电缆 2:暂降敏感点 3:变电站 4:发电厂 5:变压器
private Integer cellType;
//创建者
private String createBy;
//创建时间
private String createTime;
//更新者
private String updateBy;
//更新时间
private String updateTime;
//变电站运行电压
private Float runLevel;
//变压器正序导纳
private Float positiveAdmittance;
//变压器零序导纳
private Float zeroAdmittance;
//图元状态 0:删除 1:正常
private Integer state;
public Integer getCellIndex() {
return cellIndex;
}
public void setCellIndex(Integer cellIndex) {
this.cellIndex = cellIndex;
}
public String getCellName() {
return cellName;
}
public void setCellName(String cellName) {
this.cellName = cellName;
}
public Float getCableLength() {
return cableLength;
}
public void setCableLength(Float cableLength) {
this.cableLength = cableLength;
}
public Float getCellLevel() {
return cellLevel;
}
public void setCellLevel(Float cellLevel) {
this.cellLevel = cellLevel;
}
public Float getPositiveSequenceResistance() {
return positiveSequenceResistance;
}
public void setPositiveSequenceResistance(Float positiveSequenceResistance) {
this.positiveSequenceResistance = positiveSequenceResistance;
}
public Float getPositiveSequenceReactance() {
return positiveSequenceReactance;
}
public void setPositiveSequenceReactance(Float positiveSequenceReactance) {
this.positiveSequenceReactance = positiveSequenceReactance;
}
public Float getZeroSequenceResistance() {
return zeroSequenceResistance;
}
public void setZeroSequenceResistance(Float zeroSequenceResistance) {
this.zeroSequenceResistance = zeroSequenceResistance;
}
public Float getZeroSequenceReactance() {
return zeroSequenceReactance;
}
public void setZeroSequenceReactance(Float zeroSequenceReactance) {
this.zeroSequenceReactance = zeroSequenceReactance;
}
public Float getCoefficient() {
return coefficient;
}
public void setCoefficient(Float coefficient) {
this.coefficient = coefficient;
}
public Integer getCellType() {
return cellType;
}
public void setCellType(Integer cellType) {
this.cellType = cellType;
}
public String getWiringDiagram() {
return wiringDiagram;
}
public void setWiringDiagram(String wiringDiagram) {
this.wiringDiagram = wiringDiagram;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public Float getRunLevel() {
return runLevel;
}
public void setRunLevel(Float runLevel) {
this.runLevel = runLevel;
}
public Float getPositiveAdmittance() {
return positiveAdmittance;
}
public void setPositiveAdmittance(Float positiveAdmittance) {
this.positiveAdmittance = positiveAdmittance;
}
public Float getZeroAdmittance() {
return zeroAdmittance;
}
public void setZeroAdmittance(Float zeroAdmittance) {
this.zeroAdmittance = zeroAdmittance;
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
@Override
public String toString() {
return "SvgCells{" +
"cellIndex=" + cellIndex +
", cellName='" + cellName + '\'' +
", cableLength=" + cableLength +
", cellLevel=" + cellLevel +
", positiveSequenceResistance=" + positiveSequenceResistance +
", positiveSequenceReactance=" + positiveSequenceReactance +
", zeroSequenceResistance=" + zeroSequenceResistance +
", zeroSequenceReactance=" + zeroSequenceReactance +
", coefficient=" + coefficient +
", wiringDiagram='" + wiringDiagram + '\'' +
", cellType=" + cellType +
", createBy='" + createBy + '\'' +
", createTime='" + createTime + '\'' +
", updateBy='" + updateBy + '\'' +
", updateTime='" + updateTime + '\'' +
", runLevel=" + runLevel +
", positiveAdmittance=" + positiveAdmittance +
", zeroAdmittance=" + zeroAdmittance +
", state=" + state +
'}';
}
}

View File

@@ -0,0 +1,87 @@
package com.pqs9200.pojo.data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2021/12/14 10:58
*/
public class SvgSagDomain implements Serializable {
//暂降幅值
private double dip;
//暂降类型
private Integer eventType;
//触发点
private Integer eventPoint;
//存放所有参与计算的节点信息
private Map<String,Integer> nodesMap;
//变电站线路
private List<String> lines_substation;
//变压器线路
private List<String> lines_transformer;
public double getDip() {
return dip;
}
public void setDip(double dip) {
this.dip = dip;
}
public Integer getEventType() {
return eventType;
}
public void setEventType(Integer eventType) {
this.eventType = eventType;
}
public Map<String, Integer> getNodesMap() {
return nodesMap;
}
public Integer getEventPoint() {
return eventPoint;
}
public void setEventPoint(Integer eventPoint) {
this.eventPoint = eventPoint;
}
public void setNodesMap(Map<String, Integer> nodesMap) {
this.nodesMap = nodesMap;
}
public List<String> getLines_substation() {
return lines_substation;
}
public void setLines_substation(List<String> lines_substation) {
this.lines_substation = lines_substation;
}
public List<String> getLines_transformer() {
return lines_transformer;
}
public void setLines_transformer(List<String> lines_transformer) {
this.lines_transformer = lines_transformer;
}
@Override
public String toString() {
return "SvgSagDomain{" +
"dip=" + dip +
"nodesMap=" + nodesMap +
"nodesMap=" + nodesMap +
", lines_substation=" + lines_substation +
", lines_transformer=" + lines_transformer +
'}';
}
}

View File

@@ -0,0 +1,76 @@
package com.pqs9200.pojo.data;
import java.io.Serializable;
import java.util.Date;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2021/12/22 20:31
*/
public class SvgSensitivePoint implements Serializable {
//UUID
private String uuidIndex;
//暂降敏感点ID
private Integer cellIndex;
//暂降幅值
private Float amplitude;
//暂降类型
private Integer descentType;
//发生时刻
private String time;
public String getUuidIndex() {
return uuidIndex;
}
public void setUuidIndex(String uuidIndex) {
this.uuidIndex = uuidIndex;
}
public Integer getCellIndex() {
return cellIndex;
}
public void setCellIndex(Integer cellIndex) {
this.cellIndex = cellIndex;
}
public Float getAmplitude() {
return amplitude;
}
public void setAmplitude(Float amplitude) {
this.amplitude = amplitude;
}
public Integer getDescentType() {
return descentType;
}
public void setDescentType(Integer descentType) {
this.descentType = descentType;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
@Override
public String toString() {
return "SvgSensitivePoint{" +
"uuidIndex='" + uuidIndex + '\'' +
", cellIndex=" + cellIndex +
", amplitude=" + amplitude +
", descentType=" + descentType +
", time='" + time + '\'' +
'}';
}
}

View File

@@ -0,0 +1,22 @@
package com.pqs9200.pojo.data;
public class VdlistWaveRVO {
private String len;
private VdlistWaveVO data;
public String getLen() {
return len;
}
public void setLen(String len) {
this.len = len;
}
public VdlistWaveVO getData() {
return data;
}
public void setData(VdlistWaveVO data) {
this.data = data;
}
}

View File

@@ -0,0 +1,31 @@
package com.pqs9200.pojo.data;
public class VdlistWaveVO {
private String type;
private Long LineId;
private Long ComtradeName;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getLineId() {
return LineId;
}
public void setLineId(Long lineId) {
LineId = lineId;
}
public Long getComtradeName() {
return ComtradeName;
}
public void setComtradeName(Long comtradeName) {
ComtradeName = comtradeName;
}
}

View File

@@ -0,0 +1,24 @@
package com.pqs9200.pojo.map;
import java.util.List;
public class BaseMap {
private List<BaseMapDetail> features;
private String type;
public List<BaseMapDetail> getFeatures() {
return features;
}
public void setFeatures(List<BaseMapDetail> features) {
this.features = features;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@@ -0,0 +1,31 @@
package com.pqs9200.pojo.map;
public class BaseMapDetail {
private String type;
private BaseMapDetailRVO geometry;
private BaseMapProperties properties;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public BaseMapDetailRVO getGeometry() {
return geometry;
}
public void setGeometry(BaseMapDetailRVO geometry) {
this.geometry = geometry;
}
public BaseMapProperties getProperties() {
return properties;
}
public void setProperties(BaseMapProperties properties) {
this.properties = properties;
}
}

View File

@@ -0,0 +1,24 @@
package com.pqs9200.pojo.map;
import net.sf.json.JSONArray;
public class BaseMapDetailRVO {
private String type;
private Object coordinates;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Object getCoordinates() {
return coordinates;
}
public void setCoordinates(Object coordinates) {
this.coordinates = coordinates;
}
}

View File

@@ -0,0 +1,40 @@
package com.pqs9200.pojo.map;
public class BaseMapProperties {
private int childNum;
private int id;
private String name;
private float[] cp;
public int getChildNum() {
return childNum;
}
public void setChildNum(int childNum) {
this.childNum = childNum;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float[] getCp() {
return cp;
}
public void setCp(float[] cp) {
this.cp = cp;
}
}

View File

@@ -0,0 +1,72 @@
package com.pqs9200.pojo.weeklyreport;
import java.io.Serializable;
public class AreaPointInfo implements Comparable<AreaPointInfo>,Serializable {
private String name; // 名称
private int onLine; // 监测点在线个数
private int offLine;// 监测点离线个数
private int eventCount;// 发生的暂降个数
private int breakCount;//中断次数
private int upCount;//暂升次数
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getOnLine() {
return onLine;
}
public void setOnLine(int onLine) {
this.onLine = onLine;
}
public int getOffLine() {
return offLine;
}
public void setOffLine(int offLine) {
this.offLine = offLine;
}
public int getEventCount() {
return eventCount;
}
public void setEventCount(int eventCount) {
this.eventCount = eventCount;
}
public int getBreakCount() {
return breakCount;
}
public void setBreakCount(int breakCount) {
this.breakCount = breakCount;
}
public int getUpCount() {
return upCount;
}
public void setUpCount(int upCount) {
this.upCount = upCount;
}
@Override
public int compareTo(AreaPointInfo arg0) {
int result = (arg0.offLine + arg0.onLine) - (this.offLine + this.onLine);
if (result != 0) {
return result;
}
return arg0.eventCount - this.eventCount;
}
}

View File

@@ -0,0 +1,40 @@
package com.pqs9200.pojo.weeklyreport;
public class ResultReason {
private Integer total;
private String dicindex;
private String eventreason;
private String name;
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
public String getDicindex() {
return dicindex;
}
public void setDicindex(String dicindex) {
this.dicindex = dicindex;
}
public String getEventreason() {
return eventreason;
}
public void setEventreason(String eventreason) {
this.eventreason = eventreason;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -0,0 +1,41 @@
package com.pqs9200.pojo.weeklyreport;
import java.io.Serializable;
public class SagRate implements Serializable {
private String name;
private Integer count;
private Float rate;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Float getRate() {
return rate;
}
public void setRate(Float rate) {
// 保留两位小数
if (rate == null) {
this.rate = 0f;
return;
}
float f1 = (float) (Math.round(rate.floatValue() * 100)) / 100;
this.rate = new Float(f1);
}
}

View File

@@ -0,0 +1,52 @@
package com.pqs9200.service.advanced;
import com.njcn.utils.sagDomain.DipZoneModel;
import com.pqs9200.pojo.data.*;
import java.io.IOException;
import java.util.List;
/**
* @author hongawen
* @version 1.0.0
* @date 2021年12月07日 10:18
*/
public interface SvgService {
/**
* 保存指定文件的svg图形
* @param fileName 文件名
* @param xml xml数据
* @param svg svg数据
* @return .
*/
String saveSvg(String fileName, String xml, String svg) throws IOException;
/**
* 获取svg数据
* @param index 所选svg的uuid
* @param type 数据类型
* @return .
*/
String loadSvg(String index, String type) throws IOException;
/**
* create by: xu yang
* description: 保存图元信息
* create time: 2021/12/13 14:59
*/
void saveCell(SvgCells svgCells);
SvgCells getCell(Integer cellIndex);
void saveAllCells(SvgAllCells svgAllCells);
List<SvgCells> getAllCells();
DipZoneModel[] getSagDomain(SvgSagDomain svgSagDomain);
void saveSensitivePoint(SvgSensitivePoint svgSensitivePoint);
List<SvgCalucateInfo> getAllCalucateInfo();
int deleteCalucateInfo(String index);
}

View File

@@ -0,0 +1,59 @@
package com.pqs9200.service.area;
import java.util.Date;
import java.util.List;
import com.njcn.pojo.commons.Level;
import com.njcn.pojo.commons.area.AreaGeneral;
import com.njcn.pojo.commons.area.Iec28;
import com.njcn.pojo.commons.device.EventCause;
import com.njcn.pojo.commons.device.EventChance;
import com.njcn.pojo.commons.device.EventDataList;
import com.njcn.pojo.commons.device.EventDensity;
import com.njcn.pojo.commons.device.EventTypeList;
import com.njcn.pojo.commons.device.LineInfo;
import com.pqs9200.pojo.commons.device.DevMapInfo;
import com.pqs9200.pojo.map.BaseMap;
/**
* @author hongawen
* @Date: 2018/11/2 11:31
*/
public interface IAreaService {
// 根据区域、起始时间、截止时间获取暂降数据
AreaGeneral getGeneralDate(String area, Date sTime, Date eTime);
//概览区域数据
AreaGeneral getGeneralDate(Date sTime, Date eTime);
//根据用户选择区域查询严重度分析的结果
Level queryLevel(String area, Date startTime, Date endTime);
//根据用户选择区域查询严重度分析的结果
Level queryLevel(Date sTime, Date eTime);
public List<EventDensity> getEventDensity(Date startTime,Date endTime,String area);
public List<EventDataList> getEventDataList(Date startTime,Date endTime,String area);
public List<List> getEventDisdip(Date startTime,Date endTime,String area);
public List<List> getIEC411(Date startTime,Date endTime,String area);
public Iec28 getIEC28(Date startTime,Date endTime,String area);
public EventChance getEventChance(Date startTime,Date endTime,String area);
public List<EventCause> getEventCause(Date startTime,Date endTime,String area);
public List<EventTypeList> getEventType(Date startTime,Date endTime,String area);
public List<LineInfo> getEventMaps(Date startTime,Date endTime);
public List<LineInfo> getGdcounts(Date startTime,Date endTime);
DevMapInfo getDevMap(String area);
BaseMap getBase(String jsonStr);
}

View File

@@ -0,0 +1,21 @@
package com.pqs9200.service.data;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @author hongawen
* @Date: 2018/11/2 13:58
*/
public interface IEventPzService {
List<List> getZjsj();
/**
* 处理暂降推送事件
* @author cdf
* @date 2022/7/15
*/
boolean dealEventWarn(List<String> eventIds);
}

View File

@@ -0,0 +1,29 @@
package com.pqs9200.service.data;
import com.njcn.pojo.data.GridTop;
import com.njcn.pojo.data.LineMaps;
import com.pqs9200.pojo.commons.device.DevMapInfo;
import java.util.List;
public interface IOverviewServer {
/****************************
* 获取监测点地理信息地图数据
****************************/
List<LineMaps> getLineMaps();
/****************************
* 获取网络拓扑图数据
****************************/
List<GridTop> getGridTop();
/*******************************
* 获取监测点的经纬度及相应的信息根据归一化GUID
* *****************************/
List<LineMaps> queryLineMapByAssID(String eventass_index);
DevMapInfo getDevMap();
}

View File

@@ -0,0 +1,11 @@
package com.pqs9200.service.data;
public interface VersionService {
/**
* @Author denghuajun
* @Description
* @Date 14:45 2020/9/18
*/
String sentLineWave( String type, Long LineId,Long ComtradeName);
}

View File

@@ -0,0 +1,24 @@
package com.pqs9200.service.weeklyreport;
import java.util.Date;
import java.util.List;
import com.njcn.pojo.advanced.SagEvent;
import com.njcn.pojo.commons.device.LineInfo;
import com.pqs9200.pojo.weeklyreport.AreaPointInfo;
import com.pqs9200.pojo.weeklyreport.SagRate;
public interface WeeklyReportService {
List<AreaPointInfo> getPointData(Date start, Date end,Boolean statFlag);
List<AreaPointInfo> getVoltageData(Date start, Date end,Boolean statFlag);
List<SagEvent> getSagData(Date start, Date end,Boolean statFlag);
List<SagRate> getSagReasonData(Date start, Date end,Boolean statFlag);
List<SagEvent> getSagEvents(Date start, Date end,Boolean statFlag);
List<LineInfo> getTenList(Date start, Date end, Integer wavetype,Boolean statFlag);
}

View File

@@ -0,0 +1,441 @@
package com.pqs9200.serviceimpl.advanced;
import cn.hutool.core.collection.CollectionUtil;
import com.njcn.enums.ResultStatusEnum;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.AppConfig;
import com.njcn.utils.PubUtils;
import com.njcn.utils.sagDomain.Complex;
import com.njcn.utils.sagDomain.DipZoneModel;
import com.njcn.utils.sagDomain.SagDomainUtils;
import com.pqs9200.mapper.advanced.SvgMapper;
import com.pqs9200.pojo.data.*;
import com.pqs9200.service.advanced.SvgService;
import com.pqs9200.utils.SagDomain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author hongawen
* @version 1.0.0
* @date 2021年12月07日 10:19
*/
@Service
public class SvgServiceImpl implements SvgService {
@Autowired
private AppConfig appConfig;
@Autowired
private SvgMapper svgMapper;
@Override
public String saveSvg(String fileName, String xml, String svg) throws IOException {
String svgDirPath = appConfig.getTmppath() + File.separator + "svg" + File.separator + fileName ;
File dirFile = new File(svgDirPath);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
// String xmlPath = svgDirPath + File.separator + "svgDomain.xml";
// String svgPath = svgDirPath + File.separator + "svgDomain.svg";
String xmlPath = svgDirPath + File.separator + fileName + ".xml";
String svgPath = svgDirPath + File.separator + fileName + ".svg";
File xmlFile = new File(xmlPath);
if (!xmlFile.exists()) {
xmlFile.createNewFile();
}
FileWriter xmlWriter = new FileWriter(xmlPath);
xmlWriter.write(xml);
xmlWriter.flush();
xmlWriter.close();
File svgFile = new File(svgPath);
if (!svgFile.exists()) {
svgFile.createNewFile();
}
FileWriter svgWriter = new FileWriter(svgPath);
svgWriter.write(svg);
svgWriter.flush();
svgWriter.close();
return ResultStatusEnum.SUCCESS.getMessage();
}
@Override
public String loadSvg(String index,String type) throws IOException {
String xml;
String svgDirPath = appConfig.getTmppath() + File.separator + "svg" + File.separator + index;
File dirFile = new File(svgDirPath);
if (!dirFile.exists()) {
return ResultStatusEnum.NO_SVG_FILE.getMessage();
}
File[] files = dirFile.listFiles();
if (null == files) {
return ResultStatusEnum.NO_SVG_FILE.getMessage();
}
List<File> fileList = Stream.of(files).filter(file -> file.getName().endsWith(type)).collect(Collectors.toList());
if (CollectionUtil.isEmpty(fileList)) {
return ResultStatusEnum.NO_SVG_FILE.getMessage();
} else {
//默认读取第一xml文件的内容除非指定文件名
File xmlFile = fileList.get(0);
List<String> lines = Files.readAllLines(Paths.get(xmlFile.getPath()),
StandardCharsets.UTF_8);
xml = String.join("", lines);
}
return xml;
}
@Override
public void saveCell(SvgCells svgCells) {
Date time = new Date();
SimpleDateFormat sbf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String strUserGuid = TokenManager.getToken().getUserIndex();
SvgCells cell = svgMapper.getSvgCells(svgCells.getCellIndex());
if (Objects.isNull(cell)){
svgCells.setCreateBy(strUserGuid);
svgCells.setCreateTime(sbf.format(time));
svgMapper.saveCell(svgCells);
} else {
svgCells.setCreateBy(cell.getCreateBy());
svgCells.setCreateTime(cell.getCreateTime());
svgCells.setUpdateBy(strUserGuid);
svgCells.setUpdateTime(sbf.format(time));
svgMapper.updateCell(svgCells);
}
}
@Override
public SvgCells getCell(Integer cellIndex) {
return svgMapper.getSvgCells(cellIndex);
}
@Override
public void saveAllCells(SvgAllCells svgAllCells) {
Date time = new Date();
SimpleDateFormat sbf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String strUserGuid = TokenManager.getToken().getUserIndex();
List<Integer> lineArr = svgAllCells.getLineArr();
if (!CollectionUtils.isEmpty(lineArr)){
for (Integer id : lineArr) {
SvgCells cell = svgMapper.getSvgCells(id);
if (Objects.isNull(cell)){
SvgCells svgCells = new SvgCells();
svgCells.setCellIndex(id);
svgCells.setCellName("电缆");
svgCells.setCableLength(1f);
svgCells.setCellLevel(110f);
svgCells.setPositiveSequenceResistance(0.132f);
svgCells.setPositiveSequenceReactance(0.388f);
svgCells.setZeroSequenceResistance(0.33f);
svgCells.setZeroSequenceReactance(0.97f);
svgCells.setCoefficient(2.5f);
svgCells.setCellType(1);
svgCells.setWiringDiagram("/");
svgCells.setCreateBy(strUserGuid);
svgCells.setCreateTime(sbf.format(time));
svgCells.setRunLevel(0f);
svgCells.setState(1);
svgMapper.saveCell(svgCells);
}
}
}
List<Integer> sensitiveArr = svgAllCells.getSensitiveArr();
if (!CollectionUtils.isEmpty(sensitiveArr)){
for (Integer id : sensitiveArr) {
SvgCells cell = svgMapper.getSvgCells(id);
if (Objects.isNull(cell)){
SvgCells svgCells = new SvgCells();
svgCells.setCellIndex(id);
svgCells.setCellName(id.toString());
svgCells.setCableLength(0f);
svgCells.setCellLevel(110f);
svgCells.setPositiveSequenceResistance(0f);
svgCells.setPositiveSequenceReactance(0f);
svgCells.setZeroSequenceResistance(0f);
svgCells.setZeroSequenceReactance(0f);
svgCells.setCoefficient(0f);
svgCells.setCellType(2);
svgCells.setWiringDiagram("/");
svgCells.setCreateBy(strUserGuid);
svgCells.setCreateTime(sbf.format(time));
svgCells.setRunLevel(0f);
svgCells.setState(1);
svgMapper.saveCell(svgCells);
}
}
}
List<Integer> substationArr = svgAllCells.getSubstationArr();
if (!CollectionUtils.isEmpty(substationArr)){
for (Integer id : substationArr) {
SvgCells cell = svgMapper.getSvgCells(id);
if (Objects.isNull(cell)){
SvgCells svgCells = new SvgCells();
svgCells.setCellIndex(id);
svgCells.setCellName(id.toString());
svgCells.setCableLength(0f);
svgCells.setCellLevel(110f);
svgCells.setPositiveSequenceResistance(0f);
svgCells.setPositiveSequenceReactance(0f);
svgCells.setZeroSequenceResistance(0f);
svgCells.setZeroSequenceReactance(0f);
svgCells.setCoefficient(0f);
svgCells.setCellType(3);
svgCells.setWiringDiagram("/");
svgCells.setCreateBy(strUserGuid);
svgCells.setCreateTime(sbf.format(time));
svgCells.setRunLevel(110f);
svgCells.setState(1);
svgMapper.saveCell(svgCells);
}
}
}
List<Integer> powerArr = svgAllCells.getPowerArr();
if (!CollectionUtils.isEmpty(powerArr)){
for (Integer id : powerArr) {
SvgCells cell = svgMapper.getSvgCells(id);
if (Objects.isNull(cell)){
SvgCells svgCells = new SvgCells();
svgCells.setCellIndex(id);
svgCells.setCellName(id.toString());
svgCells.setCableLength(0f);
svgCells.setCellLevel(0f);
svgCells.setPositiveSequenceResistance(0.132f);
svgCells.setPositiveSequenceReactance(0.388f);
svgCells.setZeroSequenceResistance(0.33f);
svgCells.setZeroSequenceReactance(0.97f);
svgCells.setCoefficient(2.5f);
svgCells.setCellType(4);
svgCells.setWiringDiagram("/");
svgCells.setCreateBy(strUserGuid);
svgCells.setCreateTime(sbf.format(time));
svgCells.setRunLevel(0f);
svgCells.setState(1);
svgMapper.saveCell(svgCells);
}
}
}
List<Integer> transformerArr = svgAllCells.getTransformerArr();
if (!CollectionUtils.isEmpty(transformerArr)){
for (Integer id : transformerArr) {
SvgCells cell = svgMapper.getSvgCells(id);
if (Objects.isNull(cell)){
SvgCells svgCells = new SvgCells();
svgCells.setCellIndex(id);
svgCells.setCellName(id.toString());
svgCells.setCableLength(0f);
svgCells.setCellLevel(110f);
svgCells.setPositiveSequenceResistance(0.132f);
svgCells.setPositiveSequenceReactance(0.388f);
svgCells.setZeroSequenceResistance(0.33f);
svgCells.setZeroSequenceReactance(0.97f);
svgCells.setCoefficient(2.5f);
svgCells.setCellType(5);
svgCells.setWiringDiagram("/");
svgCells.setCreateBy(strUserGuid);
svgCells.setCreateTime(sbf.format(time));
svgCells.setRunLevel(0f);
svgCells.setState(1);
svgMapper.saveCell(svgCells);
}
}
}
//清理多余的图元信息
List<Integer> list = new ArrayList<>();
list.addAll(lineArr);
list.addAll(sensitiveArr);
list.addAll(substationArr);
list.addAll(powerArr);
list.addAll(transformerArr);
List<Integer> cellsList = svgMapper.getAllCellsId();
cellsList.removeAll(list);
if (!CollectionUtils.isEmpty(cellsList)){
svgMapper.deleteCell(cellsList);
}
}
@Override
public List<SvgCells> getAllCells() {
return svgMapper.getAllCells();
}
@Override
public DipZoneModel[] getSagDomain(SvgSagDomain svgSagDomain) {
Map nodesMap = svgSagDomain.getNodesMap();
List<String> lines_substation = svgSagDomain.getLines_substation();
List<String> lines_transformer = svgSagDomain.getLines_transformer();
/// <summary>
/// 正序阻抗矩阵
/// 首段节点号 末端节点号 支路电阻 支路电抗 对地导纳
/// </summary>
int iNodeCount = nodesMap.size();//节点数量
int iLineCount = lines_substation.size();
int iAllCount = iLineCount + lines_transformer.size();//线路数量(线路+变压器)
double [][] Z1=new double[iAllCount][6];
// 零序阻抗矩阵
double [][] Z0=new double[iAllCount][5];
String[] splitNodes;//元素分割线
Integer nodesId = 0;//元素Id
Integer startId = 0;//起始Id
Integer endId = 0;//结束Id
double resistance = 0.0,reactance = 0.0,admittance = 0.0;//电阻,电抗,导纳
String tmpLineValue;//前端求得的string值
for(int i = 0;i < iAllCount; i++){
//主线线路
if (i < iLineCount){
tmpLineValue = lines_substation.get(i);
splitNodes =tmpLineValue.split("&");
//长度为2
if (splitNodes.length == 2){
String[] tmpSplitNodes = splitNodes[0].split("->");//元素分割线
if (tmpSplitNodes.length == 2){
nodesId = Integer.parseInt(splitNodes[1]);
startId = (Integer) nodesMap.get(tmpSplitNodes[0]);//通过Map做映射
endId = (Integer) nodesMap.get(tmpSplitNodes[1]);//通过Map做映射
}
}
//通过元素Id获取实体类
SvgCells tmpSvgCells =getCell(nodesId);
//电阻 =线路长度×单位电阻
resistance = tmpSvgCells.getCableLength() * tmpSvgCells.getPositiveSequenceResistance();
//电抗 =线路长度×单位电抗
reactance = tmpSvgCells.getCableLength() * tmpSvgCells.getPositiveSequenceReactance();
//对地导纳 = 2.8×10-6×线路长度
admittance = tmpSvgCells.getCableLength() * 2.8 * 1e-6;
//10Kv
if(tmpSvgCells.getCellLevel() == 10){
//电阻 =线路长度×单位电阻
resistance = resistance * Math.pow(10.0/110.0,2);
//电抗 =线路长度×单位电抗
reactance = reactance * Math.pow(10.0/110.0,2);
//对地导纳 = 2.8×10-6×线路长度
admittance = admittance * Math.pow(110.0/10.0,2);
}
Z1[i][0] = startId;
Z1[i][1] = endId;
Z1[i][2] = PubUtils.doubleRound(6,resistance);
Z1[i][3] = PubUtils.doubleRound(6,reactance);
Z1[i][4] = PubUtils.doubleRound(6,admittance);
Z1[i][5] = tmpSvgCells.getCableLength();//长度
//Z0为Z1的2.5倍
Z0[i][0] = startId;
Z0[i][1] = endId;
Z0[i][2] = PubUtils.doubleRound(6,resistance* tmpSvgCells.getCoefficient());
Z0[i][3] = PubUtils.doubleRound(6,reactance* tmpSvgCells.getCoefficient());
Z0[i][4] = PubUtils.doubleRound(6,admittance* tmpSvgCells.getCoefficient());
}
//变压器支线线路
else{
tmpLineValue = lines_transformer.get(i - iLineCount);
splitNodes =tmpLineValue.split("&");
//长度为2
if (splitNodes.length == 2){
String[] tmpSplitNodes = splitNodes[0].split("->");//元素分割线
if (tmpSplitNodes.length == 2){
nodesId = Integer.parseInt(splitNodes[1]);
startId = (Integer) nodesMap.get(tmpSplitNodes[0]);//通过Map做映射
endId = (Integer) nodesMap.get(tmpSplitNodes[1]);//通过Map做映射
}
}
//通过元素Id获取实体类
SvgCells tmpSvgCells =getCell(nodesId);
//电阻 = 电阻
resistance = tmpSvgCells.getPositiveSequenceResistance();
//电抗 = 电抗
reactance = tmpSvgCells.getPositiveSequenceReactance();
//对地导纳 = 直接取正序导纳
admittance = tmpSvgCells.getPositiveAdmittance();
Z1[i][0] = startId;
Z1[i][1] = endId;
Z1[i][2] = PubUtils.doubleRound(6,resistance);
Z1[i][3] = PubUtils.doubleRound(6,reactance);
Z1[i][4] = PubUtils.doubleRound(6,admittance);
//Z0为Z1的2.5倍
Z0[i][0] = startId;
Z0[i][1] = endId;
Z0[i][2] = PubUtils.doubleRound(6,resistance * tmpSvgCells.getCoefficient());
Z0[i][3] = PubUtils.doubleRound(6,reactance * tmpSvgCells.getCoefficient());
Z0[i][4] = PubUtils.doubleRound(6,tmpSvgCells.getZeroAdmittance());
}
}
Complex[] Vpre =new Complex[nodesMap.size()];
//赋值
for(int i =0; i < nodesMap.size();i++){
Complex complex =new Complex(0,0);
Vpre[i] = complex;
}
//计算故障前故障点电压
for (Object key : nodesMap.keySet()) {
int iKey = Integer.parseInt(key.toString());
int iValue = Integer.parseInt(nodesMap.get(key.toString()).toString());
//通过元素Id获取实体类
SvgCells tmpSvgCells =getCell(iKey);
double runVoltage = (double)tmpSvgCells.getRunLevel();//运行电压
double nominalVoltage = (double)tmpSvgCells.getCellLevel();//额定电压
//赋值
Vpre[iValue - 1] = SagDomainUtils.getVpre(runVoltage,nominalVoltage);
}
//开始进行暂降域计算
SagDomain sagDomain =new SagDomain();
int eventPoint = Integer.parseInt(nodesMap.get(svgSagDomain.getEventPoint().toString()).toString());
DipZoneModel[] Usag_area = sagDomain.analysisSagDomain(svgSagDomain.getDip()/100.0,svgSagDomain.getEventType(),eventPoint,iNodeCount,iLineCount,Z1,Z0,Vpre);
DipZoneModel[] Usag_Result =new DipZoneModel[Usag_area.length];
//暂降域映射处理
for (int i = 0;i < Usag_area.length; i++){
DipZoneModel dipZoneModel = Usag_area[i];
//计算故障前故障点电压
for (Object key : nodesMap.keySet()) {
int iKey = Integer.parseInt(key.toString());
int iValue = Integer.parseInt(nodesMap.get(key.toString()).toString());
if(iValue == dipZoneModel.head){
dipZoneModel.setHead(iKey);
}
if(iValue == dipZoneModel.tail){
dipZoneModel.setTail(iKey);
}
}
Usag_Result[i] = dipZoneModel;
}
return Usag_Result;
}
@Override
public void saveSensitivePoint(SvgSensitivePoint svgSensitivePoint) {
int row = svgMapper.saveSensitivePoint(svgSensitivePoint);
}
@Override
public List<SvgCalucateInfo> getAllCalucateInfo() {
return svgMapper.getAllCalucateInfo();
}
@Override
public int deleteCalucateInfo(String index) {
return svgMapper.deleteCalucateInfo(index);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,80 @@
package com.pqs9200.serviceimpl.data;
import com.njcn.mapper.data.EventPzMapper;
import com.njcn.pojo.commons.AreaGeneralData;
import com.njcn.pojo.commons.area.EventPz;
import com.njcn.service.user.DeptsService;
import com.njcn.utils.UserUtil;
import com.pqs9200.service.data.IEventPzService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
* @author hongawen
* @Date: 2018/11/2 13:59
*/
@Service
public class EventPzServiceImpl implements IEventPzService {
private static final Logger logger = LoggerFactory.getLogger(EventPzServiceImpl.class);
@Autowired
DeptsService depts;
@Autowired
private UserUtil userUtil;
@Autowired
EventPzMapper ep;
@Override
public List<List> getZjsj() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<List> eventList = new ArrayList<List>();
//增加用户判断部门信息并获取详细事件信息
List<AreaGeneralData> areaGeneral = userUtil.getAreaGeneral();
List<Integer> list = new ArrayList<>();
List<Integer> list1 = new ArrayList<>();
for (AreaGeneralData data : areaGeneral) {
Integer lineId = 0;
list = data.getLineIndexs();// 获取监测点ID
if (list.isEmpty() == false) {
for (int i = 0; i < list.size(); i++) {
lineId = list.get(i);
list1.add(lineId);
}
}
}
try {
List<EventPz> eventdetail = ep.getZjsj(list1);
if (eventdetail.isEmpty()) {
return eventList;
} else {
for (EventPz detail : eventdetail) {
List<String> temp = new ArrayList<String>();
temp.add(detail.getLineName());
temp.add(detail.getTime() + "."
+ detail.getMsec());
temp.add(detail.getPersistTime().toString());
temp.add(String.format("%.2f", detail.getEventValue() * 100));
temp.add(detail.getNameGD());
temp.add(detail.getNameBD());
temp.add(detail.getEventType());
eventList.add(temp);
}
}
} catch (Exception e) {
logger.error(e.getMessage());
}
return eventList;
}
@Override
public boolean dealEventWarn(List<String> eventIds){
ep.dealEventWarn(eventIds);
return true;
}
}

View File

@@ -0,0 +1,156 @@
package com.pqs9200.serviceimpl.data;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.njcn.mapper.data.GridTopMapper;
import com.njcn.mapper.data.LineMapsMapper;
import com.njcn.pojo.commons.AreaGeneralData;
import com.njcn.pojo.commons.device.DeviceValue;
import com.njcn.pojo.data.GridTop;
import com.njcn.pojo.data.LineMaps;
import com.njcn.utils.UserUtil;
import com.pqs9200.mapper.weeklyreport.GetAreaPointInfoMapper;
import com.pqs9200.pojo.commons.device.DevMapInfo;
import com.pqs9200.service.data.IOverviewServer;
@Service
public class OverViewServiceImpl implements IOverviewServer {
@Autowired
private LineMapsMapper lineMapsMapper;
@Autowired
private GridTopMapper gridTopMapper;
@Autowired
private GetAreaPointInfoMapper areaPointInfoMapper;
@Autowired
private UserUtil userUtil;
@Override
public List<LineMaps> getLineMaps() {
List<LineMaps> vdLists=new ArrayList<LineMaps>();
List<Integer> lineList = userUtil.listLine();
if(!lineList.isEmpty()){
List<Integer> lineIndexsTemp = new ArrayList<>(lineList);
if (lineIndexsTemp.size() > 100) {
int size = lineIndexsTemp.size() / 100 + 1;
for (int i = 0; i < size; i++) {
if (lineIndexsTemp.size() > 100) {
List<Integer> tempLineIndexs = lineIndexsTemp.subList(0, 100);
List<LineMaps> tmplist = lineMapsMapper.queryLineMaps(tempLineIndexs);//返回的监测点的地理信息
vdLists.addAll(tmplist);
tempLineIndexs.clear();
} else {
List<LineMaps> tmplist = lineMapsMapper.queryLineMaps(lineIndexsTemp);//返回的监测点的地理信息
vdLists.addAll(tmplist);
}
}
} else {
vdLists = lineMapsMapper.queryLineMaps(lineIndexsTemp);//返回的监测点的地理信息
}
}
return vdLists;
}
@Override
public DevMapInfo getDevMap() {
DevMapInfo result = new DevMapInfo();
List<LineMaps> vdLists=new ArrayList<>();
List<DeviceValue> devcount = new ArrayList<>();
List<AreaGeneralData> areaGeneral = userUtil.getAreaGeneralRun();
int total = 0,ontotal=0,offtotal=0;
for (AreaGeneralData areaGeneralData : areaGeneral) {
int oncount=0;
int offcount=0;
DeviceValue tmp = new DeviceValue();
tmp.setName(areaGeneralData.getName());
List<Integer> indexs = areaGeneralData.getLineIndexs();
tmp.setAmounts(String.valueOf(indexs.size()));
// for(Integer index : indexs){
// LineMaps linemap = new LineMaps();
// linemap.setLineindex(index);
// linemap=lineMapsMapper.selectOne(linemap);
// if(null==linemap){
// continue;
// }
// vdLists.add(linemap);
// if (Integer.valueOf("0").equals(linemap.getStatus())) {
// offcount++;
// } else {
// oncount++;
// }
// }
if(indexs.size() == 0){
continue;
}
List<LineMaps> tmplist = new ArrayList<>();
tmplist = areaPointInfoMapper.getMapsBylines(indexs);
vdLists.addAll(tmplist);
for(LineMaps tmap : tmplist){
if(Integer.valueOf("0").equals(tmap.getStatus())){
offcount++;
}else{
oncount++;
}
}
tmp.setOncount(oncount);
tmp.setOffcount(offcount);
devcount.add(tmp);
total = total + indexs.size();
ontotal = ontotal + oncount;
offtotal = offtotal + offcount;
}
Collections.sort(devcount, new Comparator<DeviceValue>(){
/*
* int compare(Person p1, Person p2) 返回一个基本类型的整型,
* 返回负数表示p1 小于p2
* 返回0 表示p1和p2相等
* 返回正数表示p1大于p2
*/
public int compare(DeviceValue p1, DeviceValue p2) {
//按照Person的年龄进行升序排列
if(Integer.parseInt(p2.getAmounts()) > Integer.parseInt(p1.getAmounts())){
return 1;
}
if(Integer.parseInt(p2.getAmounts()) == Integer.parseInt(p1.getAmounts())){
return 0;
}
return -1;
}
});
DeviceValue all = new DeviceValue();
all.setName("总计");
all.setAmounts(String.valueOf(total));
all.setOncount(ontotal);
all.setOffcount(offtotal);
devcount.add(0,all);
result.setMaps(vdLists);
result.setOnline(devcount);
return result;
}
@Override
public List<GridTop> getGridTop() {
List<GridTop> vdLists;
vdLists=gridTopMapper.queryGridTop();//返回的网络拓扑图信息
return vdLists;
}
@Override
public List<LineMaps> queryLineMapByAssID(String eventass_index) {
List<LineMaps> vdLists;
vdLists=lineMapsMapper.queryLineMapByAssID(eventass_index);//返回的归一化的地理信息
return vdLists;
}
}

View File

@@ -0,0 +1,78 @@
package com.pqs9200.serviceimpl.data;
import cn.hutool.json.JSONObject;
import com.njcn.mapper.configuration.DeviceMapper;
import com.njcn.mapper.configuration.LineMapper;
import com.njcn.pojo.configuration.Device;
import com.njcn.pojo.configuration.Line;
import com.njcn.pojo.terminal.UpDevVO;
import com.njcn.shiro.token.TokenManager;
import com.njcn.sso.pojo.user.User;
import com.njcn.utils.AppConfig;
import com.njcn.utils.SocketClient;
import com.pqs9200.pojo.data.VdlistWaveRVO;
import com.pqs9200.pojo.data.VdlistWaveVO;
import com.pqs9200.service.data.VersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @Description 终端程序版本管理
* @Author cdf
* @Date 2020/8/6 13:35
**/
@Service
public class VersionServiceImpl implements VersionService {
@Autowired
private SocketClient socketClient;
@Autowired
private AppConfig appConfig;
@Autowired
private LineMapper lineMapper;
@Autowired
private DeviceMapper deviceMapper;
@Override
public String sentLineWave( String type, Long LineId,Long ComtradeName) {
String jsonStr = null;
try {
Line line =new Line();
line.setLineIndex(LineId);
line = lineMapper.selectOne(line);
Device device = new Device();
device.setDevIndex(Long.valueOf(line.getDevIndex()));
device = deviceMapper.selectOne(device);
UpDevVO upDevVO = new UpDevVO();
upDevVO.setDevIndex(LineId.toString());
upDevVO.setDevName(device.getName());
String host = lineMapper.getNodeIpbylineIndex(LineId);
Integer port = Integer.valueOf(appConfig.getSocketPort());
VdlistWaveRVO upParamVO = new VdlistWaveRVO();
VdlistWaveVO valueVO = new VdlistWaveVO();
valueVO.setType(type);
valueVO.setLineId(LineId);
valueVO.setComtradeName(ComtradeName);
JSONObject jsonstr = new JSONObject(valueVO);
Integer len = jsonstr.toString().length();
upParamVO.setLen(len.toString());
upParamVO.setData(valueVO);
JSONObject jsonObject = new JSONObject(upParamVO);
String str = jsonObject.toString();
System.out.println(str);
jsonStr = socketClient.sentLineWave(str,host,port);
}catch (Exception e){
return jsonStr;
}
return jsonStr;
}
}

View File

@@ -0,0 +1,404 @@
package com.pqs9200.serviceimpl.weeklyreport;
import cn.hutool.core.collection.CollectionUtil;
import com.njcn.mapper.advanced.RelevanceMapper;
import com.njcn.pojo.advanced.SagEvent;
import com.njcn.pojo.advanced.SagEventsQueryCondition;
import com.njcn.pojo.commons.AreaGeneralData;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.commons.device.LineInfo;
import com.njcn.pojo.configuration.DicData;
import com.njcn.pojo.user.Depts;
import com.njcn.serviceimpl.commons.WaveServiceImpl;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.PubUtils;
import com.njcn.utils.UserUtil;
import com.njcn.utils.redis.JedisManager;
import com.pqs9200.mapper.weeklyreport.GetAreaPointInfoMapper;
import com.pqs9200.mapper.weeklyreport.GetSagReasonMapper;
import com.pqs9200.mapper.weeklyreport.GetVoltageInfoMapper;
import com.pqs9200.pojo.weeklyreport.AreaPointInfo;
import com.pqs9200.pojo.weeklyreport.ResultReason;
import com.pqs9200.pojo.weeklyreport.SagRate;
import com.pqs9200.service.weeklyreport.WeeklyReportService;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
@Service
public class WeeklyReportServiceImpl implements WeeklyReportService {
private static final Logger logger = LoggerFactory.getLogger(WeeklyReportServiceImpl.class);
@Autowired
private GetAreaPointInfoMapper getAreaPointInfoMapper;
@Autowired
private UserUtil userUtil;
@Autowired
private GetVoltageInfoMapper getVoltageInfoMapper;
@Autowired
private RelevanceMapper relevanceMapper;
@Autowired
private WaveServiceImpl waveServiceImpl;
@Autowired
private GetSagReasonMapper getSagReasonMapper;
@Autowired
private JedisManager jedisManager;
public static class Info {
private String name;
private Integer id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
@Override
public List<AreaPointInfo> getPointData(Date start, Date end,Boolean statFlag) {
List<AreaPointInfo> listPointInfo = new ArrayList<>();
String area = userUtil.getDeptsIndex(TokenManager.getToken().getUserIndex());
List<AreaGeneralData> deptdLists;
if(statFlag){
deptdLists = userUtil.getAreaDataByInfoRun(area);
}else{
deptdLists = userUtil.getAreaDataByStatFlagAll(area);
}
for (AreaGeneralData areaGeneralData : deptdLists) {
AreaPointInfo areaPointInfo = new AreaPointInfo();
areaPointInfo.setName(areaGeneralData.getName());
List<Integer> listLineIndex = areaGeneralData.getLineIndexs(); // 获取监测点ID
if (listLineIndex.size() > 0) {
Integer onLineCount = getAreaPointInfoMapper.getOnline(listLineIndex); // 获取监测点在线个数
areaPointInfo.setOnLine(onLineCount == null ? 0 : onLineCount.intValue());
if (listLineIndex.size() > 0) {
Integer eventCount = getAreaPointInfoMapper.getEventCount(listLineIndex, start, end);
Integer breakCount = getAreaPointInfoMapper.getBreakCount(listLineIndex, start, end);
Integer upCount = getAreaPointInfoMapper.getUpCount(listLineIndex, start, end);
areaPointInfo.setOffLine(listLineIndex.size() - areaPointInfo.getOnLine());
areaPointInfo.setEventCount(eventCount == null ? 0 : eventCount.intValue());
areaPointInfo.setBreakCount(breakCount == null ? 0 : breakCount.intValue());
areaPointInfo.setUpCount(upCount == null ? 0 : upCount.intValue());
} else {
areaPointInfo.setOffLine(0);
areaPointInfo.setEventCount(0);
areaPointInfo.setBreakCount(0);
areaPointInfo.setUpCount(0);
}
} else {
areaPointInfo.setEventCount(0);
areaPointInfo.setBreakCount(0);
areaPointInfo.setUpCount(0);
areaPointInfo.setOffLine(0);
areaPointInfo.setOnLine(0);
}
listPointInfo.add(areaPointInfo);
}
return listPointInfo;
}
@Override
public List<AreaPointInfo> getVoltageData(Date start, Date end,Boolean statFlag) {
List<AreaPointInfo> list = new ArrayList<>();
String area = userUtil.getDeptsIndex(TokenManager.getToken().getUserIndex());
List<AreaGeneralData> deptdLists;
if(statFlag){
deptdLists = userUtil.getAreaDataByInfoRun(area);
}else{
deptdLists = userUtil.getAreaDataByStatFlagAll(area);
}
List<Integer> listLineIndex = new ArrayList<>();
for (AreaGeneralData areaGeneralData : deptdLists) {
listLineIndex.addAll(areaGeneralData.getLineIndexs());
}
List<DicData> list1 = getVoltageInfoMapper.getVoltageData();
for (DicData dicData : list1) {
AreaPointInfo areaPointInfo = new AreaPointInfo();
areaPointInfo.setName(dicData.getDicName());
//超过1000个点处理
List<Integer> list2= new ArrayList<>();
if(CollectionUtil.isNotEmpty(listLineIndex)){
if(listLineIndex.size()>1000){
List<Integer> tmp =null;
int count = listLineIndex.size()/1000+1;
for(int i=0;i<count;i++){
if(listLineIndex.size()>1000){
List<Integer> tempLine = listLineIndex.subList(0,1000);
tmp = getVoltageInfoMapper.getLineIndex(dicData.getDicIndex(), tempLine);
tempLine.clear();
}else{
tmp = getVoltageInfoMapper.getLineIndex(dicData.getDicIndex(), listLineIndex);
}
if(CollectionUtil.isNotEmpty(tmp)){
list2.addAll(tmp);
}
}
}else{
list2 = getVoltageInfoMapper.getLineIndex(dicData.getDicIndex(), listLineIndex);
}
}
JSONArray jsonArray=JSONArray.fromObject(list2);
jedisManager.saveValueByKey(RedisDB.SESSION_DB,"weeklyReportKey",jsonArray.toString(),RedisDB.SHORT_TIME);
String weeklyReportKey = jedisManager.getValueByKey(RedisDB.SESSION_DB, "weeklyReportKey");
JSONArray jsonArrayObject=JSONArray.fromObject(weeklyReportKey);
jedisManager.deleteByKey(RedisDB.SESSION_DB, "weeklyReportKey");
List<Integer> temps= (List<Integer>) JSONArray.toCollection(jsonArrayObject,Integer.class);
if (list2.size() > 0) {
Integer onLineCount = getVoltageInfoMapper.getOnLine(temps);// 获取监测点在线个数
areaPointInfo.setOnLine(onLineCount == null ? 0 : onLineCount.intValue());
Integer eventCount = getAreaPointInfoMapper.getEventCount(temps, start, end);
Integer breakCount = getAreaPointInfoMapper.getBreakCount(temps, start, end);
Integer upCount = getAreaPointInfoMapper.getUpCount(temps, start, end);
areaPointInfo.setOffLine(list2.size() - areaPointInfo.getOnLine());
areaPointInfo.setEventCount(eventCount == null ? 0 : eventCount.intValue());
areaPointInfo.setBreakCount(breakCount == null ? 0 : breakCount.intValue());
areaPointInfo.setUpCount(upCount == null ? 0 : upCount.intValue());
} else {
areaPointInfo.setOnLine(0);
areaPointInfo.setOffLine(0);
areaPointInfo.setEventCount(0);
areaPointInfo.setBreakCount(0);
areaPointInfo.setUpCount(0);
}
list.add(areaPointInfo);
}
return list;
}
public List<SagEvent> getSagEvent(Date start, Date end,Boolean statFlag) {
String area = userUtil.getDeptsIndex(TokenManager.getToken().getUserIndex());
List<AreaGeneralData> areaGeneral;
if(statFlag){
areaGeneral = userUtil.getAreaDataByInfoRun(area);
}else{
areaGeneral = userUtil.getAreaDataByStatFlagAll(area);
}
List<SagEvent> list = new ArrayList<>();
List<Integer> ll = new ArrayList<>();
for (AreaGeneralData depts : areaGeneral) {
List<Integer> listLineIndex = depts.getLineIndexs(); // 获取监测点ID
ll.addAll(listLineIndex);
}
HashSet<Integer> hashSet = new HashSet<>(ll);
for (Integer integer : hashSet) {
SagEventsQueryCondition sagEventsQueryCondition = new SagEventsQueryCondition(start, end, integer);
list.addAll(relevanceMapper.querySagEvents(sagEventsQueryCondition));
}
for (SagEvent sagEvent : list) {
try {
sagEvent.setStrTime(PubUtils.date2String(sagEvent.getSagTime(), "yyyy-MM-dd HH:mm:ss") + "."
+ PubUtils.getMs(sagEvent.getMsec()));
sagEvent.setStrEventValue(String.format("%.2f", sagEvent.getEventValue() * 100));
} catch (Exception e) {
logger.error(e.getMessage());
}
}
return list;
}
@Override
public List<SagEvent> getSagData(Date start, Date end,Boolean statFlag) {
List<SagEvent> list;
list = getSagEvent(start, end,statFlag);
Iterator iterator = list.iterator();
for (; iterator.hasNext(); ) { //只考虑暂降事件
SagEvent sagEvent = (SagEvent) iterator.next();
if (sagEvent.getWaveType().intValue() != 1) {
iterator.remove();
}
}
// 根据暂降严重度重新排序,保留前五条数据,这里的记录数需不需要做配置?
for (SagEvent sagEvent : list) {
if (sagEvent.getSeverity() == null) {
String value = waveServiceImpl.getYzd(sagEvent.getPersistTime(), sagEvent.getEventValue());
sagEvent.setSeverity(Float.parseFloat(value));
}
sagEvent.setSortType(1); // 设置排序规则
}
// 排序,根据暂降严重度排序
Collections.sort(list);
if (list.size() > 20) {
List<SagEvent> listnew = new ArrayList<>();
listnew.addAll(list.subList(0, 20));
return listnew;
}
return list;
}
@Override
public List<SagRate> getSagReasonData(Date start, Date end,Boolean statFlag) {
List<ResultReason> list = getSagReasonMapper.getReasonName();
List<SagRate> listResult = new ArrayList<>();
List<Integer> listLineId = new ArrayList<>();
String area = userUtil.getDeptsIndex(TokenManager.getToken().getUserIndex());
List<AreaGeneralData> deptdLists;
if(statFlag){
deptdLists = userUtil.getAreaDataByInfoRun(area);
}else{
deptdLists = userUtil.getAreaDataByStatFlagAll(area);
}
for (AreaGeneralData areaGeneralData : deptdLists) {
if (!areaGeneralData.getLineIndexs().isEmpty()) {
listLineId.addAll(areaGeneralData.getLineIndexs());
}
}
if (listLineId.isEmpty()) {
return null;
}
// 获取事件类型总数
List<ResultReason> listTotal= new ArrayList<>();
if(listLineId.size()>1000){
int count = listLineId.size()/1000+1;
for(int i=0;i<count;i++){
List<ResultReason> temp = null;
if(listLineId.size()>1000){
List<Integer> temLine = listLineId.subList(0,1000);
temp = getSagReasonMapper.getTotal(start, end, temLine);
temLine.clear();
}else{
temp = getSagReasonMapper.getTotal(start, end, listLineId);
}
if(CollectionUtil.isNotEmpty(temp)){
listTotal.addAll(temp);
}
}
}else{
listTotal = getSagReasonMapper.getTotal(start, end, listLineId);
}
int total = listTotal.size() > 0 ? 0 : 1;
for (ResultReason resultReason : listTotal) {
total += resultReason.getTotal().intValue();
}
for (ResultReason resultReason : list) {
SagRate sagRate = new SagRate();
sagRate.setName(resultReason.getName());
sagRate.setCount(new Integer(0));
for (ResultReason resultReason1 : listTotal) {
if (resultReason.getDicindex().equals(resultReason1.getEventreason())) {
sagRate.setCount(resultReason1.getTotal());
break;
}
}
sagRate.setRate(new Float((float) sagRate.getCount().intValue() / total * 100));
listResult.add(sagRate);
}
return listResult;
}
@Override
public List<SagEvent> getSagEvents(Date start, Date end,Boolean statFlag) {
List<SagEvent> list = getSagEvent(start, end,statFlag);
for (SagEvent sagEvent : list) {
if (sagEvent.getWaveType() != 1) {
sagEvent.setSagReason("/");
}
sagEvent.setTime(sagEvent.getSagTime().getTime() + sagEvent.getMsec());
sagEvent.setSortType(2); // 设置排序规则
}
// 排序,根据暂降发生时间排序
Collections.sort(list);
return list;
}
@Override
public List<LineInfo> getTenList(Date start, Date end, Integer wavetype,Boolean statFlag){
List<LineInfo> result = new ArrayList<>();
String area = userUtil.getDeptsIndex(TokenManager.getToken().getUserIndex());
List<AreaGeneralData> deptdLists;
if(statFlag){
deptdLists = userUtil.getAreaDataByInfoRun(area);
}else{
deptdLists = userUtil.getAreaDataByStatFlagAll(area);
}
List<Integer> lineList = new ArrayList<>();
if(CollectionUtil.isNotEmpty(deptdLists)){
for(AreaGeneralData areaGeneralData:deptdLists){
if(CollectionUtil.isNotEmpty(areaGeneralData.getLineIndexs())){
lineList.addAll(areaGeneralData.getLineIndexs());
}
}
}
if(CollectionUtil.isNotEmpty(lineList)){
if(lineList.size()>1000){
int count = lineList.size()/1000+1;
for(int i=0;i<count;i++){
List<LineInfo> resList = null;
if(lineList.size()>1000){
List<Integer> subIndexs = lineList.subList(0,1000);
resList = getAreaPointInfoMapper.getTenList(start, end, wavetype,subIndexs);
subIndexs.clear();
}else{
resList =getAreaPointInfoMapper.getTenList(start, end, wavetype,lineList);
}
if(CollectionUtil.isNotEmpty(resList)){
result.addAll(resList);
}
}
}else {
result = getAreaPointInfoMapper.getTenList(start, end, wavetype,lineList);
}
}
return result;
}
}

View File

@@ -0,0 +1,344 @@
package com.pqs9200.task;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.njcn.mapper.configuration.LineMapper;
import com.njcn.mapper.configuration.TreeMapper;
import com.njcn.mapper.data.SynDataMapper;
import com.njcn.pojo.commons.device.Tree;
import com.njcn.pojo.configuration.Line;
import com.njcn.pojo.data.SynData;
import com.njcn.service.configuration.TreeService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.sso.pojo.user.User;
import com.njcn.utils.AppConfig;
import com.njcn.utils.BalanceInfo;
import com.njcn.utils.UserUtil;
@Component
public class SynDataTask {
private static final Logger logger = LoggerFactory.getLogger(SynDataTask.class);
@Autowired
private AppConfig appConfig;
@Resource
private TreeService getDeviceTree;
@Resource
private TreeMapper treeMapper;
@Resource
private LineMapper lineMapper;
@Resource
private SynDataMapper synDataMapper;
@Autowired
private UserUtil userUtil;
@Autowired
private BalanceInfo balanceInfo;
@Scheduled(cron = "0 0 6 * * ?")
public void getSynData() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
Date endTime = calendar.getTime();
calendar.set(Calendar.DAY_OF_MONTH,1);
calendar.add(Calendar.MONTH,0);
Date startTime = calendar.getTime();
try {
getTreedata(null, startTime, endTime);
} catch (Exception e) {
logger.error(e.getMessage());
}
}
public void getTreedata(String name, Date startTime, Date endTime) {
String dky = "设备树";
int pIdNumber = Integer.parseInt(appConfig.getPidNumber());
List<Tree> list = new ArrayList<>();
List<Integer> index = lineMapper.listAllIndex();
if (index.size() == 0) {
Tree dto = new Tree();
dto.setId(100);
dto.setNodeType(0);
dto.setpId(0);
dto.setPpId(0);
dto.setName(dky);
list.add(dto);
} else {
Tree dt = new Tree();
dt.setId(100);
dt.setNodeType(0);
dt.setpId(0);
dt.setPpId(0);
dt.setName(dky);
list.add(dt);
List<Tree> proInfo = treeMapper.getTreeProInfo(index);
List<Tree> gdInfo = treeMapper.getTreeGdInfo(index);
List<Tree> subInfo = treeMapper.getTreeSubInfo(index);
List<Tree> devInfo = new ArrayList<>();
if (appConfig.getSysType() == appConfig.getSysTypeWt()) {
devInfo = treeMapper.getWTTreeDevInfo(index);
} else {
devInfo = treeMapper.getZTTreeDevInfo(index);
}
List<Tree> subvInfo = treeMapper.getTreeSubvInfo(index);
List<Tree> lineInfo = treeMapper.getLineInfo(index);
if(proInfo == null || gdInfo == null || subInfo == null || devInfo == null || subvInfo == null || lineInfo == null){
}
Map<Integer, Integer> value0 = new HashMap<Integer, Integer>();
int p0 = pIdNumber;
for (int i = 0; i < proInfo.size(); i++) {
Tree dto = new Tree();
dto.setId(++p0);
dto.setName(proInfo.get(i).getName());
dto.setpId(100);
dto.setPpId(100);
dto.setNodeIndex(proInfo.get(i).getNodeIndex());
dto.setNodeType(1);
int proIndex = proInfo.get(i).getNodeIndex();
List<Line> lines = lineMapper.getLinesByPro(proIndex);
List<Integer> indexs = new ArrayList<>();
for (int n = 0; n < lines.size(); n++) {
indexs.add(lines.get(n).getLineIndex().intValue());
}
Float synDatas = getSynData(indexs, startTime, endTime);
int lvl = getLevel(synDatas);
dto.setQualityAss(lvl);
list.add(dto);
SynData data1 = new SynData();
data1.setMyIndex(proIndex);
data1.setNode(1l);
data1.setSyndata(synDatas);
synDataMapper.deleteByIndex(proIndex, 1l);
int flag1 = synDataMapper.insert(data1);
value0.put(proInfo.get(i).getNodeIndex(), p0);
}
Map<Integer, Integer> value = new HashMap<Integer, Integer>();
int p = pIdNumber*2;
for (int i = 0; i < gdInfo.size(); i++) {
Tree dto = new Tree();
dto.setId(++p);
dto.setName(gdInfo.get(i).getName());
dto.setpId(value0.get(gdInfo.get(i).getpId()));
dto.setPpId(gdInfo.get(i).getpId());
dto.setNodeIndex(gdInfo.get(i).getNodeIndex());
dto.setNodeType(2);
Line gd_line = new Line();
gd_line.setGdIndex((long) gdInfo.get(i).getNodeIndex());
List<Line> lines = lineMapper.select(gd_line);
List<Integer> indexs = new ArrayList<>();
for (int n = 0; n < lines.size(); n++) {
indexs.add(lines.get(n).getLineIndex().intValue());
}
Float synDatas = getSynData(indexs, startTime, endTime);
int lvl = getLevel(synDatas);
dto.setQualityAss(lvl);
list.add(dto);
SynData data2 = new SynData();
data2.setMyIndex(gdInfo.get(i).getNodeIndex());
data2.setNode(2l);
data2.setSyndata(synDatas);
synDataMapper.deleteByIndex(gdInfo.get(i).getNodeIndex(), 2l);
int flag2 = synDataMapper.insert(data2);
value.put(gdInfo.get(i).getNodeIndex(), p);
}
Map<Integer, Integer> value1 = new HashMap<Integer, Integer>();
int p1 = pIdNumber * 3;
for (int i = 0; i < subInfo.size(); i++) {
if (value.get(subInfo.get(i).getpId()) != null) {
Tree dto = new Tree();
dto.setId(++p1);
dto.setName(subInfo.get(i).getName());
dto.setpId(value.get(subInfo.get(i).getpId()));
dto.setPpId(subInfo.get(i).getpId());
dto.setNodeIndex(subInfo.get(i).getNodeIndex());
dto.setNodeType(3);
Line sub_line = new Line();
sub_line.setSubIndex((long) subInfo.get(i).getNodeIndex());
List<Line> lines = lineMapper.select(sub_line);
List<Integer> indexs = new ArrayList<>();
for (int n = 0; n < lines.size(); n++) {
indexs.add(lines.get(n).getLineIndex().intValue());
}
Float synDatas = getSynData(indexs, startTime, endTime);
int lvl = getLevel(synDatas);
dto.setQualityAss(lvl);
list.add(dto);
SynData data3 = new SynData();
data3.setMyIndex(subInfo.get(i).getNodeIndex());
data3.setNode(3l);
data3.setSyndata(synDatas);
synDataMapper.deleteByIndex(subInfo.get(i).getNodeIndex(), 3l);
int flag3 = synDataMapper.insert(data3);
value1.put(subInfo.get(i).getNodeIndex(), p1);
}
}
Map<Integer, Integer> value2 = new HashMap<Integer, Integer>();
int p2 = pIdNumber * 4;
for (int i = 0; i < devInfo.size(); i++) {
if (value1.get(devInfo.get(i).getpId()) != null) {
Tree dto = new Tree();
dto.setId(++p2);
dto.setName(devInfo.get(i).getName());
dto.setpId(value1.get(devInfo.get(i).getpId()));
dto.setPpId(devInfo.get(i).getpId());
dto.setNodeIndex(devInfo.get(i).getNodeIndex());
dto.setNodeType(4);
dto.setIp(devInfo.get(i).getIp());
Line dev_line = new Line();
dev_line.setDevIndex((long) devInfo.get(i).getNodeIndex());
List<Line> lines = lineMapper.select(dev_line);
List<Integer> indexs = new ArrayList<>();
for (int n = 0; n < lines.size(); n++) {
indexs.add(lines.get(n).getLineIndex().intValue());
}
Float synDatas = getSynData(indexs, startTime, endTime);
int lvl = getLevel(synDatas);
dto.setQualityAss(lvl);
list.add(dto);
SynData data4 = new SynData();
data4.setMyIndex(devInfo.get(i).getNodeIndex());
data4.setNode(4l);
data4.setSyndata(synDatas);
synDataMapper.deleteByIndex(devInfo.get(i).getNodeIndex(), 4l);
int flag4 = synDataMapper.insert(data4);
value2.put(devInfo.get(i).getNodeIndex(), p2);
}
}
Map<Integer, Integer> value3 = new HashMap<Integer, Integer>();
int p3 = pIdNumber * 5;
for (int i = 0; i < subvInfo.size(); i++) {
if (value2.get(subvInfo.get(i).getpId()) != null) {
Tree dto = new Tree();
dto.setId(++p3);
dto.setName(subvInfo.get(i).getName());
dto.setpId(value2.get(subvInfo.get(i).getpId()));
dto.setPpId(subvInfo.get(i).getpId());
dto.setNodeIndex(subvInfo.get(i).getNodeIndex());
dto.setNodeType(5);
Line subv_line = new Line();
subv_line.setSubvIndex((long) subvInfo.get(i).getNodeIndex());
List<Line> lines = lineMapper.select(subv_line);
List<Integer> indexs = new ArrayList<>();
for (int n = 0; n < lines.size(); n++) {
indexs.add(lines.get(n).getLineIndex().intValue());
}
Float synDatas = getSynData(indexs, startTime, endTime);
int lvl = getLevel(synDatas);
dto.setQualityAss(lvl);
list.add(dto);
SynData data5 = new SynData();
data5.setMyIndex(subvInfo.get(i).getNodeIndex());
data5.setNode(5l);
data5.setSyndata(synDatas);
synDataMapper.deleteByIndex(subvInfo.get(i).getNodeIndex(), 5l);
int flag5 = synDataMapper.insert(data5);
value3.put(subvInfo.get(i).getNodeIndex(), p3);
}
}
int p4 = pIdNumber * 6;
for (int i = 0; i < lineInfo.size(); i++) {
if (value3.get(lineInfo.get(i).getpId()) != null) {
Tree dto = new Tree();
dto.setId(++p4);
dto.setName(lineInfo.get(i).getName());
dto.setpId(value3.get(lineInfo.get(i).getpId()));
dto.setPpId(lineInfo.get(i).getpId());
dto.setNodeIndex(lineInfo.get(i).getNodeIndex());
dto.setNodeType(6);
dto.setState(lineInfo.get(i).getState());
dto.setStatus(lineInfo.get(i).getStatus());
List<Integer> indexs = new ArrayList<>();
indexs.add(lineInfo.get(i).getNodeIndex());
Float synDatas = getSynData(indexs, startTime, endTime);
int lvl = getLevel(synDatas);
dto.setQualityAss(lvl);
list.add(dto);
SynData data6 = new SynData();
data6.setMyIndex(lineInfo.get(i).getNodeIndex());
data6.setNode(6l);
data6.setSyndata(synDatas);
synDataMapper.deleteByIndex(lineInfo.get(i).getNodeIndex(), 6l);
int flag6 = synDataMapper.insert(data6);
}
}
}
}
private Float getSynData(List<Integer> lineIndexs, Date startTime, Date endTime) {
Float synData = 0f;
synData = balanceInfo.getBalanceInfo(lineIndexs, startTime, endTime);
if(synData == null){
synData = 3.14159f;
}
return synData;
}
private int getLevel(Float synDatas) {
if (appConfig.getSysType() == appConfig.getSysTypeWt()) {
if (synDatas == 3.14159f) {
return 0;
}
if (0 <= synDatas && synDatas < 3) {
return 1;
} else if (3 <= synDatas && synDatas < 4) {
return 2;
} else if (4 <= synDatas && synDatas < 4.5) {
return 3;
} else {
return 4;
}
} else {
if (synDatas == null || synDatas == 3.14159f) {
return 0;
}
if (0 <= synDatas && synDatas < 0.4) {
return 1;
} else if (0.4 <= synDatas && synDatas < 0.8) {
return 2;
} else if (0.8 <= synDatas && synDatas < 1.2) {
return 3;
} else {
return 4;
}
}
}
}

View File

@@ -0,0 +1,81 @@
{
plotOptions: {
series: {
animation: false
}
},
title: {
text: '${title}',
style:{fontSize: '14px'}
},
chart: {
type: 'spline',
events:{
load:function(){
if(${cshow}){
this.series[2].show();
}else{
this.series[2].hide();
}
}
}
},
rangeSelector:{
enabled:false
},
navigator: {
enabled:false
},
scrollbar : {
enabled : false
},
credits:false,
colors:['#DAA520', '#2E8B57', '#A52a2a'],
xAxis:{
title:{
text:'ms',
enabled:true,
align: 'high'
},
labels: {
formatter: function () {
return%20this.value ;
}
}
},
yAxis: {
title: {
align: 'high',
offset: 0,
text: '${unit}',
rotation: 0,
y: -10
},
opposite:false
},
legend: {
align: 'left',
verticalAlign: 'top',
enabled:true
},
series: [{
marker: {
symbol: 'circle'
},
name: '${a}',
data: ${adata}
}, {
marker: {
symbol: 'circle'
},
name: '${b}',
data: ${bdata}
}, {
marker: {
symbol: 'circle'
},
name: '${c}',
data: ${cdata},
showInLegend:${cshow}
}]
}

View File

@@ -0,0 +1,83 @@
{
plotOptions: {
series: {
animation: false
}
},
title: {
text: '${title}',
style: {fontSize: '14px'}
},
chart: {
type: 'spline',
events:{
load:function(){
if(${cshow}){
this.series[2].show();
}else{
this.series[2].hide();
}
}
}
},
rangeSelector: {
enabled: false,
},
navigator: {
enabled: false
},
scrollbar: {
enabled: false
},
credits: false,
colors: ['#DAA520', '#2E8B57', '#A52a2a'],
xAxis: {
title: {
text: 'ms',
enabled: true,
align: 'high'
},
labels: {
formatter: function () {
return%20this.value;
}
}
},
yAxis: {
title: {
align: 'high',
offset: 0,
text: '${unit}',
rotation: 0,
y: -10
},
max: ${max},
min: ${min},
opposite: false
},
legend: {
align: 'left',
verticalAlign: 'top',
enabled: true
},
series: [{
marker: {
symbol: 'circle'
},
name: '${a}',
data: ${adata}
}, {
marker: {
symbol: 'circle'
},
name: '${b}',
data: ${bdata}
}, {
marker: {
symbol: 'circle'
},
name: '${c}',
data: ${cdata},
showInLegend:${cshow}
}]
}

View File

@@ -0,0 +1,238 @@
package com.pqs9200.utils;
import com.njcn.pojo.advanced.MessageObj;
import com.njcn.utils.WebSocketUtil;
import kafka.consumer.Consumer;
import kafka.consumer.ConsumerConfig;
import kafka.consumer.ConsumerIterator;
import kafka.consumer.KafkaStream;
import kafka.javaapi.consumer.ConsumerConnector;
import kafka.message.MessageAndMetadata;
import kafka.serializer.StringDecoder;
import kafka.utils.VerifiableProperties;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.websocket.EncodeException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class JavaKafkaConsumer implements Runnable {
/**
* Kafka数据消费对象
*/
private ConsumerConnector consumer;
/*** Kafka Topic名称 */
private String topic;
/*** 线程数量一般就是Topic的分区数量 */
private int numThreads;
/*** 线程池 */
private ExecutorService executorPool;
/*** Kafka是否打印日志 */
private static String kafka_log;
/*** 日志记录 */
private static final Logger logger = LoggerFactory.getLogger(JavaKafkaConsumer.class);
/**
* 构造函数
*
* @param topic Kafka消息Topic主题
* @param zookeeper Kafka的Zookeeper连接字符串
* @param groupId 该消费者所属group ID的值
*/
@SuppressWarnings("static-access")
public JavaKafkaConsumer(String topic, int numThreads, String zookeeper, String groupId, String kafka_log) {
// 1. 创建Kafka连接器
this.consumer = Consumer.createJavaConsumerConnector(createConsumerConfig(zookeeper, groupId));
// 2. 数据赋值
this.topic = topic;
this.numThreads = numThreads;
this.kafka_log = kafka_log;
}
@Override
public void run() {
// 1. 指定Topic
Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
topicCountMap.put(this.topic, this.numThreads);
// 2. 指定数据的解码器
StringDecoder keyDecoder = new StringDecoder(new VerifiableProperties());
StringDecoder valueDecoder = new StringDecoder(new VerifiableProperties());
// 3. 获取连接数据的迭代器对象集合
/**
* Key: Topic主题 Value: 对应Topic的数据流读取器大小是topicCountMap中指定的topic大小
*/
Map<String, List<KafkaStream<String, String>>> consumerMap = this.consumer.createMessageStreams(topicCountMap,
keyDecoder, valueDecoder);
// 4. 从返回结果中获取对应topic的数据流处理器
List<KafkaStream<String, String>> streams = consumerMap.get(this.topic);
// 5. 创建线程池
this.executorPool = Executors.newFixedThreadPool(this.numThreads);
// 6. 构建数据输出对象
int threadNumber = 0;
for (final KafkaStream<String, String> stream : streams) {
this.executorPool.submit(new ConsumerKafkaStreamProcesser(stream, threadNumber));
threadNumber++;
}
}
public void shutdown() {
// 1. 关闭和Kafka的连接这样会导致stream.hashNext返回false
if (this.consumer != null) {
this.consumer.shutdown();
}
// 2. 关闭线程池,会等待线程的执行完成
if (this.executorPool != null) {
// 2.1 关闭线程池
this.executorPool.shutdown();
// 2.2. 等待关闭完成, 等待五秒
try {
if (!this.executorPool.awaitTermination(5, TimeUnit.SECONDS)) {
logger.info("Timed out waiting for consumer threads to shut down, exiting uncleanly!!");
}
} catch (InterruptedException e) {
logger.error("Interrupted during shutdown, exiting uncleanly!!");
}
}
}
/**
* 根据传入的zk的连接信息和groupID的值创建对应的ConsumerConfig对象
*
* @param zookeeper zk的连接信息类似于<br/>
* hadoop-senior01.ibeifeng.com:2181,hadoop-senior02.ibeifeng.com:2181/kafka
* consumer所属的group id的值 group id值一样的kafka consumer会进行负载均衡
* @return Kafka连接信息
*/
private ConsumerConfig createConsumerConfig(String zookeeper, String groupId) {
// 1. 构建属性对象
Properties prop = new Properties();
// 2. 添加相关属性
prop.put("group.id", groupId); // 指定分组id
prop.put("zookeeper.connect", zookeeper); // 指定zk的连接url
prop.put("zookeeper.session.timeout.ms", "400"); //
prop.put("zookeeper.sync.time.ms", "200");
prop.put("auto.commit.interval.ms", "1000");
// 3. 构建ConsumerConfig对象
return new ConsumerConfig(prop);
}
/**
* Kafka消费者数据处理线程
*/
public static class ConsumerKafkaStreamProcesser implements Runnable {
// Kafka数据流
private KafkaStream<String, String> stream;
// 线程ID编号
private int threadNumber;
// 建立socket对象推送数据
private WebSocketUtil webSocketUtil = new WebSocketUtil();
public ConsumerKafkaStreamProcesser(KafkaStream<String, String> stream, int threadNumber) {
this.stream = stream;
this.threadNumber = threadNumber;
}
@Override
public void run() {
// 1. 获取数据迭代器
ConsumerIterator<String, String> iter = this.stream.iterator();
// 2. 迭代输出数据
while (iter.hasNext()) {
// 2.1 获取数据值
MessageAndMetadata value = iter.next();
// 新增去掉传输消息的前后字符串
String recevData = new String(((String) value.message()).trim());
/**************************************************************
* 加入try...catch处理
* 如果非json格式字符串string转jsonObject对象会异常返回
**************************************************************/
try {
translateData(recevData);
} catch (Exception e) {
logger.error("Kafka传输的字符串格式不正确" + recevData);
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.error(e.getMessage());
}
/******* 系统配置是否打印Kafka *******/
if (kafka_log.equals("true"))
logger.error(recevData);
}
}
// 解析kfka数据
@SuppressWarnings("unchecked")
public void translateData(String strData) {
JSONArray jsonArray = JSONArray.fromObject(strData);
String msgId = jsonArray.getJSONObject(0).getString("msg");
/**********************************************************
* add by sw
* kakfa消息推送中暂降幅值结果*100
**********************************************************/
List<JSONObject> list = (List<JSONObject>) jsonArray.getJSONObject(0).get("data");
if (msgId.equals("event_data")) {
for (JSONObject jsonObject : list) {
jsonObject.replace("eventvalue", jsonObject.getDouble("eventvalue") * 100);
}
}
postMsg(msgId, list);
}
// 消息推送
public void postMsg(String strMsgId, Object strBody) {
switch (strMsgId) {
case "event_data":
MessageObj messageObj = new MessageObj();
messageObj.setMsgId(messageObj.getRelevance() + 1);
messageObj.setMsgBody("insert");
messageObj.setMsgbody(strBody);
try {
webSocketUtil.sendAll(messageObj);
} catch (IOException | EncodeException e1) {
logger.error(e1.getMessage());
}
break;
case "com_data":
MessageObj messObj = new MessageObj();
messObj.setMsgId(messObj.getRelevance() + 3);
messObj.setMsgBody("update");
messObj.setMsgbody(strBody);
try {
webSocketUtil.sendAll(messObj);
} catch (IOException | EncodeException e) {
logger.error(e.getMessage());
}
break;
default:
;
}
}
}
}

View File

@@ -0,0 +1,406 @@
/*****************************
* 暂降域计算方法
* add by yxb
* 2021-12-14
****************************/
package com.pqs9200.utils;
import com.njcn.utils.PubUtils;
import com.njcn.utils.sagDomain.Complex;
import com.njcn.utils.sagDomain.DipZoneModel;
import com.njcn.utils.sagDomain.Matrix;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class SagDomain {
/// <summary>
/// 正序阻抗矩阵
/// 首段节点号 末端节点号 支路电阻 支路电抗 对地导纳
/// </summary>
public static double[][] ZL1 =
{
{1 ,3 ,0.000277, 0.000341, 0.000150 },
{1 ,4 ,0.003756, 0.004627, 0.002042 },
{1 ,2 ,0.003505, 0.004318, 0.001905 },
{3 ,5 ,0.000796, 0.000980, 0.000433 },
{5 ,4 ,0.002548, 0.003139, 0.001385 },
{5 ,2 ,0.003289, 0.004052, 0.001788 },
{6 ,9 ,1.042800, 3.065200, 0.000022 },
{7 ,9 ,0.976800, 2.871200, 0.000021 },
{9 ,13 ,5.940000, 17.460000, 0.000126 },
{9 ,11 ,4.224000, 12.416000, 0.000090 },
{9 ,12 ,1.320000, 3.880000, 0.000028 },
{9 ,10 ,4.488000, 13.192000, 0.000095 },
{12 ,16 ,1.108800, 3.259200, 0.000024 },
{16 ,10 ,0.910800, 2.677200, 0.000019 },
{6 ,8 ,1.980000, 5.820000, 0.000042 },
{8 ,10 ,1.980000, 5.820000, 0.000042 },
{10 ,15 ,6.072000, 17.848000, 0.000129 },
{10 ,14 ,6.072000, 17.848000, 0.000129 },
{15 ,14 ,3.168000, 9.312000, 0.000067 },
{4 ,7 ,0, 0.208 , 0.978}, //变压器支路
{2 ,6 ,0, 0.556 , 0.969}, //变压器支路
};
/// <summary>
/// 负序阻抗矩阵,数值和正序一致
/// 首段节点号 末端节点号 支路电阻 支路电抗 对地导纳
/// </summary>
public static double[][] ZL2 =
{
{1 ,2 ,0.000277, 0.000341, 0.000150 },
{1 ,4 ,0.003756, 0.004627, 0.002042 },
{1 ,12 ,0.003505, 0.004318, 0.001905 },
{2 ,3 ,0.000796, 0.000980, 0.000433 },
{3 ,4 ,0.002548, 0.003139, 0.001385 },
{3 ,12 ,0.003289, 0.004052, 0.001788 },
{13 ,6 ,1.042800, 3.065200, 0.000022 },
{5 ,6 ,0.976800, 2.871200, 0.000021 },
{6 ,7 ,5.940000, 17.460000, 0.000126 },
{6 ,8 ,4.224000, 12.416000, 0.000090 },
{6 ,9 ,1.320000, 3.880000, 0.000028 },
{6 ,11 ,4.488000, 13.192000, 0.000095 },
{9 ,10 ,1.108800, 3.259200, 0.000024 },
{10 ,11 ,0.910800, 2.677200, 0.000019 },
{13 ,14 ,1.980000, 5.820000, 0.000042 },
{14 ,11 ,1.980000, 5.820000, 0.000042 },
{11 ,15 ,6.072000, 17.848000, 0.000129 },
{11 ,16 ,6.072000, 17.848000, 0.000129 },
{15 ,16 ,3.168000, 9.312000, 0.000067 },
{4 ,5 ,0, 0.208 , 0.978}, //变压器支路
{12 ,13 ,0, 0.556 , 0.969}, //变压器支路
};
/// <summary>
/// 零序阻抗矩阵数值为正序的2.5倍
/// 首段节点号 末端节点号 支路电阻 支路电抗 对地导纳
/// </summary>
public static double[][] ZL0 =
{
{1 ,3 ,0.000693 ,0.000853 ,0.000375},
{1 ,4 ,0.009390 ,0.011568 ,0.005105},
{1 ,2 ,0.008763 ,0.010795 ,0.004763},
{3 ,5 ,0.001990 ,0.002450 ,0.001083},
{5 ,4 ,0.006370 ,0.007848 ,0.003463},
{5 ,2 ,0.008223 ,0.010130 ,0.004470},
{6 ,9 ,2.607000 ,7.663000 ,0.000055},
{7 ,9 ,2.442000 ,7.178000 ,0.000053},
{9 ,13 ,14.850000 ,43.650000 ,0.000315},
{9 ,11 ,10.560000 ,31.040000 ,0.000225},
{9 ,12 ,3.300000 ,9.700000 ,0.000070},
{9 ,10 ,11.220000 ,32.980000 ,0.000238},
{12 ,16 ,2.772000 ,8.148000 ,0.000060},
{16 ,10 ,2.277000 ,6.693000 ,0.000048},
{6 ,8 ,4.950000 ,14.550000 ,0.000105},
{8 ,10 ,4.950000 ,14.550000 ,0.000105},
{10 ,15 ,15.180000 ,44.620000 ,0.000323},
{10 ,14 ,15.180000 ,44.620000 ,0.000323},
{15 ,14 ,7.920000 ,23.280000 ,0.000168},
{4 ,7 ,0 ,0.52 ,2.445 }, //变压器支路
{2 ,6 ,0 ,1.39 ,2.4225 }, //变压器支路
};
public static Complex[] Vpre =
{
new Complex(0.956 ,0.434239565 ),//1
new Complex(1.002 ,0.313840724 ),//12
new Complex(0.955 ,0.436434417 ),//2
new Complex(0.983 ,0.369067744 ),//4
new Complex(0.957 ,0.432031249),//3
new Complex(1.003 ,0.310630005 ),//13
new Complex(0.984 ,0.366393231 ),//5
new Complex(1.011 ,0.283511905 ),//14
new Complex(1.007 ,0.297407128 ),//6
new Complex(1.021 ,0.245069378 ),//11
new Complex(1.03 ,0.203960781 ),//7
new Complex(1.01 ,0.287054002 ),//9
new Complex(1.03 ,0.203960781 ),//8
new Complex(1.04 ,0.144568323 ),//16
new Complex(1.028 ,0.213813002 ),//15
new Complex(1.009 ,0.290549479 )//10
};
public static void main(String[] args) {
SagDomain sagDomain =new SagDomain();
sagDomain.analysisSagDomain(0.7,1,1,16,19, ZL1,ZL0,Vpre);
}
/**********************************************
* 获取暂降域的算法
* uthre 暂降幅值
* eventType 暂降类型
* eventPoint 暂降出发点
* iNodeCount 节点目数
* iLineCount 线路目数
* ps_Value 正序数组
* ns_Value 零序数组
* vpre_Value 节点信息
**********************************************/
public DipZoneModel[] analysisSagDomain(double uthre,int eventType,int eventPoint,int iNodeCount,int iLineCount,double[][] ps_Value,double[][] ns_Value,Complex[] vpre_Value) {
Complex cmp_Base=new Complex(0,0);//做计算基础
/*System.out.println("=======静态======");
for (Complex com : Vpre) {
System.out.println(com);
}
System.out.println("=======动态======");
for (Complex com : vpre_Value) {
System.out.println(com);
}
vpre_Value = Vpre;*/
// 旋转因子,不要问我为什么设置这么多,我也不知道
Complex alpha = new Complex(-0.5,Math.sqrt(3)/2);
// 根据电网路径表将路径表上电缆等分为1000个等分点
double stepValue = 0.001;
int iAllCount = ps_Value.length;//数组总长度(包含了线路+变压器支路)
//求节点正序导纳矩阵
Complex[][] ps_Complex = getMatrix(iNodeCount,iLineCount,ps_Value);
//求节点零序导纳矩阵
Complex[][] zs_Complex = getMatrix(iNodeCount,iLineCount,ns_Value);
int rowLength = ps_Complex.length;// 获取行数
int colLength = zs_Complex[0].length;// 获取列数
//矩阵求逆,求节点阻抗矩阵
Complex[][] ps_Inverse = Matrix.Inverse(ps_Complex);//正序
Complex[][] ns_Inverse = ps_Inverse;//负序
Complex[][] zs_Inverse = Matrix.Inverse(zs_Complex);//零序
//依次选择故障线路设故障点为f距首端距离为stepValue距末端距离为(1-stepValue)
int nLineStepCount = (int)Math.ceil(1.0 / stepValue + 1 );
//单相接地故障幅值
double[][] singleGround = new double[iLineCount][nLineStepCount];
//两相短路故障幅值
double[][] twoPhaseShortOut = new double[iLineCount][nLineStepCount];
//两相短路接地故障幅值
double[][] twoPhaseGround = new double[iLineCount][nLineStepCount];
//三相短路故障幅值
double[][] threePhaseShortOut = new double[iLineCount][nLineStepCount];
// 组装四种暂降类型数组
double lStep = 0;
int m = eventPoint - 1;//敏感负荷节点号 1是节点序号-1是数组的位置是从0起始
for (int i = 0;i < iLineCount; i++)
{
lStep = 0 ;// 初始化为0
int iStart = (int)ps_Value[i][0] - 1;//首节点序号
int iEnd = (int)ps_Value[i][1] - 1;//末点序号
// 根据分割的步弧去计算
for(int j=0;j< nLineStepCount; j++)
{
lStep += stepValue;//加上计算步骤
Complex cmp_lStep =new Complex(lStep,0);//步数复数
Complex cmp_lStep_power =new Complex(Math.pow(lStep, 2),0);//步数复数平方
// 计算故障点与敏感负荷节点之间的互阻抗
// 正序
Complex Zmf1 = cmp_Base.add(cmp_Base.multiplication(cmp_Base.subduction(ps_Inverse[iEnd][m],ps_Inverse[iStart][m]),cmp_lStep ),ps_Inverse[iStart][m]);
Complex tmpZmf1 = cmp_Base.subduction(cmp_Base.add(ps_Inverse[iStart][iStart],ps_Inverse[iEnd][iEnd]),cmp_Base.multiplication(ps_Inverse[iStart][iEnd],new Complex(2,0)));
Complex tmpZmf2 = new Complex(ps_Value[i][2],ps_Value[i][3]);
Complex tmpZmf12 = cmp_Base.multiplication(cmp_Base.subduction(tmpZmf1,tmpZmf2),cmp_lStep_power);
Complex tmpZmf3 = cmp_Base.subduction(cmp_Base.multiplication(ps_Inverse[iStart][iEnd],new Complex(2,0)),cmp_Base.multiplication(ps_Inverse[iStart][iStart],new Complex(2,0)));
Complex tmpZmf32 = cmp_Base.multiplication(cmp_Base.add(tmpZmf3,tmpZmf2),cmp_lStep);
Complex Zff1 = cmp_Base.add(cmp_Base.add(tmpZmf12,tmpZmf32),ps_Inverse[iStart][iStart]);
//正序=负序
Complex Zmf2 = Zmf1;
Complex Zff2 = Zff1;
//零序
Complex Zmf0 = cmp_Base.add(cmp_Base.multiplication(cmp_Base.subduction(zs_Inverse[m][iEnd],zs_Inverse[m][iStart]),cmp_lStep),zs_Inverse[m][iStart]);
Complex tmpZff1 = cmp_Base.subduction(cmp_Base.add(zs_Inverse[iStart][iStart],zs_Inverse[iEnd][iEnd]),cmp_Base.multiplication(zs_Inverse[iStart][iEnd],new Complex(2,0)));
Complex tmpZff2 = new Complex(ns_Value[i][2],ns_Value[i][3]);
Complex tmpZff12 = cmp_Base.multiplication(cmp_Base.subduction(tmpZff1,tmpZff2),cmp_lStep_power);
Complex tmpZff3 = cmp_Base.subduction(cmp_Base.multiplication(zs_Inverse[iStart][iEnd],new Complex(2,0)),cmp_Base.multiplication(zs_Inverse[iStart][iStart],new Complex(2,0)));
Complex tmpZff32 = cmp_Base.multiplication(cmp_Base.add(tmpZff3,tmpZff2),cmp_lStep);
Complex Zff0 = cmp_Base.add(cmp_Base.add(tmpZff12,tmpZff32),zs_Inverse[iStart][iStart]);
//计算故障前故障点电压(iStart + (iEnd - iStart) * lStep)
Complex Vpre_f = cmp_Base.add(vpre_Value[iStart],cmp_Base.multiplication(cmp_Base.subduction(vpre_Value[iEnd],vpre_Value[iStart]),cmp_lStep));
//求不同故障类型在敏感负荷点造成的暂降值以a相为参考相
Complex Temp1 = cmp_Base.add(cmp_Base.add(Zmf0,Zmf1),Zmf2);//Zmf0 + Zmf1 + Zmf2
Complex Temp2 = cmp_Base.add(cmp_Base.add(Zff0,Zff1),Zff2);//Zff0 + Zff1 + Zff2
Complex Temp3 = cmp_Base.dividion(Temp1,Temp2);//Temp1/Temp2
//Complex Temp3 = cmp_Base.multiplication(Vpre_f,Temp1);//Vpre_f * Temp1
//Complex Temp4 = cmp_Base.dividion(Temp3,Temp2);//Temp3/Temp2
Complex Temp11 = cmp_Base.multiplication(alpha,alpha);
Complex Temp12 = cmp_Base.multiplication(Temp11,Zmf1);
Complex Temp13 = cmp_Base.multiplication(alpha,Zmf2);
Complex Temp14 = cmp_Base.multiplication(Temp11,vpre_Value[m]);
Complex Temp15 = cmp_Base.subduction(Temp12,Temp13);
Complex Temp16 = cmp_Base.multiplication(Vpre_f,cmp_Base.add(cmp_Base.multiplication(cmp_Base.subduction(Temp12,Zmf0),Zff2),cmp_Base.multiplication(Temp15,Zff0)));
Complex Temp21 = cmp_Base.multiplication(Zff0,Zff1);
Complex Temp22 = cmp_Base.multiplication(Zff1,Zff2);
Complex Temp23 = cmp_Base.multiplication(Zff2,Zff2);
Complex Temp24 = cmp_Base.add(cmp_Base.add(Temp21,Temp22),Temp23);
//单相接地故障
Complex Vm1 = cmp_Base.subduction(vpre_Value[m],cmp_Base.multiplication(Vpre_f,Temp3));
singleGround[i][j] = Complex.module(Vm1); //求电压幅值
//两相短路
//Complex Vm2 = Temp14 - Vpre_f * Temp15 / (Zff1 + Zff2);
Complex Vm2 = cmp_Base.subduction(Temp14,cmp_Base.dividion(cmp_Base.multiplication(Vpre_f,Temp15),cmp_Base.add(Zff1,Zff2)));
twoPhaseShortOut[i][j] = Complex.module(Vm2); //求电压幅值
//两相短路接地
//Complex Vm3 = Temp14 - Vpre_f *((Temp12 - Zmf0) * Zff2 + Temp15 * Zff0) / (Temp21 + Temp22 + Temp23);
Complex Vm3 =cmp_Base.subduction(Temp14,cmp_Base.dividion(Temp16,Temp24));
twoPhaseGround[i][j] = Complex.module(Vm3); //求电压幅值
//三相短路
//Complex Vm4 = vpre_Value[m] - Vpre_f * Zmf1 / Zff1;
Complex Vm4 = cmp_Base.subduction(vpre_Value[m],cmp_Base.dividion(cmp_Base.multiplication(Vpre_f,Zmf1),Zff1));
threePhaseShortOut[i][j] = Complex.module(Vm4); //求电压幅值
}
}
//求取临界点及暂降域
DipZoneModel[] Usag_area = new DipZoneModel[iLineCount];
int fg = eventType -1;
for (int i = 0; i < iLineCount; i++)
{
int iStart = (int)ps_Value[i][0] - 1;//线路首端编号
int iEnd = (int)ps_Value[i][1] - 1;//线路末端编号
double dlength = ps_Value[i][5];//线路末端编号
lStep = 0;
double[] sag = new double[nLineStepCount];//暂降的点位
List<Double> sag1 = new ArrayList<>();
int nSagCount = 0;
for (int j = 0; j < nLineStepCount; j++)
{
lStep += stepValue;//加上步距
switch (fg)
{
//单相接地故障
case 0:
//统计处于暂降域的故障点
if (singleGround[i][j] <= uthre) {
sag[j] = lStep;
sag1.add(lStep);
nSagCount++;
}
break;
//两相短路
case 1:
//统计处于暂降域的故障点
if (twoPhaseShortOut[i][j] <= uthre) {
sag[j] = lStep;
sag1.add(lStep);
nSagCount++;
}
break;
//两相短路接地
case 2:
//统计处于暂降域的故障点
if (twoPhaseGround[i][j] <= uthre) {
sag[j] = lStep;
sag1.add(lStep);
nSagCount++;
}
break;
//三相短路
case 3:
//统计处于暂降域的故障点
if (threePhaseShortOut[i][j] <= uthre) {
sag[j] = lStep;
sag1.add(lStep);
nSagCount++;
}
break;
}
}
Usag_area[i] = new DipZoneModel();
Usag_area[i].setHead(iStart + 1);
Usag_area[i].setTail(iEnd + 1);
if (nSagCount == 0)//整条线路都不处于暂降域
{
Usag_area[i].setJudgeType(DipZoneModel.SagJudge.SAG_NONE);
}
else if (nSagCount >= (nLineStepCount-1))//整条线路都处于暂降域
{
Usag_area[i].setJudgeType(DipZoneModel.SagJudge.SAG_ALL);
Usag_area[i].setNode2(1);
}
else if (sag[1] == stepValue && sag[nLineStepCount - 1] == 0)//暂降域为线路首端-临界点
{
Usag_area[i].setJudgeType(DipZoneModel.SagJudge.SAG_SIGLE);
Usag_area[i].setNode1(0);
Usag_area[i].setNode2(sag1.get(sag1.size() - 1));
}
else if (sag[1] == 0.0 && sag[nLineStepCount - 1] == (lStep-stepValue))//暂降域为临界点-线路末端
{
Usag_area[i].setJudgeType(DipZoneModel.SagJudge.SAG_SIGLE);
Usag_area[i].setNode1(sag1.get(0));
Usag_area[i].setNode2(1);
}
else
{
int pp = 0;
double p1 = 0;
double p2 = 0;
for (int t = 1; t < nLineStepCount; t++)
{
if (sag[t] == 0 && pp == 0)
{
p1 = (t - 2) * stepValue;
pp = 1;
}
if (sag[t] != 0 && pp == 1)
{
p2 = (t - 1) * stepValue;
break;
}
}
Usag_area[i].setJudgeType(DipZoneModel.SagJudge.SAG_SIGLE) ;
Usag_area[i].setNode1(p1) ;
Usag_area[i].setNode2(p2) ;
}
Usag_area[i].setNodeLength1(PubUtils.doubleRound(6,Usag_area[i].getNode1() * dlength)) ;
Usag_area[i].setNodeLength2(PubUtils.doubleRound(6,Usag_area[i].getNode2() * dlength)) ;
}
return Usag_area;
}
/**********************************************
* 根据线路条目和对应数组获取节点正序、零序导纳矩阵
* iNodeCount 节点目数
* iLineCount 线路目数
* param_Value 正序、零序数组
**********************************************/
private Complex[][] getMatrix(int iNodeCount,int iLineCount,double[][] param_Value){
Complex cmp_Base=new Complex(0,0);//做计算基础
int iAllCount = param_Value.length;//数组总长度(包含了线路+变压器支路)
//求节点正序导纳矩阵
Complex[][] result_Complex = new Complex[iNodeCount][iNodeCount];
//默认初始值为0
for(int i = 0; i < iNodeCount; i++){
for(int j = 0; j < iNodeCount; j++){
result_Complex[i][j] = cmp_Base;
}
}
for(int i = 0; i < iLineCount; i++)
{
int iStart = (int)param_Value[i][0] - 1;//首节点序号
int iEnd = (int)param_Value[i][1] - 1;//末点序号
Complex cmp_Line = new Complex(param_Value[i][2],param_Value[i][3]);//电阻+电抗i
result_Complex[iStart][iEnd] = cmp_Base.dividion(new Complex(-1,0),cmp_Line);
result_Complex[iEnd][iStart] = result_Complex[iStart][iEnd];
result_Complex[iStart][iStart] = cmp_Base.add(cmp_Base.add(result_Complex[iStart][iStart],cmp_Base.dividion(new Complex(1,0),cmp_Line)),new Complex(0,param_Value[i][4]));
result_Complex[iEnd][iEnd] = cmp_Base.add(cmp_Base.add(result_Complex[iEnd][iEnd],cmp_Base.dividion(new Complex(1,0),cmp_Line)), new Complex(0, param_Value[i][4]));
}
//变压器支路
for(int i = iLineCount;i < iAllCount;i++)
{
int iStart = (int)param_Value[i][0] - 1;//首节点序号
int iEnd = (int)param_Value[i][1] - 1;//末点序号
Complex cmp_Line = new Complex(0,param_Value[i][3] * param_Value[i][4]);//(电阻+电抗)i
result_Complex[iStart][iEnd] = cmp_Base.dividion(new Complex(-1,0),cmp_Line);
result_Complex[iEnd][iStart] = result_Complex[iStart][iEnd];
result_Complex[iStart][iStart] = cmp_Base.add(cmp_Base.add(result_Complex[iStart][iStart],cmp_Base.dividion(new Complex(1,0),cmp_Line)),cmp_Base.multiplication(cmp_Base.dividion(new Complex(1 - param_Value[i][4],0),new Complex(0, Math.pow(param_Value[i][4],2))),new Complex(0, param_Value[i][3])));
result_Complex[iEnd][iEnd] = cmp_Base.add(cmp_Base.add(result_Complex[iEnd][iEnd],cmp_Base.dividion(new Complex(1,0),cmp_Line)),cmp_Base.multiplication(cmp_Base.dividion(new Complex(param_Value[i][4] - 1,0), new Complex(0, param_Value[i][4])),new Complex(0, param_Value[i][3])));
}
return result_Complex;
}
}

View File

@@ -0,0 +1,705 @@
package com.pqs9200.utils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.TextAlignment;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.apache.poi.xwpf.usermodel.XWPFStyle;
import org.apache.poi.xwpf.usermodel.XWPFStyles;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType;
import com.njcn.pojo.commons.EventEigDetail;
import com.njcn.pojo.commons.EventInfoDetail;
import com.njcn.pojo.commons.WaveData;
import com.njcn.utils.echarts.EchartsUtil;
import com.njcn.utils.echarts.FreemarkerUtil;
import freemarker.template.TemplateException;
import net.sf.json.JSONArray;
import sun.misc.BASE64Decoder;
public class WordUtil {
private Map<Integer, List<byte[]>> listShunPic = new HashMap<>();
private Map<Integer, List<byte[]>> listRmsPic = new HashMap<>();
private XWPFDocument document;
private Map<Integer, List<EventEigDetail>> eventDetailEigenvalue = new HashMap<>();
private Map<Integer, EventInfoDetail> eventInfoList = new HashMap<>();
public void setEventInfoList(Integer index, EventInfoDetail eventInfoList) {
EventInfoDetail tmp = eventInfoList == null ? new EventInfoDetail() : eventInfoList;
this.eventInfoList.put(index, tmp);
}
public void setEventDetailEigenvalue(Integer index, List<EventEigDetail> eventDetailEigenvalue) {
List<EventEigDetail> tmp = eventDetailEigenvalue == null ? new ArrayList<>() : eventDetailEigenvalue;
this.eventDetailEigenvalue.put(index, tmp);
}
public XWPFDocument getDocument() {
return document;
}
public WordUtil() {
this.document = new XWPFDocument();
}
public void translateShun(Integer index, List<String> strPic) {
BASE64Decoder decoder = new BASE64Decoder();
List<byte[]> tmp = new ArrayList<>();
for (int i = 0; i < strPic.size(); i++) {
try {
byte[] buffer = decoder.decodeBuffer(strPic.get(i));
tmp.add(buffer);
} catch (Exception e) {
}
}
listShunPic.put(index, tmp);
}
public void translateRms(Integer index, List<String> strPic) {
BASE64Decoder decoder = new BASE64Decoder();
List<byte[]> tmp = new ArrayList<>();
for (int i = 0; i < strPic.size(); i++) {
try {
byte[] buffer = decoder.decodeBuffer(strPic.get(i));
tmp.add(buffer);
} catch (Exception e) {
}
}
listRmsPic.put(index, tmp);
}
public void createReport(Integer length) throws IOException, InvalidFormatException {
setHeadingStyle(this.document);
// 添加标题
XWPFParagraph titleParagraph = getCenterParagraph(this.document);
addLine(titleParagraph, 11);
// 设置段落居中
XWPFRun titleParagraphBigRun = titleParagraph.createRun();
addParagraph(titleParagraphBigRun, "宋体", 28, "000000", "暂降事件报告", true);
addLine(titleParagraph, 17);
XWPFRun titleParagraphDateRun = titleParagraph.createRun();
addParagraph(titleParagraphDateRun, "宋体", 16, "000000", "南京灿能电力自动化股份有限公司", false);
addLine(titleParagraph, 1);
titleParagraphDateRun = titleParagraph.createRun();
addParagraph(titleParagraphDateRun, "宋体", 14, "000000", "生成时间:" + getRightNow(), false);
addLine(titleParagraph, 8);
titleParagraph = getLeftParagraph(this.document);
titleParagraphDateRun = titleParagraph.createRun();
addParagraph(titleParagraphDateRun, "宋体", 10, "000000", "【申明】本公司保留对报告的修改权,恕不另行通知,敬请关注最新版本。", false);
for (int m = 0; m < length; m++) {
List<EventEigDetail> eventDetailEigenvaluetmp = this.eventDetailEigenvalue.get(m);
SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String time = sdfs.format(eventInfoList.get(m).getTimeID());
createTitle(document, String.valueOf(m+1) + ". " +time, "标题 1", 0, 20);
createTitle(document, String.valueOf(m+1) + "." +"1. 基本信息", "标题 2", 0, 15);
XWPFParagraph introductionContentParagraph = getLeftParagraph(document);
introductionContentParagraph.setIndentationFirstLine(200);
XWPFRun introductionContentRun = introductionContentParagraph.createRun();
addParagraph(introductionContentRun, "宋体", 11, "000000",
eventInfoList.get(m).getGdName() + "" + eventInfoList.get(m).getBdzName() + ",网络参数:" + eventInfoList.get(m).getIp()
+ "" + eventInfoList.get(m).getLineName() + "" + time + "发生暂降事件,特征幅值:"
+ String.valueOf(eventInfoList.get(m).getEventValue()) + "%,持续时间:" + eventInfoList.get(m).getPersistTime()
+ "s。",
false);
createTitle(document, String.valueOf(m+1) + "." +"2. 波形图", "标题 2", 0, 15);
createTitle(document, String.valueOf(m+1) + "." +"2.1 瞬时波形图", "标题 3", 200, 11);
for(int shun = 0;shun< listShunPic.get(m).size();shun++){
createPic(document, "瞬时波形"+String.valueOf(shun), listShunPic.get(m).get(shun));
}
createTitle(document, String.valueOf(m+1) + "." +"2.2 RMS波形图", "标题 3", 200, 11);
for(int rms = 0;rms< listRmsPic.get(m).size();rms++){
createPic(document, "RMS波形"+String.valueOf(rms), listRmsPic.get(m).get(rms));
}
createTitle(document, String.valueOf(m+1) + "." +"3. 多特征值", "标题 2", 0, 15);
XWPFParagraph value = getLeftParagraph(document);
XWPFRun valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "事件总分段数:" + eventDetailEigenvaluetmp.size(), false);
addLine(value, 1);
if (eventDetailEigenvaluetmp.size() == 0) {
continue;
}
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "暂降原因:" + eventDetailEigenvaluetmp.get(0).getSagReason(), false);
addLine(value, 1);
for (int i = 0; i < eventDetailEigenvaluetmp.size(); i++) {
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "分段" + (i + 1) + "多特征值", true);
addLine(value, 1);
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000",
"波形起始点相位(°)" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + ""
+ eventDetailEigenvaluetmp.get(i).getPow_a() + " "
+ (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + ""
+ eventDetailEigenvaluetmp.get(i).getPow_b() + " "
+ ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? ""
: ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + ""
+ eventDetailEigenvaluetmp.get(i).getPow_c())),
false);
addLine(value, 1);
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000",
"跳变段电压变化率(V/ms)" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + ""
+ eventDetailEigenvaluetmp.get(i).getVoltagechange_Va() + " "
+ (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + ""
+ eventDetailEigenvaluetmp.get(i).getVoltagechange_Vb() + " "
+ ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? ""
: ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + ""
+ eventDetailEigenvaluetmp.get(i).getVoltagechange_Vc())),
false);
addLine(value, 1);
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000",
"相位跳变(°)" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + ""
+ eventDetailEigenvaluetmp.get(i).getAngle_diff_ap() + " "
+ (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + ""
+ eventDetailEigenvaluetmp.get(i).getAngle_diff_bp() + " "
+ ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? ""
: ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + ""
+ eventDetailEigenvaluetmp.get(i).getAngle_diff_cp())),
false);
/*
* addLine(value, 1); valuex = value.createRun();
* addParagraph(valuex, "宋体", 11, "000000", "特征幅值(V)A相" +
* this.eventDetailEigenvalue.get(i).getUa_min() + " B相" +
* this.eventDetailEigenvalue.get(i).getUb_min() + " C相" +
* this.eventDetailEigenvalue.get(i).getUc_min(), false);
*/
/*
* addLine(value, 1); valuex = value.createRun();
* addParagraph(valuex, "宋体", 11, "000000", "持续时间(ms)" +
* this.eventDetailEigenvalue.get(i).getHold_time_dq(), false);
*/
addLine(value, 1);
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000",
"不平衡度(%)" + eventDetailEigenvaluetmp.get(i).getBph_max_value(), false);
addLine(value, 1);
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "暂降类型:" + eventDetailEigenvaluetmp.get(i).getSagType(),
false);
addLine(value, 1);
}
}
}
public void createPic(XWPFDocument document, String name, byte[] base64Info)
throws IOException, InvalidFormatException {
XWPFParagraph picParagraph = getCenterParagraph(document);
XWPFRun createRun = picParagraph.createRun();
InputStream in = new ByteArrayInputStream(base64Info);
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
}
public void createTitle(XWPFDocument document, String message, String style, int line, int fontSize) {
XWPFParagraph summaeTableParagraph = getLeftParagraph(document);
summaeTableParagraph.setStyle(style);
summaeTableParagraph.setIndentationFirstLine(line);
XWPFRun summaeTableRun = summaeTableParagraph.createRun();
addParagraph(summaeTableRun, "宋体", fontSize, "000000", message, false);
}
public void setParagraphStyle(XWPFParagraph paragraph) {
paragraph.setSpacingBefore(100);
paragraph.setSpacingAfter(100);
}
/**
* 返回指定格式的段落 居中型
*
* @param document
* 文档对象
*/
public XWPFParagraph getCenterParagraph(XWPFDocument document) {
XWPFParagraph paragraph = document.createParagraph();
setParagraphStyle(paragraph);
paragraph.setAlignment(ParagraphAlignment.CENTER);
paragraph.setVerticalAlignment(TextAlignment.CENTER);
return paragraph;
}
/**
* 返回指定格式的段落 居左型
*
* @param document
* 文档对象
*/
public XWPFParagraph getLeftParagraph(XWPFDocument document) {
XWPFParagraph paragraph = document.createParagraph();
setParagraphStyle(paragraph);
paragraph.setAlignment(ParagraphAlignment.LEFT);
return paragraph;
}
/**
* 添加换行符
*
* @param paragraph
* 指定段落
* @param amount
* 行数
*/
public void addLine(XWPFParagraph paragraph, Integer amount) {
XWPFRun run = paragraph.createRun();
run.setFontSize(11);
for (int i = 0; i < amount; i++) {
run.addCarriageReturn();
}
}
/**
* 添加段落文本
*
* @param run
* 文本执行对象
* @param fontFamily
* 字体类型
* @param fontSize
* 字体大小
* @param backgroundColor
* 字体颜色
* @param bold
* 是否加粗
*/
public void addParagraph(XWPFRun run, String fontFamily, Integer fontSize, String backgroundColor, String message,
boolean bold) {
run.setText(message);
run.setColor(backgroundColor);
run.setFontSize(fontSize);
run.setFontFamily(fontFamily);
run.setBold(bold);
}
/**
* 增加自定义标题样式。这里用的是stackoverflow的源码
*
* @param docxDocument
* 目标文档
* @param strStyleId
* 样式名称
* @param headingLevel
* 样式级别
*/
public void addCustomHeadingStyle(XWPFDocument docxDocument, String strStyleId, int headingLevel) {
CTStyle ctStyle = CTStyle.Factory.newInstance();
ctStyle.setStyleId(strStyleId);
CTString styleName = CTString.Factory.newInstance();
styleName.setVal(strStyleId);
ctStyle.setName(styleName);
CTDecimalNumber indentNumber = CTDecimalNumber.Factory.newInstance();
indentNumber.setVal(BigInteger.valueOf(headingLevel));
// lower number > style is more prominent in the formats bar
ctStyle.setUiPriority(indentNumber);
CTOnOff onoffnull = CTOnOff.Factory.newInstance();
ctStyle.setUnhideWhenUsed(onoffnull);
// style shows up in the formats bar
ctStyle.setQFormat(onoffnull);
// style defines a heading of the given level
CTPPr ppr = CTPPr.Factory.newInstance();
ppr.setOutlineLvl(indentNumber);
ctStyle.setPPr(ppr);
XWPFStyle style = new XWPFStyle(ctStyle);
// is a null op if already defined
XWPFStyles styles = docxDocument.createStyles();
style.setType(STStyleType.PARAGRAPH);
styles.addStyle(style);
}
/**
* 设置文档中标题格式
*/
public void setHeadingStyle(XWPFDocument document) {
addCustomHeadingStyle(document, "标题 1", 1);
addCustomHeadingStyle(document, "标题 2", 2);
addCustomHeadingStyle(document, "标题 3", 3);
addCustomHeadingStyle(document, "标题 4", 4);
addCustomHeadingStyle(document, "标题 5", 5);
addCustomHeadingStyle(document, "标题 6", 6);
addCustomHeadingStyle(document, "标题 7", 7);
}
/**
* 给表格添加一行数据
*
* @param paragraph
* 段落对象
* @param row
* 行对象
* @param data
* 不定长度的数据
*/
public void setExcelContent(XWPFParagraph paragraph, XWPFTableRow row, String... data) {
for (int i = 0; i < data.length; i++) {
XWPFRun run = paragraph.createRun();
run.setFontFamily("宋体");
run.setText(data[i]);
row.getCell(i).setParagraph(paragraph);
paragraph.removeRun(0);
}
}
/**
* 添加表头标题一行数据
*
* @param paragraph
* 段落对象
* @param row
* 行对象
* @param data
* 不定长度的数据
*/
public void setExcelHeadContent(XWPFParagraph paragraph, XWPFTableRow row, String... data) {
XWPFRun run = paragraph.createRun();
run.setFontFamily("宋体");
run.setBold(true);
run.setText(data[0]);
row.getCell(0).setParagraph(paragraph);
paragraph.removeRun(0);
for (int i = 1; i < data.length; i++) {
XWPFRun run1 = paragraph.createRun();
run1.setFontFamily("宋体");
run1.setBold(true);
run1.setText(data[i]);
row.addNewTableCell().setParagraph(paragraph);
paragraph.removeRun(0);
}
}
/**
* 获取当前的日期
*
* @return
*/
public String getRightNow() {
Calendar rightNow = Calendar.getInstance();
Integer year = rightNow.get(Calendar.YEAR);
Integer month = rightNow.get(Calendar.MONTH) + 1;
Integer day = rightNow.get(rightNow.DAY_OF_MONTH);
return year + "" + month + "" + day + "";
}
public String createWave(WaveData waveData) throws Exception {
HashMap<String, Object> datas = new HashMap<>();
List<List<Float>> sunData = waveData.getSunData();
int iphasic =waveData.getiPhasic();
float pt = waveData.getPt() / 1000;
float ifmax = 0f, ifmin = 0f;
List<List<Float>> adata = new ArrayList<>();
List<List<Float>> bdata = new ArrayList<>();
List<List<Float>> cdata = new ArrayList<>();
if (sunData.size() > 0) {
ifmax = sunData.get(0).get(1) * pt;
ifmin = sunData.get(0).get(1) * pt;
}
List<String> colors =new ArrayList<>();
for (int i = 0; i < sunData.size(); i++) {
float x = sunData.get(i).get(0);
if(iphasic==1){
float shunFirstA = sunData.get(i).get(1) * pt;
List<Float> a = new ArrayList() {
{
add(x);
add(shunFirstA);
}
};
adata.add(a);
ifmax = ifmax > shunFirstA ? ifmax : shunFirstA;
ifmin = ifmin < shunFirstA ? ifmin : shunFirstA;
colors.add("#DAA520");
colors.add("#fff");
colors.add("#fff");
datas.put("a", waveData.getA());
datas.put("b", "");
datas.put("c", "");
}else if(iphasic==2){
float shunFirstA = sunData.get(i).get(1) * pt;
float shunFirstB = sunData.get(i).get(2) * pt;
List<Float> a = new ArrayList() {
{
add(x);
add(shunFirstA);
}
};
adata.add(a);
List<Float> b = new ArrayList() {
{
add(x);
add(shunFirstB);
}
};
bdata.add(b);
ifmax = getMaxTwo(ifmax, shunFirstA, shunFirstB);
ifmin = getMinTwo(ifmin, shunFirstA, shunFirstB);
colors.add("#DAA520");
colors.add("#2E8B57");
colors.add("#fff");
datas.put("a", waveData.getA());
datas.put("b", waveData.getB());
datas.put("c", "");
}else if(iphasic==3){
float shunFirstA = sunData.get(i).get(1) * pt;
float shunFirstB = sunData.get(i).get(2) * pt;
float shunFirstC = sunData.get(i).get(3) * pt;
List<Float> a = new ArrayList() {
{
add(x);
add(shunFirstA);
}
};
adata.add(a);
List<Float> b = new ArrayList() {
{
add(x);
add(shunFirstB);
}
};
bdata.add(b);
List<Float> c = new ArrayList() {
{
add(x);
add(shunFirstC);
}
};
cdata.add(c);
ifmax = getMax(ifmax, shunFirstA, shunFirstB, shunFirstC);
ifmin = getMin(ifmin, shunFirstA, shunFirstB, shunFirstC);
colors.add("#DAA520");
colors.add("#2E8B57");
colors.add("#A52a2a");
datas.put("a", waveData.getA());
datas.put("b", waveData.getB());
datas.put("c", waveData.getC());
}
}
String time = waveData.getTime();
time = time.replace(" ", "%20");
float severity = waveData.getYzd();
String strSeverity = String.valueOf(severity);
String type = waveData.getWaveType();
if (severity < 0) {
strSeverity = "/";
type = "/";
}
String title = "监测点名称:" + waveData.getLineName() + "%20发生时刻" + time + "%20特征幅值" + waveData.getEventValue()
+ "%25%20持续时间" + waveData.getPersistTime() + "s";
datas.put("title", title);
datas.put("adata", JSONArray.fromObject(adata).toString());
datas.put("bdata", JSONArray.fromObject(bdata).toString());
datas.put("cdata", JSONArray.fromObject(cdata).toString());
datas.put("unit", "kV");
datas.put("max", String.valueOf(ifmax));
datas.put("min", String.valueOf(ifmin));
datas.put("colors", JSONArray.fromObject(colors).toString());
datas.put("cshow", Boolean.toString(!waveData.getOpenTri()));
String option = FreemarkerUtil.generateString("wave.ftl", "com/pqs9200/template", datas);
return EchartsUtil.generateEchartsBase64(option, "3003");
}
public String createRms(WaveData waveData) throws IOException, TemplateException {
List<List<Float>> rmsData = waveData.getRmsData();
HashMap<String, Object> datas = new HashMap<>();
int iphasic =waveData.getiPhasic();
float pt = waveData.getPt() / 1000;
List<List<Float>> adata = new ArrayList<>();
List<List<Float>> bdata = new ArrayList<>();
List<List<Float>> cdata = new ArrayList<>();
List<String> colors =new ArrayList<>();
for (int i = 0; i < rmsData.size(); i++) {
float x = rmsData.get(i).get(0);
if(iphasic==1){
float rmsFirstA = rmsData.get(i).get(1) * pt;
List<Float> a = new ArrayList() {
{
add(x);
add(rmsFirstA);
}
};
adata.add(a);
colors.add("#DAA520");
colors.add("#fff");
colors.add("#fff");
datas.put("a", waveData.getA());
datas.put("b", "");
datas.put("c", "");
}else if(iphasic==2){
float rmsFirstA = rmsData.get(i).get(1) * pt;
float rmsFirstB = rmsData.get(i).get(2) * pt;
List<Float> a = new ArrayList() {
{
add(x);
add(rmsFirstA);
}
};
adata.add(a);
List<Float> b = new ArrayList() {
{
add(x);
add(rmsFirstB);
}
};
bdata.add(b);
colors.add("#DAA520");
colors.add("#2E8B57");
colors.add("#fff");
datas.put("a", waveData.getA());
datas.put("b", waveData.getB());
datas.put("c", "");
}else if(iphasic==3){
float rmsFirstA = rmsData.get(i).get(1) * pt;
float rmsFirstB = rmsData.get(i).get(2) * pt;
float rmsFirstC = rmsData.get(i).get(3) * pt;
List<Float> a = new ArrayList() {
{
add(x);
add(rmsFirstA);
}
};
adata.add(a);
List<Float> b = new ArrayList() {
{
add(x);
add(rmsFirstB);
}
};
bdata.add(b);
List<Float> c = new ArrayList() {
{
add(x);
add(rmsFirstC);
}
};
cdata.add(c);
colors.add("#DAA520");
colors.add("#2E8B57");
colors.add("#A52a2a");
datas.put("a", waveData.getA());
datas.put("b", waveData.getB());
datas.put("c", waveData.getC());
}
}
String time = waveData.getTime();
time = time.replace(" ", "%20"); // 时分秒
float severity = waveData.getYzd();
String strSeverity = String.valueOf(severity);
String type = waveData.getWaveType();
if (severity < 0) {
strSeverity = "/";
type = "/";
}
String title = "监测点名称:" + waveData.getLineName() + "%20发生时刻" + time + "%20特征幅值" + waveData.getEventValue()
+ "%25%20持续时间" + waveData.getPersistTime() + "s";
datas.put("title", title);
datas.put("adata", JSONArray.fromObject(adata).toString());
datas.put("bdata", JSONArray.fromObject(bdata).toString());
datas.put("cdata", JSONArray.fromObject(cdata).toString());
datas.put("unit", "kV");
datas.put("colors", JSONArray.fromObject(colors).toString());
datas.put("cshow", Boolean.toString(!waveData.getOpenTri()));
String option = FreemarkerUtil.generateString("rms.ftl", "com/pqs9200/template", datas);
return EchartsUtil.generateEchartsBase64(option, "3003");
}
private float getMin(float temp, float tempA, float tempB, float tempC) {
temp = temp < tempA ? temp : tempA;
temp = temp < tempB ? temp : tempB;
temp = temp < tempC ? temp : tempC;
return temp;
}
private float getMinTwo(float temp, float tempA, float tempB) {
temp = temp < tempA ? temp : tempA;
temp = temp < tempB ? temp : tempB;
return temp;
}
private float getMax(float temp, float tempA, float tempB, float tempC) {
temp = temp > tempA ? temp : tempA;
temp = temp > tempB ? temp : tempB;
temp = temp > tempC ? temp : tempC;
return temp;
}
private float getMaxTwo(float temp, float tempA, float tempB) {
temp = temp > tempA ? temp : tempA;
temp = temp > tempB ? temp : tempB;
return temp;
}
}

View File

@@ -0,0 +1,368 @@
package com.pqs9200.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.math.BigInteger;
import java.util.Calendar;
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.TextAlignment;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.apache.poi.xwpf.usermodel.XWPFStyle;
import org.apache.poi.xwpf.usermodel.XWPFStyles;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
public class WordUtils {
public static void main(String[] args)throws Exception {
// 空白文档
XWPFDocument document= new XWPFDocument();
//把文档写进本地系统
FileOutputStream out = new FileOutputStream(new File("create_table.docx"));
//设定标题格式
setHeadingStyle(document);
//添加标题
XWPFParagraph titleParagraph = document.createParagraph();
setParagraphStyle(titleParagraph);
addLine(titleParagraph,11);
//设置段落居中
titleParagraph.setAlignment(ParagraphAlignment.CENTER);
XWPFRun titleParagraphRun = titleParagraph.createRun();
addParagraph(titleParagraphRun,"宋体",15,"000000","四川省供电公司",true);
addLine(titleParagraph,3);
XWPFRun titleParagraphBigRun = titleParagraph.createRun();
addParagraph(titleParagraphBigRun,"宋体",36,"000000","电压暂降事件分析报告",true);
addLine(titleParagraph,19);
XWPFRun titleParagraphDateRun = titleParagraph.createRun();
addParagraph(titleParagraphDateRun,"宋体",14,"000000","日期: 2018年1月3号",true);
titleParagraph.setPageBreak(true);
//段落
XWPFParagraph statisticsParagraph = document.createParagraph();
setParagraphStyle(statisticsParagraph);
//段前分页
statisticsParagraph.setPageBreak(true);
statisticsParagraph.setAlignment(ParagraphAlignment.CENTER);
XWPFRun statisticsRun = statisticsParagraph.createRun();
addParagraph(statisticsRun,"宋体",24,"000000","电压暂降事件分析报告",false);
XWPFParagraph introductionParagraph= document.createParagraph();
setParagraphStyle(introductionParagraph);
introductionParagraph.setStyle("标题 1");
introductionParagraph.setAlignment(ParagraphAlignment.LEFT);
XWPFRun introductionRun = introductionParagraph.createRun();
addParagraph(introductionRun,"宋体",15,"000000","1. 引言",true);
XWPFParagraph introductionContentParagraph = document.createParagraph();
// 首行缩进---段落
setParagraphStyle(introductionContentParagraph);
introductionContentParagraph.setAlignment(ParagraphAlignment.LEFT);
introductionContentParagraph.setIndentationFirstLine(200);
XWPFRun introductionContentRun=introductionContentParagraph.createRun();
addParagraph(introductionContentRun,"宋体",11,"000000","对所选中区间内电压暂降事件进行分析,能够直观清晰查看相应的暂降事件信息。",false);
XWPFParagraph objectParagraph=document.createParagraph();
setParagraphStyle(objectParagraph);
objectParagraph.setStyle("标题 1");
objectParagraph.setAlignment(ParagraphAlignment.LEFT);
XWPFRun objectRun= objectParagraph.createRun();
addParagraph(objectRun,"宋体",15,"000000","2. 报告分析对象:",true);
XWPFParagraph objectContentParagraph = document.createParagraph();
setParagraphStyle(objectContentParagraph);
objectContentParagraph.setAlignment(ParagraphAlignment.LEFT);
objectContentParagraph.setIndentationFirstLine(200);
XWPFRun objectContentRun = objectContentParagraph.createRun();
addParagraph(objectContentRun,"宋体",11,"000000","成都供电公司—>锦江区变电站—>锦江2号。",false);
XWPFParagraph timeParagraph = document.createParagraph();
timeParagraph.setStyle("标题 1");
timeParagraph.setAlignment(ParagraphAlignment.LEFT);
setParagraphStyle(timeParagraph);
XWPFRun timeRun = timeParagraph.createRun();
addParagraph(timeRun,"宋体",15,"000000","3. 报告分析时间:",true);
XWPFParagraph timeContentParagraph = document.createParagraph();
setParagraphStyle(timeContentParagraph);
timeContentParagraph.setAlignment(ParagraphAlignment.LEFT);
timeContentParagraph.setIndentationFirstLine(200);
XWPFRun timeContentRun = timeContentParagraph.createRun();
addParagraph(timeContentRun,"宋体",11,"000000","2017年12月21日至2017年12月30日。",false);
XWPFParagraph summaeParagraph = document.createParagraph();
setParagraphStyle(summaeParagraph);
summaeParagraph.setStyle("标题 1");
summaeParagraph.setAlignment(ParagraphAlignment.LEFT);
XWPFRun summaeRun = summaeParagraph.createRun();
addParagraph(summaeRun,"宋体",15,"000000","4. 汇总信息:",true);
XWPFParagraph summaeTableParagraph = document.createParagraph();
setParagraphStyle(summaeTableParagraph);
summaeTableParagraph.setStyle("标题 2");
summaeTableParagraph.setAlignment(ParagraphAlignment.LEFT);
summaeTableParagraph.setIndentationFirstLine(200);
XWPFRun summaeTableRun = summaeTableParagraph.createRun();
addParagraph(summaeTableRun,"宋体",11,"000000","4.1 表格",false);
//工作经历表格
XWPFTable summaTable = document.createTable();
//列宽自动分割
CTTblWidth summaTableWidth = summaTable.getCTTbl().addNewTblPr().addNewTblW();
summaTableWidth.setType(STTblWidth.DXA);
summaTableWidth.setW(BigInteger.valueOf(9072));
//表格第一行
XWPFTableRow summaTableRowOne = summaTable.getRow(0);
XWPFParagraph excelParagraph= document.createParagraph();
setParagraphStyle(excelParagraph);
excelParagraph.setAlignment(ParagraphAlignment.CENTER);
excelParagraph.setVerticalAlignment(TextAlignment.CENTER);
setExcelHeadContent(excelParagraph,summaTableRowOne,"序号","暂降发生时刻","暂降幅值(%)","持续时间(ms)","暂降类型","暂降原因","严重度");
//表格第二行
XWPFTableRow summaTableRowTwo = summaTable.createRow();
setExcelContent(excelParagraph,summaTableRowTwo,"1","2017-11-24 14:26:56.490","9","20","未识别","未明","0.91");
//表格第三行
XWPFTableRow summaTableRowThree = summaTable.createRow();
setExcelContent(excelParagraph,summaTableRowThree,"2","2017-11-24 14:25:46.472","15","19","未识别","未明","0.85");
XWPFParagraph summaePicParagraph = document.createParagraph();
summaePicParagraph.setStyle("标题 2");
summaePicParagraph.setAlignment(ParagraphAlignment.LEFT);
summaePicParagraph.setIndentationFirstLine(200);
XWPFRun summaePicRun = summaePicParagraph.createRun();
addParagraph(summaePicRun,"宋体",11,"000000","4.2 ITIC曲线",false);
CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(document, sectPr);
//添加页眉
CTP ctpHeader = CTP.Factory.newInstance();
CTR ctrHeader = ctpHeader.addNewR();
CTText ctHeader = ctrHeader.addNewT();
String headerText = "Java POI create MS word file.";
ctHeader.setStringValue(headerText);
XWPFParagraph headerParagraph = new XWPFParagraph(ctpHeader, document);
//设置为右对齐
headerParagraph.setAlignment(ParagraphAlignment.RIGHT);
XWPFParagraph[] parsHeader = new XWPFParagraph[1];
parsHeader[0] = headerParagraph;
policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT, parsHeader);
//添加页脚
CTP ctpFooter = CTP.Factory.newInstance();
CTR ctrFooter = ctpFooter.addNewR();
CTText ctFooter = ctrFooter.addNewT();
String footerText = "http://blog.csdn.net/zhouseawater";
ctFooter.setStringValue(footerText);
XWPFParagraph footerParagraph = new XWPFParagraph(ctpFooter, document);
headerParagraph.setAlignment(ParagraphAlignment.CENTER);
XWPFParagraph[] parsFooter = new XWPFParagraph[1];
parsFooter[0] = footerParagraph;
policy.createFooter(XWPFHeaderFooterPolicy.DEFAULT, parsFooter);
document.write(out);
out.close();
}
public static void setParagraphStyle(XWPFParagraph paragraph){
paragraph.setSpacingBefore(100);
paragraph.setSpacingAfter(100);
}
/**
* 返回指定格式的段落 居中型
* @param document 文档对象
*/
public static XWPFParagraph getCenterParagraph(XWPFDocument document){
XWPFParagraph paragraph = document.createParagraph();
setParagraphStyle(paragraph);
paragraph.setAlignment(ParagraphAlignment.CENTER);
paragraph.setVerticalAlignment(TextAlignment.CENTER);
return paragraph;
}
/**
* 返回指定格式的段落 居左型
* @param document 文档对象
*/
public static XWPFParagraph getLeftParagraph(XWPFDocument document){
XWPFParagraph paragraph = document.createParagraph();
setParagraphStyle(paragraph);
paragraph.setAlignment(ParagraphAlignment.LEFT);
return paragraph;
}
/**
* 添加换行符
* @param paragraph 指定段落
* @param amount 行数
* */
public static void addLine(XWPFParagraph paragraph,Integer amount){
XWPFRun run = paragraph.createRun();
run.setFontSize(11);
for(int i=0;i<amount;i++){
run.addCarriageReturn();
}
}
/**
* 添加段落文本
* @param run 文本执行对象
* @param fontFamily 字体类型
* @param fontSize 字体大小
* @param backgroundColor 字体颜色
* @param bold 是否加粗
*/
public static void addParagraph(XWPFRun run,String fontFamily,Integer fontSize,String backgroundColor,String message,boolean bold){
run.setText(message);
run.setColor(backgroundColor);
run.setFontSize(fontSize);
run.setFontFamily(fontFamily);
run.setBold(bold);
}
/**
* 增加自定义标题样式。这里用的是stackoverflow的源码
*
* @param docxDocument 目标文档
* @param strStyleId 样式名称
* @param headingLevel 样式级别
*/
public static void addCustomHeadingStyle(XWPFDocument docxDocument, String strStyleId, int headingLevel) {
CTStyle ctStyle = CTStyle.Factory.newInstance();
ctStyle.setStyleId(strStyleId);
CTString styleName = CTString.Factory.newInstance();
styleName.setVal(strStyleId);
ctStyle.setName(styleName);
CTDecimalNumber indentNumber = CTDecimalNumber.Factory.newInstance();
indentNumber.setVal(BigInteger.valueOf(headingLevel));
// lower number > style is more prominent in the formats bar
ctStyle.setUiPriority(indentNumber);
CTOnOff onoffnull = CTOnOff.Factory.newInstance();
ctStyle.setUnhideWhenUsed(onoffnull);
// style shows up in the formats bar
ctStyle.setQFormat(onoffnull);
// style defines a heading of the given level
CTPPr ppr = CTPPr.Factory.newInstance();
ppr.setOutlineLvl(indentNumber);
ctStyle.setPPr(ppr);
XWPFStyle style = new XWPFStyle(ctStyle);
// is a null op if already defined
XWPFStyles styles = docxDocument.createStyles();
style.setType(STStyleType.PARAGRAPH);
styles.addStyle(style);
}
/**
* 设置文档中标题格式
* */
public static void setHeadingStyle(XWPFDocument document){
addCustomHeadingStyle(document, "标题 1", 1);
addCustomHeadingStyle(document, "标题 2", 2);
addCustomHeadingStyle(document, "标题 3", 3);
addCustomHeadingStyle(document, "标题 4", 4);
addCustomHeadingStyle(document, "标题 5", 5);
addCustomHeadingStyle(document, "标题 6", 6);
addCustomHeadingStyle(document, "标题 7", 7);
}
/**
* 给表格添加一行数据
* @param paragraph 段落对象
* @param row 行对象
* @param data 不定长度的数据
*/
public static void setExcelContent(XWPFParagraph paragraph, XWPFTableRow row,String... data){
for (int i=0;i<data.length;i++){
XWPFRun run =paragraph.createRun();
run.setFontFamily("宋体");
run.setText(data[i]);
row.getCell(i).setParagraph(paragraph);
paragraph.removeRun(0);
}
}
/**
* 添加表头标题一行数据
* @param paragraph 段落对象
* @param row 行对象
* @param data 不定长度的数据
*/
public static void setExcelHeadContent(XWPFParagraph paragraph, XWPFTableRow row,String... data){
XWPFRun run= paragraph.createRun();
run.setFontFamily("宋体");
run.setBold(true);
run.setText(data[0]);
row.getCell(0).setParagraph(paragraph);
paragraph.removeRun(0);
for(int i=1;i<data.length;i++){
XWPFRun run1 =paragraph.createRun();
run1.setFontFamily("宋体");
run1.setBold(true);
run1.setText(data[i]);
row.addNewTableCell().setParagraph(paragraph);
paragraph.removeRun(0);
}
}
/**
* 获取当前的日期
* @return
*/
public static String getRightNow(){
Calendar rightNow = Calendar.getInstance();
Integer year = rightNow.get(Calendar.YEAR);
Integer month = rightNow.get(Calendar.MONTH)+1;
Integer day = rightNow.get(rightNow.DAY_OF_MONTH);
return year+""+month+""+day+"";
}
}

View File

@@ -0,0 +1,57 @@
################################通用且因环境变化而变化
#波形文路径(本地配置)
WAVE_PATH=C:/Comtrade
#服务器临时文件路径(用于存储离线、报告存储)
TMP_PATH=C:/
#webSocket
WEBSOCKET=ws://127.0.0.1:8080/pqs9200/websocket/
#socket端口配置
SOCKETPORT=60000
#Kafka
ZOOKEEPER=192.168.1.200:2181
GROUPID=test-consumer-group
TOPIC=eventdata
KAFKA_LOG=false
#报表生成路径
REPORT_PATH=http://www.pqmcc.com:8040/shiningCloud/appfiles/
#服务器白名单
SYSTEM_HOST=192.168.1.211
#是否输出业务日志
BUSINESS_LOG_FLAG=false
#监测点数量级
PID_Number=10000
#9300谐波越限天数
overRunDay=1
#报表查询条件设定(单位:天)
REPORT_DAY=1
#是否发送邮件
MAIL_FLAG=false
#邮件服务器连接地址
MAIL_HOST=smtp.qq.com
#发送方邮箱
MAIL_ADDRESS=83944980@qq.com
#SMTP授权码
SMTP_NUM=tcdulnyrztxjbhfb
#海南短信验证
MSG_USER=1C6CC426DFE8D7C2BC42C7C19F101D80
MSG_PASSWORD=8836E651F09195FA3EE892A1B700DC65
#加密方式 0、base64 1 、3des
CDKEY_ENCY=1
################################独立配置且不随环境变化
#当前系统标志
SYSTEM_FLAG=PQS9200
#当前系统的GUID
SYS_TYPE=1cfcd6e2-c5fe-4b15-988a-32b90f1170c1
SYS_TYPE_ZT=1cfcd6e2-c5fe-4b15-988a-32b90f1170c1
SYS_TYPE_WT=983f9dfe-4f9a-4c96-89d8-7d425a1f1d6c
#sso认证中心url
SSO_URL=http://127.0.0.1:7878/sso/user/
#如果相同容器的话直接根据request获取url配置路径否则自定义配置url
ONE_CONTAINER=true
SSO_JUDGE=http://127.0.0.1:7878/sso/user/judgeLogin?item=pqs9200
#sso认证中心完毕后前往子系统进行二次认证
#如果相同容器的话直接根据request获取url配置路径否则自定义配置url
pqs9200.regist.url=http://127.0.0.1:8080/pqs9200/user/ssoRegister?token=
pqs9000.regist.url=http://127.0.0.1:8088/pqs9000/user/ssoRegister?token=

View File

@@ -0,0 +1,56 @@
# 数据库连接配置
dataSource=Oracle
oracle.driverClass=oracle.jdbc.driver.OracleDriver
#oracle.jdbcUrl=jdbc\:oracle\:thin\:@192.168.1.34\:1521\:PQSBASE
#oracle.user=8836E651F09195FA3EE892A1B700DC65
#oracle.password=110ADDC7B3686BE36E80EB3BC5BD63E8
#oracle.jdbcUrl=jdbc\:oracle\:thin\:@192.168.1.51\:1521\:pqsbase
#oracle.user=8836E651F09195FA6312AD217B40D520
#oracle.password=8836E651F09195FA3EE892A1B700DC65
#jibei
#oracle.jdbcUrl=jdbc\:oracle\:thin\:@192.168.1.51\:1521\:pqsbase
#oracle.user=8836E651F09195FA36F59F764BEC048E
#oracle.password=8836E651F09195FA3EE892A1B700DC65
#本地 jibei
oracle.jdbcUrl=jdbc\:oracle\:thin\:@127.0.0.1\:1521\:ORCL
oracle.user=8836E651F09195FA36F59F764BEC048E
oracle.password=8836E651F09195FA3EE892A1B700DC65
# 池初始化大小
oracle.initialSize=1
# 池最小连接数
oracle.minIdle=1
# 池最大连接数
oracle.maxActive=5
# 获取连接等待超时的时间
oracle.maxWait=60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
oracle.timeBetweenEvictionRunsMillis=60000
# 一个连接在池中最小生存的时间,单位是毫秒
oracle.minEvictableIdleTimeMillis=300000
# 是否打开PSCache
oracle.poolPreparedStatements=false
# 指定每个连接上PSCache的大小
oracle.maxPoolPreparedStatementPerConnectionSize=20
mariadb.driverClass = org.mariadb.jdbc.Driver
mariadb.jdbcUrl=jdbc:mariadb://192.168.1.60:1521/PQSBASE?useUnicode=true&characterEncoding=utf-8&useSSL=false
mariadb.user=8836E651F09195FA77E666C5494E46F1
mariadb.password=8836E651F09195FA3EE892A1B700DC65
# 池初始化大小
mariadb.initialSize=1
# 池最小连接数
mariadb.minIdle=1
# 池最大连接数
mariadb.maxActive=5
# 获取连接等待超时的时间
mariadb.maxWait=60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
mariadb.timeBetweenEvictionRunsMillis=60000
# 一个连接在池中最小生存的时间,单位是毫秒
mariadb.minEvictableIdleTimeMillis=300000
# 是否打开PSCache
mariadb.poolPreparedStatements=false
# 指定每个连接上PSCache的大小
mariadb.maxPoolPreparedStatementPerConnectionSize=20

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<log4j:configuration debug="true">
<!-- 在控制台输出的日志文件info级别以上 -->
<appender name="Console" class="org.apache.log4j.ConsoleAppender">
<param name="Encoding" value="UTF-8"/>
<param name="Threshold" value="ERROR"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p %c %t %m%n"/>
</layout>
</appender>
<!--输出文件中该文件中只能输出info级别的日志 -->
<appender name="INFO" class="org.apache.log4j.DailyRollingFileAppender">
<param name="Encoding" value="UTF-8"/>
<param name="File" value="e:/logs/pqs9200/info/info.log"/>
<!--<param name="File" value="/usr/local/logs/pqs9200/info/info.log" />-->
<param name="DatePattern" value=".yyyy-MM-dd"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p %c %t %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="INFO"/>
<param name="LevelMax" value="INFO"/>
</filter>
</appender>
<!--输出文件中该文件中只能输出erro级别的日志 -->
<appender name="ERROR" class="org.apache.log4j.DailyRollingFileAppender">
<param name="Encoding" value="UTF-8"/>
<param name="File" value="e:/logs/pqs9200/error/error.log"/>
<!--<param name="File" value="/usr/local/logs/pqs9200/error/error.log" />-->
<param name="DatePattern" value=".yyyy-MM-dd"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p %c %t %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="ERROR"/>
<param name="LevelMax" value="ERROR"/>
</filter>
</appender>
<category name="org.apache.ibatis">
<priority value="debug"/>
<appender-ref ref="Console"/>
</category>
<category name="org.mybatis.spring">
<priority value="debug"/>
<appender-ref ref="Console"/>
</category>
<root>
<priority value="INFO"/>
<appender-ref ref="INFO"/>
<appender-ref ref="ERROR"/>
<appender-ref ref="Console"/>
</root>
</log4j:configuration>

View File

@@ -0,0 +1,37 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace='com.njcn.mapper.advanced.GetBalanceMapper'>
<select id="getSarfiValue" resultType="java.lang.Float">
select avg(eventvalue)
from
pqs_eventdetail where eventvalue &lt;= #{fvalue} and lineid
= #{id}
and
timeid between #{start} and #{end}
</select>
<select id="getSarfiCount" resultType="java.lang.Integer">
select count(*)
from
pqs_eventdetail where eventvalue &lt;= #{fvalue} and lineid
= #{id}
and
timeid between #{start} and #{end} and persisttime &lt; 60000
</select>
<select id="getSarifiList" resultType="com.njcn.utils.GetBalance$Sarifi">
select
a.pt1 pt1,
a.pt2 pt2,
b.eventvalue
sarifiValue,b.persisttime time from pq_line a,
pqs_eventdetail b where
b.lineid
= #{id} and a.line_index = b.lineid
and
b.eventvalue &lt;= #{fvalue} and
b.timeid between #{start} and #{end}
and persisttime &lt; 60000
</select>
</mapper>

View File

@@ -0,0 +1,49 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace='com.njcn.mapper.advanced.RangeMapper'>
<select id="queryEventsByTime" resultType="EventAssObj" databaseId="Oracle">
select eventass_index
indexEventAss, timeid
time,range bRange,describe,name from pqs_eventass
where timeid between
#{startTime} and
#{endTime} and eventass_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="queryEventsByTime" resultType="EventAssObj" databaseId="MariaDB">
select eventass_index
indexEventAss, timeid
time,`range` as bRange,`describe`,name from pqs_eventass
where timeid between
#{startTime} and
#{endTime} and eventass_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<update id="updatebRangeByGUID" parameterType="java.lang.String" databaseId="Oracle">
update
pqs_eventass set range = 0 where
eventass_index = #{indexEventAss}
</update>
<update id="updatebRangeByGUID" parameterType="java.lang.String" databaseId="MariaDB">
update
pqs_eventass set `range` = 0 where
eventass_index = #{indexEventAss}
</update>
<select id="getEventAssIndex" resultType="java.lang.String">
select distinct (eventass_index)
from pqs_eventdetail
where lineid in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and eventass_index is not null and timeid between #{start} and #{end}
</select>
</mapper>

View File

@@ -0,0 +1,203 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace='com.njcn.mapper.advanced.RelevanceMapper'>
<!-- 获取暂降事件信息高级映射必须要加id否则查询数据有误 -->
<resultMap type="SagEvent" id="SagEventMap" autoMapping="true">
<id column="indexEventDetail" property="indexEventDetail"/>
<association property="plantInfo" javaType="PlantInfo"
autoMapping="true">
<id property="indexPoint" column="indexPoint"/>
</association>
</resultMap>
<select id="querySagEvents" resultMap="SagEventMap"
parameterType="SagEventsQueryCondition">
select
A.firstMs,
A.waveType,
A.sagTypeDes,
A.severity,
A.firstTime,
A.firstType,
A.fileFlag,
A.dealFlag,
A.indexEventDetail,
A.sagTime,
A.msec,
A.PERSISTTIME,
A.sagType,
A.eventValue,
A.indexPoint,
A.namePoint,
A.nameSubV,
A.nameBD,
A.nameGD,
A.objName,
A.sagSource,
B.dic_name monitorVoltageLevel,
C.dic_name monitorLoadType,
D.dic_name sagReason
from
(
select
pqs_eventdetail.firstms firstMs,
pqs_eventdetail.wavetype waveType,
pqs_dicdata.dic_name sagTypeDes,
pqs_eventdetail.severity severity,
pqs_eventdetail.firsttime firstTime,
pqs_eventdetail.firsttype firstType,
pqs_eventdetail.fileflag fileFlag,
pqs_eventdetail.dealflag dealFlag,
pqs_eventdetail.eventdetail_index indexEventDetail,
pqs_eventdetail.timeid sagTime,
pqs_eventdetail.ms msec,
round(pqs_eventdetail .PERSISTTIME/1000, 3) PERSISTTIME,
pqs_eventdetail.eventtype sagType,
pqs_eventdetail.eventreason eventreason,
pqs_eventdetail.EventValue eventValue,
pq_line.line_index indexPoint,
pq_line.name namePoint,
pq_subvoltage.name nameSubV,
pq_substation.name nameBD,
pq_gdinformation.name nameGD,
pq_line.scale monitorVoltageLevel,
pq_linedetail.loadtype monitorLoadType,
nvl(pq_linedetail.objname,'/') objName,
pqs_eventdetail.sagsource sagSource
from
pq_gdinformation,pq_substation,pq_subvoltage,pq_line,pqs_eventdetail,pq_device,pqs_dicdata,pq_linedetail
where
pq_line.subv_index = pq_subvoltage.subv_index
and
pq_line.sub_index =
pq_substation.sub_index and pq_line.gd_index =
pq_gdinformation.gd_index and pq_line.line_index =
pqs_eventdetail.lineid and pq_line.dev_index = pq_device.dev_index and
pq_device.devmodel = 1 and pq_device.datatype != 1 and pq_device.devflag = 0 and
pqs_dicdata.dic_index = pqs_eventdetail.eventtype and pqs_eventdetail.wavetype != 5
and pq_line.line_index = pq_linedetail.line_index
<if test="startTime != null and endTime != null">
and pqs_eventdetail.timeid between #{startTime} and #{endTime}
and pqs_eventdetail.eventass_index is null
</if>
<if test="lineId != null">
and pqs_eventdetail.lineid = #{lineId}
</if>
) A
LEFT JOIN
pqs_dicdata B
ON A.monitorVoltageLevel = B.dic_index
LEFT JOIN
pqs_dicdata C
ON A.monitorLoadType = C.dic_index
LEFT JOIN
pqs_dicdata D
ON A.EVENTREASON = D.dic_index
</select>
<!-- pqs_eventass批量插入数据 -->
<insert id="insertEventAssData" parameterType="java.util.List">
insert into
pqs_eventass
<foreach collection="list" item="eventAssData" index="index"
separator="UNION ALL">
select
#{eventAssData.indexEventAss},#{eventAssData.time},#{eventAssData.describe},
#{eventAssData.bRange},#{eventAssData.indexUser},#{eventAssData.updateTime},#{eventAssData.state},#{eventAssData.name},null
from dual
</foreach>
</insert>
<insert id="insertRelevance" parameterType="EntityPqsRelevance">
insert into
pqs_relevance values
(#{timeId},#{describe},#{state},#{indexUser},#{timeUpdate})
</insert>
<!-- 批量更新pqs_eventdetail记录 -->
<update id="updateSagEventData" parameterType="java.util.List">
<foreach collection="list" item="SagEvent" index="index"
separator=";" open="begin" close=";end;">
update pqs_eventdetail
<set>
eventass_index = #{SagEvent.indexEventAss},
dealtime =
#{SagEvent.dealTime}
</set>
where timeid = #{SagEvent.sagTime} and ms = #{SagEvent.msec} and
lineid = #{SagEvent.indexPoint}
</foreach>
</update>
<!-- 获取 -->
<select id="queryLineIdbyPointId" resultType="java.lang.Integer"
parameterType="java.lang.Integer">
select subv_index from pq_line where line_index =
#{pointId}
</select>
<select id="queryCodebyGuid" resultType="java.lang.Integer"
parameterType="java.lang.String">
select triphase from pqs_dicdata where dic_index =
#{guid}
</select>
<select id="queryEvents" resultType="EntityPqsRelevance" databaseId="Oracle">
select a.timeid
timeId,a.describe describe,b.loginname userName from pqs_relevance
a,pqs_user b
where a.state = 1 and a.user_index = b.user_index and a.timeid in
(select a.timeid from pqs_relevance a,pqs_eventass b where a.state = 1 and
a.updatetime = b.updatetime group by a.timeid)
</select>
<select id="queryEvents" resultType="EntityPqsRelevance" databaseId="MariaDB">
select a.timeid as
timeId,a.`describe` as `describe`,b.loginname as userName from pqs_relevance
a,pqs_user b
where a.state = 1 and a.user_index = b.user_index and a.timeid in
(select a.timeid from pqs_relevance a,pqs_eventass b where a.state = 1 and
a.updatetime = b.updatetime group by a.timeid)
</select>
<delete id="deleteEvent" parameterType="java.util.Date">
delete from pqs_eventass
where updatetime = #{date}
</delete>
<update id="updateEvent" parameterType="java.util.Date">
update pqs_eventdetail
set eventass_index = '' where dealtime = #{date}
</update>
<update id="updateFlag" parameterType="java.util.Date">
update pqs_relevance set
state = 0 where updatetime = #{date}
</update>
<select id="queryDealTotal" resultType="java.lang.Integer">
select
count(a.eventdetail_index) from pqs_eventdetail a, pq_line b,
pq_device c where a.dealflag = 0
and a.eventass_index is null and a.lineid = b.line_index
and b.dev_index = c.dev_index and c.devmodel = 1 and c.datatype != 1 and c.devflag = 0 and a.lineid in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<select id="queryFileTotal" resultType="java.lang.Integer">
select
count(a.eventdetail_index) from pqs_eventdetail a, pq_line b,
pq_device c where a.fileflag = 0
and a.eventass_index is null and a.lineid = b.line_index
and b.dev_index = c.dev_index and c.devmodel = 1 and c.devflag = 0 and c.datatype != 1 and a.lineid in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,142 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace='com.pqs9200.mapper.advanced.SvgMapper'>
<select id="getSvgCells" resultType="com.pqs9200.pojo.data.SvgCells">
SELECT * FROM SVG_CELLINFO WHERE CELL_INDEX = #{cellId} AND state = 1
</select>
<insert id="saveCell" parameterType="com.pqs9200.pojo.data.SvgCells">
INSERT INTO
SVG_CELLINFO
(
CELL_INDEX,
CELL_NAME,
CABLE_LENGTH,
CELL_LEVEL,
POSITIVE_SEQUENCE_RESISTANCE,
POSITIVE_SEQUENCE_REACTANCE,
ZERO_SEQUENCE_RESISTANCE,
ZERO_SEQUENCE_REACTANCE,
COEFFICIENT,
WIRING_DIAGRAM,
CREATE_BY,
CREATE_TIME,
UPDATE_BY,
UPDATE_TIME,
CELL_TYPE,
RUN_LEVEL,
POSITIVE_ADMITTANCE,
ZERO_ADMITTANCE,
STATE
)
VALUES
(
#{cellIndex},
#{cellName},
#{cableLength},
#{cellLevel},
#{positiveSequenceResistance},
#{positiveSequenceReactance},
#{zeroSequenceResistance},
#{zeroSequenceReactance},
#{coefficient},
#{wiringDiagram},
#{createBy,jdbcType=VARCHAR},
to_date(#{createTime,jdbcType=VARCHAR},'yyyy-MM-dd hh24:mi:ss'),
#{updateBy,jdbcType=VARCHAR},
to_date(#{updateTime,jdbcType=VARCHAR},'yyyy-MM-dd hh24:mi:ss'),
#{cellType},
#{runLevel},
#{positiveAdmittance},
#{zeroAdmittance},
#{state}
)
</insert>
<update id="updateCell" parameterType="com.pqs9200.pojo.data.SvgCells">
UPDATE
SVG_CELLINFO
SET
CELL_NAME = #{cellName},
CABLE_LENGTH = #{cableLength},
CELL_LEVEL=#{cellLevel},
POSITIVE_SEQUENCE_RESISTANCE=#{positiveSequenceResistance},
POSITIVE_SEQUENCE_REACTANCE=#{positiveSequenceReactance},
ZERO_SEQUENCE_RESISTANCE=#{zeroSequenceResistance},
ZERO_SEQUENCE_REACTANCE=#{zeroSequenceReactance},
WIRING_DIAGRAM=#{wiringDiagram},
CREATE_BY=#{createBy,jdbcType=VARCHAR},
CREATE_TIME=to_date(#{createTime,jdbcType=VARCHAR},'yyyy-MM-dd hh24:mi:ss'),
UPDATE_BY=#{updateBy,jdbcType=VARCHAR},
UPDATE_TIME=to_date(#{updateTime,jdbcType=VARCHAR},'yyyy-MM-dd hh24:mi:ss'),
COEFFICIENT=#{coefficient},
RUN_LEVEL=#{runLevel},
POSITIVE_ADMITTANCE=#{positiveAdmittance},
ZERO_ADMITTANCE=#{zeroAdmittance},
STATE=#{state}
WHERE
CELL_INDEX = #{cellIndex}
</update>
<select id="getAllCellsId" resultType="integer">
SELECT CELL_INDEX FROM SVG_CELLINFO WHERE state = 1
</select>
<delete id="deleteCell">
UPDATE SVG_CELLINFO SET STATE = 0 WHERE CELL_INDEX IN
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<select id="getAllCells" resultType="com.pqs9200.pojo.data.SvgCells">
SELECT * FROM SVG_CELLINFO WHERE state = 1
</select>
<insert id="saveSensitivePoint" parameterType="com.pqs9200.pojo.data.SvgSensitivePoint">
INSERT INTO
SVG_CALUCATEINFO
(
CALUCATE_INDEX,
CELL_INDEX,
AMPLITUDE,
DESCENTTYPE,
TIMEID
)
VALUES
(
#{uuidIndex},
#{cellIndex},
#{amplitude},
#{descentType},
to_date(#{time,jdbcType=VARCHAR},'yyyy-MM-dd hh24:mi:ss')
)
</insert>
<select id="getAllCalucateInfo" resultType="com.pqs9200.pojo.data.SvgCalucateInfo">
SELECT
A.CALUCATE_INDEX calucateIndex,
B.CELL_NAME cellName,
A.AMPLITUDE amplitude,
A.TIMEID timeId,
CASE
A.DESCENTTYPE
WHEN 1 THEN '单相接地'
WHEN 2 THEN '两相短路'
WHEN 3 THEN '两相接地'
WHEN 4 THEN '三相接地'
ELSE '无'
END descentType
FROM
SVG_CALUCATEINFO A,
SVG_CELLINFO B
WHERE
A.CELL_INDEX = B.CELL_INDEX ORDER BY A.TIMEID DESC
</select>
<delete id="deleteCalucateInfo">
DELETE SVG_CALUCATEINFO WHERE CALUCATE_INDEX = #{index}
</delete>
</mapper>

View File

@@ -0,0 +1,138 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace='com.njcn.mapper.advanced.WaveformMapper'>
<!-- 抽取sql片段 -->
<sql id="dicType">
select pqs_dicdata.dic_name from pqs_dicdata,pqs_dictype
</sql>
<sql id="dicTypeCondition">
pqs_dicdata.dic_type = pqs_dictype.dictype_index and
</sql>
<resultMap type="SagEvent" id="SagEventMap" autoMapping="true">
<id column="indexEventDetail" property="indexEventDetail"/>
<association property="plantInfo" javaType="PlantInfo"
autoMapping="true">
<id property="indexPoint" column="indexPoint"/>
</association>
</resultMap>
<select id="queryEventsByGUID" resultMap="SagEventMap">
select pqs_eventdetail.eventdetail_index
indexEventDetail,pqs_eventdetail.eventass_index
indexEventAss,pqs_eventdetail.ms msec,pqs_dicdata.dic_name strVoltage,pqs_eventdetail.EventValue
eventValue,round(pqs_eventdetail .PERSISTTIME/1000, 3) PERSISTTIME,
pqs_eventdetail.timeid
sagTime,(
<include refid="dicType"></include>
<where>
<include refid="dicTypeCondition"></include>
pqs_dictype.dictype_name = '暂降原因' and pqs_eventdetail.eventreason =
pqs_dicdata.dic_index
</where>
) sagReason,(
<include refid="dicType"></include>
<where>
<include refid="dicTypeCondition"></include>
pqs_dictype.dictype_name = '暂降类型' and pqs_eventdetail.eventtype =
pqs_dicdata.dic_index
</where>
) sagType,
pq_line.line_index
indexPoint,
pq_line.name
namePoint,pq_subvoltage.name
nameSubV
,pq_substation.name
nameBD,pq_gdinformation.name nameGD
from
pq_gdinformation,pq_substation,pq_subvoltage,pq_line,pqs_eventdetail,pq_device,pqs_dicdata
where
pq_line.subv_index = pq_subvoltage.subv_index
<if test="eventsQueryCondition.strGuid != null and eventsQueryCondition.startTime == null">
and pqs_eventdetail.eventass_index = #{eventsQueryCondition.strGuid}
</if>
<if test="eventsQueryCondition.listIndex != null">
and pqs_eventdetail.eventdetail_index
<foreach collection="eventsQueryCondition.listIndex" item="listIndex" index="index"
separator="," open="in(" close=")">
#{listIndex}
</foreach>
</if>
<if test="eventsQueryCondition.startTime != null and eventsQueryCondition.endTime != null">
and pqs_eventdetail.timeid between #{eventsQueryCondition.startTime} and
#{eventsQueryCondition.endTime} and (pqs_eventdetail.eventass_index &lt;&gt; #{eventsQueryCondition.strGuid}
or pqs_eventdetail.eventass_index is
null) and pq_line.line_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and
pq_line.sub_index =
pq_substation.sub_index and pq_line.gd_index =
pq_gdinformation.gd_index and pq_line.line_index =
pqs_eventdetail.lineid and pq_line.dev_index = pq_device.dev_index and pq_device.devmodel = 1 and pq_device.devflag = 0 and
pq_device.datatype != 1 and pq_line.scale = pqs_dicdata.dic_index
</select>
<update id="addNormalization" parameterType="java.util.List">
<foreach collection="list" item="SagEvent" index="index"
separator=";" open="begin" close=";end;">
update pqs_eventdetail
<set>
eventass_index = #{SagEvent.indexEventAss}
</set>
where (eventass_index &lt;&gt; #{SagEvent.indexEventAss} or eventass_index is null) and
eventdetail_index = #{SagEvent.indexEventDetail}
</foreach>
</update>
<select id="queryDataByGuid" resultMap="SagEventMap" parameterType="string">
select eventdetail_index indexEventDetail,ms msec,timeid sagTime,firsttime firstTime,firstms firstMs
from pqs_eventdetail where eventass_index = #{indexEventAss}
</select>
<delete id='deleteDataByGuid'>
delete from pqs_eventass where eventass_index =
#{indexEventAss}
</delete>
<update id="updateDataByGuid" parameterType="java.util.List" databaseId="Oracle">
<foreach collection="list" item="EventAssObj" index="index"
separator=";" open="begin" close=";end;">
update pqs_eventass
<set>
describe = #{EventAssObj.describe},timeid = #{EventAssObj.time}
,user_index = #{EventAssObj.indexUser}<!-- ,updatetime = #{EventAssObj.updateTime} -->
,name = #{EventAssObj.name}
</set>
where eventass_index = #{EventAssObj.indexEventAss}
</foreach>
</update>
<update id="updateDataByGuid" parameterType="java.util.List" databaseId="MariaDB">
<foreach collection="list" item="EventAssObj" index="index"
separator=";" open="begin" close=";end;">
update pqs_eventass
<set>
`describe` = #{EventAssObj.describe},timeid = #{EventAssObj.time}
,user_index = #{EventAssObj.indexUser}<!-- ,updatetime = #{EventAssObj.updateTime} -->
,name = #{EventAssObj.name}
</set>
where eventass_index = #{EventAssObj.indexEventAss}
</foreach>
</update>
<update id="updateWaveForm" parameterType="java.util.List">
<foreach collection="list" item="guidIndex" index="index"
separator=";" open="begin" close=";end;">
update pqs_eventdetail
<set>
eventass_index = &apos;&apos;
</set>
where eventdetail_index = #{guidIndex}
</foreach>
</update>
</mapper>

View File

@@ -0,0 +1,362 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.configuration.DeviceDetailMapper'>
<resultMap type="DeviceDetail" id="deviceMap" autoMapping="true">
<id column="DEV_INDEX" property="devIndex"/>
</resultMap>
<select id="getDeviceDetails" resultMap="deviceMap">
select DISTINCT
a.name,
a.dev_Index devIndex,
b.gd_index as gdName,
b.name as gdNa,
c.name as subName,
<if test="_databaseId == 'MariaDB'">
date_format(a.logontime,'%Y-%m-%d')
</if>
<if test="_databaseId == 'Oracle'">
to_char(a.logontime, 'yyyy-MM-dd')
</if>
as time,
i.dic_name as manufacturer,
j.dic_name as DevType,
a.ip,
a.portid,
<if test="_databaseId == 'MariaDB'">
case
when a.devflag = 0 then '投运'
when a.devflag = 1 then '热备用'
when a.devflag = 2 then '停运'
end
as devflag,
case
when a.status = 0 then '中断'
when a.status = 1 then '正常'
end
as status,
</if>
<if test="_databaseId == 'Oracle'">
decode(a.devflag, 0, '投运', 1, '热备用', '停运') as devflag,
decode(a.status, 0, '中断', 1, '正常') as status,
</if>
<if test="_databaseId == 'Oracle'">
to_char(a.updatetime, 'yyyy-MM-dd hh24:mi:ss') as updatetime,
</if>
<if test="_databaseId == 'MariaDB'">
date_format(a.updatetime, '%Y-%m-%d %H:%I:%S') as updatetime,
</if>
h.onlineratetj as evaluate
from pq_device a,
pq_gdinformation b,
pq_substation c,
pq_line d,
pq_devicedetail h,
pqs_dicdata i,
pqs_dicdata j
where a.devmodel = 1
and a.datatype in (0,2)
and a.gd_index = b.gd_index
and a.sub_index = c.sub_index
and a.dev_index = h.dev_index
and h.manufacturer = i.dic_index
and a.devtype = j.dic_index
and d.dev_index = a.dev_index
and a.devflag like #{devflag}
and a.status like #{status}
and b.name like #{gdName}
and i.dic_name like #{manufacturer}
and d.line_index in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
order by updatetime desc
</select>
<select id="getGdname" resultMap="deviceMap">
select distinct
b.name as gdNa
from pq_device a,
pq_gdinformation b
where a.devmodel = 1
and a.datatype in (0,2)
and a.gd_index = b.gd_index
and a.gd_index in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
</select>
<select id="getManufacturers" resultMap="deviceMap">
select
distinct i.dic_name as manufacturer
from pq_device a,
pq_line b,
pq_devicedetail h,
pqs_dicdata i
where a.devmodel = 1
and a.datatype in (0,2)
and a.dev_index = h.dev_index
and b.dev_index = a.dev_index
and h.manufacturer = i.dic_index
and b.line_index in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
</select>
<!-- 统计装备型号 -->
<select id="getDevtype" resultMap="deviceMap">
select b.dic_name as
DevType,count(1) as yAxis from pq_device a ,
pqs_dicdata b,pq_line c where
a.DEVMODEL = 1
and a.datatype in (0,2)
and a.devtype=b.dic_index
and c.dev_index = a.dev_index
and c.line_index in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
group by a.devtype ,
b.dic_name
</select>
<!-- 统计终端产家 -->
<select id="getManufacturer" resultMap="deviceMap">
select T3.DIC_NAME AS manufacturer,
count(1) as yAxis from PQ_DEVICE T1
, PQ_DEVICEDETAIL t2,PQS_DICDATA T3,pq_line T4 WHERE T1.DEVMODEL = 1
and T1.datatype in (0,2)
and T1.DEV_INDEX = T2.DEV_INDEX AND T3.DIC_INDEX=T2.MANUFACTURER
and T4.DEV_INDEX = T1.DEV_INDEX
and T4.line_index in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
group by
T3.DIC_NAME
</select>
<!-- 统计电压等级 -->
<select id="getScale" resultMap="deviceMap">
select f.dic_name as Scale,count(1) as yAxis from pqs_dicdata
f,pq_line
a,pq_device b where b.DEVMODEL = 1
and b.datatype in (0,2)
and a.scale=f.dic_index and a.dev_index =
b.dev_index
and a.line_index in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
group by f.dic_name,f.dic_number
order by f.dic_number desc
</select>
<select id="getSelName" resultMap="deviceMap">
select a.ip,
a.PORTID
from pq_device a
where a.name=#{name} and a.datatype in (0,2)
</select>
<select id="getSbyc" resultMap="deviceMap">
select distinct b.name as name,
a.gd_index as gdname,
c.name as subname,
<if test="_databaseId == 'MariaDB'">
date_format(b.logontime, '%Y-%m-%d') as time,
</if>
<if test="_databaseId == 'Oracle'">
to_char(b.logontime, 'yyyy-MM-dd') as time,
</if>
(select m.dic_name from pqs_dicdata m where m.dic_index = b.devtype) as devtype,
b.ip,
b.portid as portid,
<if test="_databaseId == 'MariaDB'">
case
when b.status = 0 then '中断'
when b.status = 1 then '正常'
end
as devflag,
</if>
<if test="_databaseId == 'Oracle'">
decode(b.status, 0,'中断',1, '正常') as devflag,
</if>
<if test="_databaseId == 'Oracle'">
to_char(b.UpdateTime, 'yyyy-MM-dd hh24:mi:ss') as updatetime
</if>
<if test="_databaseId == 'MariaDB'">
date_format(b.UpdateTime, '%Y-%m-%d %H:%I:%S') as updatetime
</if>
from pq_device b,pq_gdinformation a,pq_substation c,pq_line d
where b.DEVMODEL = 1
and b.datatype in (0,2)
and a.gd_index = b.gd_index
and b.sub_index = c.sub_index
and d.dev_index = b.dev_index
and b.DEVFLAG=0
and b.status=0
and d.line_index in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
order by updatetime desc
</select>
<!-- 统计异常数量 -->
<select id="getTj" resultMap="deviceMap">
select count (distinct b.DEV_INDEX) yAxis
from pq_device b,pq_line d
where b.DEVMODEL = 1
and b.datatype in (0,2)
and d.dev_index = b.dev_index
and b.DEVFLAG=0
and b.status=0
and d.line_index in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
</select>
<select id="selState" resultMap="deviceMap">
select * from pq_device b where b.DEV_INDEX=#{devIndex} and b.gd_index in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
</select>
<select id="queryDeviceDetailById" resultMap="deviceMap">
select distinct a.dev_index as devIndex,
a.name,
b.gd_index as gdName,
b.name as gdNa,
c.name as subName,
(select n.dic_name from pqs_dicdata n where n.dic_index = d.scale) as scale,
<if test="_databaseId == 'MariaDB'">
date_format(a.logontime,'%Y-%m-%d %H:%I:%S') as time,
</if>
<if test="_databaseId == 'Oracle'">
to_char(a.logontime, 'yyyy-MM-dd hh24:mi:ss') as time,
</if>
T3.DIC_NAME AS manufacturer,
(select m.dic_name from pqs_dicdata m where m.dic_index = a.devtype) as
DevType,
a.ip,
a.PORTID,
<if test="_databaseId == 'MariaDB'">
case
when a.devflag = 0 then '投运'
when a.devflag = 1 then '热备用'
when a.devflag = 2 then '停运'
end
as devflag,
case
when a.status = 0 then '中断'
when a.status = 1 then '正常'
end
as status,
</if>
<if test="_databaseId == 'Oracle'">
decode(a.DEVFLAG, 0, '正常', 1, '热备用', '停运') as devflag,
decode(a.status, 0, '中断', 1, '正常') as status,
</if>
<if test="_databaseId == 'Oracle'">
to_char(a.UpdateTime, 'yyyy-MM-dd hh24:mm:ss') as updatetime,
</if>
<if test="_databaseId == 'MariaDB'">
date_format(a.UpdateTime, '%Y-%m-%d %H:%I:%S') as updatetime,
</if>
t2.OnlineRateTj as evaluate
from pq_device a,
pq_gdinformation b,
pq_substation c,
pq_line d,
pqs_dicdata e,
PQS_OnlineRate g,
PQ_DEVICEDETAIL t2,
PQS_DICDATA T3
where a.DEVMODEL = 1
and a.datatype in (0,2)
and a.gd_index = b.gd_index
and d.dev_index =a.dev_inde
and a.sub_index = c.sub_index
and d.dev_index = a.dev_index
and d.scale = e.dic_index
and g.dev_index=a.dev_index
AND T3.DIC_INDEX=T2.MANUFACTURER
AND T2.dev_index=a.dev_index
and a.dev_index = #{devIndex}
order by b.gd_index
</select>
<select id="queryDeviceDetailByLineId" resultMap="deviceMap">
select DISTINCT
a.name,
a.dev_Index devIndex,
b.gd_index as gdName,
c.name as subName,
<if test="_databaseId == 'MariaDB'">
date_format(a.logontime,'%Y-%m-%d')
</if>
<if test="_databaseId == 'Oracle'">
to_char(a.logontime, 'yyyy-MM-dd')
</if>
as time,
i.dic_name as manufacturer,
j.dic_name as DevType,
h.DEV_LOCATION as devLocation,
h.DEV_NO as devNo,
a.ip,
a.portid,
<if test="_databaseId == 'MariaDB'">
case
when a.devflag = 0 then '投运'
when a.devflag = 1 then '热备用'
when a.devflag = 2 then '停运'
end
as devflag,
case
when a.status = 0 then '中断'
when a.status = 1 then '正常'
end
as status,
</if>
<if test="_databaseId == 'Oracle'">
decode(a.devflag, 0, '投运', 1, '热备用', '停运') as devflag,
decode(a.status, 0, '中断', 1, '正常') as status,
</if>
<if test="_databaseId == 'Oracle'">
decode(d.status, 0, '投运', 1, '热备用', '停运') as lineStatus,
</if>
<if test="_databaseId == 'Oracle'">
to_char(a.updatetime, 'yyyy-MM-dd hh24:mi:ss') as updatetime,
</if>
<if test="_databaseId == 'MariaDB'">
date_format(a.updatetime, '%Y-%m-%d %H:%i:%s') as updatetime,
</if>
h.onlineratetj as evaluate
from pq_device a,
pq_gdinformation b,
pq_substation c,
pq_line d,
pq_devicedetail h,
pqs_dicdata i,
pqs_dicdata j
where a.devmodel = 1
and a.datatype in (0,2)
and a.gd_index = b.gd_index
and a.sub_index = c.sub_index
and a.dev_index = h.dev_index
and h.manufacturer = i.dic_index
and a.devtype = j.dic_index
and d.dev_index = a.dev_index
and d.line_index = #{lineIndex}
order by updatetime desc
</select>
</mapper>

View File

@@ -0,0 +1,78 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.configuration.DeviceInfoMapper'>
<resultMap type="LineInfo" id="deviceMap" autoMapping="true">
<id column="Gd_index" property="nodeIndex" />
</resultMap>
<select id="getDeviceInfo" resultMap="deviceMap" databaseId="Oracle">
select
a.name,a.subv_name,b.LogonTime as updatetime,d.dic_name as
manufacturer,b.devtype,b.ip,b.status,e.objname objName,e.loadtype loadType,
a.scale,a.pt1,a.pt2,a.ct1,a.ct2,a.jzcmp,a.dlcmp,a.xycmp,a.devcmp,decode(e.pttype,0,'2PT',1,'3PT') as pttype
from pq_line a,pq_device b ,pq_devicedetail c,pqs_dicdata d,pq_linedetail e
where e.line_index = a.line_index and
a.dev_index = b.dev_index and b.dev_index = c.dev_index and c.manufacturer =
d.dic_index and
a.line_index = #{line_index}
</select>
<select id="getDeviceInfo" resultMap="deviceMap" databaseId="MariaDB">
select
a.name,a.subv_name,b.LogonTime as updatetime,d.dic_name as
manufacturer,b.devtype,b.ip,b.status,e.objname objName,e.loadtype loadType,
a.scale,a.pt1,a.pt2,a.ct1,a.ct2,a.jzcmp,a.dlcmp,a.xycmp,a.devcmp,
(case e.pttype when 0 then '2PT' else '3PT' end) as pttype
from pq_line a,pq_device b ,pq_devicedetail c,pqs_dicdata d,pq_linedetail e
where e.line_index = a.line_index and
a.dev_index = b.dev_index and b.dev_index = c.dev_index and c.manufacturer =
d.dic_index and
a.line_index = #{line_index}
</select>
<select id="getRunInfo" resultType="ComInformation">
select UpdateTime,Type
from PQS_COMINFORMATION
where State = 1
and Line_Index = #{line_index}
and UpdateTime between #{startTime} and #{endTime}
order by UpdateTime
</select>
<select id="getFlowInfo" resultMap="deviceMap">
SELECT nvl(fm.fm_number,
nvl((select FM_NUMBER
from PQS_FLOWMEAL
where type = 0
and SECOND_TYPE = 0),
0)) as baseFlow,
nvl(fm2.fm_number, 0) as extendFlow,
nvl((SELECT af.actualflow
FROM PQS_MONTHFLOW af
WHERE af.DEV_INDEX = pq.DEV_INDEX
and to_char(af.timeid, 'yyyy-MM') =
to_char(sysdate, 'yyyy-MM')),
0) / nullif(((nvl(fm.fm_number,
nvl((select FM_NUMBER
from PQS_FLOWMEAL
where type = 0
and SECOND_TYPE = 0),
0))) + (nvl(fm2.fm_number, 0))) * 1024 * 1024,
0) as useFlow
FROM PQ_DEVICE pq
left join PQS_DEVEDASS ded
on pq.DEV_INDEX = ded.DEV_INDEX
and ded.STATE = 1
and ded.UPDATERESULT = 1
left join PQS_EDDATA ed
on ded.ED_INDEX = ed.ED_INDEX
left join PQS_DEVFMASS dm
on pq.DEV_INDEX = dm.DEV_INDEX
left join PQS_FLOWMEAL fm
on dm.FM_BASE_INDEX = fm.FM_INDEX
left join PQS_FLOWMEAL fm2
on dm.FM_REAM_INDEX = fm2.FM_INDEX
WHERE pq.DEVMODEL = 1
and pq.dev_index =
(select dev_index from pq_line where line_index = #{pointIndex})
</select>
</mapper>

View File

@@ -0,0 +1,130 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.configuration.DeviceMapper'>
<update id="updateDevice">
update pq_device set DEVFLAG=#{devflag} where dev_index=#{name}
</update>
<select id="getDevicesByDevIndexs" resultType="device">
SELECT
T.DEV_INDEX,
T.DEVFLAG
FROM
PQ_DEVICE t
where
t.DEV_INDEX in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<!-- to_Char(T1.LOGONTIME,'yyyy-MM') between #{startTime} and #{endTime} -->
<!--根据供电公司找出合理的终端索引-->
<select id="getDeviceIndexs" resultType="int">
select
t.dev_index
from
pq_device t
where
t.gd_index in
<foreach collection="list" open="(" close=")" separator="," item="item">
#{item}
</foreach>
AND
t.DEVModel= #{devModel}
AND
t.DataType in
<foreach collection="type" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</select>
<select id="getDeviceIndexsByCompanyName" resultType="Integer">
SELECT T2.DEV_INDEX from PQ_DEVICE t2
INNER JOIN(
SELECT
*
FROM
PQ_DEVICEDETAIL
WHERE
MANUFACTURER = #{comIndex}
) t1 ON
T1.dev_index=T2.DEV_INDEX
AND
T2.DEVMODEL =#{devModel}
AND
T2.DataType in
<foreach collection="type" open="(" close=")" separator="," item="item">
#{item}
</foreach>
AND
T2.Dev_Index IN
<foreach collection="list" open="(" close=")" separator="," item="item1">
#{item1}
</foreach>
</select>
<select id="getIPByEventIndex" resultType="String">
SELECT
T3.IP
FROM
PQS_EVENTDETAIL t1,
PQ_LINE t2,
PQ_DEVICE t3
WHERE
T1.LINEID = T2.LINE_INDEX
AND T2.DEV_INDEX = T3.DEV_INDEX
AND T1.EVENTDETAIL_INDEX = #{index}
</select>
<select id="getRunDeviceIndex" resultType="Integer">
SELECT
DEV_INDEX
FROM
PQ_DEVICE
WHERE
DEV_INDEX IN
<foreach collection="list" open="(" close=")" separator="," item="item1">
#{item1}
</foreach>
AND DEVFLAG = 0
AND DEVMODEL IN (0,1)
</select>
<select id="getDeviceIndexByLineIndex" resultType="int">
SELECT
DISTINCT(DEV_INDEX)
FROM
PQ_LINE
WHERE
LINE_INDEX IN
<foreach collection="list" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</select>
<select id="deviceDescribe" resultType="String">
SELECT
'将'|| gd.name || sub.name || '下的' || device.name || '(' || device.ip || ')'
FROM
PQ_DEVICE device
LEFT JOIN PQ_GDINFORMATION gd ON device.GD_INDEX = gd.GD_INDEX
LEFT JOIN PQ_SUBSTATION sub ON device.SUB_INDEX = sub.SUB_INDEX
WHERE
device.DEV_INDEX = #{devIndex}
</select>
<select id="getDevIndex" resultType="int">
SELECT
dev_index
FROM
PQ_DEVICE
WHERE
DATATYPE IN
<foreach collection="list" open="(" close=")" separator="," item="item1">
#{item1}
</foreach>
AND DEVMODEL = 1
</select>
</mapper>

View File

@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.configuration.DicDataMapper">
<resultMap type="com.njcn.pojo.configuration.DicType" id="DicDataTypeMapperMap" autoMapping="true">
<id property="dicTypeIndex" column="DICTYPE_INDEX"/>
<association property="uID" autoMapping="true" javaType="User">
<id property="userIndex" column="USER_INDEX"/>
</association>
</resultMap>
<resultMap type="com.njcn.sso.pojo.user.User" id="UserMapperMap" autoMapping="true">
<id property="userIndex" column="USER_INDEX"/>
</resultMap>
<!-- 数据字典 -->
<resultMap type="com.njcn.pojo.configuration.DicData" id="DicDataMapperMap" autoMapping="true">
<id property="dicIndex" column="DIC_INDEX"/>
<collection property="uID" resultMap="UserMapperMap" ></collection>
<collection property="dt" resultMap="DicDataTypeMapperMap"></collection>
</resultMap>
<!-- 增加 -->
<insert id="insertData">
insert into Pqs_Dicdata (Dic_Index,Dic_Name,Dic_type,Dic_Number,UpdateTime,Leave,User_Index,State)
values(#{dicIndex},#{dicName},#{dicType},#{dicNumber},#{updateTime},#{leave},#{userIndex},#{state})
</insert>
<!-- 删除 -->
<update id="deleteData">
update Pqs_Dicdata set state=0 where dic_Index=#{dicIndex,jdbcType=VARCHAR}
</update>
<!-- 修改 -->
<update id="updateData">
update pqs_DicData set DIC_NAME=#{dicName},DIC_TYPE=#{dicType},UPDATETIME=#{updateTime},leave=#{leave} where DIC_INDEX=#{dicIndex,jdbcType=VARCHAR}
</update>
<!-- 查询排序最大 -->
<select id="selNumMax" resultType="int">
select max(dic_number) from pqs_dicdata where state=1 order by dic_number desc
</select>
<!-- 根據Id查詢所有 -->
<select id="selectId" resultMap="DicDataMapperMap">
select *from pqs_dicData where DIC_INDEX=#{dicIndex,jdbcType=VARCHAR} and state=1 order by dic_index
</select>
<!-- 根据typeId查询总条数 -->
<select id="selCount" resultType="java.lang.Integer">
select count(*) from pqs_dicData where dic_type=#{dicTypeIndex,jdbcType=VARCHAR} and state=1
</select>
<!-- 根据名称查询 -->
<select id="seleAll" resultMap="DicDataMapperMap">
select *from pqs_Dicdata d join pqs_dictype t on d.dic_type=t.dictype_index where dic_name like #{name} and d.state=1 order by d.dic_number
</select>
<select id="setArea" resultMap="DicDataMapperMap">
select t.* from PQS_DICDATA t where t.dic_index not in(select area from pqs_depts where state=1) and t.STATE=1 and t.dic_type=(SELECT DICTYPE_INDEX from PQS_DICTYPE where DICTYPE_NAME = #{dicTypeName})
</select>
<!-- 根据typeName查询 -->
<select id="selAll" resultMap="DicDataMapperMap">
select * from pqs_Dicdata d join pqs_dictype t on d.dic_type=t.dictype_index
where dic_type=#{typeId,jdbcType=VARCHAR} and d.state=1 order by d.dic_number
</select>
<!-- 根据name查询所有 -->
<select id="getSelName" resultMap="DicDataMapperMap">
select * from pqs_dicdata where dic_name like #{name} and state=1
</select>
<select id="selAllId" resultMap="DicDataMapperMap">
select * from pqs_Dicdata d join pqs_dictype t on d.dic_type=t.dictype_index
where dic_type=#{typeId,jdbcType=VARCHAR} and d.state=1 order by d.dic_number
</select>
<!-- 查询除此之外的名称 -->
<select id="selectName" resultMap="DicDataMapperMap">
select * from pqs_Dicdata where dic_name not in (select dic_name from pqs_Dicdata where dic_index=#{dicIndex} and state=1) and state = 1
</select>
<!-- 查询接线方式 -->
<select id="selectWring" resultMap="DicDataMapperMap">
select * from pqs_dicdata dt where dt.dic_type=(SELECT DICTYPE_INDEX from PQS_DICTYPE where DICTYPE_NAME = #{dicTypeName})
</select>
<select id="selectDataName" resultMap="DicDataMapperMap">
select * from pqs_dicdata dt where dic_index =#{dicIndex} and dt.state=1 order by dt.updatetime desc
</select>
<select id="selectWiring" resultMap="DicDataMapperMap">
select * from pqs_dicdata dt where dt.dic_type=(SELECT DICTYPE_INDEX from PQS_DICTYPE where DICTYPE_NAME = #{dicTypeName}) and dt.dic_index <![CDATA[ <> ]]>#{typeId} and dt.state=1
</select>
<!-- 查询重复 -->
<select id="selectdicName" resultMap="DicDataMapperMap">
select * from pqs_dicdata where dic_name=#{dicName} and state=1
</select>
<!-- 更新字典表根据主键-->
<update id="updateByPrimaryKeyBySql">
UPDATE PQS_DICDATA
SET DIC_LEAVE = #{dicLeave}
WHERE
DIC_INDEX = #{dicIndex}
</update>
<!-- 获取设备树电压等级 -->
<select id="getTreeScale" resultMap="DicDataMapperMap">
select distinct a.dic_name, a.dic_index,a.dic_number
from pqs_dicdata a,pq_device b, pq_line c, pq_subvoltage d
where d.scale = a.dic_index
and d.subv_index = c.subv_index
and b.dev_index = c.dev_index
and b.datatype in (0, 2)
and b.DEVModel = 1
and c.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by a.dic_number">
#{item}
</foreach>
</select>
<!-- 获取设备树装置厂家 -->
<select id="getTreeManc" resultMap="DicDataMapperMap">
select distinct a.dic_name, a.dic_index,a.dic_number
from pqs_dicdata a,pq_device b, pq_line c, pq_subvoltage d,pq_devicedetail e
where e.manufacturer = a.dic_index
and e.dev_index = c.dev_index
and d.subv_index = c.subv_index
and b.dev_index = c.dev_index
and b.datatype in (0, 2)
and b.DEVModel = 1
and c.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by a.dic_number">
#{item}
</foreach>
</select>
<!-- 获取设备树干扰源类型 -->
<select id="getTreeLoadType" resultMap="DicDataMapperMap">
select distinct a.dic_name, a.dic_index,a.dic_number
from pqs_dicdata a,pq_device b, pq_line c, pq_subvoltage d,pq_linedetail e
where e.loadtype = a.dic_index
and e.line_index = c.line_index
and d.subv_index = c.subv_index
and b.dev_index = c.dev_index
and b.datatype in (0, 2)
and b.DEVModel = 1
and c.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by a.dic_number">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.configuration.DicDataTypeMapper">
<!-- 数据字典 -->
<resultMap type="com.njcn.pojo.configuration.DicType" id="DicDataTypeMapperMap" autoMapping="true">
<id property="dicTypeIndex" column="DICTYPE_INDEX"/>
<association property="uID" autoMapping="true" javaType="User">
<id property="userIndex" column="USER_INDEX"/>
</association>
</resultMap>
<!-- 增加 -->
<insert id="insertType">
insert into pqs_dictype(DICTYPE_INDEX,DICTYPE_NAME,DICTYPE_NUMBER,DICTYPE_DESCRIBE,USER_INDEX,UPDATETIME,STATE,SYSTYPE)
values(#{dicTypeIndex},#{dicTypeName},#{dicTypeNumber},#{dicTypeDiscribe},#{userIndex},#{updateTime},#{state},#{sysType})
</insert>
<!-- 删除 -->
<update id="deleteType">
update pqs_dicType set state=0 where DICTYPE_INDEX=#{dicTypeIndex,jdbcType=VARCHAR} and systype=#{sysType}
</update>
<!-- 修改 -->
<update id="updateType">
update pqs_dicType set DICTYPE_NAME=#{dicTypeName},DICTYPE_DESCRIBE=#{dicTypeDiscribe},UPDATETIME=#{updateTime},SYSTYPE=#{sysType} where DICTYPE_INDEX=#{dicTypeIndex,jdbcType=VARCHAR}
</update>
<!-- 查询排序最大 -->
<select id="selNumMax" resultType="int">
select max(dictype_number) from pqs_dictype where systype=#{sysType} and state=1 order by dictype_number desc
</select>
<select id="selectIndexAll" resultMap="DicDataTypeMapperMap">
select * from pqs_dictype dt join pqs_user u on dt.USER_INDEX=u.USER_INDEX where dt.systype=#{sysType} and dt.state=1 order by dt.updatetime desc
</select>
<!-- 查询 -->
<select id="All" resultMap="DicDataTypeMapperMap">
select * from pqs_dictype dt join pqs_user u on dt.USER_INDEX=u.USER_INDEX where dt.dictype_index <![CDATA[ <> ]]>#{typeId} and dt.systype=#{sysType} and dt.state=1 order by dt.updatetime desc
</select>
<!-- 查询 -->
<select id="selectTypeName" resultMap="DicDataTypeMapperMap">
select * from pqs_dictype dt join pqs_user u on dt.USER_INDEX=u.USER_INDEX where dt.dictype_index =#{typeId} and dt.systype=#{sysType} and dt.state=1 order by dt.updatetime desc
</select>
<select id="getLog" resultMap="DicDataTypeMapperMap">
select * from pqs_dictype where systype=#{sysType} and state=1 and dictype_name like '%事件类型%'
</select>
<!-- 根据dictype_name查询 -->
<select id="querybyname" resultMap="DicDataTypeMapperMap">
select * from pqs_dictype where DICTYPE_NAME=#{dicTypename,jdbcType=VARCHAR} and state=1
</select>
<!-- 查询除此之外的名称 -->
<select id="selectName" resultMap="DicDataTypeMapperMap">
select * from pqs_dictype where DICTYPE_NAME not in (select DICTYPE_NAME from pqs_dictype where DICTYPE_INDEX=#{dicTypeIndex} and systype=#{sysType} and state=1) and state = 1
</select>
</mapper>

View File

@@ -0,0 +1,299 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.configuration.EventDataMapper'>
<resultMap type="EventDataList" id="eventdataMap" autoMapping="true">
</resultMap>
<select id='getEventDataList' resultMap="eventdataMap" databaseId="Oracle">
SELECT M.EVENTDETAIL_INDEX,
M.LINEID,
to_char(M.TIMEID, 'YYYY-mm-dd hh24:mi:ss.') || M.MS time,
round(M.PERSISTTIME / 1000, 3) PERSISTTIME,
M.EVENTVALUE,
M.EVENTREASON,
M.EVENTTYPE,
M.WAVETYPE TYPE,
M.NAME lineName,
M.fileFlag,
M.Severity,
M.EVENTASS_INDEX,
S. NAME GDNAME,
S1. NAME SUBNAME,
S2.DIC_NAME SCALE,
S3.NAME EVENTNAME
FROM (SELECT T1.EVENTDETAIL_INDEX,
T1.LINEID,
T1.TIMEID,
nvl(substr(10000 + T1.MS, -3), T1.MS) MS,
T1.PERSISTTIME,
T1.EVENTVALUE,
T1.fileFlag,
T2.DIC_NAME EVENTREASON,
T3.DIC_NAME EVENTTYPE,
DECODE(T1.WAVETYPE, 0, '扰动', 1, '暂降', 2, '暂升', '中断') WAVETYPE,
T1.EVENTASS_INDEX,
T1.Severity,
T4. NAME,
T4.GD_INDEX GDINDEX,
T4.SUB_INDEX SUBINDEX,
T4. SCALE
FROM PQS_EVENTDETAIL T1
INNER JOIN PQS_DICDATA T2
ON T1.EVENTREASON = T2.DIC_INDEX
INNER JOIN PQS_DICDATA T3
ON T1.EVENTTYPE = T3.DIC_INDEX
INNER JOIN PQ_LINE T4
ON T1.LINEID = T4.LINE_INDEX
WHERE T1.TIMEID between #{startTime} and #{endTime}
and T1.LINEID = #{lineIndex}
and T1.WAVETYPE !=5 ) M
INNER JOIN PQ_GDINFORMATION S
ON M.GDINDEX = S.GD_INDEX
INNER JOIN PQ_SUBSTATION S1
ON M.SUBINDEX = S1.SUB_INDEX
INNER JOIN PQS_DICDATA S2
ON M . SCALE = S2.DIC_INDEX
LEFT JOIN PQS_EVENTASS S3
ON M.EVENTASS_INDEX = S3.EVENTASS_INDEX
ORDER BY M.TIMEID DESC
</select>
<select id='getEventDataList' resultMap="eventdataMap" databaseId="MariaDB">
SELECT
M .EVENTDETAIL_INDEX,
M .LINEID,
CONCAT(date_format(M .TIMEID,'%Y-%m-%d %H:%i:%S.'), M.MS) time,
round(M .PERSISTTIME/1000, 3) PERSISTTIME,
M
.EVENTVALUE,
M .EVENTREASON,
M .EVENTTYPE,
M.WAVETYPE TYPE,
M .NAME lineName,
M.fileFlag,
M.Severity,
M
.EVENTASS_INDEX,
S. NAME GDNAME,
S1. NAME SUBNAME,
S2.DIC_NAME SCALE,
S3.NAME EVENTNAME
FROM
(
SELECT
T1.EVENTDETAIL_INDEX,
T1.LINEID,
T1.TIMEID,
nvl(substr(10000+T1.MS,-3),T1.MS) MS,
T1.PERSISTTIME,
T1.EVENTVALUE,
T1.fileFlag,
T2.DIC_NAME EVENTREASON,
T3.DIC_NAME EVENTTYPE,
(case T1.WAVETYPE
when 0 then
'扰动'
when 1 then
'暂降'
when 2 then
'暂升'
else
'中断'
end) WAVETYPE,
T1.EVENTASS_INDEX,
T1.Severity,
T4.
NAME,
T4.GD_INDEX GDINDEX,
T4.SUB_INDEX SUBINDEX, T4. SCALE
FROM
PQS_EVENTDETAIL T1
INNER JOIN PQS_DICDATA T2 ON T1.EVENTREASON =
T2.DIC_INDEX
INNER JOIN PQS_DICDATA T3 ON T1.EVENTTYPE = T3.DIC_INDEX
INNER JOIN PQ_LINE T4 ON T1.LINEID = T4.LINE_INDEX
WHERE
T1.TIMEID
between #{startTime} and #{endTime}
and T1.LINEID = #{lineIndex}
and T1.WAVETYPE = 1
) M
INNER JOIN PQ_GDINFORMATION S ON M .GDINDEX = S.GD_INDEX
INNER JOIN
PQ_SUBSTATION S1 ON M .SUBINDEX = S1.SUB_INDEX
INNER JOIN PQS_DICDATA
S2 ON M . SCALE = S2.DIC_INDEX
LEFT JOIN PQS_EVENTASS S3 ON
M.EVENTASS_INDEX=S3.EVENTASS_INDEX
ORDER BY
M .TIMEID DESC
</select>
<select id="getCountsByInterval" resultType="Integer" databaseId="Oracle">
select count(*) from PQS_EVENTDETAIL where to_char(TIMEID,'YYYY-MM') = #{interTime} and LINEID = #{lineIndex}
</select>
<select id="getCountsByInterval" resultType="Integer" databaseId="MariaDB">
select count(*) from PQS_EVENTDETAIL where date_format(TIMEID,'%Y-%m') = #{interTime} and LINEID = #{lineIndex}
</select>
<select id='areaEventDataList' resultMap="eventdataMap" databaseId="Oracle">
SELECT
M .EVENTDETAIL_INDEX,
M .LINEID,
to_char(M .TIMEID,'YYYY-mm-dd hh24:mi:ss.')||M.MS time,
round(M .PERSISTTIME/1000, 3) PERSISTTIME,
M
.EVENTVALUE,
M .EVENTREASON,
M .EVENTTYPE,
M .NAME lineName,
M.fileFlag,
M
.EVENTASS_INDEX,
S. NAME GDNAME,
S1. NAME SUBNAME,
S2.DIC_NAME SCALE,
S3.NAME EVENTNAME
FROM
(
SELECT
T1.EVENTDETAIL_INDEX,
T1.LINEID,
T1.TIMEID,
nvl(substr(10000+T1.MS,-3),T1.MS) MS,
T1.PERSISTTIME,
T1.EVENTVALUE,
T1.fileFlag,
T2.DIC_NAME EVENTREASON,
T3.DIC_NAME EVENTTYPE,
T1.EVENTASS_INDEX,
T4.
NAME,
T4.GD_INDEX GDINDEX,
T4.SUB_INDEX SUBINDEX, T4. SCALE
FROM
PQS_EVENTDETAIL T1
INNER JOIN PQS_DICDATA T2 ON T1.EVENTREASON =
T2.DIC_INDEX
INNER JOIN PQS_DICDATA T3 ON T1.EVENTTYPE = T3.DIC_INDEX
INNER JOIN PQ_LINE T4 ON T1.LINEID = T4.LINE_INDEX
WHERE
T1.TIMEID
between #{startTime} and #{endTime}
and T1.LINEID in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
) M
INNER JOIN PQ_GDINFORMATION S ON M .GDINDEX = S.GD_INDEX
INNER JOIN
PQ_SUBSTATION S1 ON M .SUBINDEX = S1.SUB_INDEX
INNER JOIN PQS_DICDATA
S2 ON M . SCALE = S2.DIC_INDEX
LEFT JOIN PQS_EVENTASS S3 ON
M.EVENTASS_INDEX=S3.EVENTASS_INDEX
ORDER BY
M .TIMEID DESC
</select>
<select id='areaEventDataList' resultMap="eventdataMap" databaseId="MariaDB">
SELECT
M .EVENTDETAIL_INDEX,
M .LINEID,
CONCAT(date_format(M .TIMEID,'%Y-%m-%d %H:%i:%S.'), M.MS) time,
round(M .PERSISTTIME/1000, 3) PERSISTTIME,
M
.EVENTVALUE,
M .EVENTREASON,
M .EVENTTYPE,
M .NAME lineName,
M.fileFlag,
M
.EVENTASS_INDEX,
S. NAME GDNAME,
S1. NAME SUBNAME,
S2.DIC_NAME SCALE,
S3.NAME EVENTNAME
FROM
(
SELECT
T1.EVENTDETAIL_INDEX,
T1.LINEID,
T1.TIMEID,
nvl(substr(10000+T1.MS,-3),T1.MS) MS,
T1.PERSISTTIME,
T1.EVENTVALUE,
T1.fileFlag,
T2.DIC_NAME EVENTREASON,
T3.DIC_NAME EVENTTYPE,
T1.EVENTASS_INDEX,
T4.
NAME,
T4.GD_INDEX GDINDEX,
T4.SUB_INDEX SUBINDEX, T4. SCALE
FROM
PQS_EVENTDETAIL T1
INNER JOIN PQS_DICDATA T2 ON T1.EVENTREASON =
T2.DIC_INDEX
INNER JOIN PQS_DICDATA T3 ON T1.EVENTTYPE = T3.DIC_INDEX
INNER JOIN PQ_LINE T4 ON T1.LINEID = T4.LINE_INDEX
WHERE
T1.TIMEID
between #{startTime} and #{endTime}
and T1.LINEID in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
) M
INNER JOIN PQ_GDINFORMATION S ON M .GDINDEX = S.GD_INDEX
INNER JOIN
PQ_SUBSTATION S1 ON M .SUBINDEX = S1.SUB_INDEX
INNER JOIN PQS_DICDATA
S2 ON M . SCALE = S2.DIC_INDEX
LEFT JOIN PQS_EVENTASS S3 ON
M.EVENTASS_INDEX=S3.EVENTASS_INDEX
ORDER BY
M .TIMEID DESC
</select>
<select id='getCountByIndex' resultType="Integer">
select count(*) from
PQS_EVENTDETAIL
where TIMEID
between #{startTime} and #{endTime}
and LINEID = #{lineIndex}
</select>
<select id='getGdcounts' resultType="Integer">
select count(*)
from PQS_EVENTDETAIL t
where t.TIMEID
between #{startTime} and #{endTime}
and t.lineid in
(select a.line_index
from pq_line a, pq_device b
where a.dev_index = b.dev_index
and b.devmodel = 1
and b.datatype in (0,2)
and a.gd_index = #{gdIndex})
</select>
<select id="getEventTypeCount" resultType="EventTypeList">
SELECT
T2.DIC_NAME type ,
COUNT (1) count
FROM
PQS_EVENTDETAIL t1,
PQS_DICDATA t2
WHERE
T1.EVENTTYPE = T2.DIC_INDEX
AND
T1.LINEID = #{lineIndex}
AND
TIMEID between #{startTime} and #{endTime}
GROUP BY
T2.DIC_NAME
ORDER BY
count
</select>
</mapper>

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.1//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.configuration.GDInforMapper">
<select id="queryGDByDept" parameterType="String" resultType="GDInformation" >
select * from PQ_GDINFORMATION
<where>
<if test="_parameter != null">
GD_INDEX in(#{gdIndex})
</if>
</where>
</select>
<select id="selectAll" parameterType="String" resultType="GDInformation" >
select * from PQ_GDINFORMATION
</select>
<select id="selectNoGd" resultType="GDInformation">
select * from pq_gdinformation where gd_index not in (select gd_index from pqs_deptsgd where depts_index in(select depts_index from pqs_depts where systype=#{sysType}))
</select>
<select id="selectOthersNoGd" resultType="GDInformation">
select * from pq_gdinformation where gd_index in(select gd_index from pqs_deptsgd where depts_index in( select
depts_index from pqs_depts where sysType=#{sysType}) and depts_index!=#{deptsIndex})
</select>
<select id="selectMaxIndex" parameterType="String" resultType="Long" >
select max(gd_index) from PQ_GDINFORMATION
</select>
<select id="getGdName" resultType="String" >
select T2.name from pq_gdinformation T2 left join pq_device T1
on T1.GD_INDEX=t2.GD_INDEX where T1.GD_INDEX =#{gdIndex} and rownum=1
</select>
<select id="testName" resultType="GDInformation" >
select * from pq_gdinformation where name = #{name} and PROVINCE_INDEX = #{proIndex}
</select>
</mapper>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.1//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.configuration.LineDetailMapper">
<select id="getAmounts" resultType="int" databaseId="Oracle">
SELECT
COUNT (*)
FROM
PQ_LINEDETAIL T
WHERE
TO_CHAR (T .LAST_TIME, 'yyyy-MM') = #{time}
</select>
<select id="getAmounts" resultType="int" databaseId="MariaDB">
SELECT
COUNT (*)
FROM
PQ_LINEDETAIL T
WHERE
date_format(T .LAST_TIME,'%Y-%m') = #{time}
</select>
</mapper>

View File

@@ -0,0 +1,335 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.1//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.configuration.LineMapper">
<resultMap id="lineMap" type="com.njcn.pojo.configuration.Line" autoMapping="true">
<id column="line_index" property="lineIndex"/>
</resultMap>
<select id="queryAllLineByGDInfo" resultType="line">
SELECT
T1.LINE_INDEX
FROM
PQ_LINE T1
WHERE T1.GD_INDEX IN
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<!-- 按电压等级区分后的监测点数 -->
<select id="queryLineCounts" resultType="simpleValue">
SELECT
COUNT (*) value,
dic_name name
FROM
LINE_DICDATA
WHERE LINE_INDEX IN
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY
DIC_NAME
</select>
<select id="queryLineData" resultType="line">
SELECT
T .GD_INDEX,
T .SUB_INDEX,
T.DEV_INDEX,
T .NAME
FROM
PQ_LINE T
where t.line_index=#{lineid}
</select>
<select id="getLineCounts" resultType="Integer">
select count(*) from PQ_LINE where GD_INDEX=#{gdIndex}
</select>
<select id="getlines" resultType="line">
SELECT
T1.LINE_INDEX,
T1.NAME,
T1.SCALE,
T2.LOADTYPE
FROM
PQ_LINE t1
LEFT JOIN PQ_LINEDETAIL t2 ON T1.LINE_INDEX = T2.LINE_INDEX
WHERE T1."SCALE" in
<foreach collection="vols" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and T2.LOADTYPE in
<foreach collection="types" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="queryAllLineByGDInfoAndScale" resultType="line">
SELECT
T1.DEV_INDEX
FROM
PQ_LINE T1
WHERE
T1.SCALE=#{dicIndex}
AND
T1.GD_INDEX IN
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getCountsByDeviceIndex" resultType="int">
select count(*)
FROM
pq_line t
WHERE
t.dev_index in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getLineIndex" resultType="int">
SELECT
T.LINE_INDEX
FROM
PQ_LINE T
WHERE
T.Dev_Index
IN
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getLineIndexs" resultType="int">
SELECT
T.LINE_INDEX
FROM
PQ_LINE T
WHERE
T.SCALE=#{dicIndex}
AND
T.DEV_INDEX
IN
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getDeviceIndexs" resultType="int">
SELECT
DEV_INDEX
FROM
PQ_LINE
WHERE
DEV_INDEX IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND
SCALE=#{dicIndex}
GROUP BY
DEV_INDEX
</select>
<select id="selectMaxIndex" parameterType="String" resultType="Long" >
select max(line_index) from PQ_LINE
</select>
<select id="testName" resultType="Line" >
select * from PQ_LINE where name = #{name} and line_index != #{lineIndex}
</select>
<select id="selectLineName" resultType="String" >
select g.name ||'->'|| s.name ||'->'||d.name ||'->'|| l.name name from PQ_LINE l
LEFT JOIN PQ_GDINFORMATION g on l.GD_INDEX=g.GD_INDEX
LEFT JOIN PQ_SUBSTATION s on l.sub_index=s.sub_index
LEFT JOIN PQ_DEVICE d on l.dev_index=d.dev_index
where l.LINE_INDEX=#{name}
</select>
<update id="updateScale">
update pq_line set scale = #{scale}, subv_name = #{subvName},jzcmp=#{jzCmp},pt1=#{pt} where subv_index = #{subvIndex}
</update>
<select id="getLineByEventDetailIndex" resultType="line">
select
t1.*
from
PQ_LINE t1,PQS_EVENTDETAIL t2
where
t1.LINE_INDEX=t2.LINEID
and
t2.EVENTDETAIL_INDEX=#{eventIndex}
</select>
<select id="getNodeIpbylineIndex" resultType="String">
select
t1.Node_IP
from
NODEINFORMATION t1,PQ_LINE t2,PQ_DEVICE t3
where
t1.Node_Index=t3.NODE_INDEX
and T2.DEV_INDEX = t3.DEV_INDEX
and T2.LINE_INDEX =#{lineIndex}
</select>
<select id="getNodeIpbyDevIndex" resultType="String">
SELECT
t1.Node_IP
FROM
NODEINFORMATION t1,
PQ_DEVICE t3
WHERE
t1.Node_Index = t3.NODE_INDEX
and t3.DEV_INDEX =#{lineIndex}
</select>
<select id="getLinesByPro" resultType="line">
select *
from pq_line
where gd_index in
(select gd_index from pq_gdinformation where province_index = #{proIndex})
</select>
<select id="getGWLines" resultType="Integer">
SELECT
T2.LINE_INDEX
FROM
PQ_LINE t1,
PQ_LINEDETAIL t2,
PQ_DEVICE t3
WHERE
T1.LINE_INDEX = T2.LINE_INDEX
AND T1.DEV_INDEX=T3.DEV_INDEX
AND T3.DEVFLAG=0
AND
T1.LINE_INDEX
IN
<foreach collection="list" item="item" open="(" close=")"
separator=",">
#{item}
</foreach>
AND T2.MONITOR_ID IS NOT NULL
</select>
<select id="getRole" resultType="java.lang.Integer">
select count(a.path)
from pqs_function a, pqs_rolefunction b, pqs_functionploy c
where a.path = #{url}
and a.function_index = b.function_index
and b.function_ploy = c.function_index
and c.state = 1
and b.role_index in
<foreach collection="role" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="listAllIndex" resultType="java.lang.Integer">
select line_index from pq_line
</select>
<select id="getLineIndexsByLoadType" resultType="int">
SELECT
T.LINE_INDEX
FROM
PQ_LINE T
INNER JOIN
PQ_LINEDETAIL T1
ON T.LINE_INDEX=T1.LINE_INDEX
WHERE
T1.LoadType=#{dicIndex}
AND
T.DEV_INDEX
IN
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="lineResultMap" autoMapping="true">
<id column="line_index" property="nodeIndex"/>
<result column="subv_index" property="pId"/>
</resultMap>
<select id='getTreeBySubv' resultMap='lineResultMap'>
select
a.subv_index, a.name,a.line_index,b.devflag as state,b.status,d.powerid as powerType
from pq_line a,pq_device b ,pq_subvoltage c,pq_linedetail d
where
a.dev_index = b.dev_index
and a.subv_index = c.subv_index
and a.line_index = d.line_index
and c.subv_index = #{subvIndex}
and a.line_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=") order by subv_index">
#{item}
</foreach>
</select>
<select id="getDeviceIndexsByLoadType" resultType="int">
SELECT
DEV_INDEX
FROM
PQ_LINE T
INNER JOIN PQ_LINEDETAIL T1
ON
T.LINE_INDEX=T1.LINE_INDEX
WHERE
T.DEV_INDEX
IN
<foreach collection="list" item="item" open="(" close=")"
separator=",">
#{item}
</foreach>
AND
T1.LOADTYPE=#{dicIndex}
GROUP BY
T.DEV_INDEX
</select>
<select id="getGwLinesByDeviceType" resultType="Integer">
SELECT
t3.LINE_INDEX
FROM
PQ_LINEDETAIL t3
WHERE
MONITOR_ID IS NOT NULL
AND t3.LINE_INDEX IN (
SELECT
t2.LINE_INDEX
FROM
PQ_LINE t2
WHERE
t2.DEV_INDEX IN (
SELECT
t1.DEV_INDEX
FROM
pq_device t1
WHERE
t1.DATATYPE IN
<foreach collection="type" open="(" close=")" separator="," item="item">
#{item}
</foreach>
))
</select>
<select id="getSubNameById" resultType="java.lang.String" >
SELECT NAME FROM PQ_SUBSTATION WHERE SUB_INDEX = #{id}
</select>
<select id="getLineListBySubVId" resultMap="lineMap">
select * from pq_line where subv_index =#{subVindex}
</select>
</mapper>

View File

@@ -0,0 +1,119 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.data.OnlineRateMapper'>
<select id="selectOnlineRateByDeviceIndexAndTime" resultType="simpleValue">
SELECT
SUM (T1.ONLINEMIN) countOnline,
SUM (T1.ONLINEMIN) + SUM (T1.OFFLINEMIN) countAll
FROM
PQS_ONLINERATE T1
WHERE
T1.DEV_INDEX in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND
T1.TIMEID BETWEEN #{startTime} AND #{endTime}
</select>
<select id="selectCityOnlineRate" resultType="simpleValue">
SELECT
t1.RATE onlineRate,
T2.NAME,
T2.ip,
t3.name gdName,
t4.name subName
FROM
(
SELECT
T .*,
ROWNUM row_num
FROM
(
SELECT
DEV_INDEX,
ROUND (
SUM (ONLINEMIN) / (
SUM (OFFLINEMIN) + SUM (ONLINEMIN)
),4) * 100 RATE
FROM
PQS_ONLINERATE
WHERE
DEV_INDEX IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND
TIMEID BETWEEN #{startTime} AND #{endTime}
GROUP BY
DEV_INDEX
ORDER BY
RATE ASC
) T
) t1
LEFT JOIN PQ_DEVICE t2 ON t1.dev_index = t2.dev_index
LEFT JOIN PQ_GDINFORMATION t3 ON t2.GD_INDEX =t3.GD_INDEX
LEFT JOIN PQ_SUBSTATION t4 ON T2.SUB_INDEX=T4.SUB_INDEX
WHERE t1.row_num &lt; 11
</select>
<select id="selectOnlineRate" resultType="onlineRateData">
SELECT
T5. NAME powerCompany,
T6. NAME substation,
T2. NAME device,
T2.IP deviceIp,
T4.DIC_NAME company,
T1.ONLINERATE onlineRate
FROM
(
SELECT
T1.DEV_INDEX,
ROUND (
SUM (T1.ONLINEMIN) / (
SUM (T1.ONLINEMIN) + SUM (T1.OFFLINEMIN)
),
4
) * 100 onlineRate
FROM
PQS_ONLINERATE T1
WHERE
T1.DEV_INDEX IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND t1.TIMEID BETWEEN #{startTime} AND #{endTime}
GROUP BY
T1.DEV_INDEX
) T1,
PQ_DEVICE T2,
PQ_DEVICEDETAIL T3,
PQS_DICDATA T4,
PQ_GDINFORMATION T5,
PQ_SUBSTATION T6
WHERE
T1.DEV_INDEX = T2.DEV_INDEX
AND T1.DEV_INDEX = T3.DEV_INDEX
AND T3.MANUFACTURER = T4.DIC_INDEX
AND T2.GD_INDEX = T5.GD_INDEX
AND T2.SUB_INDEX = T6.SUB_INDEX
</select>
<select id="getGWOnlineRate" resultType="float">
SELECT
AVG(ONLINERATE)
FROM
PQS_NGCPONLINERATE
WHERE
TIMEID BETWEEN #{startTime} AND #{endTime}
AND
LINE_INDEX IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,39 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.configuration.RPTreeMapper'>
<resultMap type="RPTree" id="resultMap" autoMapping="true">
<id column="node" property="nodeIndex"/>
<id column="RD_Name" property="name"/>
<id column="RD_Index" property="rdIndex"/>
<result column="parentNode" property="pId"/>
</resultMap>
<select id='getfirstData' resultMap='resultMap'>
select
*
from PQS_RptData
where parentnode=0 and State = 1 and datatype = #{dataType}
order by Sort
</select>
<select id='getsecondData' resultMap='resultMap'>
select
*
from PQS_RptData
where State = 1 and datatype = #{dataType} and parentnode in
<foreach collection="first" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
order by Sort
</select>
<select id="getExcelSetting" resultType="RptData" databaseId="Oracle">
select rd_index rdIndex,rd_name rdName,RD_DESCRIBE rdDescribe,createtime createTime,parentguid parentGUID from pqs_rptdata
where state = 1 and datatype = 2 order by createtime asc
</select>
<select id="getExcelSetting" resultType="RptData" databaseId="MariaDB">
select rd_index as rdIndex,rd_name as rdName,RD_DESCRIBE as rdDescribe,createtime as createTime,parentguid as parentGUID from pqs_rptdata
where state = 1 and datatype = 2 order by createtime asc
</select>
</mapper>

View File

@@ -0,0 +1,46 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.configuration.RptDataMapper'>
<select id="selectMaxRDIndex" resultType="String">
select max(rd_index) from pqs_rptdata where State = 1
</select>
<select id="getMaxDesc" resultType="int">
select nvl(max(sort),0) from pqs_rptdata where State = 1
</select>
<select id="testName" resultType="RptData">
select * from PQS_RptData where State = 1 and RD_Name = #{name} and RD_Index != #{rdIndex}
</select>
<select id="getDatasByPloy" resultType="RptData">
select * from PQS_RPTDATA t2 where T2.RD_INDEX in(
select T1.RD_INDEX from PQS_RPTASS t1 where T1.RP_INDEX = #{rpIndex}
)
</select>
<update id="deleteData">
update pqs_rptdata set state = 0,updatetime = #{updateTime} where rd_index = #{rdIndex} or parentguid = #{rdIndex}
</update>
<update id="updateData" databaseId="Oracle">
update pqs_rptdata set rd_name = #{shortName},describe = #{fullName},updatetime = #{updateTime} where rd_index = #{rdIndex}
</update>
<update id="updateData" databaseId="MariaDB">
update pqs_rptdata set rd_name = #{shortName},`describe` = #{fullName},updatetime = #{updateTime} where rd_index = #{rdIndex}
</update>
<select id="getNodeData" resultType="RptData">
select
*
from PQS_RptData
where parentnode=#{parent} and datatype=#{dataType} and State = 1 and parentguid is null
order by Sort
</select>
<select id="getTreeState" resultType="java.lang.String">
select rd_index from pqs_rptass where rp_index = #{rpIndex}
</select>
</mapper>

View File

@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.configuration.RptPloyMapper'>
<select id="testName" resultType="RptPloy" >
select * from PQS_RptPloy where State = 1 and RP_Name = #{name} and RP_Index != #{rpIndex}
</select>
</mapper>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.1//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.configuration.SubStationMapper">
<select id="selectMaxIndex" parameterType="String" resultType="Long">
select max(sub_index) from PQ_SUBSTATION
</select>
<select id="testName" resultType="SubStation">
select * from
PQ_SUBSTATION where name = #{name} and sub_index != #{subIndex}
</select>
</mapper>

View File

@@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.configuration.SysMapper'>
<select id="getListMenu" resultType="MenuEntity">
select a.function_index guid,a.path path,a.parentnode parentNode from pqs_function a, pqs_rolefunction b where
a.function_index = b.function_index
and b.role_index in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and a.state = 1 and a.systype = #{sysType}
</select>
</mapper>

View File

@@ -0,0 +1,21 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.configuration.TerminalLogsMapper'>
<resultMap type="TerminalLogs" id="getResultMap" autoMapping="true">
<id column="LOGS_INDEX" property="logsIndex"/>
</resultMap>
<select id="selectLogs" resultMap="getResultMap">
SELECT
*
FROM
PQS_TERMINALLOGS
WHERE
dev_index IN
<foreach collection="list" open="(" close=")" separator="," item="item">
#{item}
</foreach>
ORDER BY UPDATETIME desc
</select>
</mapper>

View File

@@ -0,0 +1,873 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.configuration.TreeMapper'>
<resultMap type="Tree" id="gdResultMap" autoMapping="true">
<id column="Gd_index" property="nodeIndex"/>
<result column="province_index" property="pId"/>
</resultMap>
<select id='getGdInfo' resultMap='gdResultMap' >
select
gd_index,name
from pq_gdinformation
where
gd_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=") order by gd_index">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="subResultMap" autoMapping="true">
<id column="Sub_index" property="nodeIndex"/>
<result column="gd_index" property="pId"/>
</resultMap>
<select id='getSubInfo' resultMap='subResultMap'>
select
gd_index, name,sub_index
from pq_substation
where
gd_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=") order by sub_index">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="transResultMap" autoMapping="true">
<id column="TFLGASS_INDEX" property="nodeTf"/>
<result column="Sub_index" property="pId"/>
</resultMap>
<select id='getTransInfo' resultMap='transResultMap'>
select ts.sub_index,ts.tfname as name,ts.tf_index
from pqs_transformer ts
where ts.sub_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
order by updatetime desc
</select>
<resultMap type="Tree" id="devResultMap" autoMapping="true">
<id column="Dev_index" property="nodeIndex"/>
<result column="sub_index" property="pId"/>
</resultMap>
<select id='getDevInfo' resultMap='devResultMap'>
select
sub_index, name,dev_index,gd_index
from pq_device
where
DEVMODEL = 1
and datatype in (0, 2)
and gd_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=") order by dev_index">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="devicetMap" autoMapping="true">
<id column="Dev_index" property="nodeIndex"/>
<result column="sub_index" property="pId"/>
</resultMap>
<select id='getDevice' resultMap='devicetMap'>
select
sub_index, name,dev_index,gd_index
from pq_device
where
gd_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=") order by dev_index">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="subvResultMap" autoMapping="true">
<id column="subv_index" property="nodeIndex"/>
<result column="Dev_index" property="pId"/>
</resultMap>
<resultMap type="Tree" id="lineResultMap" autoMapping="true">
<id column="line_index" property="nodeIndex"/>
<result column="subv_index" property="pId"/>
</resultMap>
<select id='getLineInfo' resultMap='lineResultMap'>
select
a.subv_index, a.name,a.line_index,b.devflag as state,b.status
from pq_line a,pq_device b
where
a.dev_index = b.dev_index
and a.line_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=") order by a.line_index">
#{item}
</foreach>
</select>
<select id='getTreeGdInfo' resultMap='gdResultMap' >
select
gd_index,name,province_index
from pq_gdinformation
where
gd_index in
(select gd_index
from pq_line
where line_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")) order by gd_index">
#{item}
</foreach>
</select>
<select id='getTreeSubInfo' resultMap='subResultMap'>
select
gd_index, name,sub_index
from pq_substation
where
sub_index in
(select sub_index
from pq_line
where line_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")) order by sub_index">
#{item}
</foreach>
</select>
<select id='getZTTreeDevInfo' resultMap='devResultMap'>
select
sub_index, name,dev_index,gd_index,ip
from pq_device
where DEVMODEL = 1
and datatype in (0, 2)
and dev_index in
(select dev_index
from pq_line
where line_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")) order by dev_index">
#{item}
</foreach>
</select>
<select id='getWTTreeDevInfo' resultMap='devResultMap'>
select
sub_index, name,dev_index,gd_index
from pq_device
where
dev_index in
(select dev_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in (1, 2) and DEVModel = 1))
and DEVMODEL = 1
and datatype in (1,2)
and gd_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=") order by dev_index">
#{item}
</foreach>
</select>
<select id='getTreeSubvInfo' resultMap='subvResultMap'>
select
dev_index, name,subv_index,sub_index
from pq_subvoltage
where
subv_index in
(select subv_index
from pq_line
where line_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")) order by subv_index">
#{item}
</foreach>
</select>
<select id='getOffTreeSubInfo' resultMap='subResultMap'>
select
gd_index, name,sub_index
from pq_substation
where
sub_index in
(select sub_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in (0, 2) and DEVModel = 2))
and gd_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=") order by sub_index">
#{item}
</foreach>
</select>
<select id='getDeviceWT' resultMap='devicetMap'>
select
sub_index, name,dev_index,gd_index
from pq_device
where
datatype in (1, 2) and
gd_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by dev_index">
#{item}
</foreach>
</select>
<select id='getDeviceZT' resultMap='devicetMap'>
select
sub_index, name,dev_index,gd_index
from pq_device
where
datatype in (0, 2) and
gd_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by dev_index">
#{item}
</foreach>
</select>
<select id='getProInfo' resultType='tree'>
SELECT
pro.province_index nodeIndex,
dic.DIC_NAME name
FROM
pq_province pro,
pqs_dicdata dic
WHERE
pro.name = dic.DIC_INDEX
</select>
<select id='getGdByPro' resultType='tree'>
select
gd_index nodeIndex,name,province_index pId
from pq_gdinformation
where
province_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by gd_index">
#{item}
</foreach>
</select>
<select id='getOffLineDevice' resultType="Tree">
select
sub_index pId, name,dev_index nodeIndex,gd_index
from pq_device
where
DEVMODEL = #{devModel}
and datatype in
<foreach collection="dataType" index="index" item="item" open="("
separator="," close=")">
#{item}
</foreach>
and gd_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by dev_index">
#{item}
</foreach>
</select>
<select id="getProInfoByDevice" resultType="Tree">
SELECT
t5.PROVINCE_INDEX nodeIndex,
dic.DIC_NAME name
FROM
PQ_PROVINCE t5,
pqs_dicdata dic
WHERE
T5.PROVINCE_INDEX IN (
SELECT
T4.PROVINCE_INDEX
FROM
PQ_GDINFORMATION t4
WHERE
T4.GD_INDEX IN (
SELECT DISTINCT
(t3.GD_INDEX)
FROM
PQ_LINE t3
WHERE
T3.DEV_INDEX IN (
SELECT
T2.DEV_INDEX
FROM
PQ_DEVICE t2
WHERE
T2.DATATYPE IN
<foreach collection="dataType" index="index" item="item" open="("
separator="," close=")">
#{item}
</foreach>
)
)
)
and
t5.name = dic.DIC_INDEX
</select>
<select id="getGDInfoByDevice" resultType="Tree">
SELECT
T4.GD_INDEX nodeIndex,
T4.NAME
FROM
PQ_GDINFORMATION t4
WHERE
T4.GD_INDEX IN (
SELECT DISTINCT
(t3.GD_INDEX)
FROM
PQ_LINE t3
WHERE
T3.DEV_INDEX IN (
SELECT
T2.DEV_INDEX
FROM
PQ_DEVICE t2
WHERE
T2.DATATYPE IN
<foreach collection="dataType" index="index" item="item" open="("
separator="," close=")">
#{item}
</foreach>
)
)
AND
T4.PROVINCE_INDEX=#{nodeIndex}
</select>
<select id="getSubInfoByDevice" resultType="Tree">
SELECT
T4.SUB_INDEX nodeIndex,
T4.NAME
FROM
PQ_SUBSTATION t4
WHERE
T4.GD_INDEX IN (
SELECT DISTINCT
(t3.GD_INDEX)
FROM
PQ_LINE t3
WHERE
T3.DEV_INDEX IN (
SELECT
T2.DEV_INDEX
FROM
PQ_DEVICE t2
WHERE
T2.DATATYPE IN
<foreach collection="dataType" index="index" item="item" open="("
separator="," close=")">
#{item}
</foreach>
)
)
AND T4.GD_INDEX = #{nodeIndex}
</select>
<select id="getDevInfoByDevice" resultType="Tree">
SELECT
T1.DEV_INDEX nodeIndex,
T1.NAME
FROM
PQ_DEVICE t1
WHERE
T1.DATATYPE IN
<foreach collection="dataType" index="index" item="item" open="("
separator="," close=")">
#{item}
</foreach>
AND T1.SUB_INDEX = #{nodeIndex}
</select>
<select id="getSubvInfoByDevice" resultType="Tree">
SELECT
T1.SUBV_INDEX nodeIndex,
T1.NAME
FROM
PQ_SUBVOLTAGE t1
WHERE
T1.DEV_INDEX=#{nodeIndex}
</select>
<select id="getLineInfoByDevice" resultType="Tree">
SELECT
T1.subv_index,
T1.NAME,
T1.line_index nodeIndex,
T2.devflag state,
T2.status
FROM
pq_line t1,PQ_DEVICE t2
WHERE
T1.dev_index=T2.dev_index
AND
T1.SUBV_INDEX =#{nodeIndex}
</select>
<select id="getOffYearProJInfo" resultMap="proJResultMap">
select distinct a.project_index nodeIndex, a.name name
from pq_project a,
pq_province b,
pq_gdinformation c,
pq_device d,
pq_line e,
offl_log f
where b.project_index = a.project_index
and c.province_index = b.province_index
and e.gd_index = c.gd_index
and f.line_index = e.line_index
and f.year in
<foreach collection="year" index="index" item="item" open="("
separator="," close=")">
#{item}
</foreach>
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="proVResultMap" autoMapping="true">
<id column="province_index" property="nodeIndex"/>
<id column="project_index" property="pId"/>
</resultMap>
<select id="getOffYearProVInfo" resultMap="proVResultMap">
select distinct a.province_index nodeIndex,
(select dic_name
from pqs_dicdata
where dic_index = a.name
and state = 1) || e.year name,
a.project_index pId
from pq_province a,
pq_gdinformation b,
pq_line c,
pq_device d,
offl_log e
where b.province_index = a.province_index
and c.gd_index = b.gd_index
and e.line_index = c.line_index
and e.year = #{year}
and c.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="offsubResultMap" autoMapping="true">
<id column="Sub_index" property="nodeIndex"/>
<result column="province_index" property="pId"/>
</resultMap>
<select id="getOffYearSubInfo" resultMap="offsubResultMap">
select distinct b.province_index pId, a.name name, a.sub_index nodeIndex
from pq_substation a, pq_province b, pq_gdinformation c ,pq_line d,offl_log e,pq_device f
where a.gd_index = c.gd_index
and c.province_index = b.province_index
and d.sub_index = a.sub_index
and e.line_index = d.line_index
and e.year = #{year}
and d.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getOffYearLineInfo" resultMap="offlineResultMap">
select
distinct a.sub_index pId, a.name name,a.line_index nodeIndex
from pq_line a,pq_device b,pq_substation c,offl_log d
where
a.sub_index = c.sub_index
and d.line_index = a.line_index
and d.year = #{year}
and a.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="proJResultMap" autoMapping="true">
<id column="project_index" property="nodeIndex"/>
</resultMap>
<select id="getOffTypeProJInfo" resultMap="proJResultMap">
select distinct a.project_index nodeIndex, a.name
from pq_project a,
pq_province b,
pq_gdinformation c,
pq_device d,
pq_line e,
pq_linedetail f
where b.project_index = a.project_index
and c.province_index = b.province_index
and e.gd_index = c.gd_index
and f.line_index = e.line_index
and f.loadtype = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getOffTypeProVInfo" resultMap="proVResultMap">
select distinct a.province_index nodeIndex, a.name name, a.project_index pId
from pq_province a,
pq_gdinformation b,
pq_line c,
pq_device d,
pq_linedetail e
where b.province_index = a.province_index
and c.gd_index = b.gd_index
and e.line_index = c.line_index
and e.loadtype = #{type}
and c.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getOffTypeSubInfo" resultMap="offsubResultMap">
select distinct b.province_index pId, a.name name, a.sub_index nodeIndex
from pq_substation a, pq_province b, pq_gdinformation c ,pq_line d,pq_linedetail e,pq_device f
where a.gd_index = c.gd_index
and c.province_index = b.province_index
and d.sub_index = a.sub_index
and e.line_index = d.line_index
and e.loadtype = #{type}
and d.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="offlineResultMap" autoMapping="true">
<id column="line_index" property="nodeIndex"/>
<result column="sub_index" property="pId"/>
</resultMap>
<select id="getOffTypeLineInfo" resultMap="offlineResultMap">
select distinct
a.sub_index pId, a.name name,a.line_index nodeIndex
from pq_line a,pq_device b,pq_substation c,pq_linedetail d
where
a.sub_index = c.sub_index
and d.line_index = a.line_index
and d.loadtype = #{type}
and a.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="proResultMap" autoMapping="true">
<id column="province_index" property="nodeIndex"/>
</resultMap>
<select id='getTreeProInfo' resultMap='proResultMap' >
select province_index, name
from pq_province
where province_index in
(select province_index
from pq_gdinformation
where gd_index in
(select gd_index
from pq_line
where line_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close="))) order by province_index">
#{item}
</foreach>
</select>
<select id="getScaleProVInfo" resultMap="proVResultMap">
select distinct b.province_index nodeIndex, b.name
from pq_province b,
pq_gdinformation c,
pq_subvoltage d,
pq_line e
where c.province_index = b.province_index
and e.gd_index = c.gd_index
and e.subv_index = d.subv_index
and d.scale = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getScaleGdInfo" resultMap="gdResultMap">
select distinct b.province_index pId,a.gd_index nodeIndex, a.name
from pq_province b,
pq_gdinformation a,
pq_subvoltage d,
pq_line e
where b.province_index = a.province_index
and e.gd_index = a.gd_index
and e.subv_index = d.subv_index
and d.scale = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getScaleSubInfo" resultMap="subResultMap">
select distinct b.gd_index pId,a.sub_index nodeIndex, a.name
from pq_gdinformation b,
pq_substation a,
pq_subvoltage d,
pq_line e
where b.gd_index = a.gd_index
and e.sub_index = a.sub_index
and e.subv_index = d.subv_index
and d.scale = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getScaleDevInfo" resultMap="devResultMap">
select distinct a.sub_index pId,d.dev_index nodeIndex, d.name
from pq_substation a,
pq_subvoltage b,
pq_device d,
pq_line e
where d.sub_index = a.sub_index
and e.dev_index = d.dev_index
and e.subv_index = b.subv_index
and b.scale = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getScaleSubvInfo" resultMap="subvResultMap">
select distinct b.sub_index pId,a.subv_index nodeIndex, a.name
from pq_subvoltage a,
pq_substation b,
pq_device d,
pq_line e
where b.sub_index = e.sub_index
and d.dev_index = a.dev_index
and e.subv_index = a.subv_index
and a.scale = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getMancProVInfo" resultMap="proVResultMap">
select distinct b.province_index nodeIndex, b.name
from pq_province b,
pq_devicedetail a,
pq_gdinformation c,
pq_subvoltage d,
pq_line e
where c.province_index = b.province_index
and e.gd_index = c.gd_index
and e.subv_index = d.subv_index
and a.dev_index = e.dev_index
and a.manufacturer = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getMancGdInfo" resultMap="gdResultMap">
select distinct b.province_index pId,a.gd_index nodeIndex, a.name
from pq_province b,
pq_gdinformation a,
pq_devicedetail c,
pq_subvoltage d,
pq_line e
where b.province_index = a.province_index
and e.gd_index = a.gd_index
and e.subv_index = d.subv_index
and c.dev_index = e.dev_index
and c.manufacturer = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getMancSubInfo" resultMap="subResultMap">
select distinct b.gd_index pId,a.sub_index nodeIndex, a.name
from pq_gdinformation b,
pq_substation a,
pq_devicedetail c,
pq_subvoltage d,
pq_line e
where b.gd_index = a.gd_index
and e.sub_index = a.sub_index
and e.subv_index = d.subv_index
and c.dev_index = e.dev_index
and c.manufacturer = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getMancDevInfo" resultMap="devResultMap">
select distinct a.sub_index pId,d.dev_index nodeIndex, d.name
from pq_substation a,
pq_subvoltage b,
pq_devicedetail c,
pq_device d,
pq_line e
where d.sub_index = a.sub_index
and e.dev_index = d.dev_index
and e.subv_index = b.subv_index
and c.dev_index = e.dev_index
and c.manufacturer = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getMancSubvInfo" resultMap="subvResultMap">
select distinct b.sub_index pId,a.subv_index nodeIndex, a.name
from pq_subvoltage a,
pq_substation b,
pq_devicedetail c,
pq_device d,
pq_line e
where b.sub_index = e.sub_index
and d.dev_index = a.dev_index
and e.subv_index = a.subv_index
and c.dev_index = e.dev_index
and c.manufacturer = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getLoadTypeProVInfo" resultMap="proVResultMap">
select distinct b.province_index nodeIndex, b.name
from pq_province b,
pq_linedetail a,
pq_gdinformation c,
pq_subvoltage d,
pq_line e
where c.province_index = b.province_index
and e.gd_index = c.gd_index
and e.subv_index = d.subv_index
and a.line_index = e.line_index
and a.loadtype = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getLoadTypeGdInfo" resultMap="gdResultMap">
select distinct b.province_index pId,a.gd_index nodeIndex, a.name
from pq_province b,
pq_gdinformation a,
pq_linedetail c,
pq_subvoltage d,
pq_line e
where b.province_index = a.province_index
and e.gd_index = a.gd_index
and e.subv_index = d.subv_index
and c.line_index = e.line_index
and c.loadtype = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getLoadTypeSubInfo" resultMap="subResultMap">
select distinct b.gd_index pId,a.sub_index nodeIndex, a.name
from pq_gdinformation b,
pq_substation a,
pq_linedetail c,
pq_subvoltage d,
pq_line e
where b.gd_index = a.gd_index
and e.sub_index = a.sub_index
and e.subv_index = d.subv_index
and c.line_index = e.line_index
and c.loadtype = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getLoadTypeDevInfo" resultMap="devResultMap">
select distinct a.sub_index pId,d.dev_index nodeIndex, d.name
from pq_substation a,
pq_subvoltage b,
pq_linedetail c,
pq_device d,
pq_line e
where d.sub_index = a.sub_index
and e.dev_index = d.dev_index
and e.subv_index = b.subv_index
and c.line_index = e.line_index
and c.loadtype = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<select id="getLoadTypeSubvInfo" resultMap="subvResultMap">
select distinct b.sub_index pId,a.subv_index nodeIndex, a.name
from pq_subvoltage a,
pq_substation b,
pq_linedetail c,
pq_device d,
pq_line e
where b.sub_index = e.sub_index
and d.dev_index = a.dev_index
and e.subv_index = a.subv_index
and c.line_index = e.line_index
and c.loadtype = #{type}
and e.line_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by nodeIndex">
#{item}
</foreach>
</select>
<resultMap type="Tree" id="nodesubvResultMap" autoMapping="true">
<id column="subv_index" property="nodeIndex"/>
<result column="Sub_index" property="pId"/>
</resultMap>
<select id='getNodeTreeSubvInfo' resultMap='nodesubvResultMap'>
select
sub_index, name,subv_index,sub_index
from pq_subvoltage
where
subv_index in
(select subv_index
from pq_line
where line_index in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")) order by subv_index">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,70 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.data.AssesMapper'>
<select id="getVol" resultType="asses">
SELECT
AVG(VU_DEV) VU_DEV ,
AVG(Freq_Dev) Freq_Dev ,
AVG(Data_PLT) Data_PLT ,
AVG(V_Unbalance_CP95) V_Unbalance_CP95 ,
AVG(V_THD_CP95) V_THD_CP95
FROM
PQS_ASSES
WHERE
TIMEID BETWEEN #{startTime}
AND #{endTime}
AND LINEID IN
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<select id="getSynData" resultType="pqsComasses">
SELECT
T .LINEID,
AVG (T .freq_Dev1) freqDev1,
AVG (T .freq_Dev2) freqDev2,
AVG (T .freq_Dev3) freqDev3,
AVG (T .freq_Dev4) freqDev4,
AVG (T .freq_Dev5) freqDev5,
AVG (T .vu_Dev1) vuDev1,
AVG (T .vu_Dev2) vuDev2,
AVG (T .vu_Dev3) vuDev3,
AVG (T .vu_Dev4) vuDev4,
AVG (T .vu_Dev5) vuDev5,
AVG (T .data_Pst1) dataPst1,
AVG (T .data_Pst2) dataPst2,
AVG (T .data_Pst3) dataPst3,
AVG (T .data_Pst4) dataPst4,
AVG (T .data_Pst5) dataPst5,
AVG (T .v_Unbalance1) vUnbalance1,
AVG (T .v_Unbalance2) vUnbalance2,
AVG (T .v_Unbalance3) vUnbalance3,
AVG (T .v_Unbalance4) vUnbalance4,
AVG (T .v_Unbalance5) vUnbalance5,
AVG (T .v_Thd1) vThd1,
AVG (T .v_Thd2) vThd2,
AVG (T .v_Thd3) vThd3,
AVG (T .v_Thd4) vThd4,
AVG (T .v_Thd5) vThd5,
AVG (T .event1) event1,
AVG (T .event2) event2,
AVG (T .event3) event3,
AVG (T .event4) event4,
AVG (T .event5) event5
FROM
PQS_COMASSES T
where
TIMEID BETWEEN #{startTime}
AND #{endTime}
and LINEID in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
GROUP BY
LINEID
</select>
</mapper>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.1//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.data.EventAssMapper">
<select id="getCountsByInterval" resultType="Integer" databaseId="Oracle">
select count(*) from PQS_EVENTDETAIL where to_char(TIMEID,'YYYY-MM') = #{interTime} AND EVENTASS_INDEX is not null
</select>
<select id="getCountsByInterval" resultType="Integer" databaseId="MariaDB">
select count(*) from PQS_EVENTDETAIL where
date_format(TIMEID,'%Y-%m') = #{interTime} AND EVENTASS_INDEX is not null
</select>
</mapper>

View File

@@ -0,0 +1,726 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.data.EventDetailMapper">
<select id="queryVoltageCountsByLineIndexs" resultType="Integer">
SELECT
count(1)
FROM
PQS_EVENTDETAIL
WHERE
LINEID IN
<foreach collection="list" item="item" separator="," open="("
close=")">
#{item}
</foreach>
AND TIMEID between #{startTime} and #{endTime}
AND WaveType=1
</select>
<select id="querySubLevel" resultType="simpleValue">
SELECT
t1.name name,
t2.allcount value
FROM
pq_substation t1,
(
SELECT
COUNT (A.lineid) allcount
FROM
pqs_eventdetail A,
pq_line b,
pq_substation c,
PQ_DEVICE d
WHERE
c.sub_index = #{subIndex}
AND b.sub_index = c.sub_index
AND A .lineid = b.line_index
AND b.DEV_INDEX=d.DEV_INDEX
AND d.DEVMODEL = 1
AND d.DATATYPE in (0,2)
and b.line_index in
<foreach collection="lineIndex" open="(" close=")" separator="," item="lineId">
#{lineId}
</foreach>
and a.TIMEID between #{startTime}
and #{endTime}
) t2
WHERE
t1.sub_index =#{subIndex}
</select>
<select id="queryLineLevel" resultType="simpleValue" databaseId="Oracle">
select * from
(
select
LINEID name,
count(1) VALUE
FROM
PQS_EVENTDETAIL A
WHERE
TIMEID between #{startTime} and #{endTime}
AND
LINEID IN
<foreach collection="lineIndex" item="item" index="index"
open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY LINEID
ORDER BY VALUE DESC)
WHERE ROWNUM <![CDATA[ <= ]]>
30
</select>
<select id="queryLineLevel" resultType="simpleValue" databaseId="MariaDB">
select * from
(
select
LINEID name,
count(1) VALUE
FROM
PQS_EVENTDETAIL A
WHERE
TIMEID between #{startTime} and #{endTime}
AND
LINEID IN
<foreach collection="lineIndex" item="item" index="index"
open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY LINEID
ORDER BY VALUE DESC) as t
limit 30
</select>
<select id="queryEventDetail" resultType="StatisticsEventDetail" databaseId="Oracle">
SELECT
M .TIMEID,
M.EVENTDETAIL_INDEX,
to_char(M .TIMEID,'YYYY-mm-dd
hh24:mi:ss.')||M.MS time,
round(M.PERSISTTIME/1000,3) PERSISTTIME,
round(M.EVENTVALUE*100,2) EVENTVALUE,
M.EVENTREASON,
M.EVENTTYPE,
M.NAME,
M.LINEID,
S.DIC_NAME SCALE,
S1.DIC_NAME LOADTYPE,
s2.name gdName,
s3.name subName
FROM
(SELECT
T1.TIMEID,
T1.EVENTDETAIL_INDEX,
nvl(substr(10000+T1.MS,-3),T1.MS) MS,
T1.PERSISTTIME,
T1.EVENTVALUE,
T2.DIC_NAME EVENTREASON,
T3.BACK_UP EVENTTYPE,
T4. NAME,
T1.LINEID,
T4.SCALE,
T4.SUB_INDEX,
T4.GD_INDEX,
T5.LOADTYPE
FROM
PQS_EVENTDETAIL T1
INNER JOIN PQS_DICDATA T2 ON T1.EVENTREASON = T2.DIC_INDEX
INNER JOIN
PQS_DICDATA T3 ON T1.EVENTTYPE = T3.DIC_INDEX
INNER JOIN PQ_LINE T4 ON
T1.LINEID = T4.LINE_INDEX
INNER JOIN PQ_LINEDETAIL T5 ON
T1.LINEID=T5.LINE_INDEX
WHERE
T1.LINEID IN
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
AND
T1.TIMEID BETWEEN #{startTime} AND #{endTime}
and T1.WaveType &lt;&gt; 5
)M
INNER JOIN
PQS_DICDATA S ON M.SCALE=S.DIC_INDEX
INNER JOIN PQS_DICDATA
S1 ON
M.LOADTYPE=S1.DIC_INDEX
INNER JOIN PQ_GDINFORMATION S2 ON
M.gd_index=S2.gd_INDEX
INNER JOIN PQ_SUBSTATION S3 ON
M.sub_index=S3.sub_index
</select>
<select id="queryEventDetail" resultType="StatisticsEventDetail" databaseId="MariaDB">
SELECT
M .TIMEID,
M.EVENTDETAIL_INDEX,
CONCAT(date_format(M .TIMEID,'%Y-%m-%d %H:%i:%S.'), M.MS) time,
round(M.PERSISTTIME/1000,3) PERSISTTIME,
round(M.EVENTVALUE*100,2) EVENTVALUE,
M.EVENTREASON,
M.EVENTTYPE,
M.NAME,
M.LINEID,
S.DIC_NAME SCALE,
S1.DIC_NAME LOADTYPE,
s2.name gdName,
s3.name subName
FROM
(SELECT
T1.TIMEID,
T1.EVENTDETAIL_INDEX,
nvl(substr(10000+T1.MS,-3),T1.MS) MS,
T1.PERSISTTIME,
T1.EVENTVALUE,
T2.DIC_NAME EVENTREASON,
T3.BACK_UP EVENTTYPE,
T4. NAME,
T1.LINEID,
T4.SCALE,
T4.SUB_INDEX,
T4.GD_INDEX,
T5.LOADTYPE
FROM
PQS_EVENTDETAIL T1
INNER JOIN PQS_DICDATA T2 ON T1.EVENTREASON = T2.DIC_INDEX
INNER JOIN
PQS_DICDATA T3 ON T1.EVENTTYPE = T3.DIC_INDEX
INNER JOIN PQ_LINE T4 ON
T1.LINEID = T4.LINE_INDEX
INNER JOIN PQ_LINEDETAIL T5 ON
T1.LINEID=T5.LINE_INDEX
WHERE
T1.LINEID IN
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
AND
T1.TIMEID BETWEEN #{startTime} AND #{endTime}
and T1.WaveType &lt;&gt; 5
)M
INNER JOIN
PQS_DICDATA S ON M.SCALE=S.DIC_INDEX
INNER JOIN PQS_DICDATA
S1 ON
M.LOADTYPE=S1.DIC_INDEX
INNER JOIN PQ_GDINFORMATION S2 ON
M.gd_index=S2.gd_INDEX
INNER JOIN PQ_SUBSTATION S3 ON
M.sub_index=S3.sub_index
</select>
<select id="queryVoltageList" resultType="eventDetail" databaseId="Oracle">
SELECT
M.EVENTDETAIL_INDEX,
M.LINEID,
M.WAVETYPE,
M.fileflag,
TO_CHAR (
M.TIMEID,
'YYYY-mm-dd hh24:mi:ss.'
) || M.MS TIME,
ROUND (M.PERSISTTIME / 1000, 3) PERSISTTIME,
ROUND(M.EVENTVALUE * 100 ,2) EVENTVALUE,
M .EVENTREASON,
M .EVENTTYPE,
M . NAME lineName,
M .EVENTASS_INDEX,
M .severity,
S. NAME GDNAME,
S1. NAME SUBNAME,
S2.DIC_NAME SCALE,
S3.IP,
M.DEVTYPE devtype
FROM
(
SELECT
T1.EVENTDETAIL_INDEX,
T1.LINEID,
T1.TIMEID,
T1.FILEFLAG,
NVL (
SUBSTR (10000 + T1.MS ,- 3),
T1.MS
) MS,
T1.PERSISTTIME,
T1.severity,
T1.EVENTVALUE,
T1.WAVETYPE,
T2.DIC_NAME EVENTREASON,
T3.DIC_NAME EVENTTYPE,
T1.EVENTASS_INDEX,
T4. NAME,
T4.GD_INDEX GDINDEX,
T4.SUB_INDEX SUBINDEX,
T4. SCALE,
T4.DEV_INDEX DEVINDEX,
s5.DIC_NAME DEVTYPE
FROM
PQS_EVENTDETAIL T1
INNER JOIN PQS_DICDATA T2 ON T1.EVENTREASON = T2.DIC_INDEX
INNER JOIN PQS_DICDATA T3 ON T1.EVENTTYPE = T3.DIC_INDEX
INNER JOIN PQ_LINE T4 ON T1.LINEID = T4.LINE_INDEX
INNER JOIN pq_device S4 ON T4 .dev_index = S4.Dev_index
INNER JOIN PQS_DICDATA S5 ON S4.devtype=S5 .DIC_INDEX
WHERE
T1.TIMEID
BETWEEN #{startTime} AND #{endTime}
and
T1.LINEID in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
<if test="minfuzhi !=null and maxfuzhi!=null">
and T1.EVENTVALUE between #{minfuzhi} and #{maxfuzhi}
</if>
<if test="minfuzhi !=null and maxfuzhi==null">
and T1.EVENTVALUE > #{minfuzhi}
</if>
<if test="minfuzhi ==null and maxfuzhi!=null">
and T1.EVENTVALUE &lt; #{maxfuzhi}
</if>
<if test="mintime !=null and maxtime!=null">
and T1.PERSISTTIME between #{mintime} and #{maxtime}
</if>
<if test="mintime !=null and maxtime==null">
and T1.PERSISTTIME > #{mintime}
</if>
<if test="mintime ==null and maxtime!=null">
and T1.PERSISTTIME &lt; #{maxtime}
</if>
<if test="minseverity !=null and maxseverity!=null">
and T1.severity between #{minseverity} and #{maxseverity}
</if>
<if test="minseverity !=null and maxseverity==null">
and T1.severity > #{minseverity}
</if>
<if test="minseverity ==null and maxseverity!=null">
and T1.severity &lt; #{maxseverity}
</if>
<if test="eventType!=null">
and T1.EVENTTYPE in
<foreach collection="eventType" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="eventReason!=null">
and T1.EVENTREASON in
<foreach collection="eventReason" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="triggerType!=null">
and T1.WAVETYPE in
<foreach collection="triggerType" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="fileflag!=null">
and T1.FILEFLAG = #{fileflag}
</if>
) M
INNER JOIN PQ_GDINFORMATION S ON M .GDINDEX = S.GD_INDEX
INNER JOIN PQ_SUBSTATION S1 ON M .SUBINDEX = S1.SUB_INDEX
INNER JOIN PQS_DICDATA S2 ON M . SCALE = S2.DIC_INDEX
INNER JOIN pq_device S3 ON M .DEVINDEX = S3.Dev_index
ORDER BY
M .TIMEID DESC
</select>
<select id="queryVoltageList" resultType="eventDetail" databaseId="MariaDB">
SELECT
M .EVENTDETAIL_INDEX,
M .LINEID,
M.WAVETYPE,
m.fileflag,
CONCAT(date_format(M .TIMEID,'%Y-%m-%d %H:%i:%S.'), M.MS) time,
round(M
.PERSISTTIME/1000, 3) PERSISTTIME,
round(M.EVENTVALUE*100,2) EVENTVALUE,
M
.EVENTREASON,
M .EVENTTYPE,
M .NAME lineName,
M.EVENTASS_INDEX,
M.severity,
S. NAME GDNAME,
S1. NAME SUBNAME,
S2.DIC_NAME SCALE,
S3.IP,
M.DEVTYPE devtype
FROM
(
SELECT
T1.EVENTDETAIL_INDEX,
T1.LINEID,
T1.TIMEID,
T1.FILEFLAG,
nvl(substr(10000+T1.MS,-3),T1.MS) MS,
T1.PERSISTTIME,
T1.severity,
T1.EVENTVALUE,
T1.WAVETYPE,
T2.DIC_NAME EVENTREASON,
T3.DIC_NAME EVENTTYPE,
T1.EVENTASS_INDEX,
T4.NAME,
T4.GD_INDEX GDINDEX,
T4.SUB_INDEX SUBINDEX,
T4.SCALE,
T4.DEV_INDEX DEVINDEX,
s5.DIC_NAME DEVTYPE
FROM
PQS_EVENTDETAIL T1
INNER JOIN
PQS_DICDATA T2 ON T1.EVENTREASON =
T2.DIC_INDEX
INNER JOIN PQS_DICDATA
T3 ON T1.EVENTTYPE = T3.DIC_INDEX
INNER JOIN PQ_LINE T4 ON T1.LINEID =
T4.LINE_INDEX
INNER JOIN pq_device S4 ON T4 .dev_index = S4.Dev_index
INNER JOIN PQS_DICDATA S5 ON S4.devtype=S5 .DIC_INDEX
WHERE
T1.TIMEID
BETWEEN #{startTime} AND #{endTime}
and
T1.LINEID in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
) M
INNER JOIN PQ_GDINFORMATION S ON M .GDINDEX = S.GD_INDEX
INNER JOIN
PQ_SUBSTATION S1 ON M .SUBINDEX = S1.SUB_INDEX
INNER JOIN PQS_DICDATA
S2 ON M . SCALE = S2.DIC_INDEX
INNER JOIN pq_device S3 ON M . DEVINDEX
= S3.Dev_index
ORDER BY
M .TIMEID DESC
</select>
<select id="getCountsByInterval" resultType="Integer" databaseId="Oracle">
select count(*) from PQS_EVENTDETAIL where to_char(TIMEID,'YYYY-MM') =
#{interTime} and LINEID in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
AND WaveType=1
</select>
<select id="getCountsByInterval" resultType="Integer" databaseId="MariaDB">
select count(*) from PQS_EVENTDETAIL where date_format(TIMEID,'%Y-%m') =
#{interTime} and LINEID in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
AND
WaveType=1
</select>
<select id="getrunevent" resultType="eventDetail" databaseId="Oracle">
select * from (select
pq_line.name
lineName,pqs_eventdetail.timeid
timeId,c.dic_name as eventType
from
pq_gdinformation,pq_substation,pq_subvoltage,pq_line,pqs_eventdetail,pqs_dicdata
c
where
pq_line.subv_index = pq_subvoltage.subv_index
and
pqs_eventdetail.eventass_index is null
AND
pqs_eventdetail.LINEID IN
<foreach collection="lineIndex" item="item" index="index"
open="(" separator="," close=")">
#{item}
</foreach>
and
pq_line.sub_index =
pq_substation.sub_index and pq_line.gd_index =
pq_gdinformation.gd_index and pq_line.line_index =
pqs_eventdetail.lineid
and pqs_eventdetail.eventtype=c.dic_index
order
by pqs_eventdetail.timeid desc)
where ROWNUM <![CDATA[ <= ]]>10
</select>
<select id="getrunevent" resultType="eventDetail" databaseId="MariaDB">
select * from (select
pq_line.name
lineName,pqs_eventdetail.timeid
timeId,c.dic_name as eventType
from
pq_gdinformation,pq_substation,pq_subvoltage,pq_line,pqs_eventdetail,pqs_dicdata
c
where
pq_line.subv_index = pq_subvoltage.subv_index
and
pqs_eventdetail.eventass_index is null
and
pq_line.sub_index =
pq_substation.sub_index and pq_line.gd_index =
pq_gdinformation.gd_index and pq_line.line_index =
pqs_eventdetail.lineid
and pqs_eventdetail.eventtype=c.dic_index
order
by pqs_eventdetail.timeid desc) as t
limit 10
</select>
<select id="queryDealFlag" resultType="java.lang.Integer"
parameterType="java.lang.String">
select dealflag from pqs_eventdetail where
eventdetail_index = #{indexEvt}
</select>
<update id="updateDealFlag">
update pqs_eventdetail set dealflag = #{code} where
eventdetail_index = #{indexEvt}
</update>
<update id="updateCause">
update pqs_eventdetail set eventreason = (select
a.dic_index from pqs_dicdata a,pqs_dictype b where b.dictype_name =
'暂降原因' and a.dic_type = b.dictype_index and a.triphase = #{code} and
a.state = 1 and b.state = 1)
where
eventdetail_index = #{indexEvt}
</update>
<select id="querySagDescriptionbyId" resultType="java.lang.String">
select
a.dic_name from pqs_dicdata a,pqs_dictype b where b.dictype_name =
#{typename} and a.dic_type = b.dictype_index and a.triphase =#{code}
and a.state = 1 and b.state = 1
</select>
<select id="querySagDescriptionbyIndex" resultType="java.lang.String">
select
b.dic_name from pqs_dicdata b,pqs_eventdetail
a where a.eventreason =
b.dic_index and a.eventdetail_index =
#{indexEvt}
</select>
<update id="updateSagData">
update pqs_eventdetail
set eventtype =(select
a.dic_index from pqs_dicdata a,pqs_dictype b where b.dictype_name =
'暂降类型' and a.dic_type = b.dictype_index and a.triphase =
#{sagEvent.sagType} and a.state = 1 and b.state = 1)
,dqtime =
#{sagEvent.dqTime},
num =
#{sagEvent.number},firsttime =
#{sagEvent.firstTime},firstms =
#{sagEvent.firstMs}
,firsttype = (select
a.dic_index from pqs_dicdata
a,pqs_dictype b where b.dictype_name =
'暂降类型' and a.dic_type =
b.dictype_index and a.triphase =
#{sagEvent.firstType} and a.state = 1 and b.state = 1)
where
eventdetail_index =
#{sagEvent.indexEventDetail}
</update>
<update id="updateSeverity" >
update
PQS_EVENTDETAIL
set
Severity = #{severity}
where
EVENTDETAIL_INDEX=#{index}
</update>
<select id="queryLineEvents" resultType="simpleValue" databaseId="Oracle">
select i."LINE_NAME" as name, i."GD_NAME" as gdName, i."SUB_NAME" as subName, h.totalcount value
from ((select distinct MainTable.lineid, NVL(SubTable.count, 0) totalcount
from pqs_eventdetail MainTable
LEFT JOIN (select count(*) count, lineid
from pqs_eventdetail
where WAVETYPE = 1 and timeid between #{startTime} and #{endTime}
group by lineid
order by lineid) SubTable
ON MainTable.lineid = SubTable.lineid) h RIGHT JOIN
(select a.line_index line_index, a.name line_name, b.name gd_name, c.name sub_name
from pq_line a, pq_gdinformation b,pq_substation c, pq_device e
where a.gd_index = b.gd_index
and a.sub_index = c.sub_index
and a.dev_index = e.dev_index
and e.devmodel = 1
and e.datatype in (0, 2)
and a.line_index in
<foreach collection="list" item="item" separator="," open="("
close=")">
#{item}
</foreach>
) i ON h.lineid = i.line_index)
where h.totalcount > 0 and rownum &lt; 101
order by value desc
</select>
<select id="queryLineEvents" resultType="simpleValue" databaseId="MariaDB">
select i.LINE_NAME as name, i.GD_NAME as gdName, i.SUB_NAME as subName, h.totalcount value
from ((select distinct MainTable.lineid, NVL(SubTable.count, 0) totalcount
from pqs_eventdetail MainTable
LEFT JOIN (select count(*) count, lineid
from pqs_eventdetail
where WAVETYPE = 1
and timeid between #{startTime} and #{endTime}
group by lineid
order by lineid) SubTable
ON MainTable.lineid = SubTable.lineid) h RIGHT JOIN
(select a.line_index line_index, a.name line_name, b.name gd_name, c.name sub_name
from pq_line a, pq_gdinformation b,pq_substation c, pq_device e
where a.gd_index = b.gd_index
and a.sub_index = c.sub_index
and a.dev_index = e.dev_index
and e.devmodel = 1
and e.datatype in (0, 2)
and a.line_index in
<foreach collection="list" item="item" separator="," open="("
close=")">
#{item}
</foreach>
) i ON h.lineid = i.line_index)
where h.totalcount > 0
order by value desc LIMIT 10
</select>
<resultMap type="com.njcn.pojo.commons.EventInfoDetail" id="EventInfoDetailMapperMap"
autoMapping="true">
<id property="eventDetailIndex" column="EVENTDETAIL_INDEX"/>
</resultMap>
<select id="eventDetailBaseInfoByIndex" resultMap="EventInfoDetailMapperMap">
SELECT LINE.name lineName,
gd.name gdName,
sub.name bdzName,
dev.name devName,
dic.dic_name scale,
dev.ip ip,
EV.EVENTDETAIL_INDEX eventDetailIndex,
EV.TIMEID timeID,
EV.PERSISTTIME / 1000 persistTime,
round(EV.EVENTVALUE * 100,2) eventValue,
ev.ms ms
FROM PQS_EVENTDETAIL ev,
PQ_LINE line,
PQ_GDINFORMATION gd,
PQ_SUBSTATION sub,
PQ_DEVICE dev,
PQS_DICDATA dic
WHERE line.line_index = ev.lineid
AND gd.gd_index = line.gd_index
AND sub.sub_index = line.sub_index
AND dev.dev_index = line.dev_index
and dic.dic_index = line.scale
AND ev.eventdetail_index = #{eventdetailIndex}
</select>
<select id="getPtType" resultType="java.lang.Integer">
select b.pttype
from pqs_eventdetail a, pq_linedetail b
where a.eventdetail_index = #{eventIndex}
and a.lineid = b.line_index
</select>
<select id="selectByIndex" resultType="eventDetail">
SELECT
EVENTDETAIL_INDEX,
LINEID,
TIMEID,
MS,
WAVETYPE,
PERSISTTIME,
EVENTVALUE,
EVENTREASON,
EVENTTYPE,
EVENTASS_INDEX,
DQTIME,
DEALTIME,
NUM,
FILEFLAG,
DEALFLAG,
FIRSTTIME,
FIRSTTYPE,
FIRSTMS,
WAVENAME,
Energy,
Severity
FROM
PQS_EVENTDETAIL
WHERE
EVENTDETAIL_INDEX = #{eventIndex}
</select>
<select id="selectByTimeIdAndLineIndex" resultType="eventDetail">
SELECT
EVENTDETAIL_INDEX,
LINEID,
TIMEID,
MS,
WAVETYPE,
PERSISTTIME,
EVENTVALUE,
EVENTREASON,
EVENTTYPE,
EVENTASS_INDEX,
DQTIME,
DEALTIME,
NUM,
FILEFLAG,
DEALFLAG,
FIRSTTIME,
FIRSTTYPE,
FIRSTMS,
WAVENAME,
Energy,
Severity
FROM
PQS_EVENTDETAIL
WHERE
TIMEID = #{timeId}
and
MS = #{ms}
and
lineId =#{lineId}
</select>
<select id="getSuspendByMonitor" resultType="java.lang.Integer">
SELECT
NVL(COUNT(1),0)
FROM
PQS_EVENTDETAIL T1
WHERE
T1.TIMEID
BETWEEN #{startTime} AND #{endTime}
and T1.LINEID in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
and T1.WAVETYPE = 1
</select>
</mapper>

View File

@@ -0,0 +1,95 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.data.EventPzMapper'>
<resultMap type="EventPz" id="eventPzMap" autoMapping="true">
<id column="EVENTDETAIL_INDEX" property="eventdetalIndex" />
</resultMap>
<select id="getZjsj" resultMap="eventPzMap" databaseId="Oracle">
SELECT
even.eventdetail_index indexEventDetail,
even.timeid TIME,
even.ms msec,
round(even.persisttime/1000, 3) persisttime,
even.describe EVENTS,
even.EventValue eventValue,
lin.line_index indexPoint,
lin. NAME lineName,
sg. NAME nameSubV,
sb. NAME nameBD,
gd. NAME nameGD,
c.dic_name eventType
FROM
(
SELECT
*
FROM
pqs_eventdetail event
WHERE
event.eventass_index IS NULL
AND
event.LINEID IN
<foreach collection="lineIndex" item="item" index="index"
open="(" separator="," close=")">
#{item}
</foreach>
ORDER BY
event.timeid DESC
) even
LEFT JOIN (SELECT * FROM PQ_LINE) lin ON lin.line_index = even.lineid
LEFT JOIN (SELECT * FROM pq_subvoltage) sg ON lin.subv_index = sg.subv_index
LEFT JOIN (SELECT * FROM pq_substation) sb ON lin.sub_index = sb.sub_index
LEFT JOIN (SELECT * FROM PQ_GDINFORMATION) gd ON lin.gd_index = gd.gd_index
LEFT JOIN (SELECT * FROM PQS_DICDATA) c ON even.eventtype = c.dic_index
WHERE
ROWNUM &lt;=100
</select>
<select id="getZjsj" resultMap="eventPzMap" databaseId="MariaDB">
(SELECT
even.eventdetail_index indexEventDetail,
even.timeid TIME,
even.ms msec,
round(even.persisttime/1000, 3) persisttime,
even.`describe` EVENTS,
even.EventValue eventValue,
lin.line_index indexPoint,
lin. NAME lineName,
sg. NAME nameSubV,
sb. NAME nameBD,
gd. NAME nameGD,
c.dic_name eventType
FROM
(
SELECT
*
FROM
pqs_eventdetail event
WHERE
event.eventass_index IS NULL
AND
event.LINEID IN
<foreach collection="lineIndex" item="item" index="index"
open="(" separator="," close=")">
#{item}
</foreach>
) even
LEFT JOIN (SELECT * FROM PQ_LINE) lin ON lin.line_index = even.lineid
LEFT JOIN (SELECT * FROM pq_subvoltage) sg ON lin.subv_index = sg.subv_index
LEFT JOIN (SELECT * FROM pq_substation) sb ON lin.sub_index = sb.sub_index
LEFT JOIN (SELECT * FROM PQ_GDINFORMATION) gd ON lin.gd_index = gd.gd_index
LEFT JOIN (SELECT * FROM PQS_DICDATA) c ON even.eventtype = c.dic_index
ORDER BY
timeid DESC
)LIMIT 100
</select>
<update id="dealEventWarn" parameterType="list">
update pqs_eventdetail set look_flag = 1
where eventdetail_index in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
</mapper>

View File

@@ -0,0 +1,119 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.data.IntegrityMapper'>
<select id="selectIntegralityByLineIndexAndTime" resultType="simpleValue">
SELECT
SUM (T1.real) countOnline,
SUM (T1.due) countAll
FROM
PQS_Integrity T1
WHERE
T1.Line_index in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND
T1.TIMEID BETWEEN #{startTime} AND #{endTime}
</select>
<select id="selectGwIntegralityByLineIndexAndTime" resultType="simpleValue">
SELECT
SUM (T1.real) countOnline,
SUM (T1.due) countAll
FROM
PQS_NGCPINTEGRITY T1
WHERE
T1.Line_index in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND
T1.TIMEID BETWEEN #{startTime} AND #{endTime}
</select>
<select id="selectGistIntegrality" resultType="simpleValue">
SELECT
t1.integrality,
t2. NAME,
T3.NAME devName,
t3.ip,
t4.name gdName,
t5.name subName
FROM
(
SELECT
T .*, ROWNUM row_num
FROM
(
SELECT
LINE_INDEX,
ROUND ( SUM (REAL) / SUM (DUE),4) * 100 integrality
FROM
PQS_INTEGRITY
WHERE
LINE_INDEX IN <foreach collection="list" item="item" open="(" close=")" separator=",">#{item}</foreach>
AND TIMEID BETWEEN #{startTime} AND #{endTime}
GROUP BY
LINE_INDEX
ORDER BY
integrality ASC
) T
) t1
LEFT JOIN PQ_LINE t2 ON t1.LINE_INDEX = t2.LINE_INDEX
LEFT JOIN PQ_DEVICE t3 ON t2.dev_index = t3.dev_index
LEFT JOIN PQ_GDINFORMATION t4 ON t2.GD_INDEX = t4.GD_INDEX
LEFT JOIN PQ_SUBSTATION t5 ON T2.SUB_INDEX = T5.SUB_INDEX
WHERE t1.row_num &lt; 20
</select>
<select id="selectIntegrityData" resultType="intergralityTable" >
SELECT
T6. NAME powerCompany,
T7. NAME substation,
T3. NAME device,
T3.IP deviceIp,
T3.UpdateTime updateTime,
T3.Status status,
T3.DevFlag devFlag,
T5.DIC_NAME company,
T8.DIC_NAME voltage,
T2.NAME lineName,
T1.integrity integrity
FROM
(
SELECT
T1.LINE_INDEX,
ROUND (
SUM (T1.REAL) / (
SUM (T1.DUE)
),
4
) * 100 integrity
FROM
PQS_Integrity T1
WHERE
T1.LINE_INDEX IN <foreach collection="list" item="item" open="(" close=")" separator=",">#{item}</foreach>
AND t1.TIMEID BETWEEN #{startTime} AND #{endTime}
GROUP BY
T1.LINE_INDEX
) T1,
PQ_LINE T2,
PQ_DEVICE T3,
PQ_DEVICEDETAIL T4,
PQS_DICDATA T5,
PQ_GDINFORMATION T6,
PQ_SUBSTATION T7,
PQS_DICDATA T8
WHERE
T1.LINE_INDEX = T2.LINE_INDEX
AND T2.DEV_INDEX = T3.DEV_INDEX
AND T3.DEV_INDEX =T4.DEV_INDEX
AND T4.MANUFACTURER=T5.DIC_INDEX
AND T2.GD_INDEX=T6.GD_INDEX
AND T2.SUB_INDEX=T7.SUB_INDEX
AND T2.SCALE=T8.DIC_INDEX
</select>
</mapper>

View File

@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.1//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.data.LineMapsMapper">
<select id="queryLineMaps" parameterType="String" resultType="LineMaps" >
select * from line_maps where line_index in
<foreach collection="lstGDsql" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="queryLineMapByAssID" parameterType="String" resultType="LineMaps" >
select a.*
from line_maps a,pqs_eventdetail b
where a.line_index=b.lineid and b.eventass_index=#{eventass_index}
</select>
<select id="queryLineMapsForAll" parameterType="String" resultType="LineMaps" >
SELECT
i."LINE_INDEX",
i."LINE_NAME",
i."PT1",
i."PT2",
i."CT1",
i."CT2",
i."GD_INDEX",
i."GD_NAME",
i."SUB_NAME",
i."SUBV_NAME",
i."DEVFLAG",
i."STATUS",
i."IP",
i."MANUFACTURER",
i."LONGITUDE",
i."LATITUDE",
NVL( h.totalcount, 0 ) totalcount
FROM
(
(
SELECT DISTINCT
MainTable.lineid,
NVL( SubTable.count, 0 ) totalcount
FROM
pqs_eventdetail MainTable
LEFT JOIN (
SELECT
count( * ) count,
lineid
FROM
pqs_eventdetail
where eventass_index is null
and timeid >= TRUNC( SYSDATE, 'YYYY' )
GROUP BY
lineid
ORDER BY
lineid
) SubTable ON MainTable.lineid = SubTable.lineid
) h
RIGHT JOIN (
SELECT
a.line_index line_index,
a.name line_name,
a.pt1 pt1,
a.pt2 pt2,
a.ct1 ct1,
a.ct2 ct2,
b.gd_index gd_index,
b.name gd_name,
c.name sub_name,
d.name subv_name,
e.devflag devflag,
e.status status,
e.ip ip,
h.dic_name manufacturer,
f.longitude longitude,
f.latitude latitude
FROM
pq_line a,
pq_gdinformation b,
pq_substation c,
pq_subvoltage d,
pq_device e,
pqs_map f,
pq_devicedetail g,
pqs_dicdata h
WHERE
a.gd_index = b.gd_index
AND a.sub_index = c.sub_index
AND a.subv_index = d.subv_index
AND a.dev_index = e.dev_index
AND a.sub_index = f.sub_index
AND e.dev_index = g.dev_index
AND f.state = 1
AND g.manufacturer = h.dic_index
AND h.dic_type = 'cbb2de8a-87da-4ae9-a35c-aaab999c7bc7' --只读取实际设备
AND e.devmodel = 1 --只读取属于暂降系统数据
AND e.datatype IN ( 0, 2 )
ORDER BY
a.line_index
) i ON h.lineid = i.line_index
) where LINE_INDEX in
<foreach collection="lstGDsql" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.data.SynDataMapper'>
<!-- 删除 -->
<update id="deleteByIndex">
delete from Pqs_syndata where myIndex = #{myIndex} and node = #{node}
</update>
<select id="getSynData" resultType="Float">
select synData from pqs_syndata where myIndex = #{myIndex} and node = #{node}
</select>
</mapper>

View File

@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.log.UserLogDetailMapper">
<!-- 日志 -->
<resultMap type="com.njcn.pojo.log.UserLogDetail" id="UserLogDetailMapperMap" autoMapping="true">
</resultMap>
<!-- 查询所有日志 -->
<select id="getUserLog" resultMap="UserLogDetailMapperMap" databaseId="Oracle">
select t.dictype_name as type,
a.dic_name as name,
u.USERLOG_DESCRIBE as describe,
u.updatetime as updatetime,
u.ip as ip,
decode(a.DIC_LEAVE, 0, '普通', 1, '中等',2,'严重') as leval
from pqs_userlog u ,
pqs_dicdata a ,
pqs_dictype t
where u.type=a.dic_index
and a.dic_type=t.dictype_index
order by u.updatetime desc
</select>
<select id="getUserLog" resultMap="UserLogDetailMapperMap" databaseId="MariaDB">
select t.dictype_name as type,
a.dic_name as name,
u.`describe` as `describe`,
u.updatetime as updatetime,
u.ip as ip,
(case a.leave when 0 then '普通' when 1 then '中等' else '严重' end) as leval
from pqs_userlog u ,
pqs_dicdata a ,
pqs_dictype t
where u.type=a.dic_index
and a.dic_type=t.dictype_index
order by u.updatetime desc
</select>
<!-- 根据条件查询所有日志 -->
<select id="getUserLogId" resultMap="UserLogDetailMapperMap" databaseId="Oracle">
select t.dictype_name as type,
a.dic_name as name,
u.USERLOG_DESCRIBE as describe,
u.updatetime as updatetime,
u.ip as ip,
decode(a.DIC_LEAVE, 0, '普通', 1, '中等',2,'严重') as leval
from pqs_userlog u ,
pqs_dicdata a ,
pqs_dictype t
where u.type=a.dic_index
and a.dic_type=t.dictype_index
and t.dictype_index like #{type}
and a.dic_index like #{name}
and u.updatetime between #{startTime}
and #{endTime}
order by u.updatetime desc
</select>
<select id="getUserLogId" resultMap="UserLogDetailMapperMap" databaseId="MariaDB">
select t.dictype_name as type,
a.dic_name as name,
u.`describe` as `describe`,
u.updatetime as updatetime,
u.ip as ip,
(case a.leave when 0 then '普通' when 0 then '中等' else '严重' end) as leval
from pqs_userlog u ,
pqs_dicdata a ,
pqs_dictype t
where u.type=a.dic_index
and a.dic_type=t.dictype_index
and t.dictype_index like #{type}
and a.dic_index like #{name}
and u.updatetime between #{startTime}
and #{endTime}
order by u.updatetime desc
</select>
<!-- 统计事件类型 -->
<select id="geteventtype" resultMap="UserLogDetailMapperMap" databaseId="Oracle">
select t.dictype_name as type,
count(1) as num
from pqs_userlog u ,
pqs_dicdata a ,
pqs_dictype t
where u.type=a.dic_index
and a.dic_type=t.dictype_index
and u.updatetime between #{startTime}
and #{endTime}
group by t.dictype_name
</select>
<select id="geteventtype" resultMap="UserLogDetailMapperMap" databaseId="MariaDB">
select t.dictype_name as type,
count(1) as num
from pqs_userlog u ,
pqs_dicdata a ,
pqs_dictype t
where u.type=a.dic_index
and a.dic_type=t.dictype_index
and u.updatetime between #{startTime}
and #{endTime}
group by t.dictype_name
</select>
<!-- 统计详细事件 -->
<select id="getdetailtype" resultMap="UserLogDetailMapperMap">
select a.dic_name as name,
count(1) as num
from pqs_userlog u ,
pqs_dicdata a ,
pqs_dictype t
where u.type=a.dic_index
and a.dic_type=t.dictype_index
and to_number(to_char(u.updatetime, 'yyyyMMddHHmmss')) between #{startTime}
and #{endTime}
group by a.dic_name
</select>
<!-- 统计用户统计 -->
<select id="getUserStatistics" resultMap="UserLogDetailMapperMap" databaseId="Oracle">
select b.loginname name,
count(1) num
from pqs_userlog a,
pqs_user b
where A.USERLOG_DESCRIBE like '%'||b.loginname||'%'
and a.user_index=b.user_index
and to_number(to_char(a.updatetime, 'yyyyMMddHHmmss')) between #{startTime}
and #{endTime}
group by b.loginname
</select>
<select id="getUserStatistics" resultMap="UserLogDetailMapperMap" databaseId="MariaDB">
select b.loginname name,
count(1) num
from pqs_userlog a,
pqs_user b
where a.`describe` like '%'||b.loginname||'%'
and a.user_index=b.user_index
and to_number(to_char(a.updatetime, 'yyyyMMddHHmmss')) between #{startTime}
and #{endTime}
group by b.loginname
</select>
<delete id="delExpireLog" databaseId="Oracle">
delete from pqs_userlog
where rowid = (select rowid
from (select UPDATETIME from pqs_userlog where UPDATETIME &lt; #{endTime} order by UPDATETIME)
where rownum = 1)
</delete>
<delete id="delExpireLog" databaseId="MariaDB">
delete from pqs_userlog
where UPDATETIME = (select UPDATETIME from pqs_userlog where UPDATETIME &lt; #{endTime} order by UPDATETIME LIMIT 1 )
</delete>
</mapper>

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.log.UserLoginMapper">
<!-- 日志 -->
<resultMap type="com.njcn.pojo.log.UserLogin" id="UserLoginMapperMap" autoMapping="true">
</resultMap>
<!-- 查询所有登录信息 -->
<select id="getUserLogin" resultMap="UserLoginMapperMap">
SELECT
*
FROM
pqs_userlogin ul,
pqs_user U
WHERE
ul.user_index = U .user_index
AND TO_NUMBER (
TO_CHAR (
ul.loginTime,
'yyyyMMddHHmiss'
)
) BETWEEN # { startTime }
AND # { endTime }
ORDER BY
ul.loginTime DESC
</select>
<select id="getLastedLogin" resultType="userLogin">
SELECT
*
FROM
(
SELECT
*
FROM
PQS_USERLOGIN
WHERE
USER_INDEX=#{userIndex}
ORDER BY
LOGINTIME DESC
)
WHERE
ROWNUM = 1
</select>
</mapper>

View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.point.PointBaseInfoMapper">
<select id="getLineLedger" resultType="com.njcn.pojo.pointInfo.LineLedger">
SELECT
j.dic_name province,
a.line_index lineIndex,
mod(a.line_index,10) as lineNum,
a.name lineName,
a.status lineStatus,
b.pttype ptType,
b.MONITOR_ID monitorId,
a.devcmp devCmp,
a.dlcmp dlCmp,
a.xycmp xyCmp,
b.objname objName,
nvl(b.POWER_SUBSTATION_NAME,e.name) as powerSubstationName,
g.dic_name scale,
h.dic_name loadType,
d.name devName,
d.status,
e.name subName,
f.name gdName,
c.freq_dev freqDev,
c.voltage_dev voltageDev,
c.uvoltage_dev uVoltageDev,
c.ubalance uBalance,
c.flicker,
c.uaberrance aberrance,
c.i_neg iNeg,
c.iharm_2 iharm2,
c.iharm_3 iharm3,
c.iharm_4 iharm4,
c.iharm_5 iharm5,
c.iharm_6 iharm6,
c.iharm_7 iharm7,
c.iharm_8 iharm8,
c.iharm_9 iharm9,
c.iharm_10 iharm10,
c.iharm_11 iharm11,
c.iharm_12 iharm12,
c.iharm_13 iharm13,
c.iharm_14 iharm14,
c.iharm_15 iharm15,
c.iharm_16 iharm16,
c.iharm_17 iharm17,
c.iharm_18 iharm18,
c.iharm_19 iharm19,
c.iharm_20 iharm20,
c.iharm_21 iharm21,
c.iharm_22 iharm22,
c.iharm_23 iharm23,
c.iharm_24 iharm24,
c.iharm_25 iharm25,
c.uharm_2 uharm2,
c.uharm_3 uharm3,
c.inuharm_3 inuharmAll,
c.inuharm_2 inuharm2,
k.NODE_NAME nodeName
FROM
pq_line a
LEFT JOIN pq_linedetail b ON a.line_index = b.line_index
LEFT JOIN overlimit c ON a.line_index = myindex
LEFT JOIN pq_device d ON a.dev_index = d.dev_index
LEFT JOIN pq_substation e ON a.sub_index = e.sub_index
LEFT JOIN pq_gdinformation f ON a.gd_index = f.gd_index
LEFT JOIN pqs_dicdata g ON a.scale = g.dic_index
LEFT JOIN pqs_dicdata h ON b.loadtype = h.dic_index
LEFT JOIN pq_province i ON f.province_index = i.province_index
LEFT JOIN pqs_dicdata j ON i.name = j.dic_index
LEFT JOIN NODEINFORMATION k ON d.NODE_INDEX = k.NODE_INDEX
where a.line_index in
<foreach collection="lineList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
<if test="loadTypeList!=null">
and h.dic_index in
<foreach collection="loadTypeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="scaleList!=null">
and g.dic_index in
<foreach collection="scaleList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="status!=null">
and d.status = #{status}
</if>
<choose>
<when test="type == 0"> and b.MONITOR_ID is not null and b.MONITOR_ID != ' '</when>
<when test="type == 1"> and (b.MONITOR_ID IS NULL or b.MONITOR_ID IN (' '))</when>
</choose>
</select>
<select id="getDeptsLineIndex" resultType="java.lang.Integer"
databaseId="Oracle">
select distinct (a.line_index)
from pqs_deptsline a,
pq_device b, pq_line c
where a.depts_index in
(select depts_index
from
pqs_depts
start with parentnodeid = #{deptsIndex}
connect by prior
depts_index = parentnodeid)
and a.systype = #{sysIndex}
and c.line_index = a.line_index
and c.dev_index = b.dev_index
and b.devmodel = 1
</select>
</mapper>

View File

@@ -0,0 +1,193 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.user.DeptsLineMapper'>
<resultMap type="com.njcn.pojo.user.DeptsLine" id="DeptsLineMapperMap" autoMapping="true">
<id property="deptsIndex" column="DEPTS_INDEX"/>
</resultMap>
<select id="getBind" resultMap="DeptsLineMapperMap">
select * from pqs_deptsLine where depts_index = #{deptsIndex}
</select>
<update id="changeBindLine">
update PQS_DEPTSLINE set depts_index = #{deptsIndex} where line_index = #{index} and systype=#{sysType}
</update>
<select id="selectIndexsByDept" resultType="IndexsCount">
SELECT
t2.LINE_INDEX lineIndex,
t2.SUB_INDEX subIndex,
t2.DEV_INDEX devIndex,
t2.GD_INDEX gdIndex
FROM
PQS_DEPTSLINE t1,
PQ_LINE t2,
PQ_DEVICE t3
WHERE
t1.LINE_INDEX = t2.LINE_INDEX
AND t2.DEV_INDEX = t3.DEV_INDEX
AND t1.DEPTS_INDEX = #{deptsIndex}
<if test="sysType != null">
AND t1.systype=#{sysType}
</if>
AND t3.DEVMODEL = #{devModel}
AND t3.DATATYPE in
<foreach collection="dataType" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectIndexsByDepts" resultType="IndexsCount">
SELECT
t2.LINE_INDEX lineIndex,
t2.SUB_INDEX subIndex,
t2.DEV_INDEX devIndex,
t2.GD_INDEX gdIndex
FROM
PQS_DEPTSLINE t1,
PQ_LINE t2,
PQ_DEVICE t3
WHERE
t1.LINE_INDEX = t2.LINE_INDEX
AND t2.DEV_INDEX = t3.DEV_INDEX
AND t1.DEPTS_INDEX in
<foreach collection="depts" item="item" open="(" separator="," close=")">
#{item.deptsIndex}
</foreach>
AND t1.systype=#{sysType}
AND t3.DEVMODEL = #{devModel}
AND t3.DATATYPE in
<foreach collection="dataType" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectIndexsByDeptsRun" resultType="IndexsCount">
SELECT
t2.LINE_INDEX lineIndex,
t2.SUB_INDEX subIndex,
t2.DEV_INDEX devIndex,
t2.GD_INDEX gdIndex
FROM
PQS_DEPTSLINE t1,
PQ_LINE t2,
PQ_DEVICE t3
WHERE
t1.LINE_INDEX = t2.LINE_INDEX
AND t2.DEV_INDEX = t3.DEV_INDEX
AND t1.DEPTS_INDEX in
<foreach collection="depts" item="item" open="(" separator="," close=")">
#{item.deptsIndex}
</foreach>
AND t1.systype=#{sysType}
AND t3.DEVMODEL = #{devModel}
<if test="devStatus!=null">
AND t3.DevFlag=#{devStatus}
</if>
<if test="status!=null">
AND t3.status = #{status}
</if>
AND t3.DATATYPE in
<foreach collection="dataType" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectIndexsByDeptRun" resultType="IndexsCount">
SELECT
t2.LINE_INDEX lineIndex,
t2.SUB_INDEX subIndex,
t2.DEV_INDEX devIndex,
t2.GD_INDEX gdIndex
FROM
PQS_DEPTSLINE t1,
PQ_LINE t2,
PQ_DEVICE t3
WHERE
t1.LINE_INDEX = t2.LINE_INDEX
AND t2.DEV_INDEX = t3.DEV_INDEX
AND t1.DEPTS_INDEX = #{deptsIndex}
<if test="sysType != null">
AND t1.systype=#{sysType}
</if>
AND t3.DEVMODEL = #{devModel}
AND t3.DevFlag=#{devStatus}
<if test="status!=null">
AND t3.status = #{status}
</if>
AND t3.DATATYPE in
<foreach collection="dataType" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectIndexsByDeptsRunForStatFlag" resultType="IndexsCount">
SELECT
t2.LINE_INDEX lineIndex,
t2.SUB_INDEX subIndex,
t2.DEV_INDEX devIndex,
t2.GD_INDEX gdIndex
FROM
PQS_DEPTSLINE t1,
PQ_LINE t2,
PQ_DEVICE t3,
PQ_LINEDETAIL t4
WHERE
t1.LINE_INDEX = t2.LINE_INDEX
AND t2.DEV_INDEX = t3.DEV_INDEX
AND t2.LINE_INDEX = t4.LINE_INDEX
AND t1.DEPTS_INDEX in
<foreach collection="depts" item="item" open="(" separator="," close=")">
#{item.deptsIndex}
</foreach>
AND t1.systype=#{sysType}
AND t3.DEVMODEL = #{devModel}
<if test="devStatus!=null">
AND t3.DevFlag=#{devStatus}
</if>
<if test="status!=null">
AND t3.status = #{status}
</if>
AND t4.statflag = 1
AND t3.DATATYPE in
<foreach collection="dataType" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectIndexsByDeptRunForStatFlag" resultType="IndexsCount">
SELECT
t2.LINE_INDEX lineIndex,
t2.SUB_INDEX subIndex,
t2.DEV_INDEX devIndex,
t2.GD_INDEX gdIndex
FROM
PQS_DEPTSLINE t1,
PQ_LINE t2,
PQ_DEVICE t3,
PQ_LINEDETAIL t4
WHERE
t1.LINE_INDEX = t2.LINE_INDEX
AND t2.DEV_INDEX = t3.DEV_INDEX
AND t2.LINE_INDEX = t4.LINE_INDEX
AND t1.DEPTS_INDEX = #{deptsIndex}
<if test="sysType != null">
AND t1.systype=#{sysType}
</if>
AND t3.DEVMODEL = #{devModel}
AND t3.DevFlag=#{devStatus}
<if test="status!=null">
AND t3.status = #{status}
</if>
AND t4.statflag = 1
AND t3.DATATYPE in
<foreach collection="dataType" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,547 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper
PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='com.njcn.mapper.user.DeptsLineTreeMapper'>
<resultMap type="DeptslineTree" id="proResultMap" autoMapping="true">
<id column="province_index" property="nodeIndex"/>
</resultMap>
<resultMap type="DeptslineTree" id="proJResultMap" autoMapping="true">
<id column="project_index" property="nodeIndex"/>
</resultMap>
<resultMap type="DeptslineTree" id="proVResultMap" autoMapping="true">
<id column="province_index" property="nodeIndex"/>
<id column="project_index" property="pId"/>
</resultMap>
<resultMap type="DeptslineTree" id="offgdResultMap" autoMapping="true">
<id column="gd_index" property="nodeIndex"/>
<result column="province_index" property="pId"/>
</resultMap>
<resultMap type="DeptslineTree" id="offsubResultMap" autoMapping="true">
<id column="Sub_index" property="nodeIndex"/>
<result column="gd_index" property="pId"/>
</resultMap>
<resultMap type="DeptslineTree" id="offlineResultMap" autoMapping="true">
<id column="line_index" property="nodeIndex"/>
<result column="sub_index" property="pId"/>
</resultMap>
<select id='getGdInfo' resultMap='offgdResultMap'>
select
gd_index,name
from pq_gdinformation
where
gd_index in
<foreach collection="list" index="index" item="item" open="("
separator="," close=") order by gd_index">
#{item}
</foreach>
</select>
<resultMap type="DeptslineTree" id="gdByProMap" autoMapping="true">
<id column="Gd_index" property="nodeIndex"/>
<result column="province_index" property="pId"/>
</resultMap>
<resultMap type="DeptslineTree" id="subResultMap" autoMapping="true">
<id column="Sub_index" property="nodeIndex"/>
<result column="gd_index" property="pId"/>
</resultMap>
<resultMap type="DeptslineTree" id="transResultMap" autoMapping="true">
<id column="TFLGASS_INDEX" property="nodeTf"/>
<result column="Sub_index" property="pId"/>
</resultMap>
<resultMap type="DeptslineTree" id="devResultMap" autoMapping="true">
<id column="Dev_index" property="nodeIndex"/>
<result column="sub_index" property="pId"/>
</resultMap>
<resultMap type="DeptslineTree" id="devicetMap" autoMapping="true">
<id column="Dev_index" property="nodeIndex"/>
<result column="sub_index" property="pId"/>
</resultMap>
<resultMap type="DeptslineTree" id="subvResultMap" autoMapping="true">
<id column="subv_index" property="nodeIndex"/>
<result column="Dev_index" property="pId"/>
</resultMap>
<resultMap type="DeptslineTree" id="subvMap" autoMapping="true">
<id column="subv_index" property="nodeIndex"/>
<result column="Dev_index" property="pId"/>
</resultMap>
<resultMap type="DeptslineTree" id="lineResultMap" autoMapping="true">
<id column="line_index" property="nodeIndex"/>
<result column="subv_index" property="pId"/>
</resultMap>
<!--未绑定的(自定义)-->
<select id='getTreeGdInfo' resultMap='gdByProMap'>
select
gd_index,name,province_index
from pq_gdinformation
where
gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index not in(select line_index from pqs_deptsLine where depts_index=#{deptsIndex}and
systype=#{sysType})
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=") order by gd_index">
#{item}
</foreach>
</select>
<select id='getOffTreeProVInfo' resultMap='proVResultMap'>
select
pq.province_index province_index,dic.DIC_NAME name,pq.project_index project_index
from pq_province pq,PQS_DICDATA dic
where
pq.province_index in
(select province_index from pq_gdinformation where gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index not in(select line_index from pqs_deptsLine where depts_index=#{deptsIndex}and
systype=#{sysType})
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close="))">
#{item}
</foreach>
and dic.DIC_INDEX = pq.name
order by province_index
</select>
<select id='getOffTreeSubInfo' resultMap='offsubResultMap'>
select b.province_index, a.name, a.sub_index,c.gd_index
from pq_substation a, pq_province b, pq_gdinformation c
where a.gd_index = c.gd_index
and c.province_index = b.province_index
and a.sub_index in
(select sub_index
from pq_line
where dev_index in (select dev_index
from pq_device
where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index not in(select line_index from pqs_deptsLine where depts_index=#{deptsIndex}and
systype=#{sysType})
)
and c.gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=") order by sub_index">
#{item}
</foreach>
</select>
<select id='getOffTreeLineInfo' resultMap='offlineResultMap'>
select
a.sub_index, a.name,a.line_index,b.devflag as state,b.status
from pq_line a,pq_device b,pq_substation c
where
a.sub_index = c.sub_index
and a.dev_index = b.dev_index
and b.datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
and a.gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and a.line_index not in(select line_index from pqs_deptsLine where depts_index=#{deptsIndex} and
systype=#{sysType})
order by a.line_index
</select>
<!--自己本身绑定的(自定义、非自定义)-->
<select id='getTreeGdInfomyself' resultMap='gdByProMap'>
select
gd_index,name,province_index
from pq_gdinformation
where
gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index in(select line_index from pqs_deptsLine where depts_index=#{deptsIndex}and
systype=#{sysType})
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=") order by gd_index">
#{item}
</foreach>
</select>
<!--省级-->
<select id='getOffTreeProVInfomyself' resultMap='proVResultMap'>
select
pq.province_index province_index,dic.DIC_NAME name,pq.project_index project_index
from pq_province pq,PQS_DICDATA dic
where
pq.province_index in
(select province_index from pq_gdinformation where gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index in(select line_index from pqs_deptsLine where depts_index=#{deptsIndex}and
systype=#{sysType})
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close="))">
#{item}
</foreach>
and dic.DIC_INDEX = pq.name
order by province_index
</select>
<!--其他-->
<select id='getOffTreeProVInfosmyself' resultMap='proVResultMap'>
select
pq.province_index province_index,dic.DIC_NAME name,pq.project_index project_index
from pq_province pq,PQS_DICDATA dic
where
pq.province_index in
(select province_index from pq_gdinformation where pq.name = #{area} and gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index in(select line_index from pqs_deptsLine where depts_index=#{deptsIndex}and
systype=#{sysType})
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close="))">
#{item}
</foreach>
and dic.DIC_INDEX = pq.name
order by province_index
</select>
<select id='getOffTreeSubInfomyself' resultMap='offsubResultMap'>
select b.province_index, a.name, a.sub_index,c.gd_index
from pq_substation a, pq_province b, pq_gdinformation c
where a.gd_index = c.gd_index
and c.province_index = b.province_index
and a.sub_index in
(select sub_index
from pq_line
where dev_index in (select dev_index
from pq_device
where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index in(select line_index from pqs_deptsLine where depts_index=#{deptsIndex}and
systype=#{sysType})
)
and c.gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=") order by sub_index">
#{item}
</foreach>
</select>
<select id='getOffTreeLineInfomyself' resultMap='offlineResultMap'>
select
a.sub_index, a.name,a.line_index,b.devflag as state,b.status
from pq_line a,pq_device b,pq_substation c
where
a.sub_index = c.sub_index
and a.dev_index = b.dev_index
and b.datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
and a.gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and a.line_index in(select line_index from pqs_deptsLine where depts_index=#{deptsIndex} and
systype=#{sysType})
order by a.line_index
</select>
<!--非自定义未绑定的-->
<select id='getTreeGdInfono' resultMap='gdByProMap'>
select
gd_index,name,province_index
from pq_gdinformation
where
gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index not in(select line_index from pqs_deptsLine where SYSTYPE = #{sysType} and DEPTS_INDEX not in(select DEPTS_INDEX from pqs_depts where CUSTOM_DEPT in(1,2)))
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=") order by gd_index">
#{item}
</foreach>
</select>
<select id='getOffTreeProVInfono' resultMap='proVResultMap'>
select
pq.province_index province_index,dic.DIC_NAME name,pq.project_index project_index
from pq_province pq,PQS_DICDATA dic
where
pq.province_index in
(select province_index from pq_gdinformation where gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index not in(select line_index from pqs_deptsLine where SYSTYPE = #{sysType} and DEPTS_INDEX not in(select DEPTS_INDEX from pqs_depts where CUSTOM_DEPT in(1,2))))
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close="))">
#{item}
</foreach>
and dic.DIC_INDEX = pq.name
order by province_index
</select>
<select id='getOffTreeProVInfonoarea' resultMap='proVResultMap'>
select
pq.province_index province_index,dic.DIC_NAME name,pq.project_index project_index
from pq_province pq,PQS_DICDATA dic
where
pq.province_index in
(select province_index from pq_gdinformation where pq.name = #{area} and gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index not in(select line_index from pqs_deptsLine where SYSTYPE = #{sysType} and DEPTS_INDEX not in(select DEPTS_INDEX from pqs_depts where CUSTOM_DEPT in(1,2))))
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close="))">
#{item}
</foreach>
and dic.DIC_INDEX = pq.name
order by province_index
</select>
<select id='getOffTreeSubInfono' resultMap='offsubResultMap'>
select b.province_index, a.name, a.sub_index,c.gd_index
from pq_substation a, pq_province b, pq_gdinformation c
where a.gd_index = c.gd_index
and c.province_index = b.province_index
and a.sub_index in
(select sub_index
from pq_line
where dev_index in (select dev_index
from pq_device
where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index not in(select line_index from pqs_deptsLine where SYSTYPE = #{sysType} and DEPTS_INDEX not in(select DEPTS_INDEX from pqs_depts where CUSTOM_DEPT in(1,2)))
)
and c.gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=") order by sub_index">
#{item}
</foreach>
</select>
<select id='getOffTreeLineInfono' resultMap='offlineResultMap'>
select
a.sub_index, a.name,a.line_index,b.devflag as state,b.status
from pq_line a,pq_device b,pq_substation c
where
a.sub_index = c.sub_index
and a.dev_index = b.dev_index
and b.datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
and a.gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and a.line_index not in(select line_index from pqs_deptsLine where SYSTYPE = #{sysType} and DEPTS_INDEX not in(select DEPTS_INDEX from pqs_depts where CUSTOM_DEPT in(1,2)))
order by a.line_index
</select>
<!--非自定义其他已绑定的-->
<select id='getTreeGdInfoother' resultMap='gdByProMap'>
select
gd_index,name,province_index
from pq_gdinformation
where
gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index in(select line_index from pqs_deptsLine where DEPTS_INDEX !=#{deptsIndex} and DEPTS_INDEX not in(select DEPTS_INDEX from pqs_depts where CUSTOM_DEPT in(1,2)) and SYSTYPE =#{sysType})
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=") order by gd_index">
#{item}
</foreach>
</select>
<select id='getOffTreeProVInfoother' resultMap='proVResultMap'>
select
pq.province_index province_index,dic.DIC_NAME name,pq.project_index project_index
from pq_province pq,PQS_DICDATA dic
where
pq.province_index in
(select province_index from pq_gdinformation where gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index in(select line_index from pqs_deptsLine where DEPTS_INDEX !=#{deptsIndex} and DEPTS_INDEX not in(select DEPTS_INDEX from pqs_depts where CUSTOM_DEPT in(1,2)) and SYSTYPE =#{sysType})
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close="))">
#{item}
</foreach>
and dic.DIC_INDEX = pq.name
order by province_index
</select>
<select id='getOffTreeProVInfootherarea' resultMap='proVResultMap'>
select
pq.province_index province_index,dic.DIC_NAME name,pq.project_index project_index
from pq_province pq,PQS_DICDATA dic
where
pq.province_index in
(select province_index from pq_gdinformation where pq.name = #{area} and gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index in(select line_index from pqs_deptsLine where DEPTS_INDEX !=#{deptsIndex} and DEPTS_INDEX not in(select DEPTS_INDEX from pqs_depts where CUSTOM_DEPT IN(1,2)) and SYSTYPE =#{sysType})
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close="))">
#{item}
</foreach>
and dic.DIC_INDEX = pq.name
order by province_index
</select>
<select id='getOffTreeSubInfoother' resultMap='offsubResultMap'>
select b.province_index, a.name, a.sub_index,c.gd_index
from pq_substation a, pq_province b, pq_gdinformation c
where a.gd_index = c.gd_index
and c.province_index = b.province_index
and a.sub_index in
(select sub_index
from pq_line
where dev_index in (select dev_index
from pq_device
where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
and line_index in(select line_index from pqs_deptsLine where DEPTS_INDEX !=#{deptsIndex} and DEPTS_INDEX not in(select DEPTS_INDEX from pqs_depts where CUSTOM_DEPT IN(1,2)) and SYSTYPE =#{sysType})
)
and c.gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=") order by sub_index">
#{item}
</foreach>
</select>
<select id='getOffTreeLineInfoother' resultMap='offlineResultMap'>
select
a.sub_index, a.name,a.line_index,b.devflag as state,b.status
from pq_line a,pq_device b,pq_substation c
where
a.sub_index = c.sub_index
and a.dev_index = b.dev_index
and b.datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
and a.gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and a.line_index in(select line_index from pqs_deptsLine where DEPTS_INDEX !=#{deptsIndex} and DEPTS_INDEX not in(select DEPTS_INDEX from pqs_depts where CUSTOM_DEPT IN(1,2)) and SYSTYPE =#{sysType})
order by a.line_index
</select>
<select id='getOffTreeProVInfos' resultMap='proVResultMap'>
select
pq.province_index province_index,dic.DIC_NAME name,pq.project_index project_index
from pq_province pq,PQS_DICDATA dic
where
pq.province_index in
(select province_index from pq_gdinformation where pq.name = #{area} and gd_index in
(select gd_index
from pq_line
where dev_index in
(select dev_index from pq_device where datatype in
<foreach collection="dataType" item="index" open="(" separator="," close=")">
#{index}
</foreach>
)
)
and gd_index in
<foreach collection="gdindex" item="item" open="(" separator="," close="))">
#{item}
</foreach>
and dic.DIC_INDEX = pq.name
order by province_index
</select>
</mapper>

View File

@@ -0,0 +1,258 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.user.DeptsMapper">
<!-- 部门 -->
<resultMap type="Depts" id="DeptsMapperMap" autoMapping="true">
</resultMap>
<!-- 修改 -->
<update id="updateDepts">
update pqs_depts
set DEPTSNAME=#{deptsName},
PARENTNODE=#{parentNode},UPDATETIME=#{updateTime},
DEPTS_DESCRIPTION=#{deptsDescription},AREA=#{area} where DEPTS_INDEX=#{deptsIndex}
</update>
<!-- 根据父节点查询名称 -->
<select id="selectName" resultMap="DeptsMapperMap">
select * from pqs_depts
where node in
(
select parentnode from pqs_depts
where parentnode=#{parentNode}
)
and systype=#{sysType}
and state=1
</select>
<!-- 查询 -->
<select id="selectDeptAll" resultMap="DeptsMapperMap">
select*from pqs_depts where SYSTYPE=#{sysType} and state=1 order by node
</select>
<select id="queryDeptsByLikeAreaName" resultType="Depts">
select * from PQS_DEPTS where AREA like #{area} AND SYSTYPE=#{sysType} and state=1
</select>
<!-- 除去本身的名称 -->
<select id="selparentnode" resultMap="DeptsMapperMap">
select * from PQS_DEPTS where parentnode in (select parentnode from PQS_DEPTS where DEPTS_INDEX=#{deptsIndex} and state=1) and systype=#{sysType}
</select>
<!-- 查询除此之外的名称 -->
<select id="selName" resultMap="DeptsMapperMap">
select * from PQS_DEPTS where node not in (select parentnode from PQS_DEPTS where DEPTS_INDEX=#{deptsIndex} and state=1) and systype=#{sysType}
</select>
<select id="getId" resultMap="DeptsMapperMap">
select * from pqs_depts where node=#{node} and systype=#{sysType} and state=1
</select>
<!-- 根据deptsIndex查询所有 -->
<select id="selectByIndex" resultMap="DeptsMapperMap">
select * from PQS_DEPTS where depts_index not in (select depts_index from PQS_DEPTS where DEPTS_INDEX=#{deptsIndex} and state=1) and systype=#{sysType}
</select>
<select id="getAreaName" resultType="String">
select
t2.DIC_NAME
from PQS_DEPTS t1,PQS_DICDATA t2
where
t1.AREA=t2.DIC_INDEX
and
t1.SYSTYPE=#{sysType}
and
t1.state=1
order by T1.NODE asc
</select>
<select id="selectDeptsByDeptsIndex" resultType="Depts">
SELECT
t2.DIC_NAME area,
t2.DIC_NAME areaName,
t1.*
FROM
PQS_DEPTS t1,
PQS_DICDATA t2
WHERE
t1.AREA=t2.DIC_INDEX
AND
t1.DEPTS_INDEX=#{deptsIndex}
AND
t1.STATE=1
</select>
<select id="getDirectDeptsByNode" resultType="Depts">
SELECT
t1.DEPTS_INDEX,
t1.DEPTSNAME,
t1.DEPTS_DESC,
t2.DIC_NAME area,
t1.CUSTOM_DEPT
FROM
PQS_DEPTS t1
LEFT JOIN PQS_DICDATA t2 ON t1.area = t2.dic_index
WHERE
t1.PARENTNODEID = #{node}
AND t1.STATE =1
AND
t1.CUSTOM_DEPT <![CDATA[ <> ]]> 2
ORDER BY t1.DEPTS_DESC ASC
</select>
<select id="getNoDirectDeptsByNode" resultType="Depts">
SELECT
t1.DEPTS_INDEX,
t1.DEPTSNAME,
t1.DEPTS_DESC,
t2.DIC_NAME area,
t1.CUSTOM_DEPT
FROM
PQS_DEPTS t1
LEFT JOIN PQS_DICDATA t2 ON t1.area = t2.dic_index
WHERE
t1.PARENTNODEID = #{node}
AND t1.STATE =1
AND
t1.CUSTOM_DEPT = 0
ORDER BY t1.DEPTS_DESC ASC
</select>
<select id="getDeptsByNode" resultType="Depts" databaseId="Oracle">
SELECT
t1.DEPTS_INDEX,
t1.PARENTNODEID,
t1.DEPTSNAME,
t1.DEPTS_DESC,
t2.DIC_NAME area,
t1.CUSTOM_DEPT
FROM
PQS_DEPTS t1,
PQS_DICDATA t2
WHERE
t1.area = t2.dic_index
AND t1.STATE = 1
AND
t1.CUSTOM_DEPT <![CDATA[ <> ]]> 2
START WITH t1.PARENTNODEID = #{node} CONNECT BY PRIOR t1.DEPTS_INDEX = t1.PARENTNODEID
ORDER BY
t1.PARENTNODEID,
t1.DEPTS_DESC ASC
</select>
<select id="getDeptsByNode" resultType="Depts" databaseId="MariaDB">
WITH recursive t3 AS (
SELECT
a.DEPTS_INDEX,
a.PARENTNODEID,
a.DEPTSNAME,
a.DEPTS_DESC,
a.DIC_NAME,
a.CUSTOM_DEPT
FROM
(
SELECT
t1.DEPTS_INDEX,
t1.PARENTNODEID,
t1.DEPTSNAME,
t1.DEPTS_DESC,
t2.DIC_NAME,
t1.CUSTOM_DEPT
FROM
PQS_DEPTS t1,
PQS_DICDATA t2
WHERE
t1.STATE = 1
AND
t1.CUSTOM_DEPT <![CDATA[ <> ]]> 2
AND t1.area = t2.dic_index
AND t1.PARENTNODEID = #{node}
) a UNION ALL
SELECT
b.DEPTS_INDEX,
b.PARENTNODEID,
b.DEPTSNAME,
b.DEPTS_DESC,
b.DIC_NAME,
b.CUSTOM_DEPT
FROM
(
SELECT
t1.DEPTS_INDEX,
t1.PARENTNODEID,
t1.DEPTSNAME,
t1.DEPTS_DESC,
t2.DIC_NAME,
t1.CUSTOM_DEPT
FROM
PQS_DEPTS t1,
PQS_DICDATA t2
WHERE
t1.STATE = 1
AND
t1.CUSTOM_DEPT <![CDATA[ <> ]]> 2
AND t1.area = t2.dic_index
) b,
t3
WHERE
t3.DEPTS_INDEX = b.PARENTNODEID
) SELECT
*
FROM
t3 order by t3.depts_index
</select>
<select id="getDeptsByNodeUp" resultType="Depts" databaseId="Oracle">
SELECT DISTINCT
t1.DEPTS_INDEX,
t1.PARENTNODEID,
t1.DEPTSNAME,
t1.DEPTS_DESC,
t2.DIC_NAME area,
t1.CUSTOM_DEPT
FROM
PQS_DEPTS t1,
PQS_DICDATA t2
WHERE
t1.STATE = 1
AND
t1.CUSTOM_DEPT <![CDATA[ <> ]]> 2
AND t1.area = t2.dic_index START WITH t1.DEPTS_INDEX = #{deptsIndex} CONNECT BY PRIOR t1.PARENTNODEID = t1.DEPTS_INDEX
ORDER BY
t1.PARENTNODEID,
t1.DEPTS_DESC ASC
</select>
<select id="getDeptsByNodeUp" resultType="Depts" databaseId="MariaDB">
with recursive t3 as
(
select
a.DEPTS_INDEX,
a.PARENTNODEID,
a.DEPTSNAME,
a.DEPTS_DESC,
a.DIC_NAME,
a.CUSTOM_DEPT from
(SELECT
t1.DEPTS_INDEX,
t1.PARENTNODEID,
t1.DEPTSNAME,
t1.DEPTS_DESC,
t2.DIC_NAME,
t1.CUSTOM_DEPT
FROM PQS_DEPTS t1,PQS_DICDATA t2
where t1.STATE = 1 AND t1.CUSTOM_DEPT <![CDATA[ <> ]]> 2 and t1.area = t2.dic_index and t1.DEPTS_INDEX = #{deptsIndex}) a
union all
select
b.DEPTS_INDEX,
b.PARENTNODEID,
b.DEPTSNAME,
b.DEPTS_DESC,
b.DIC_NAME,
b.CUSTOM_DEPT from
(SELECT
t1.DEPTS_INDEX,
t1.PARENTNODEID,
t1.DEPTSNAME,
t1.DEPTS_DESC,
t2.DIC_NAME,
t1.CUSTOM_DEPT
FROM PQS_DEPTS t1,PQS_DICDATA t2
where t1.STATE = 1 AND t1.CUSTOM_DEPT <![CDATA[ <> ]]> 2 and t1.area = t2.dic_index ) b,t3 where b.DEPTS_INDEX = t3.PARENTNODEID
)select * from t3
</select>
</mapper>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.user.ManageListMapper">
<resultMap type="com.njcn.pojo.user.ManageList" id="ManageListMap" autoMapping="true">
<id property="res_Index" column="RES_INDEX"/>
</resultMap>
<!-- 根据guid查询 -->
<select id="selectOneByIndex" resultMap="ManageListMap">
SELECT RES_INDEX,NAME,DESCRIPTION,RES_URL,UPDATEUSER,UPDATETIME,STATE,SYSTYPE FROM PQS_ResInformation WHERE RES_INDEX =#{res_Index} and state=1
</select>
<update id="deleteIndex">
update PQS_ResInformation set state=0 where RES_INDEX =#{res_Index}
</update>
<select id="getBasemang" resultMap="ManageListMap">
select * from PQS_RESINFORMATION where STATE=1 and type ='93290044-2c03-4587-8319-4f604af7a80f' and
SYSTYPE=#{sysType}
</select>
<select id="getReport" resultMap="ManageListMap">
select * from PQS_RESINFORMATION where STATE=1 and type ='6da9882c-aba0-439e-8e04-dc6695bfc49c' and
SYSTYPE=#{sysType}
</select>
<select id="getSub" resultMap="ManageListMap">
select * from PQS_RESINFORMATION where STATE=1 and type ='3c81323b-9de6-43a1-b90a-d395aa76ed61' and
SYSTYPE=#{sysType}
</select>
</mapper>

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.user.RoleMapper">
<!-- 角色组 -->
<!-- 用户 -->
<!-- 角色 -->
<resultMap type="com.njcn.pojo.user.Role" id="RoleMapperMap" autoMapping="true">
<id property="roleIndex" column="ROLE_INDEX"/>
<association property="uID" autoMapping="true" javaType="User">
<id property="userIndex" column="USER_INDEX"/>
</association>
</resultMap>
<!-- 增加 -->
<insert id="insertRole">
insert into pqs_role (role_index,RoleName,user_index,updatetime,ROLE_DESCRIPTION,state) values(#{roleIndex},#{roleName},#{userIndex},#{updateTime},#{roleDescription},#{state})
</insert>
<!-- 删除 -->
<update id="deleteRole">
update PQS_Role set state=0 where role_Index=#{roleIndex,jdbcType=VARCHAR}
</update>
<!-- 修改 -->
<update id="updateRole">
update pqs_role set RoleName=#{roleName},user_index=#{userIndex},updatetime=#{updateTime},ROLE_DESCRIPTION=#{roleDescription},state=#{state} where role_Index=#{roleIndex,jdbcType=VARCHAR}
</update>
<!-- 根据id查询id -->
<select id="selectRoleIndex" resultMap="RoleMapperMap">
select *from pqs_role where role_Index=#{roleIndex,jdbcType=VARCHAR}
</select>
<!-- 根据id查询用户名 -->
<select id="selectUserId" resultMap="RoleMapperMap">
select *from pqs_role where user_index=#{userId}
</select>
<!-- 查询角色名 -->
<select id="selName" resultType="java.lang.Integer">
select COUNT(*) from pqs_role where rolename=#{roleName}
</select>
<!-- 根据角色名查询所有 -->
<select id="queryNameAll" resultMap="RoleMapperMap">
select *from pqs_role r join pqs_user u on r.user_Index=u.user_Index where rolename like #{roleName} ORDER BY updatetime desc
</select>
<!-- 查询 -->
<select id="selectAll" resultMap="RoleMapperMap">
select *from PQS_Role r join pqs_user u on r.user_Index=u.user_Index ORDER BY updatetime desc
</select>
<select id="getRoles" resultType="String">
SELECT
T2.ROLENAME
FROM
PQS_ROLEGPASS t1
LEFT JOIN PQS_ROLE t2 ON T1.ROLE_INDEX = T2.ROLE_INDEX
WHERE
T1.ROLEGP_INDEX = #{roleGPIndex}
</select>
<select id="selectAlls" resultMap="RoleMapperMap">
select *from PQS_ROLE where rolename not in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and state = 1
</select>
</mapper>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.mapper.user.SecretKeyMapper">
<resultMap type="com.njcn.pojo.user.SecretKey" id="SecretKeyMapperMap" autoMapping="true">
<id property="secretKeyIndex" column="SECRETKEY_INDEX"/>
<association property="uID" autoMapping="true" javaType="User">
<id property="userIndex" column="USER_INDEX"/>
</association>
</resultMap>
<select id="selectSecretkey" resultMap="SecretKeyMapperMap">
select *from PQS_SECRETKEY where USER_INDEX=#{userIndex,jdbcType=VARCHAR}
</select>
</mapper>

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