Compare commits

..

No commits in common. "2d18527b96319ab9f0971abff4b9c81b0663cb6b" and "63542bef08d4fd11c2197747927a0a4e17feff23" have entirely different histories.

7 changed files with 66 additions and 178 deletions

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,37 +41,7 @@ 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,8 +24,6 @@ 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 {
@ -34,7 +32,6 @@ 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
@ -249,10 +246,9 @@ export default class UdpClientByCenter {
callback({
id, length, body: list, sendId: this.sendId
})
this.interval=setInterval(()=>{
// this.interval=setInterval(()=>{
//
// },3000)
},3000)
});
}
@ -307,40 +303,18 @@ 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.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
// this.stashFn=()=>{}
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
@ -354,8 +328,6 @@ 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(() => {
@ -369,19 +341,14 @@ 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,7 +41,12 @@ 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,9 +101,6 @@ 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,deleteAllFIleLog } from '../common/service/indexService';
import { getliushuiNum, setliushuiNum, takePhotoFn } 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,7 +421,6 @@ struct Index {
}
async initParams() {
deleteAllFIleLog()
//设置plc udp 同步requesthost
await getUDP(this.context, false)
this.loading = false
@ -447,13 +446,9 @@ struct Index {
this.heartMsg()
}
const data=AppStorage.Get('errorMsg'); // returns 47
console.log('1123',data,globalThis.type)
console.log('1123',data)
if(data==1){
if(globalThis.type=='3'&&!globalThis.dialogOpen){
globalThis.dialogOpen=true
}else if(globalThis.type=='1'){
this.errorDialog.open()
}
this.errorDialog.open()
}
}, 1000)
//下载模型

View File

@ -72,7 +72,6 @@ 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 = ''
@ -120,7 +119,6 @@ struct UserInfo {
)
async onPageShow() {
this.updateTimeLimit=false
this.ksksLimit=false
console.log('响应头地址响应头地址')
const mediaTest = new FilePhoto(this.context);
this.filePhoto = new FilePhoto(this.context);
@ -130,47 +128,39 @@ struct UserInfo {
this.initData()
//身份证读卡器初始化
// this.openDeviceByIDCard()
const routerParam=router.getParams()||{type :0};
console.log('routerParam',JSON.stringify(routerParam))
// @ts-ignore
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))
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)
}
})
}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
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)
}
}
this.list.forEach((res,index)=>{
res.id=index.toString()
})
await upDateTableByArray('USERLIST', this.list||[])
}else{
this.getExaminationStudentInfoFn()
}
}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||[])
// 如果是单机模式则模拟假数据
//获取sysset表数据
@ -363,6 +353,7 @@ struct UserInfo {
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId
}
globalThis.udpClient2.sendMsgExt(param, this.context)
}
@ -524,7 +515,6 @@ struct UserInfo {
qkFn() {
this.faceCompareSucess = 0
this.ksksLimit=false
if (globalThis.singlePlay) {
this.qkFlag = false
return
@ -626,7 +616,6 @@ struct UserInfo {
kString:keystr || ''
}
}, router.RouterMode.Single);
this.updateTimeLimit=false
this.stopDeviceById()
this.stepFlag = false
})
@ -893,10 +882,6 @@ struct UserInfo {
Image($r('app.media.qk_btn'))
.commStyle()
.onClick(() => {
if(this.ksksLimit){
return
}
this.ksksLimit=true
this.qkFlag = true
})
@ -921,10 +906,6 @@ 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
@ -932,8 +913,6 @@ struct UserInfo {
if (!this.currentUser.xm) {
return
}
this.ksksLimit=true
if (globalThis.singlePlay) {
const {examSubject} = globalThis.carInfo;
this.currentUser.id='0'
@ -945,8 +924,6 @@ struct UserInfo {
kfdm: this.sczbkf,
}
}, router.RouterMode.Single);
this.ksksLimit=false
this.stopDeviceById()
return
}
@ -986,7 +963,6 @@ struct UserInfo {
}
.commStyle()
.onClick(() => {
this.ksksLimit=false
this.qkFlag = false
})

View File

@ -5,26 +5,36 @@ export default struct errorMsgDialog {
}
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)
.fontSize(30)
.margin(120)
}
if (this.type=='3') {
Row() {
Button('取消')
.onClick(() => {
if (this.controller != undefined) {
this.confirm()
this.controller.close()
}
})
.margin(20)
Button('确定')
.onClick(() => {
if (this.controller != undefined) {
this.cancel()
this.controller.close()
}
})
.margin(20)
}
}
if (this.type=='2') {
Image($r('app.media.open_loading'))
@ -40,38 +50,6 @@ export default struct errorMsgDialog {
})
.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 })