humitureDetectionCtrl.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. "use strict";
  2. angular.module('app.intelligent').controller("humitureDetectionCtrl", function ($scope, $state, $rootScope, $stateParams, $uibModal, temperatureRecordService, $interval, basicThresholdSetService) {
  3. // 默认分页
  4. $scope.pageInfo = {pageNum: 1, pageSize: 10};
  5. // 筛选条件
  6. $scope.search = {};
  7. $scope.updateTime = 30;
  8. $scope.stopEvent;
  9. // 加载列表
  10. $scope.loadData = function () {
  11. $scope.search.time = $("input[name='time']").val(); // 时间控件获取值
  12. // 检测类型0测温,1粮油,2测水分
  13. temperatureRecordService.getTemperatureRecordPageInfo($scope.pageInfo, $scope.search, '0').then(function (data) {
  14. $scope.pageInfo = data.data;
  15. }, function (data) {
  16. console.log(data);
  17. });
  18. if ($scope.updateTime == 1){
  19. $interval.cancel($scope.stopEvent);
  20. console.log('测试成功停止刷新!');
  21. $scope.stopEvent = undefined;
  22. }
  23. };
  24. $scope.loadData();
  25. // 详情(层温)
  26. $scope.grainDetectionDetail = function (humitureDetection, zsfs) {
  27. var params = [];
  28. params.vCfCode = humitureDetection.storehouse; // 仓房编码
  29. params.time = humitureDetection.time; // 检测时间
  30. params.intemp = humitureDetection.intemp; // 仓内温
  31. params.inh = humitureDetection.inh; // 仓内湿
  32. params.outtemp = humitureDetection.outtemp; // 仓外温
  33. params.outh = humitureDetection.outh; // 仓外湿
  34. params.max = humitureDetection.max; // 最高粮温
  35. params.min = humitureDetection.min; // 最低粮温
  36. params.avg = humitureDetection.avg; // 平均粮温
  37. params.id = humitureDetection.id;
  38. params.zsfs = zsfs;
  39. /*if (zsfs == "1") {
  40. $uibModal.open({
  41. size: 'lg',
  42. templateUrl: 'app/intelligent/grainDetection/views/humitureDetection-model2.html',
  43. controller: 'humitureDetectionModel2',
  44. resolve: {
  45. // 传入参数
  46. items: function () {
  47. // 这个值会被模态框的控制器获取到
  48. return params;
  49. }
  50. }
  51. });
  52. } else {
  53. $uibModal.open({
  54. size: 'lg',
  55. templateUrl: 'app/intelligent/grainDetection/views/humitureDetection-model.html',
  56. controller: 'humitureDetectionModel',
  57. resolve: {
  58. // 传入参数
  59. items: function () {
  60. // 这个值会被模态框的控制器获取到
  61. return params;
  62. }
  63. }
  64. });
  65. }*/
  66. var pageurl;
  67. var ctrlurl;
  68. if (zsfs == '1') {
  69. pageurl = 'app/intelligent/grainDetection/views/humitureDetection-model2.html';
  70. ctrlurl = 'humitureDetectionModel2';
  71. } else {
  72. pageurl = 'app/intelligent/grainDetection/views/humitureDetection-model.html';
  73. ctrlurl = 'humitureDetectionModel';
  74. }
  75. $uibModal.open({
  76. size: 'lg',
  77. templateUrl: pageurl,
  78. controller: ctrlurl,
  79. resolve: {
  80. // 传入参数
  81. items: function () {
  82. // 这个值会被模态框的控制器获取到
  83. return params;
  84. }
  85. }
  86. });
  87. }
  88. // 所有仓检测
  89. $scope.allStoreGrainTemperatureDetection = function () {
  90. if (!confirm("您确认发送粮温全库检测请求!")) {
  91. return;
  92. }
  93. $scope.stopEvent = $interval(function () {
  94. $scope.updateTime = 1;
  95. $scope.loadData();
  96. }, 1000 * 60 * 3, -1);
  97. // 检测类型0测温,1粮油,2测水分
  98. temperatureRecordService.allStoreGrainTemperatureDetection('0').then(function (data) {
  99. if (data.retCode === '200' && data.message === 'success') {
  100. if (data.data === '3232302D46696C') {
  101. alert("无法连接到设备!");
  102. return;
  103. }
  104. alert(data.data);
  105. }
  106. }, function (data) {
  107. console.log(data);
  108. });
  109. };
  110. // 单仓检测
  111. $scope.onlyStoreGrainTemperatureDetection = function (storehouse) {
  112. if (!confirm("您确认检测" + $rootScope.storeHouseCodeObj[storehouse].storehouseName + "粮温!")) {
  113. return;
  114. }
  115. $scope.stopEvent = $interval(function () {
  116. $scope.updateTime = 1;
  117. $scope.loadData();
  118. }, 1000 * 60 * 1, -1);
  119. // 检测类型0测温,1粮油,2测水分
  120. temperatureRecordService.onlyStoreDetection(storehouse, '0').then(function (data) {
  121. if (data.retCode === '200' && data.message === 'success') {
  122. if (data.data === '3232302D46696C') {
  123. alert("无法连接到设备!");
  124. return;
  125. }
  126. alert(data.data);
  127. }
  128. }, function (data) {
  129. console.log(data);
  130. });
  131. };
  132. $scope.getCompareDate = function CompareDate(d1, d2) {
  133. //将所有的短横线替换为斜杠
  134. return ((new Date(d1.replace(/-/g, "\/"))) >= (new Date(d2.replace(/-/g, "\/"))));
  135. }
  136. // 清空搜索时间
  137. $scope.emptyTime = function () {
  138. $scope.search.time = '';
  139. $scope.search.vCfCode = '';
  140. $scope.loadData();
  141. };
  142. // 翻页
  143. $scope.goPage = function (pageNum) {
  144. if ($scope.pageInfo.pageNum !== pageNum && pageNum > 0) {
  145. $scope.pageInfo.pageNum = pageNum;
  146. $scope.loadData();
  147. }
  148. };
  149. });