2025-06-27 10:04:22 +08:00

460 lines
15 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

app.controller('PlanControlCtrl', ['$scope', 'JCDW', 'RWDZ', 'YPJBXXGL', '$uibModal', '$sessionStorage', 'wyOdataNodeService', '$timeout', function ($scope, JCDW, RWDZ, YPJBXXGL, $uibModal, $sessionStorage, wyOdataNodeService, $timeout) {
$scope.myttt = "0";
/**************************************************************************************/
//通过STMATETable 分页显示数据
//以下的参数每个控制器都要有一份
$scope.ttt = [];
$scope.tableState = []; //这个参数后面会让每次访问服务器后进行同步返回的值赋值,作为中间值使用
$scope.selectList = []; //这个参数会让每次选中或者没有选中的条目直接暴露在这个值里面
$scope.searchSql = "ZTtype eq 2 ";
if ($sessionStorage.user.type == 4 || $sessionStorage.user.type == 5) {
$scope.searchSql = $scope.searchSql + "and JCDW eq '" + $sessionStorage.user.name + "'";
$scope.YSSS = true;
}
$scope.isShow = false; //这个参数主要进行页面加载的loading显示的directive的值得操作
$scope.itemsOptions = [5, 10, 20, 50, 100, 200]; //这个参数进行分页页面上面的每页多少条的设置
$scope.curpageNumber = 10; //这个参数传递当前的每页多少条的数据
//任何动作都会触发服务端的接口
$scope.getService = function (tableState, ctrl) {
$scope.tableState = tableState;
if (!$scope.tableState.pagination.number) {
$scope.tableState.pagination.number = $scope.curpageNumber;
}
$scope.isShow = true;
// console.log($scope.searchSql+"aaa");
wyOdataNodeService.getData(pubserver, 'RWDZ_DB', $scope.tableState, $scope.searchSql).then(function (data) {
//console.log( data);
$scope.displayed = data;
$sessionStorage.Cha = data;
$timeout(function () {
$scope.JKData(data);
}, 1000)
//当前页面的ID号数组
$scope.isShow = false;
$scope.ids = Enumerable.From($scope.displayed).Select(function (x) { return x.id }).ToArray();
$scope.myttt = tableState.count;
$scope.$broadcast('checkini');
});
};
//$timeout(function () {
// console.log($scope.displayed);
//}, 2000)
//模板的分页选择触发操作
$scope.setPageNumber = function (pageNo) {
// alert("1")
$scope.getService($scope.tableState);
}
//查询参数的调用
$scope.search = function () {
$scope.searchSql = [$scope.sql];
$scope.getA($scope.tableState);
//约定成数字的按照前后
//日期按照前后
//字符串的模糊查询
//var sql = '$filter=EventDateTime eq DateTime'2010-12-21T10:10:19.390625';
//日期参考如下:
//(EventDateTime eq DateTime'2010-12-21T10:10:19.390625' ) and (BusinessUnitCode eq '2')
//var dT=dd ge 12 and dd le 33
}
/**************************************************************************************/
//转换时间格式
$scope.formatDate = function (day) {
var cc = new Date(day);
var y = cc.getFullYear();
var m = cc.getMonth() + 1;
var d = cc.getDate();
if (m < 10) {
m = "0" + m;
}
if (d < 10) {
d = "0" + d;
}
return aa = y + "/" + m + "/" + d;
}
//转换时间格式
$scope.formatDate1 = function (day) {
var cc = new Date(day);
var y = cc.getFullYear();
var m = cc.getMonth() + 1;
var d = cc.getDate();
if (m < 10) {
m = "0" + m;
}
if (d < 10) {
d = "0" + d;
}
return aa = y + "-" + m + "-" + d;
}
//任务来源
$scope.RELYdata = [
{ name: "国家食品药品监督管理总局", PY: "GJZJ" },
{ name: "上海市食品药品监督管理局", PY: "SHZJ" }
];
//检测机构
JCDW.get(function (data) {
$scope.JCDWdata = data.value;
})
//任务性质
$scope.RWXZdata = [
{ name: "常规监测", PY: "CGJC" },
{ name: "专项监测", PY: "ZXJC" },
{ name: "应急监测", PY: "YJJC" },
{ name: "能力验证", PY: "NLYZ" },
];
function getLastDay(year, month) {
var new_year = year; //取当前的年份
var new_month = month++;//取下一个月的第一天,方便计算(最后一天不固定)
if (new_month > 12) //如果当前大于12月则年份转到下一年
{
new_month -= 12; //月份减
new_year++; //年份增
}
var newnew_date = new Date(new_year, new_month, 1); //取当年当月中的第一天
return (new Date(newnew_date.getTime() - 1000 * 60 * 60 * 24)).getDate();//获取当月最后一天日期
}
function getmynewdate(datestr) {
var dateIntArray = datestr.split("/");
var nianfen = dateIntArray[0] * 1;
var yuefen = (dateIntArray[1] * 1)+1;
var tianshu = dateIntArray[2] * 1
if (yuefen>12) {
yuefen = 1;
nianfen += 1;
}
return nianfen + "/" + yuefen + "/" + tianshu;
}
/***********************************这个是查询的总方法******************************/
$scope.Cha = function () {
$scope.selectList = [];
//判断查询的初始条件
$scope.searchSql = "ZTtype eq 2 and ";
if ($sessionStorage.user.type == 4 || $sessionStorage.user.type == 5) {
$scope.searchSql = $scope.searchSql + "JCDW eq '" + $sessionStorage.user.name + "' and ";
$scope.YSSS = true;
}
//检测机构
var jcjg = $scope.jcjg;
//任务来源
var rwly = $scope.rwly;
//r任务开始时间
var ypkssj = $scope.ypkssj;
//任务结束时间
var ypjssj = $scope.ypjssj;
//任务性质
var rwxz = $scope.rwxz;
//检测机构不为空
if (jcjg != undefined) {
$scope.searchSql = $scope.searchSql + "JCDW eq '" + jcjg.JCJGMC + "' and ";
}
//恩任务来源不为空
if (rwly != undefined) {
$scope.searchSql = $scope.searchSql + "RWLY eq '" + rwly.name + "' and ";
}
//任务性质不为空
if (rwxz != undefined) {
$scope.searchSql = $scope.searchSql + "RWXZ eq '" + rwxz.name + "' and ";
}
//开始时间结束时间不为空
if (ypkssj != undefined) {
var Ktime = $scope.formatDate(ypkssj);
$scope.searchSql = $scope.searchSql + "YPKSSJ ge '" + Ktime + "' and ";
}
//结束时间不为空
if (ypjssj != undefined) {
var Jtime = $scope.formatDate(ypjssj);
var datearray = Jtime.split("/");
var lday = getLastDay(datearray[0] * 1, datearray[1] * 1);
var newjtime = datearray[0] + "/" + datearray[1] + "/" + lday
var myLastDay = getmynewdate(newjtime);
$scope.searchSql = $scope.searchSql + "YPJSSJ le '" + myLastDay + "' and ";
}
//总合计
$scope.hj = 0;
//总还未开始
$scope.zhwks = 0;
//总的已经采样
$scope.zyjcy = 0;
//总的已经检验
$scope.zyjjy = 0;
//总已经审核
$scope.zyjsh = 0;
//总已经批准
$scope.zyjpz = 0
//总的合格率
$scope.zwcl = 0;
$scope.searchSql = $scope.searchSql.substring(0, $scope.searchSql.length - 4);
$scope.getService($scope.tableState, $scope.searchSql);
//console.log($sessionStorage.Cha);
$timeout(function () {
$scope.JKData($scope.displayed);
}, 2000)
//这里需要查询出当前未开始额数据有多少
//angular.forEach($scope.displayed, function (data){
// // console.log(angular.toJson(data));
// //通过任务编号查询出当前样品基本信息库里面有多少条数据
// $scope.hj = parseInt($scope.hj) + parseInt(data.JCRWHJ);
// var filter = "RWBH eq '" + data.RWBH + "'";
// YPJBXXGL.getAll({ $filter: filter }, function (data1) {
// var mydd = data1.value;
// //console.log(angular.toJson(mydd));
// //还未开始
// data.HWKS = parseInt(data.JCRWHJ) - parseInt(mydd.length);
// console.log(data.HWKS);
// //已经采样
// data.YJCY = Enumerable.From(mydd).Where(function (x) { return x.YPJBZTType!= 0}).Count();
// //已经检验
// data.YJJY = Enumerable.From(mydd).Where(function (x) { return x.YPJBZTType == 2 || x.YPJBZTType == 3 || x.YPJBZTType == 4 }).Count();
// //已经审核
// data.YJSH = Enumerable.From(mydd).Where(function (x) { return x.YPJBZTType == 3|| x.YPJBZTType == 4 }).Count();
// //已经批准
// data.YJPZ= Enumerable.From(mydd).Where(function (x) { return x.YPJBZTType == 4 }).Count();
// //完成率
// data.WCL = ((parseFloat(data.YJPZ) / parseFloat(data.JCRWHJ)) * 100).toFixed(2);
// $scope.zhwks = parseInt($scope.zhwks) + parseInt(data.HWKS);
// $scope.zyjcy = parseInt($scope.zyjcy) + parseInt(data.YJCY);
// $scope.zyjjy = parseInt($scope.zyjjy) + parseInt(data.YJJY);
// $scope.zyjsh = parseInt($scope.zyjsh) + parseInt(data.YJSH);
// $scope.zyjpz = parseInt($scope.zyjpz) + parseInt(data.YJPZ);
// })
//})
////总的完成率
//if ($scope.zhwks != 0) {
// $scope.zwcl = ((parseFloat($scope.zyjsh) / parseFloat($scope.hj)) * 100).toFixed(F2);
//}
}
$scope.JKData = function (mydata) {
$scope.hj = 0;
$scope.zhwks = 0;
$scope.zyjcy = 0;
$scope.zyjjy = 0;
$scope.zyjsh = 0;
$scope.zyjpz = 0;
//总的合格率
$scope.zwcl = 0;
angular.forEach(mydata, function (data) {
// console.log(angular.toJson(data));
//通过任务编号查询出当前样品基本信息库里面有多少条数据
$scope.hj = parseInt($scope.hj) + parseInt(data.JCRWHJ);
var filter = "RWBH eq '" + data.RWBH + "'";
YPJBXXGL.getAll({ $filter: filter }, function (data1) {
var mydd = data1.value;
// console.log( Enumerable.From(mydd).Select("$.YPJBZTType").ToArray());
//console.log(angular.toJson(mydd));
//还未开始
data.HWKS = parseInt(data.JCRWHJ) - parseInt(mydd.length);
// console.log(data.HWKS);
//已经采样
data.YJCY = Enumerable.From(mydd).Where(function (x) { return x.YPJBZTType != undefined }).Count();
//已经检验
data.YJJY = Enumerable.From(mydd).Where(function (x) { return x.YPJBZTType == 2 || x.YPJBZTType == 3 || x.YPJBZTType == 4 }).Count();
//已经审核
data.YJSH = Enumerable.From(mydd).Where(function (x) { return x.YPJBZTType == 3 || x.YPJBZTType == 4 }).Count();
//已经批准
data.YJPZ = Enumerable.From(mydd).Where(function (x) { return x.YPJBZTType == 4 }).Count();
//完成率
data.WCL = ((parseFloat(data.YJPZ) / parseFloat(data.JCRWHJ)) * 100).toFixed(1);
$scope.zhwks = parseInt($scope.zhwks) + parseInt(data.HWKS);
$scope.zyjcy = parseInt($scope.zyjcy) + parseInt(data.YJCY);
$scope.zyjjy = parseInt($scope.zyjjy) + parseInt(data.YJJY);
$scope.zyjsh = parseInt($scope.zyjsh) + parseInt(data.YJSH);
$scope.zyjpz = parseInt($scope.zyjpz) + parseInt(data.YJPZ);
})
})
////总的完成率
if ($scope.zhwks != 0) {
$scope.zwcl = ((parseFloat($scope.zyjsh) / parseFloat($scope.hj)) * 100).toFixed(2);
}
//总的任务数 找到监控页面数据中的所有任务数合计
//任务数合计
//不需要批准 找合计
var aa = $scope.searchSql.substring(15, $scope.searchSql.length);
RWDZ.getAllSelect({ $filter: aa, $select: "JCRWHJ" }, function (data) {
var dd = Enumerable.From(data.value).Select("$.JCRWHJ").Sum();
$scope.hjAll = dd;
// console.log(angular.toJson(data));
// console.log($scope.myttt2);
})
//样品表查询的$filter
$scope.searchSqlY = '';
//检测机构
var jcjg = $scope.jcjg;
//任务来源
var rwly = $scope.rwly;
//r任务开始时间
var ypkssj = $scope.ypkssj;
//任务结束时间
var ypjssj = $scope.ypjssj;
//任务性质
var rwxz = $scope.rwxz;
//恩任务来源不为空
if ($sessionStorage.user.type == 4 || $sessionStorage.user.type == 5) {
$scope.searchSqlY = "JCDW eq '" + $sessionStorage.user.name + "' and ";
}
//检测机构不为空
if (jcjg != undefined) {
$scope.searchSqlY = $scope.searchSqlY + "JCDW eq '" + jcjg.JCJGMC + "' and ";
}
//恩任务来源不为空
if (rwly != undefined) {
$scope.searchSqlY = $scope.searchSqlY + "RWLY eq '" + rwly.name + "' and ";
}
//任务性质不为空
if (rwxz != undefined) {
$scope.searchSqlY = $scope.searchSqlY + "RWXZ eq '" + rwxz.name + "' and ";
}
//如果开始时间不为空
if (ypkssj != undefined) {
var Ktime = $scope.formatDate1(ypkssj);
$scope.searchSqlY = $scope.searchSqlY + "CYSJ ge '" + Ktime + "' and ";
}
if (ypjssj != undefined) {
//console.log(ypjssj);
var Jtime = $scope.formatDate1(ypjssj);
$scope.searchSqlY = $scope.searchSqlY + "CYSJ le '" + Jtime + "' and ";
}
$scope.searchSqlY = $scope.searchSqlY.substring(0, $scope.searchSqlY.length - 4);
// console.log($scope.searchSqlY);
YPJBXXGL.getAllSelect({ $filter: $scope.searchSqlY, $select: "YPJBZTType" }, function (data) {
$scope.zyjcyAll = Enumerable.From(data.value).Select(function (x) { return x.YPJBZTType != undefined }).Count();
$scope.zhwksAll = $scope.hjAll - $scope.zyjcyAll;
$scope.zyjjyAll = Enumerable.From(data.value).Where(function (x) { return x.YPJBZTType == 2 || x.YPJBZTType == 3 || x.YPJBZTType == 4 }).Count();
$scope.zyjshAll = Enumerable.From(data.value).Where(function (x) { return x.YPJBZTType == 3 || x.YPJBZTType == 4 }).Count();
$scope.zyjpzAll = Enumerable.From(data.value).Where(function (x) { return x.YPJBZTType == 4 }).Count();
$scope.zwclAll = ((parseFloat($scope.zyjpzAll) / parseFloat($scope.hjAll)) * 100).toFixed(2);
})
}
}])