Compare commits

...

2 Commits

Author SHA1 Message Date
f61ec2bc2e 外殼問題修改 2024-08-20 09:12:02 +08:00
05f31c4b7c 合并 2024-08-19 14:56:36 +08:00
8 changed files with 300 additions and 44 deletions

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License,Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default class
CommonConstants {
/**
* Rdb database config.
*/
static readonly STORE_CONFIG = { name: 'USERLIST.db' };
/**
* Account table config.
*/
static readonly ACCOUNT_TABLE = {
tableName: 'USERLIST',
sqlCreate: 'CREATE TABLE IF NOT EXISTS USERLIST(id TEXT,sfzmhm TEXT,xm CHAR(20), lsh TEXT, kszp TEXT,ksdd TEXT,kssycs TEXT,kslx TEXT,kscx TEXT,ksxl TEXT,ksy1 TEXT)',
columns: ['id','sfzmhm','xm','lsh','kszp','ksdd','kssycs','kslx','kscx','ksxl','ksy1']
};
/**
* Search text of Search component.
*/
// static readonly SEARCH_TEXT = '搜索';
/**
* toast text of prompt component.
*/
// static readonly TOAST_TEXT_1 = '账目类型不能为空';
// static readonly TOAST_TEXT_2 = '账目金额不为正整数';
/**
* Component size.
*/
// static readonly FULL_WIDTH = '100%';
// static readonly FULL_HEIGHT = '100%';
// static readonly DIALOG_HEIGHT = '55%';
// static readonly TABS_HEIGHT = '45%';
// static readonly MINIMUM_SIZE = 0;
// static readonly FULL_SIZE = 1;
// static readonly PROMPT_BOTTOM = '70vp';
/**
* Component location.
*/
// static readonly EDIT_POSITION_X = '80%';
// static readonly EDIT_POSITION_Y = '90%';
// static readonly DELETE_POSITION_X = '50%';
// static readonly DELETE_POSITION_Y = '90%';
/**
* Log tag.
*/
static readonly RDB_TAG = '[Debug.Rdb]';
static readonly TABLE_TAG = '[Debug.AccountTable]';
static readonly INDEX_TAG = '[Debug.Index]';
}

View File

