Commit 4a861be1 authored by wangqinghua's avatar wangqinghua

workService

parent d050f344
<!--资源告警统计-->
<p>
resource-alarm works!
</p>
<div nz-row class="breadcrumbs">
<div nz-col nzSpan="16">
<nz-breadcrumb class="padding-8-0">
<nz-breadcrumb-item>
首页
</nz-breadcrumb-item>
<nz-breadcrumb-item>
<a>统计分析</a>
</nz-breadcrumb-item>
<nz-breadcrumb-item>
告警统计
</nz-breadcrumb-item>
</nz-breadcrumb>
</div>
<div nz-col nzSpan="8" class="text-right">
<button (click)="search()" nz-button nzType="primary"><i class="anticon anticon-search"></i></button>
<button nz-button nzType="primary"><i class="anticon anticon-sync"></i></button>
<button nz-button nzType="primary"><i class="anticon anticon-arrows-alt"></i></button>
</div>
</div>
<div nz-row [nzGutter]="4" class="search-form">
<div nz-col nzSpan="3">
<nz-select style="width: 100%;" nzPlaceHolder="所有分组" [(ngModel)]="obj.groupid">
<ng-container *ngFor="let item of groupList">
<nz-option nzLabel="{{item.name}}" nzValue="{{item.groupid}}"></nz-option>
</ng-container>
</nz-select>
</div>
<div nz-col nzSpan="3">
<nz-select style="width: 100%;" nzPlaceHolder="所有告警" [(ngModel)]="obj.priority">
<nz-option nzLabel="告警" nzValue="告警"></nz-option>
<nz-option nzLabel="严重" nzValue="严重"></nz-option>
</nz-select>
</div>
<div nz-col nzSpan="7">
<nz-radio-group style="width: 100%;" [(ngModel)]="timeType" (ngModelChange)="changeType()" [nzButtonStyle]="'solid'">
<label nz-radio-button nzValue="1">今天</label>
<label nz-radio-button nzValue="2">昨天</label>
<label nz-radio-button nzValue="3">三天</label>
<label nz-radio-button nzValue="4">一周</label>
<label nz-radio-button nzValue="5">自定义</label>
</nz-radio-group>
</div>
<div nz-col nzSpan="8" *ngIf="timeType == '5'">
<nz-date-picker
nzShowTime
[(ngModel)]="timeBegin"
nzPlaceHolder="开始时间"
></nz-date-picker>
<nz-date-picker
nzShowTime
nzFormat="yyyy-MM-dd HH:mm:ss"
[(ngModel)]="timeEnd"
nzPlaceHolder="结束时间"
></nz-date-picker>
</div>
</div>
<nz-spin [nzSpinning]="isLoading">
<div echarts [options]="chartOption" style="height: 400px;width: 100%"></div>
</nz-spin>
<h2>常见问题TOP10</h2>
<!--<nz-table #nzTable [nzData]="inList" [nzLoading]="inLoading" [nzFrontPagination]="false" [nzTotal]="inTotalNum"-->
<!--[nzPageIndex]="inPageNum" [nzPageSize]="inPageCount" (nzPageIndexChange)="inChnagePage($event)">-->
<!--<thead>-->
<!--<tr>-->
<!--<th nzWidth="20%">资源名称</th>-->
<!--<th>所在分组</th>-->
<!--<th>告警名称</th>-->
<!--<th>严重性</th>-->
<!--<th>时间段内发生次数</th>-->
<!--</tr>-->
<!--</thead>-->
<!--<tbody>-->
<!--<ng-container *ngFor="let item of inList">-->
<!--<tr (click)="getEcharts(item.itemid)">-->
<!--<td>{{item.itemName}}</td>-->
<!--<td>{{item.max | toUtil}}</td>-->
<!--<td>{{item.min | toUtil}}</td>-->
<!--<td>{{item.avg | toUtil}}</td>-->
<!--<td>{{item.avg | toUtil}}</td>-->
<!--</tr>-->
<!--</ng-container>-->
<!--</tbody>-->
<!--</nz-table>-->
<h2>统计报告</h2>
<!--<nz-table #nzTable [nzData]="outList" [nzLoading]="outLoading" [nzFrontPagination]="false" [nzTotal]="outTotalNum"-->
<!--[nzPageIndex]="outPageNum" [nzPageSize]="outPageCount" (nzPageIndexChange)="outChnagePage($event)">-->
<!--<thead>-->
<!--<tr>-->
<!--<th nzWidth="20%">时间</th>-->
<!--<th>异常总数</th>-->
<!--<th>告警次数</th>-->
<!--<th>严重告警次数</th>-->
<!--</tr>-->
<!--</thead>-->
<!--<tbody>-->
<!--<ng-container *ngFor="let data of outList">-->
<!--<tr class="cursor" (click)="getEcharts(data.itemid)">-->
<!--<td>{{data.itemName}}</td>-->
<!--<td>{{data.max | toUtil}}</td>-->
<!--<td>{{data.min | toUtil}}</td>-->
<!--<td>{{data.avg | toUtil}}</td>-->
<!--</tr>-->
<!--</ng-container>-->
<!--</tbody>-->
<!--</nz-table>-->
import { Component, OnInit } from '@angular/core';
import {AnalysisService} from '../analysis.service';
import {NzMessageService} from 'ng-zorro-antd';
import {DatePipe} from '@angular/common';
import {pageSize} from '../../app.constants';
import {OverAllService} from '../../overAll/overAll.service';
@Component({
selector: 'smart-resource-alarm',
......@@ -7,9 +12,155 @@ import { Component, OnInit } from '@angular/core';
})
export class ResourceAlarmComponent implements OnInit {
constructor() { }
timeType;
startTime;
endTime;
groupList;
obj = {
priority:"",
groupid:"",
startTime:"",
endTime:"",
};
pageCount = pageSize;
pageNum = 1;
inList = [];
outList = [];
constructor(private analysisSer:AnalysisService,private message:NzMessageService,
private datePipe:DatePipe,private overAllSer:OverAllService) { }
ngOnInit() {
this.getGroup();
}
getData(){
this.getAlarmTopEchart();
this.getAlarmTrend();
this.getCommonTop();
this.getAnalysis();
}
//获取分组
getGroup() {
this.overAllSer.getgroups({}).subscribe(
(res) => {
if (res.errCode == 10000) {
this.groupList = res.data;
}
}
);
}
//告警总数TOP10
getAlarmTopEchart(){
const data = {
groupid:this.obj.groupid,
startTime:this.obj.startTime,
endTime:this.obj.endTime,
priority:this.obj.priority,
};
this.analysisSer.waringCountTop(data).subscribe(
(res)=>{
}
)
}
//告警总数趋势
getAlarmTrend(){
const data = {
groupid:this.obj.groupid,
startTime:this.obj.startTime,
endTime:this.obj.endTime,
priority:this.obj.priority,
};
this.analysisSer.waringTrend(data).subscribe(
(res)=>{
}
)
}
//常发问题TOP10
getCommonTop(){
const data = {
groupid:this.obj.groupid,
startTime:this.obj.startTime,
endTime:this.obj.endTime,
priorityName:this.obj.priority,
};
this.analysisSer.commonProblemTop(data).subscribe(
(res)=>{
}
)
}
//统计报告
getAnalysis(){
const data = {
pageCount:this.pageCount,
pageNum:this.pageNum,
obj:{
startTime:this.obj.startTime,
endTime:this.obj.endTime,
priorityName:this.obj.priority,
}
};
this.analysisSer.statisticalReport(data).subscribe(
(res)=>{
}
)
}
//时间改变
changeType(){
const nowDate = new Date().getTime();
let day1,day2;
switch (this.timeType){
case'1':{
this.obj.startTime = this.datePipe.transform(nowDate,'yyyy-MM-dd') +' 00:00:00';
this.obj.endTime = this.datePipe.transform(nowDate,'yyyy-MM-dd') +' 23:59:59';
break;
}
case'2':{
day1 = nowDate - 1*24*60*60*1000;
this.obj.startTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 23:59:59';
break;
}
case'3':{
day1 = nowDate - 3*24*60*60*1000;
day2 = nowDate - 1*24*60*60*1000;
this.obj.startTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(day2,'yyyy-MM-dd') + ' 23:59:59';
break;
}
case'4':{
day1 = nowDate - 7*24*60*60*1000;
day2 = nowDate - 1*24*60*60*1000;
this.obj.startTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(day2,'yyyy-MM-dd') + ' 23:59:59';
break;
}
case'5':{
break;
}
}
}
//搜索
search(){
if(this.timeType == '5'){
this.obj.startTime = this.datePipe.transform(this.startTime,'yyyy-MM-dd HH:mm:ss');
this.obj.endTime = this.datePipe.transform(this.endTime,'yyyy-MM-dd HH:mm:ss');
}
this.getData();
}
}
......@@ -10,8 +10,11 @@ export class LayoutService {
}
getMenu(): Observable<any>{
return this.http.get(SERVER_API_URL + '/api/getMenu', );
return this.http.get(SERVER_API_URL + '/resources/getMenu');
}
}
getAllMenu(): Observable<any>{
return this.http.get(SERVER_API_URL + "/resources/getAll");
}
}
<nz-modal [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<nz-modal [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<form [formGroup]="validateForm" nz-form >
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">部门名称</nz-form-label>
......
......@@ -27,7 +27,7 @@ export class GroupModalComponent implements OnInit {
initForm(){
this.validateForm = this.fb.group({
name:[null,[Validators.required,Validators.maxLength(15)]],
parentId:[null,[Validators.required]],
parentId:[null],
});
}
......@@ -41,7 +41,6 @@ export class GroupModalComponent implements OnInit {
}
handleOk(){
this.isVisible = true;
for(let i in this.validateForm.controls){
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
......
......@@ -18,10 +18,10 @@
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="comments">角色说明</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="comment">角色说明</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<textarea id="comments" row="4" nz-input formControlName="comments"></textarea>
<nz-form-explain *ngIf="validateForm.get('comments').dirty && validateForm.get('comments').errors">请输入角色说明!</nz-form-explain>
<textarea id="comment" row="4" nz-input formControlName="comment"></textarea>
<nz-form-explain *ngIf="validateForm.get('comment').dirty && validateForm.get('comment').errors">请输入角色说明!</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
......@@ -41,14 +41,18 @@
</nz-form-control>
</nz-form-item>
<nz-form-item>
<!--<nz-form-label [nzSm]="6" [nzXs]="24" >资源权限</nz-form-label>-->
<!--<nz-form-control [nzSm]="14" [nzXs]="24">-->
<!--<nz-select id="isBoolean" nzPlaceHolder="选择性别">-->
<!--<nz-option nzValue="有效" nzLabel="有效"></nz-option>-->
<!--<nz-option nzValue="无效" nzLabel="无效"></nz-option>-->
<!--</nz-select>-->
<!--&lt;!&ndash;<nz-form-explain *ngIf="validateForm.get('gender').dirty && validateForm.get('gender').errors">Please select your gender!</nz-form-explain>&ndash;&gt;-->
<!--</nz-form-control>-->
<!--</nz-form-item>-->
<nz-form-label [nzSm]="6" [nzXs]="24" >资源权限</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-tree #nzTree
[(ngModel)]="nodes" [ngModelOptions]="{standalone: true}"
[nzCheckable]="true"
[nzAsyncData]="true"
[nzCheckStrictly]="true"
(nzCheckBoxChange)="selectCheckTree($event)"
(nzClick)="mouseAction('expand',$event)"
(nzExpandChange)="mouseAction('expand',$event)" >
</nz-tree>
</nz-form-control>
</nz-form-item>
</form>
</nz-modal>
......@@ -26,6 +26,7 @@ export class RoleComponent implements OnInit {
nodes;
nodeList;
roleId;
constructor(private fb: FormBuilder, private message: NzMessageService,
private systemSer: SystemService,private layoutSer:LayoutService,private commonSer:CommonService) {
......@@ -40,13 +41,13 @@ export class RoleComponent implements OnInit {
this.validateForm = this.fb.group({
name: [null, [Validators.required]],
status: [null, [Validators.required]],
comments: [null, [Validators.required]],
comment: [null, [Validators.required]],
});
}
//获取菜单栏
getMenu(){
this.layoutSer.getMenu().subscribe(
this.layoutSer.getAllMenu().subscribe(
(res)=>{
if(res.errCode == 10000){
this.menuList =this.commonSer.listToTree('id','parentId',res.data);
......@@ -71,6 +72,8 @@ export class RoleComponent implements OnInit {
});
}
//获取所有分组
showAddModal(): void {
this.title = '新增角色';
this.isVisible = true;
......@@ -79,10 +82,11 @@ export class RoleComponent implements OnInit {
showEditModal(id){
this.title = "编辑角色";
this.isVisible = true;
this.roleId = id;
this.systemSer.getRole(id).subscribe(
(res)=>{
if(res.errCode == 10000){
const data = res.data;
const data = res.data.role;
data.status += "";
this.validateForm.patchValue(data);
}
......@@ -102,21 +106,61 @@ export class RoleComponent implements OnInit {
if (this.validateForm.invalid) {
return false;
}
if(this.title == "新增角色"){
this.create();
}
if(this.title == "编辑角色"){
this.update();
}
}
//新增
create(){
const data = {
role:{
name:this.validateForm.value.name,
status:this.validateForm.value.status,
comments:this.validateForm.value.comments,
comment:this.validateForm.value.comment,
},
resources:[],
menus:[]
modules:[],
resources:[]
};
this.systemSer.addRole(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.isVisible = false;
this.add.emit();
this.message.info('新增成功');
this.ininForm();
this.message.success('新增成功');
}else{
this.message.error(res.errMsg);
}
}
);
}
//编辑
update(){
const data = {
role:{
id:this.roleId,
name:this.validateForm.value.name,
status:this.validateForm.value.status,
comment:this.validateForm.value.comment,
},
modules:[],
resources:[]
};
this.systemSer.editRole(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.isVisible = false;
this.add.emit();
this.ininForm();
this.message.success('修改成功');
}else{
this.message.error(res.errMsg);
}
}
);
......
<nz-modal [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<nz-modal [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleCancel()">
<div style="position: absolute;left:20%;top: 15px;">
<nz-switch [(ngModel)]="first.check"></nz-switch>
<nz-switch [(ngModel)]="first.check" (ngModelChange)="changeValue('1')"></nz-switch>
</div>
<form nz-form>
<nz-form-item *ngFor="let item of list">
<nz-form-label [nzSm]="8" [nzXs]="24" [ngModelOptions]="{standalone: true}" >{{item.name}}</nz-form-label>
<nz-form-item *ngFor="let item of list;let i = index;">
<nz-form-label [nzSm]="8" [nzXs]="24" [ngModelOptions]="{standalone: true}">{{item.comment}}</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-switch [(ngModel)]="item.check" [ngModelOptions]="{standalone: true}"></nz-switch>
<nz-switch [(ngModel)]="item.check" [ngModelOptions]="{standalone: true}" (ngModelChange)="changeValue(i+2)"></nz-switch>
</nz-form-control>
</nz-form-item>
</form>
......
......@@ -15,7 +15,7 @@ export class SeparationComponent implements OnInit {
value = 0;
first = {
id:"",
value:null,
scValue:null,
check:null
};
......@@ -26,11 +26,11 @@ export class SeparationComponent implements OnInit {
//查询三员分立
separationPowerStatus() {
this.systemSer.separationPowers().subscribe(
this.systemSer.getSeparationConfig().subscribe(
(res) => {
if (res.errCode == 10000) {
this.first = res.data[0];
if(this.first.value == 0){
if(this.first.scValue == 1){
this.first.check = true;
}else{
this.first.check = false;
......@@ -38,7 +38,7 @@ export class SeparationComponent implements OnInit {
res.data.splice(0, 1);
this.list = res.data;
this.list.forEach(e=>{
if(e.value == 0){
if(e.scValue == 1){
e.check = true;
}else{
e.check = false;
......@@ -59,6 +59,47 @@ export class SeparationComponent implements OnInit {
this.isVisible = false;
}
changeValue(type) {
let arr = {
check:"",
scValue:null,
id:""
};
if (type == "1") {
arr = this.first;
}
if (type == "2") {
arr = this.list[0];
}
if (type == "3") {
arr = this.list[1];
}
if (arr.check) {
arr.scValue = 1;
} else {
arr.scValue = 0;
}
const data = {
id: arr.id,
scValue: arr.scValue,
};
this.systemSer.updateValue(data).subscribe(
(res) => {
if (res.errCode == 10000) {
if (this.first.check) {
this.message.success("已开启三员分立功能");
} else {
this.message.success("已关闭三员分立功能");
}
} else {
this.message.error(res.errMsg);
}
}
)
}
//保存
handleOk() {
let arr = [];
......@@ -67,16 +108,16 @@ export class SeparationComponent implements OnInit {
let arr1 = arr.map(res=>{
const data = {
id:res.id,
value:null
}
scValue:null,
};
if(res.check){
data.value = 0;
data.scValue = 0;
}else{
data.value = 1;
data.scValue = 1;
}
return data;
});
this.systemSer.updateSeparationPowerStatus(arr1).subscribe(
this.systemSer.updateValue(arr1).subscribe(
(res)=>{
if(res.errCode == 10000){
if(this.first.check){
......
......@@ -53,7 +53,7 @@
<td class="handle">
<span (click)="grantUser(data)">授予用户</span>
<span>查看</span>
<span (click)="showEditModal(data.id)">编辑</span>
<span (click)="showEditModal(data)">编辑</span>
<span (click)="deleteRole(data)">删除</span>
</td>
</tr>
......
......@@ -42,8 +42,12 @@ export class PowerComponent implements OnInit {
}
//编辑角色
showEditModal(id){
this.smartRole.showEditModal(id);
showEditModal(data){
if(data.isEdit == 0){
this.message.warning("该角色不可编辑");
return false;
}
this.smartRole.showEditModal(data.id);
}
//授予用户
......@@ -74,14 +78,21 @@ export class PowerComponent implements OnInit {
}
//删除角色
deleteRole(data) {
deleteRole(item) {
if(item.isEdit == 0){
this.message.warning("该角色不可删除");
return false;
}
this.modalSer.confirm({
nzTitle:'删除',
nzContent:'<b style="color: red">确定删除该角色</b>',
nzOkText:'确定',
nzOkType:'danger',
nzOnOk:()=>{
this.systemSer.deleteRole(data.id).subscribe(
const data = {
id:item.id
}
this.systemSer.deleteRole(data).subscribe(
(res) => {
if(res.errCode == 10000){
this.message.success("删除成功");
......
......@@ -12,27 +12,27 @@ export class SystemService {
//角色列表
role(): Observable<any>{
return this.http.get(SERVER_API_URL + '/role');
return this.http.get(SERVER_API_URL + '/role/getAllRole');
}
//获取单个角色
getRole(params): Observable<any>{
return this.http.get(SERVER_API_URL + '/role/'+params);
return this.http.get(SERVER_API_URL + '/role/'+ params);
}
//编辑角色
editRole(data): Observable<any>{
return this.http.put(SERVER_API_URL + '/role',data);
return this.http.post(SERVER_API_URL + '/role/updateRole',data);
}
//新增角色
addRole(data): Observable<any>{
return this.http.post(SERVER_API_URL + '/role',data);
return this.http.post(SERVER_API_URL + '/role/createRole',data);
}
//删除用户
deleteRole(params): Observable<any>{
return this.http.delete(SERVER_API_URL + '/role/' +params);
return this.http.get(SERVER_API_URL + '/role/deleteRoleById?' +this.commonSer.toQuery(params));
}
//用户列表
......@@ -50,19 +50,24 @@ export class SystemService {
return this.http.delete(SERVER_API_URL + '/user/'+ params);
}
//组织结构列表
//组织结构列表 /organization/updateOrganization
organization(): Observable<any>{
return this.http.get(SERVER_API_URL + '/organization',);
return this.http.get(SERVER_API_URL + '/organization/getAll',);
}
//编辑组织
updateOrganization(): Observable<any>{
return this.http.get(SERVER_API_URL + '/organization/updateOrganization',);
}
//创建组织结构
createOrg(data): Observable<any>{
return this.http.post(SERVER_API_URL + '/organization',data);
return this.http.post(SERVER_API_URL + '/organization/createOrganization',data);
}
//三员分立列表
separationPowers(): Observable<any>{
return this.http.get(SERVER_API_URL + '/approval/separationPowers',);
getSeparationConfig(): Observable<any>{
return this.http.get(SERVER_API_URL + '/separationConfig/getSeparationConfig',);
}
//审计列表
......@@ -86,8 +91,8 @@ export class SystemService {
}
//修改三员分立状态
updateSeparationPowerStatus(data): Observable<any>{
return this.http.put(SERVER_API_URL + '/approval/separationPowers',data);
updateValue(data): Observable<any>{
return this.http.post(SERVER_API_URL + '/separationConfig/updateValue',data);
}
//获取当前登录人角色
......@@ -142,4 +147,9 @@ export class SystemService {
unApproveList(): Observable<any>{
return this.http.get(SERVER_API_URL + '/approval/unApproveList' );
}
//修改密码
modifyPassword(data): Observable<any>{
return this.http.post(SERVER_API_URL + '/modifyPassword',data );
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment