2 Commits 0f84ba424d ... 6fbc5110c8

Autor SHA1 Mensagem Data
  ximinghao 6fbc5110c8 Merge branch 'master' of http://47.103.92.60:3003/skyversation/qp_onemap_ui 3 semanas atrás
  ximinghao b6b88eabdd 补充几个接口 3 semanas atrás
1 arquivos alterados com 37 adições e 7 exclusões
  1. 37 7
      src/api/count.js

+ 37 - 7
src/api/count.js

@@ -1,8 +1,8 @@
 import {
-    postform,get
+    postform, get
 } from '../utils/request'
 
-const dmsPath = systemConfig.dmsDataProxy 
+const dmsPath = systemConfig.dmsDataProxy
 
 const oauthPath = systemConfig.oauthServiceUrl
 
@@ -222,6 +222,7 @@ export function totalCount(start, end) {
 
     return resolveDmsMultiTableResult(postform(multiSearch, data));
 }
+
 export function totalCountGroupByTime(start, end) {
     let data = {
         "columnId": preCountDmsId,
@@ -238,7 +239,7 @@ export function totalCountGroupByTime(start, end) {
             }, {
                 "table": "precount",
                 "column": "c_date",
-                "alias":"time"
+                "alias": "time"
             }
         ]),
         "groupBy": JSON.stringify([
@@ -254,9 +255,28 @@ export function totalCountGroupByTime(start, end) {
 
     return resolveDmsMultiTableResult(postform(multiSearch, data));
 }
-export function countUserData(){
-        return resolveoauthResult(get(oauthCountUser))
+
+export function countUserData() {
+    return resolveoauthResult(get(oauthCountUser))
+}
+export function countUserDataByTime(time1, time2, time3) {
+    let data = {
+        "time": JSON.stringify([
+            {
+                name: "last",
+                start: formatDateToDb(time1),
+                end: formatDateToDb(time2)
+            },
+            {
+                name: "this",
+                start: formatDateToDb(time2),
+                end: formatDateToDb(time3)
+            },
+        ])
+    }
+    return resolveoauthResult(postform(oauthCountUser, data))
 }
+
 function timeCheckers(start, end) {
     let output = []
     if (start != null) {
@@ -299,7 +319,7 @@ async function resolveDmsMultiTableResult(result) {
     } else if (result.code == 202) {
         return [];
     } else {
-        return null;
+        throw new Error(result.message)
     }
 }
 async function resolveoauthResult(result) {
@@ -307,6 +327,16 @@ async function resolveoauthResult(result) {
     if (result.code == 200) {
         return result.content
     } else {
-        return null;
+        throw new Error(result.message)
     }
+}
+function formatDateToDb(date) {
+  const year = date.getFullYear();
+  const month = String(date.getMonth() + 1).padStart(2, '0');
+  const day = String(date.getDate()).padStart(2, '0');
+  const hours = String(date.getHours()).padStart(2, '0');
+  const minutes = String(date.getMinutes()).padStart(2, '0');
+  const seconds = String(date.getSeconds()).padStart(2, '0');
+  
+  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
 }