@ -16,7 +16,7 @@ import {
} from '../../common/service/initable'
import { GlobalConfig } from '../../config/index'
import testNapi from '@ohos.hiserialsdk'
import fs from '@ohos.file.fs';
let num = 0
export async function getliushuiNum(context) {
@ -41,7 +41,37 @@ export async function getliushuiNum(context) {
// return str
}
}
export async function deleteAllFIleLog(){
let options = {
"recursion": false,
"listNum": 0,
};
let filenames = fs.listFileSync(GlobalConfig.comoonfileWriteAddress+'/PLC/', options);
console.info("listFile succeed",JSON.stringify(filenames));
for (let i = 0; i < filenames.length; i++) {
if(isSevenDaysAgo(filenames[i])){
fs.rmdir(GlobalConfig.comoonfileWriteAddress+'/PLC/'+filenames[i], (err) => {
if (err) {
console.error("rmdir failed with error message: " + err.message + ", error code: " + err.code);
} else {
console.info("rmdir succeed");
}
});
}
// console.info("filename: %s", filenames[i]);
}
}
function isSevenDaysAgo(date) {
const today = new Date(); // 当前日期
const target = new Date(date); // 需要判断的日期
const diff = today.getTime() - target.getTime(); // 计算两个日期之间的毫秒数差异
const diffDays = diff / (1000 * 60 * 60 * 24); // 将毫秒转换为天数
// 如果差异天数正好是7则原日期是当前日期的前七天
return diffDays > 7;
}
//配置流水号
export async function setliushuiNum(context) {
const fileUtil = new FileUtil(context)

View File

@ -24,6 +24,8 @@ import hilog from '@ohos.hilog';
import prompt from '@ohos.prompt'
import promptAction from '@ohos.promptAction';
import { getUDP } from './GlobalUdp';
import { dateFormat } from '../utils/tools'
import { formatTime } from '../../../chengmai/ets/common/utils/tools';
export default class UdpClientByCenter {
@ -32,6 +34,7 @@ export default class UdpClientByCenter {
private oppositeIp: string = ''
private oppositeIpPort: string = ''
private udpMsg: any = ''
private chafenFlag: number = 0
private num: number = 0
private fileUtil: FileUtil
private udp: UDPSocket = null
@ -246,9 +249,10 @@ export default class UdpClientByCenter {
callback({
id, length, body: list, sendId: this.sendId
})
this.interval=setInterval(()=>{
},3000)
// this.interval=setInterval(()=>{
//
// },3000)
});
}
@ -303,18 +307,40 @@ export default class UdpClientByCenter {
console.log(`${TAG} udp222 on message array buffer:${str}`);
strachArr[28] = globalThis.chuankoMsg || strachArr[28]
// this.stashFn(str)
const newArr = JSON.parse(JSON.stringify(strachArr))
// this.stashFn=()=>{}
this.writeLog({
time:dateFormat(new Date()),
PLC: JSON.stringify(newArr.toString()),
})
if(strachArr[83]!='4'){
this.chafenFlag++
if(this.chafenFlag>=15&&!globalThis.dialogOpen){
globalThis.title='差分状态异常'
globalThis.type='3'
AppStorage.SetOrCreate('errorMsg', 1);
}
}else{
globalThis.dialogOpen=false
}
this.chafenFlag=0
callback && callback(newArr.toString())
this.currentValue = newArr.toString();
} else {
callback && callback('')
}
console.log('messageTimeEnd')
this.testIfUdpConnetced(callback)
}
async writeLog(param){
const fileUtil = new FileUtil(globalThis.context)
const date=dateFormat(new Date).split(' ')[0]
const folderPath = await fileUtil.initFolder(`/PLC/${date}`);
fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`)
}
//获取当前UDP信号
getCurrentMessage = () => {
return this.currentValue
@ -328,6 +354,8 @@ export default class UdpClientByCenter {
const arrRedBuffer = Array2Byte(arrRed).buffer
const arrGreenBugger = Array2Byte(arrGreen).buffer
let num = 0
globalThis.dialogOpen=false
//监听udp是否断开
clearInterval(globalThis.messageTimer)
globalThis.messageTimer = setInterval(() => {
@ -341,14 +369,19 @@ export default class UdpClientByCenter {
console.log(TAG, 'plc udp信号丢失')
if (num == 3) {
getUDP(globalThis.context,true)
num = 0
}
globalThis.title='plc udp信号丢失'
globalThis.type='3'
if(!globalThis.dialogOpen){
AppStorage.SetOrCreate('errorMsg', 1);
}
prompt.showToast({
message: 'plc udp信号丢失',
duration: 2000
});
}
this.plcUdpError = true;
}, 2000)
}, 3000)

View File

@ -41,12 +41,7 @@ export default async function request(req: any) {
// let baseUrl=host?config.csptHost:config.host'
console.log('响应头地址' + baseUrl,url)
// writeLog({
// time:dateFormat(new Date()),
// url,
// extraData: JSON.stringify(data),
// state:'start'
// })
const {result,responseCode} = await httpRequest.request(`${baseUrl}${url}${paramsStr}`, options);
// fileUtil.editFile(`${folderPath}/request.txt`, JSON.stringify(arrList))
// writeLog({

View File

@ -101,6 +101,9 @@ export default struct Index {
}
router.pushUrl({
url: 'pages/UserInfo',
params:{
type:1
}
}, router.RouterMode.Single);
console.log('res11', JSON.stringify(res))

View File

@ -10,7 +10,7 @@ import FileUtil from '../common/utils/File';
import { getUDP, getUDP2 } from '../common/utils/GlobalUdp';
import { initJudgeUdp } from '../common/utils/UdpJudge';
import { getTCP } from '../common/utils/GlobalTcp';
import { getliushuiNum, setliushuiNum, takePhotoFn } from '../common/service/indexService';
import { getliushuiNum, setliushuiNum, takePhotoFn,deleteAllFIleLog } from '../common/service/indexService';
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
import worker, { MessageEvents } from '@ohos.worker';
import promptAction from '@ohos.promptAction'
@ -62,7 +62,7 @@ struct Index {
.height(69 * this.ratio * this.dialogRatio)
.backgroundImage($r('app.media.button_nor'))
.backgroundImageSize({ width: '100%', height: '100%' })
.margin({ bottom: 12 * this.ratio })
// .margin({ bottom: 12 * this.ratio })
}
build() {
@ -421,6 +421,7 @@ struct Index {
}
async initParams() {
deleteAllFIleLog()
//设置plc udp 同步requesthost
await getUDP(this.context, false)
this.loading = false
@ -446,9 +447,13 @@ struct Index {
this.heartMsg()
}
const data=AppStorage.Get('errorMsg'); // returns 47
console.log('1123',data)
console.log('1123',data,globalThis.type)
if(data==1){
this.errorDialog.open()
if(globalThis.type=='3'&&!globalThis.dialogOpen){
globalThis.dialogOpen=true
}else if(globalThis.type=='1'){
this.errorDialog.open()
}
}
}, 1000)
//下载模型

View File

@ -72,6 +72,7 @@ struct UserInfo {
@State signNum: number = 0;
@State isCanClick: boolean = true;
@State updateTimeLimit: boolean = false
@State ksksLimit: boolean = false
@State faceFlag: string = '0';
@State FaceOpenStatue: string = '0'; //是否开启人脸识别
@State faceCatchImg: string = ''
@ -119,6 +120,7 @@ struct UserInfo {
)
async onPageShow() {
this.updateTimeLimit=false
this.ksksLimit=false
console.log('响应头地址响应头地址')
const mediaTest = new FilePhoto(this.context);
this.filePhoto = new FilePhoto(this.context);
@ -128,39 +130,47 @@ struct UserInfo {
this.initData()
//身份证读卡器初始化
// this.openDeviceByIDCard()
const routerParam=router.getParams()||{type :0};
console.log('routerParam',JSON.stringify(routerParam))
// @ts-ignore
this.list =await getSyncData('USERLIST')
// @ts-ignore
const data=await getSyncData('USER')
console.log('datadata',JSON.stringify(data));
console.log('datadata2',JSON.stringify(this.list))
if(routerParam.type!=1){
// @ts-ignore
this.list =await getSyncData('USERLIST')
// @ts-ignore
const data=await getSyncData('USER')
console.log('datadata',JSON.stringify(data));
console.log('datadata2',JSON.stringify(this.list))
const user=data[0]
if(user&&Number(user.kssycs)){
this.list.forEach(res=>{
if(res.sfzmhm==user.sfzmhm){
res.kssycs=user.kssycs
this.getCurrentStudent(res.sfzmhm)
const user=data[0]
if(user&&Number(user.kssycs)){
this.list.forEach(res=>{
if(res.sfzmhm==user.sfzmhm){
res.kssycs=user.kssycs
this.getCurrentStudent(res.sfzmhm)
}
})
}else if(user&&(user.kssycs=='0'||user.kssycs=='')){
console.log('datadatadatadata')
this.list=this.list.filter(res=>{
return res.sfzmhm!=user.sfzmhm
})
this.pageIndex=0
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
if(this.dataList.length){
this.currentUser=this.dataList[0]
}else{
this.currentUser=EmptyCandidateObject
}
})
}else if(user&&(user.kssycs=='0'||user.kssycs=='')){
console.log('datadatadatadata')
this.list=this.list.filter(res=>{
return res.sfzmhm!=user.sfzmhm
})
this.pageIndex=0
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
if(this.dataList.length){
this.currentUser=this.dataList[0]
}else{
this.currentUser=EmptyCandidateObject
}
this.list.forEach((res,index)=>{
res.id=index.toString()
})
await upDateTableByArray('USERLIST', this.list||[])
}else{
this.getExaminationStudentInfoFn()
}
this.list.forEach((res,index)=>{
res.id=index.toString()
})
await upDateTableByArray('USERLIST', this.list||[])
// 如果是单机模式则模拟假数据
//获取sysset表数据
@ -353,7 +363,6 @@ struct UserInfo {
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId
}
globalThis.udpClient2.sendMsgExt(param, this.context)
}
@ -515,6 +524,7 @@ struct UserInfo {
qkFn() {
this.faceCompareSucess = 0
this.ksksLimit=false
if (globalThis.singlePlay) {
this.qkFlag = false
return
@ -616,6 +626,7 @@ struct UserInfo {
kString:keystr || ''
}
}, router.RouterMode.Single);
this.updateTimeLimit=false
this.stopDeviceById()
this.stepFlag = false
})
@ -882,6 +893,10 @@ struct UserInfo {
Image($r('app.media.qk_btn'))
.commStyle()
.onClick(() => {
if(this.ksksLimit){
return
}
this.ksksLimit=true
this.qkFlag = true
})
@ -906,6 +921,10 @@ struct UserInfo {
Image($r('app.media.ksks_btn'))
.commStyle()
.onClick(async () => {
if(this.ksksLimit){
return
}
console.log('routerParamrouterParam')
try {
await this.checkSignal()
this.faceCompareSucess = 0
@ -913,6 +932,8 @@ struct UserInfo {
if (!this.currentUser.xm) {
return
}
this.ksksLimit=true
if (globalThis.singlePlay) {
const {examSubject} = globalThis.carInfo;
this.currentUser.id='0'
@ -924,6 +945,8 @@ struct UserInfo {
kfdm: this.sczbkf,
}
}, router.RouterMode.Single);
this.ksksLimit=false
this.stopDeviceById()
return
}
@ -963,6 +986,7 @@ struct UserInfo {
}
.commStyle()
.onClick(() => {
this.ksksLimit=false
this.qkFlag = false
})

View File

@ -0,0 +1,98 @@
@CustomDialog
export default struct errorMsgDialog {
private controller?: CustomDialogController
cancel: () => void = () => {
}
confirm: () => void = () => {
}
dialogRatio:number=0.8
title?: string
type: string //1 tip 2loading 3Dialog
@State angle: number = 0
@Styles
commStyle(){
.width(220 * globalThis.ratio * this.dialogRatio )
.height(69 * globalThis.ratio * this.dialogRatio)
.backgroundImage($r('app.media.button_nor'))
.backgroundImageSize({ width: '100%', height: '100%' })
// .margin({ bottom: 12 * this.ratio })
}
build() {
Column() {
if(this.title){
Text(this.title)
.fontSize(30* this.dialogRatio)
.margin(120* this.dialogRatio)
}
if (this.type=='2') {
Image($r('app.media.open_loading'))
.width(200)
.rotate({ angle: this.angle })
.height(200)
.animation({
duration: 5000, // 动画时长
curve: Curve.EaseOut, // 动画曲线
delay: 500, // 动画延迟
iterations: -1, // 播放次数
playMode: PlayMode.Normal, // 动画模式
})
.margin(50)
}
if (this.type=='3') {
Row() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(' 取 消 ')
.fontSize(24 * globalThis.ratio* this.dialogRatio )
.fontColor('#fff')
.width(100 * globalThis.ratio* this.dialogRatio)
}
.commStyle()
.onClick(() => {
if (this.controller != undefined) {
this.cancel()
this.controller.close()
}
}).margin({ right: 10 * globalThis.ratio * this.dialogRatio})
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(' 确 定 ')
.fontSize(24 * globalThis.ratio* this.dialogRatio)
.fontColor('#fff')
.width(100 * globalThis.ratio* this.dialogRatio)
}
.commStyle()
.onClick(() => {
if (this.controller != undefined){
this.confirm()
this.controller.close()
}
})
}
}
}.backgroundColor('#E6E3DF')
.borderRadius(19 * globalThis.ratio)
.constraintSize({ minWidth: 520 })
}
aboutToAppear() {
AppStorage.SetOrCreate('errorMsg', 0);
setTimeout(() => {
console.log('this.type',this.type,this.angle)
if (this.type=='2') {
this.angle = 360
}
},1000)
if(this.type=='1'){
setTimeout(()=>{
this.controller.close()
},2000)
}
}
aboutToDisappear() {
this.title=''
this.angle = 0
}
}