Browse Source

登录和退出登录逻辑修改。ip修改。

jiaxiaoqiang 8 months ago
parent
commit
088c094724

+ 2 - 2
build-profile.json5

@@ -22,9 +22,9 @@
         "name": "default",
         "material": {
           "certpath": "C:/Users/Administrator/.ohos/config/openharmony/default_xf-ohos_X8TOyHb28yqSkBeeCoAe5D77NG67SlqdwI214NdhMP0=.cer",
-          "storePassword": "0000001B099379D1077D0D21F63B0F354F09A095D0FC7583A8C53EF285F76241509C088A3C0385F6DCB0F8",
+          "storePassword": "0000001B07F227F5BB46C31F3383D164E612D40EFB2D1A5BDB8BA553CE4759E92B35F757BB0319F9377BFA",
           "keyAlias": "debugKey",
-          "keyPassword": "0000001B14013BBCC22566BC6CB95E9BC0B2BEA11851A71EF1DEC364113A80AF935345A223EDA21C9CF8BA",
+          "keyPassword": "0000001B78F507ACA350630BF903A6A5FAAAFA243E1195EFF442777358C19F27B66A08768D5C5DB5A70D95",
           "profile": "C:/Users/Administrator/.ohos/config/openharmony/default_xf-ohos_X8TOyHb28yqSkBeeCoAe5D77NG67SlqdwI214NdhMP0=.p7b",
           "signAlg": "SHA256withECDSA",
           "storeFile": "C:/Users/Administrator/.ohos/config/openharmony/default_xf-ohos_X8TOyHb28yqSkBeeCoAe5D77NG67SlqdwI214NdhMP0=.p12"

+ 21 - 6
entry/src/main/ets/common/component/TitleStateComp.ets

@@ -6,6 +6,8 @@ import UniversalCard from '../../model/UniversalCard'
 import process from '@ohos.process'
 import { RfidAllocation } from '../../pages/RfidAllocation'
 import NoticeInfo from '../../model/NoticeInfo'
+import UserInfo from '../../model/UserInfo'
+import UserAuthModel from '../../model/database/UserAuthModel'
 
 /*
  * 顶部状态栏
@@ -240,12 +242,9 @@ struct login {
           .backgroundColor('#0A59F7')
           .textAlign(TextAlign.Center)
           .fontColor('#ffff')
-          .onClick(() => {
-            this.controller.close()
-            CommonConstants.LOGIN_OUT = true
-            router.replaceUrl({
-              url: 'pages/LoginPage'
-            })
+          .onClick(async  () => {
+            this.goOut()
+
 
           })
       }
@@ -258,6 +257,22 @@ struct login {
     .borderRadius(15)
     .backgroundColor('#ffff')
   }
+
+
+  goOut = async  () => {
+    this.controller.close()
+
+    let userInfo = await UserAuthModel.getLast()
+    if (userInfo) {
+      userInfo.isLogin = false
+      UserAuthModel.updateUser(userInfo)
+    }
+
+    router.replaceUrl({
+      url: 'pages/LoginPage'
+    })
+  }
+
 }
 
 //头像点击弹窗

+ 14 - 7
entry/src/main/ets/common/util/request/EquipmentRequest.ets

@@ -1,11 +1,18 @@
-import axios, { AxiosError, AxiosResponse, AxiosRequestHeaders,AxiosRequestConfig, CreateAxiosDefaults,InternalAxiosRequestConfig } from '@ohos/axios';
+import axios, {
+  AxiosError,
+  AxiosResponse,
+  AxiosRequestHeaders,
+  AxiosRequestConfig,
+  CreateAxiosDefaults,
+  InternalAxiosRequestConfig
+} from '@ohos/axios';
 import CommonConstants from '../../constants/CommonConstants';
 //import PreferencesUtil from '../PreferencesUtil';
 import { printError, printRequest, printResponse, handleRes } from './Helps';
 
 //const baseUrl = "http://192.168.137.5:8000/"
 // const baseUrl = "http://0.0.0.0:8000/"
-const baseUrl = "http://10.88.19.120:8000/"
+const baseUrl = "http://10.88.20.120:8000/"
 const DEBUG = true //
 
 // 创建实例
@@ -28,13 +35,13 @@ JGRequest.interceptors.request.use((config: InternalAxiosRequestConfig) => {
   printRequest(config)
 
   return config;
-}, (error:AxiosError) => {
+}, (error: AxiosError) => {
   // 对请求错误做些什么
   printError(error)
   return Promise.reject(error);
 });
 // 添加响应拦截器
-JGRequest.interceptors.response.use((response: AxiosResponse)=> {
+JGRequest.interceptors.response.use((response: AxiosResponse) => {
   // 对响应数据做点什么
   printResponse(response)
 
@@ -44,8 +51,8 @@ JGRequest.interceptors.response.use((response: AxiosResponse)=> {
   // console.log('textTag'+"handleRes的返回结果 ", success, msg)
 
   if (success) {
-  //  console.log('textTag'+"handleRes的返回结果 ", JSON.stringify(response.data))
-   // return response.data.data;
+    //  console.log('textTag'+"handleRes的返回结果 ", JSON.stringify(response.data))
+    // return response.data.data;
     return response.data;
   }
   else {
@@ -53,7 +60,7 @@ JGRequest.interceptors.response.use((response: AxiosResponse)=> {
 
   }
 
-}, (error:AxiosError)=> {
+}, (error: AxiosError) => {
   // 对响应错误做点什么
   printError(error)
 

+ 14 - 6
entry/src/main/ets/common/util/request/Request.ets

@@ -1,11 +1,18 @@
-import axios, { AxiosError, AxiosResponse, AxiosRequestHeaders,AxiosRequestConfig, CreateAxiosDefaults,InternalAxiosRequestConfig } from '@ohos/axios';
+import axios, {
+  AxiosError,
+  AxiosResponse,
+  AxiosRequestHeaders,
+  AxiosRequestConfig,
+  CreateAxiosDefaults,
+  InternalAxiosRequestConfig
+} from '@ohos/axios';
 import CommonConstants from '../../constants/CommonConstants';
 //import PreferencesUtil from '../PreferencesUtil';
 import { printError, printRequest, printResponse, handleRes } from './Helps';
 
- // const baseUrl = "http://121.41.179.41:8079/"
+// const baseUrl = "http://121.41.179.41:8079/"
 //const baseUrl = "http://10.88.19.200:8079/"
-const baseUrl = "http://10.88.19.222:8079/"
+const baseUrl = "http://10.88.11.200:8079/"
 const DEBUG = true //
 
 // 创建实例
@@ -28,13 +35,13 @@ JGRequest.interceptors.request.use((config: InternalAxiosRequestConfig) => {
   printRequest(config)
 
   return config;
-}, (error:AxiosError) => {
+}, (error: AxiosError) => {
   // 对请求错误做些什么
   printError(error)
   return Promise.reject(error);
 });
 // 添加响应拦截器
-JGRequest.interceptors.response.use((response: AxiosResponse)=> {
+JGRequest.interceptors.response.use((response: AxiosResponse) => {
   // 对响应数据做点什么
   printResponse(response)
 
@@ -50,12 +57,13 @@ JGRequest.interceptors.response.use((response: AxiosResponse)=> {
     return Promise.reject<string>(msg)
   }
 
-}, (error:AxiosError)=> {
+}, (error: AxiosError) => {
   // 对响应错误做点什么
   printError(error)
 
   return Promise.reject(error);
 });
+
 // // 添加响应拦截器
 // JGRequest.interceptors.response.use((response: AxiosResponse)=> {
 //   // 对响应数据做点什么

+ 18 - 10
entry/src/main/ets/common/util/request/StorageRequest.ets

@@ -1,10 +1,17 @@
-import axios, { AxiosError, AxiosResponse, AxiosRequestHeaders,AxiosRequestConfig, CreateAxiosDefaults,InternalAxiosRequestConfig } from '@ohos/axios';
+import axios, {
+  AxiosError,
+  AxiosResponse,
+  AxiosRequestHeaders,
+  AxiosRequestConfig,
+  CreateAxiosDefaults,
+  InternalAxiosRequestConfig
+} from '@ohos/axios';
 import CommonConstants from '../../constants/CommonConstants';
 import { printError, printRequest, printResponse, handleRes } from './Helps';
 
- // const baseUrl = "http://121.41.179.41:8079/"
+// const baseUrl = "http://121.41.179.41:8079/"
 //const baseUrl = "http://10.88.19.200:8079/"
-const baseUrl = "http://10.88.19.222:8079/"
+const baseUrl = "http://10.88.11.200:8079/"
 const DEBUG = true //
 
 // 创建实例
@@ -24,10 +31,10 @@ StorageRequest.interceptors.request.use((config: InternalAxiosRequestConfig) =>
 
   // 以后登录之后可以在这里传
   config.headers.Authorization = CommonConstants.AUTH_TOKEN
- // config.headers.Authorization ="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOnsiaWQiOjM3LCJsb2dpblR5cGUiOiJhaW8ifSwiZGV2aWNlIjoiYWlvIiwiZWZmIjoxNzE3NTExMjYwODI4LCJyblN0ciI6InRSenNBTGdlZ3lqS0FHeDZTSkdYZTNLbFY3eWh1OG1PIn0.FVAeESiz_PH1NtBFDmGZr0IwtXzubV2d8JTQdGdJnxc"
+  // config.headers.Authorization ="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOnsiaWQiOjM3LCJsb2dpblR5cGUiOiJhaW8ifSwiZGV2aWNlIjoiYWlvIiwiZWZmIjoxNzE3NTExMjYwODI4LCJyblN0ciI6InRSenNBTGdlZ3lqS0FHeDZTSkdYZTNLbFY3eWh1OG1PIn0.FVAeESiz_PH1NtBFDmGZr0IwtXzubV2d8JTQdGdJnxc"
   printRequest(config)
   return config;
-}, (error:AxiosError) => {
+}, (error: AxiosError) => {
   // 对请求错误做些什么
   printError(error)
   return Promise.reject(error);
@@ -35,13 +42,13 @@ StorageRequest.interceptors.request.use((config: InternalAxiosRequestConfig) =>
 
 
 // 添加响应拦截器
-StorageRequest.interceptors.response.use((response: AxiosResponse)=> {
+StorageRequest.interceptors.response.use((response: AxiosResponse) => {
   console.log("testTag", "---------------------------")
   // 对响应数据做点什么
   printResponse(response)
-    let res = handleRes(response)
-    let success = res[0] as boolean
-    let msg = res[1] as string
+  let res = handleRes(response)
+  let success = res[0] as boolean
+  let msg = res[1] as string
   console.debug("handleRes的返回结果 ", success, msg)
 
   if (success) {
@@ -51,12 +58,13 @@ StorageRequest.interceptors.response.use((response: AxiosResponse)=> {
     return Promise.reject<string>(msg)
   }
 
-}, (error:AxiosError)=> {
+}, (error: AxiosError) => {
   // 对响应错误做点什么
   printError(error)
 
   return Promise.reject(error);
 });
+
 export default StorageRequest;
 
 

+ 2 - 0
entry/src/main/ets/model/UserAuthInfo.ets

@@ -22,4 +22,6 @@ export default class UserAuthInfo {
   updateTime?: number;
   // 用户头像
   avatar?: string;
+
+  isLogin?:boolean //是否是登录的状态
 }

+ 10 - 7
entry/src/main/ets/pages/LoginPage.ets

@@ -89,12 +89,12 @@ struct LoginPage {
       }
     }
 
-    if (CommonConstants.LOGIN_OUT) {
-      if (userInfo) {
-        this.loginName = userInfo.userName ? userInfo.userName : ''
-        this.password = userInfo.password ? userInfo.password : ''
+    if (userInfo) {
+      this.loginName = userInfo.userName ? userInfo.userName : ''
+      this.password = userInfo.password ? userInfo.password : ''
+      if (!userInfo.isLogin) {
+        return
       }
-      return
     }
 
     if (userInfo && userInfo.maintainLoginStatus === 1) {
@@ -113,6 +113,7 @@ struct LoginPage {
         CommonConstants.USER_AVATAR = user.avatar!
         CommonConstants.USER_AVATAR = user.avatar!
         CommonConstants.LOGIN_OUT = false
+        CommonConstants.STATION_CODE = user.stationCode!
       }
       if (CommonConstants.AUTH_TOKEN && CommonConstants.AUTH_TOKEN.length > 0) {
         if (CommonConstants.stationDictValue === '5') {
@@ -408,7 +409,8 @@ struct LoginPage {
                 stationDictValue: this.workstation?.stationDictValue ? this.workstation.stationDictValue! : '',
                 avatar: userInfo.avatar,
                 maintainLoginStatus: 1,
-                updateTime: new Date().getTime()
+                updateTime: new Date().getTime(),
+                isLogin: true,
               }
               let res = await UserAuthModel.addUser(user)
               res = await AssistantSetModel.addAssistantSet({
@@ -417,7 +419,8 @@ struct LoginPage {
                 timbre: 2,
                 wakeFree: 2,
                 promptBroadcast: 1,
-                voiceVolume: 0
+                voiceVolume: 0,
+
               })
             }
             CommonConstants.LOGIN_OUT = false

+ 16 - 5
entry/src/main/ets/pages/SmartFactory.ets

@@ -1271,11 +1271,7 @@ struct login {
           .textAlign(TextAlign.Center)
           .fontColor('#ffff')
           .onClick(() => {
-            this.controller.close()
-            CommonConstants.LOGIN_OUT = true
-            router.replaceUrl({
-              url: 'pages/LoginPage'
-            })
+            this.goOut()
 
           })
       }
@@ -1288,6 +1284,21 @@ struct login {
     .borderRadius(15)
     .backgroundColor('#ffff')
   }
+
+  goOut = async () => {
+    this.controller.close()
+    CommonConstants.LOGIN_OUT = true
+
+    let userInfo = await UserAuthModel.getLast()
+    if (userInfo) {
+      userInfo.isLogin = false
+      UserAuthModel.updateUser(userInfo)
+    }
+
+    router.replaceUrl({
+      url: 'pages/LoginPage'
+    })
+  }
 }
 
 @CustomDialog

+ 18 - 3
entry/src/main/ets/pages/WarehouseMap.ets

@@ -98,7 +98,7 @@ export struct WarehouseMap {
   @State storeyNumber: number = -1
   @State private storey: number[] = [6, 5, 4, 3, 2, 1]
   @State private YAxis: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
-  @State private XAxis: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
+  @State private XAxis: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]
   @State private XYxis: number[][] = [
     [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 6, 0, 6, 6],
     [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 6, 0, 6, 6],
@@ -166,13 +166,28 @@ export struct WarehouseMap {
   getStorageXYData = async () => {
     let result: number[][] = await StorageRequest.post("/api/v1/wms/position/lineInfo/")
 
-    this.XYxis = result
+    let doubleArray: number[][] = []
+    // let arrOne: number[] = []
+    result.forEach((level1) => {
+      let arrTwo: number[] = []
+
+      level1.forEach((value) => {
+        if (arrTwo.length < 20) {
+          arrTwo.push(value)
+        }
+      })
+
+      doubleArray.push(arrTwo)
+    })
+    // doubleArray.push(arrOne)
+
+    this.XYxis = doubleArray
 
 
   }
 
   aboutToAppear(): void {
-    this.getStorageXYData()
+    // this.getStorageXYData()
 
     this.CarPositionHttp().then((res: carPositionClass) => {
 

+ 13 - 7
entry/src/main/ets/view/CompleteSet.ets

@@ -109,12 +109,12 @@ export struct CompleteSet {
   @State private TasklistoutboundData: Array<Tasklist> = []
   //扫码控制器
   textController: TextInputController = new TextInputController()
-  //硬件出库位置
-  locationRequest = async (): Promise<stat3> => {
-    let res: stat3 = await EquipmentRequest.get("api/v1/wcs/stat/stat3")
-    console.log('testTag1' + '-------------' + JSON.stringify(res))
-    return res
-  }
+  // //硬件出库位置
+  // locationRequest = async (): Promise<stat3> => {
+  //   let res: stat3 = await EquipmentRequest.get("api/v1/wcs/stat/stat3")
+  //   console.log('testTag1' + '-------------' + JSON.stringify(res))
+  //   return res
+  // }
   // 通过RFID请求读取料箱的信息
   rfidTimer: number = -1
   @State private recentlyRecordObject: StationInfoModel = {}
@@ -130,7 +130,13 @@ export struct CompleteSet {
     this.materialGridStatus = 0
     if (this.recentlyRecordObject && this.recentlyRecordObject.rfid) {
       this.materialGridStatus = 1
-      this.recentlyRecordObject.weight = this.recentlyRecordObject.weight + 'Kg'
+      if (this.recentlyRecordObject.weight) {
+        this.recentlyRecordObject.weight = this.recentlyRecordObject.weight + 'Kg'
+      }
+      else {
+        this.recentlyRecordObject.weight = '0 Kg'
+
+      }
     }
   }
   //扫码请求

+ 19 - 6
entry/src/main/ets/view/UserInfoSetView.ets

@@ -232,12 +232,8 @@ export struct UserInfoSetView {
           .textAlign(TextAlign.Center)
           .backgroundColor('#0f000000')
           .onClick(() => {
-            CommonConstants.AUTH_TOKEN = ''
-            CommonConstants.USER_ID = 0
-            CommonConstants.LOGIN_OUT = true
-            router.replaceUrl({
-              url: 'pages/LoginPage'
-            })
+            this.goOut()
+
           })
         Blank()
       }
@@ -384,5 +380,22 @@ export struct UserInfoSetView {
     .height('100%')
     .backgroundColor('#F1F3F5')
   }
+
+  goOut = async () => {
+
+    CommonConstants.AUTH_TOKEN = ''
+    CommonConstants.USER_ID = 0
+    CommonConstants.LOGIN_OUT = true
+
+    let userInfo = await UserAuthModel.getLast()
+    if (userInfo) {
+      userInfo.isLogin = false
+      UserAuthModel.updateUser(userInfo)
+    }
+
+    router.replaceUrl({
+      url: 'pages/LoginPage'
+    })
+  }
 }