411 lines
17 KiB
TypeScript
411 lines
17 KiB
TypeScript
/// <reference path="../../includes.ts"/>
|
||
/// <reference path="systemPlugin.ts"/>
|
||
/// <reference path="systemHelpers.ts"/>
|
||
/// <reference path="systemServices.ts"/>
|
||
/// <reference path="../../configs/ts/configsUtils.ts"/>
|
||
/// <reference path="../../kubernetes/ts/kubernetesHelpers.ts"/>
|
||
/// <reference path="../../configs/ts/customAlert.ts"/>
|
||
/// <reference path="../../configs/ts/configsDataService.ts"/>
|
||
/// <reference path="../../kubernetes/ts/term.ts"/>
|
||
|
||
module System {
|
||
export var SystemVerificationController = controller('SystemVerificationController', ['$scope', '$interval', '$location', '$http', '$templateCache', 'Upload', 'NgTableParams', 'ngDialog', 'SystemModel', '$element', '$timeout', 'ConfigsModel', 'DataModel', 'TerminalService', 'KubernetesModel', ($scope, $interval, $location, $http, $templateCache, Upload, NgTableParams, ngDialog, SystemModel, $element, $timeout, ConfigsModel, DataModel, TerminalService, KubernetesModel) => {
|
||
shareInit($scope);
|
||
$scope.cities = classifyCity(SystemModel.regionalismInfo);
|
||
$scope.model = SystemModel;
|
||
$scope.tableData = null;
|
||
$scope.checkboxes = {
|
||
checked: false,
|
||
items: {}
|
||
};
|
||
// 表数据
|
||
$scope.tableParams = new NgTableParams({ count: 25 }, {
|
||
counts: [25, 50, 100],
|
||
dataset: $scope.tableData
|
||
});
|
||
|
||
$scope.citySelect = (x) => {
|
||
$scope.countries = [];
|
||
$scope.y = "all";
|
||
if (x != 'all') {
|
||
$scope.countries = classifyCountry(SystemModel.regionalismInfo, x);
|
||
$.ajax({
|
||
async: false,
|
||
type: "POST",
|
||
contentType: "application/json; charset=utf-8",
|
||
url: UrlHelpers.join("/java/console/api/checkout/findByCity"),
|
||
dataType: 'json',
|
||
data: JSON.stringify(x),
|
||
// data: { "idList": idList, "typeList": typeList },
|
||
// data: JSON.stringify(formData),
|
||
|
||
success: (data) => {
|
||
$scope.tableData = data.data;
|
||
$scope.tableParams.settings({
|
||
dataset: $scope.tableData
|
||
});
|
||
|
||
},
|
||
error: (data) => {
|
||
Configs.customAlert("提示", "请求失败!", '', null, 0, "error");
|
||
}
|
||
});
|
||
} else {
|
||
//$scope.countries=[];
|
||
//$scope.y = "all";
|
||
$scope.tableData = null;
|
||
$scope.checkboxes = {
|
||
checked: false,
|
||
items: {}
|
||
};
|
||
}
|
||
}
|
||
|
||
$scope.countrySelect = (y) => {
|
||
if (y != 'all') {
|
||
var result = [];
|
||
angular.forEach($scope.tableData, (item) => {
|
||
if (item.districtName == y)
|
||
result.push(item);
|
||
});
|
||
$scope.tableParams.settings({
|
||
dataset: result
|
||
});
|
||
} else {
|
||
$scope.tableParams.settings({
|
||
dataset: $scope.tableData
|
||
});
|
||
}
|
||
}
|
||
|
||
$scope.checkSQLSERVER = () => {
|
||
/**
|
||
** 检查是否有默认标准表汇总库
|
||
**/
|
||
var answer = false;
|
||
for (var i = 0; i < ConfigsModel.oracleParam.length; ++i) {
|
||
if (ConfigsModel.oracleParam[i].type == 1) {
|
||
answer = true
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (answer == false) {
|
||
/**
|
||
提示没有配置标准表汇总库
|
||
**/
|
||
Configs.customAlert("提示", "操作失败:没有配置默认的标准表汇总库", '', null, 0, "error");
|
||
return;
|
||
}
|
||
|
||
var selectedItems = [];
|
||
if ($scope.tableData && $scope.tableData.length > 0) {
|
||
for (var i = 0; i < $scope.tableData.length; ++i) {
|
||
var item = $scope.tableData[i];
|
||
if ($scope.checkboxes.items[item.id]) {
|
||
if (item.collection == '否') {
|
||
/*
|
||
**提示出现没有采集数据的信息系统
|
||
code
|
||
*/
|
||
Configs.customAlert("提示", "操作失败:选择的系统存在没有数据的系统", '', null, 0, "error");
|
||
return;
|
||
}
|
||
7
|
||
|
||
item["_key"] = item.areaCode + "-" + item.sysCode + "-" + item.dataVersion;
|
||
if (item.dataBaseType == 'ORACLE') {
|
||
Configs.customAlert("提示", "操作失败:ORACLE数据请在服务集群界面中抽取标准表!", '', null, 0, "error");
|
||
return;
|
||
}
|
||
selectedItems.push(item);
|
||
}
|
||
}
|
||
|
||
$http({
|
||
url: "/java/console/api/checkout/extractList",
|
||
method: "POST",
|
||
data: selectedItems
|
||
}).success((data, header, config, status) => {
|
||
//console.log(data);
|
||
|
||
}).error((data, header, config, status) => {
|
||
throw "请求失败"
|
||
});
|
||
}
|
||
}
|
||
|
||
$scope.deleteRows = () => {
|
||
var filter = [];
|
||
if ($scope.tableData && $scope.tableData.length > 0) {
|
||
angular.forEach($scope.tableData, (item) => {
|
||
if ($scope.checkboxes.items[item.id]) {
|
||
item["index"] = item.cityName + "_" + item.districtName + "_" + item.sysName + "_" + item.year + "_版本" + item.dataVersion;
|
||
item["_key"] = item.areaCode + "-" + item.sysCode + "-" + item.dataVersion;
|
||
filter.push(item);
|
||
}
|
||
});
|
||
}
|
||
//检查数据是否存在
|
||
for (var i = 0; i < filter.length; i++) {
|
||
if (filter[i].collection == '否') {
|
||
Configs.customAlert("提示", "操作失败:部分数据不存在,无法删除", '', null, 0, "error");
|
||
return;
|
||
}
|
||
}
|
||
|
||
//检查数据是否已启动 //检查数据是否在迁移
|
||
|
||
var message = Kubernetes.checkForMigration(KubernetesModel.replicationControllers, DataModel.transferTasks, filter, "verify");
|
||
|
||
if (message != "") {
|
||
Configs.customAlert("提示", "操作失败:部分数据" + message + ",无法删除", '', null, 0, "error");
|
||
return
|
||
}
|
||
|
||
|
||
UI.multiItemConfirmActionDialog( < UI.MultiItemConfirmActionOptions > {
|
||
collection: filter,
|
||
index: 'index',
|
||
onClose: (result: boolean) => {
|
||
if (result) {
|
||
$http({
|
||
url: "/java/console/api/checkout/deleteList",
|
||
method: "POST",
|
||
data: filter
|
||
}).success((data, header, config, status) => {
|
||
$scope.tableData = data.data;
|
||
var result = [];
|
||
if ($scope.y != 'all') {
|
||
angular.forEach($scope.tableData, (item) => {
|
||
if (item.districtName == $scope.y)
|
||
result.push(item);
|
||
});
|
||
} else {
|
||
result = $scope.tableData;
|
||
}
|
||
$scope.tableParams.settings({
|
||
dataset: result
|
||
});
|
||
}).error((data, header, config, status) => {
|
||
throw "请求失败"
|
||
});
|
||
}
|
||
},
|
||
title: '是否需要删除采集数据?',
|
||
action: '以下采集数据文件将会被删除:',
|
||
okText: '删除',
|
||
okClass: 'btn-danger sj_btn_cir',
|
||
custom: "该删除操作将会彻底删除数据文件,是否删除,请确认!",
|
||
customClass: "alert alert-warning sj_alert-warning",
|
||
cancelText: "取消",
|
||
cancelClass: 'sj_btn_grey'
|
||
}).open();
|
||
}
|
||
|
||
$scope.check = () => {
|
||
//var sqlServerDB = [];
|
||
var oracleDB = [];
|
||
var selectedItems = [];
|
||
/**
|
||
** 检查是否有默认标准表汇总库
|
||
**/
|
||
var answer = false;
|
||
for (var i = 0; i < ConfigsModel.oracleParam.length; ++i) {
|
||
if (ConfigsModel.oracleParam[i].type == 1) {
|
||
answer = true
|
||
break;
|
||
}
|
||
}
|
||
if (answer == false) {
|
||
/**
|
||
提示没有配置标准表汇总库
|
||
**/
|
||
Configs.customAlert("提示", "操作失败:没有配置默认的标准表汇总库", '', null, 0, "error");
|
||
return;
|
||
}
|
||
|
||
if ($scope.tableData && $scope.tableData.length > 0) {
|
||
for (var i = 0; i < $scope.tableData.length; ++i) {
|
||
var item = $scope.tableData[i];
|
||
if ($scope.checkboxes.items[item.id]) {
|
||
if (item.collection == '否') {
|
||
/*
|
||
**提示出现没有采集数据的信息系统
|
||
code
|
||
*/
|
||
Configs.customAlert("提示", "操作失败:选择的系统存在没有数据的系统", '', null, 0, "error");
|
||
return;
|
||
}
|
||
/**
|
||
*/
|
||
/*if(item.payResultLast == 1){
|
||
Configs.customAlert("提示", "操作失败:选择的系统存在不需要校验的系统", '',null, 0, "error");
|
||
return;
|
||
}
|
||
|
||
/**
|
||
检查数据是否在热区
|
||
*/
|
||
|
||
if (item.mark == 1 && item.dataBaseType == 'ORACLE') {
|
||
Configs.customAlert("提示", "操作失败:选择的系统的数据存储在冷区,请先将数据迁移到热区再检验!", '', null, 0, "error");
|
||
return
|
||
}
|
||
item["_key"] = item.areaCode + "-" + item.sysCode + "-" + item.dataVersion;
|
||
selectedItems.push(item);
|
||
if (item.dataBaseType == 'ORACLE') {
|
||
oracleDB.push(item);
|
||
}
|
||
}
|
||
}
|
||
|
||
/*
|
||
此处需要检查数据是否已挂载、正在迁移。
|
||
*/
|
||
var exited = Kubernetes.checkForCreateOracle(DataModel.transferTasks, selectedItems);
|
||
if (exited.length > 0) {
|
||
Configs.customAlert("提示", "操作失败: 正在迁移的数据不能执行校验操作!", '', null, 0, "error");
|
||
return;
|
||
}
|
||
|
||
/*
|
||
如果是Oracle数据,先启动oracle数据
|
||
*/
|
||
if (oracleDB.length > 0) {
|
||
angular.forEach(oracleDB, (item) => {
|
||
Kubernetes.createRC({
|
||
name: item._key,
|
||
labels: {
|
||
system: item.sysCode.toString(),
|
||
version: item.dataVersion.toString(),
|
||
region: item.areaCode.toString()
|
||
},
|
||
annotations: {
|
||
cityName: item.cityName,
|
||
districtName: item.districtName,
|
||
systemName: item.sysName,
|
||
id: item.dataId + "",
|
||
year: item.year,
|
||
checkoutFlag: item.checkoutFlag
|
||
},
|
||
path: item.path + "app/",
|
||
isTarget: "false",
|
||
isExtract: item.extractStatus
|
||
}, (rc) => {
|
||
//Kubernetes.connectOracle($http, $timeout, "/java/console/api/connectOracle", "create", rc, 0);
|
||
});
|
||
});
|
||
$timeout(() => {
|
||
$location.path('/kubernetes/namespace/default/replicationControllers');
|
||
}, 500);
|
||
}
|
||
|
||
$http({
|
||
url: "/java/console/api/checkout/checkList",
|
||
method: "POST",
|
||
data: selectedItems
|
||
}).success((data, header, config, status) => {
|
||
$scope.tableData = data.data;
|
||
var result = [];
|
||
if ($scope.y != 'all') {
|
||
angular.forEach($scope.tableData, (item) => {
|
||
if (item.districtName == $scope.y)
|
||
result.push(item);
|
||
});
|
||
} else {
|
||
result = $scope.tableData;
|
||
}
|
||
|
||
$scope.tableParams.settings({
|
||
dataset: result
|
||
});
|
||
}).error((data, header, config, status) => {
|
||
throw "请求失败"
|
||
});
|
||
}
|
||
}
|
||
// watch for check all checkbox
|
||
$scope.$watch(function() {
|
||
return $scope.checkboxes.checked;
|
||
}, function(value) {
|
||
angular.forEach($scope.tableData, function(item) {
|
||
$scope.checkboxes.items[item.id] = value;
|
||
});
|
||
});
|
||
|
||
// watch for data checkboxes
|
||
$scope.$watch(function() {
|
||
return $scope.checkboxes.items;
|
||
}, function(values) {
|
||
$scope.checkable = false;
|
||
for (var index in values) {
|
||
if (values[index] == true) {
|
||
$scope.checkable = true;
|
||
break;
|
||
}
|
||
}
|
||
var checked = 0,
|
||
unchecked = 0,
|
||
total = -1;
|
||
if ($scope.tableData && ($scope.tableData instanceof Array))
|
||
total = $scope.tableData.length;
|
||
angular.forEach($scope.tableData, function(item) {
|
||
checked += ($scope.checkboxes.items[item.id]) || 0;
|
||
unchecked += Number(!$scope.checkboxes.items[item.id]) || 0;
|
||
});
|
||
|
||
if ((unchecked == 0) || (checked == 0)) {
|
||
$scope.checkboxes.checked = (checked == total);
|
||
}
|
||
// grayed checkbox
|
||
angular.element($element[0].getElementsByClassName("select-all")).prop("indeterminate", (checked != 0 && unchecked != 0));
|
||
}, true);
|
||
|
||
$scope.update = (entity) => {
|
||
ngDialog.open({
|
||
template: 'sysVerificationUpdate.html',
|
||
controller: 'Configs.sysVerUpdateController',
|
||
width: 900,
|
||
height: 600,
|
||
closeByDocument: false,
|
||
data: entity,
|
||
scope: $scope,
|
||
className: 'ngdialog-theme-default'
|
||
});
|
||
}
|
||
|
||
$scope.$on('updateRow', (event, data) => {
|
||
$http({
|
||
url: "/java/console/api/checkout/update",
|
||
method: 'POST',
|
||
data: JSON.stringify(data)
|
||
}).success(function(data, header, config, status) {
|
||
if (header == 200) {
|
||
Configs.customAlert("提示", "操作成功!", '', null, 0, "success");
|
||
var result = [];
|
||
if ($scope.y != 'all') {
|
||
angular.forEach(data.data, (item) => {
|
||
if ($scope.y == item.districtName)
|
||
result.push(item);
|
||
})
|
||
} else
|
||
result = data.data;
|
||
$scope.tableParams.settings({
|
||
dataset: result
|
||
});
|
||
} else
|
||
Configs.customAlert("提示", "操作失败!", '', null, 0, "error");
|
||
}).error(function(data, header, config, status) {
|
||
Configs.customAlert("提示", "操作失败:发生请求失败,不能删除!", '', null, 0, "error");
|
||
});
|
||
});
|
||
|
||
$scope.openLog = (entity) => {
|
||
var name = entity.areaCode + "_" + entity.sysCode + "_" + entity.dataVersion
|
||
var containerName = entity.cityName + "-" + entity.districtName + "-" + entity.sysName + "-版本" + entity.dataVersion;
|
||
entity["name"] = name;
|
||
TerminalService.newTerminal($interval, entity.id + "", containerName, entity, "/java/console/api/standardextract/log?rcName=" + name, $templateCache.get(UrlHelpers.join(Kubernetes.templatePath, 'logShell.html')));
|
||
}
|
||
}]);
|
||
} |