Compare commits

..

No commits in common. "b987bac5f0f442da6008ee7de44cd097a2995eb8" and "23ea400ee392e31ec84f5dcd148abeef9555bc3c" have entirely different histories.

5 changed files with 460 additions and 443 deletions

View File

@ -3,22 +3,20 @@ import promptAction from '@ohos.promptAction'
import router from '@ohos.router'
import { dateFormat } from '../utils/tools'
import FileUtil from '../../common/utils/File'
import AccountTable from '../../common/database/tables/AccountTable'
import MA_SYSSET from '../../common/constants/MA_SYSSET'
import { takePhoto } from '../../common/service/videoService'
import AccountTable from '../../common/database/tables/AccountTable';
import MA_SYSSET from '../../common/constants/MA_SYSSET';
import { takePhoto, deleteAllFileByPiC } from '../../common/service/videoService'
import {
delSyncTable,
getDataBaseTable,
upDateTable,
getMySystemSetTable,
upDataZhongxinginitialization,
upDateTable
delSyncTable,
upDataZhongxinginitialization
} from '../../common/service/initable'
import { GlobalConfig } from '../../config/index'
import testNapi from '@ohos.hiserialsdk'
let num=0
export async function getliushuiNum(context){
console.log('getLiushuihao')
const fileUtil = new FileUtil(context)
@ -41,7 +39,6 @@ export async function getliushuiNum(context) {
// return str
}
}
//配置流水号
export async function setliushuiNum(context) {
const fileUtil = new FileUtil(context)
@ -81,11 +78,21 @@ export async function setliushuiNum(context) {
export async function getDoubleCeneterTable(param) {
return new Promise(async (reslove, reject) => {
// MA_SYSSET双中心下做合并表格操作
delSyncTable('MA_SYSSET', param.context).then(async () => {
const db = new AccountTable(() => {
}, MA_SYSSET);
db.getRdbStore(() => {
db.query('0', async (array) => {
if (array.length) {
delSyncTable('MA_SYSSET').then(async () => {
await getDataBaseTable({ tableName: 'MA_SYSSET' },param)
await getMySystemSetTable({ tableName: 'MA_SYSSET' },param)
})
} else {
await getDataBaseTable({ tableName: 'MA_SYSSET' },param)
await getMySystemSetTable({ tableName: 'MA_SYSSET' },param)
}
})
},param.context)
const typeObj = {
'MA_MARKRULE': false,
'MA_SYSTEMPARM': false,
@ -123,7 +130,6 @@ export async function getDoubleCeneterTable(param) {
})
}
//单中心存表
export async function getSingleCenterTable(param) {
return new Promise((reslove, reject) => {
@ -253,10 +259,8 @@ export async function takePhotoFn(context) {
}
}, 3000)
}
let fd
const devPath="/dev/ttyS3"
function openChuankouFn(callback) {
console.log('SerialOpen in indexservice, path=' + devPath)
@ -319,9 +323,7 @@ function getChuankouFnMsg() {
// let revTestInfo = testNapi?.SerialRecv(globalThis.fd, timeout);
}
let chuankou
export async function getChuankouFn(){
if(globalThis.fd){
return

View File

@ -1,5 +1,7 @@
// @ts-nocheck
import { initCenterCache, initCenterCacheByKSPT, initEsModel, initialization } from '../../api/index';
import data_rdb from '@ohos.data.rdb';
import UIAbility from '@ohos.app.ability.UIAbility';
import { initCenterCache,initCenterCacheByKSPT,initEsModel,initialization } from '../../api/index'
import { dateFormat } from '../utils/tools';
import AccountTable from '../database/tables/AccountTable';
import MA_MARKRULE from '../constants/MA_MARKRULE';
@ -21,12 +23,12 @@ import MA_ITEMINFO from '../constants/MA_ITEMINFO';
import MA_T_CARPARMSET from '../constants/MA_T_CARPARMSET';
import ES_CAR_VIDEO_PARAMETER from '../constants/ES_CAR_VIDEO_PARAMETER';
import IpConfigTable from '../constants/IpConfigTable';
import CommonConstants from '../constants/CommonConstants';
import DeviceInfoTable from '../constants/DeviceInfoTable';
import USER from '../constants/USER';
import CommonConstants from '../constants/CommonConstants'
import DeviceInfoTable from '../constants/DeviceInfoTable'
import USER from '../constants/USER'
import util from '@ohos.util';
import zlib from '@ohos.zlib';
import FileModel from '../../pages/judgeSDK/utils/fileModel';
// @ts-nocheck
//读表
//参数平台
@ -77,7 +79,7 @@ const centerToMap = {
// 'ES_CAR_VIDEO_PARAMETER':ES_CAR_VIDE0pO_PARAMETER
}
function sqlInsertCommonFn(tableName, resultArr, context?, delFlag = true) {
function sqlInsertCommonFn(tableName,resultArr,context?){
return new Promise((resolve,reject)=>{
const accountTable = new AccountTable(() => {
}, map[tableName],context);
@ -111,9 +113,7 @@ function sqlInsertCommonFn(tableName, resultArr, context?, delFlag = true) {
})
}
else {
if (delFlag) {
await delSyncTable(tableName,context)
}
const result= await sqlInsertCommonFn(tableName,resultArr,context)
resolve(result)
}
@ -121,10 +121,17 @@ function sqlInsertCommonFn(tableName, resultArr, context?, delFlag = true) {
},context);
})
}
//参数平台
export async function getDataBaseTable(params,reqParam) {
return new Promise(async (resolve, reject) => {
return new Promise((resolve, reject) => {
const accountTable = new AccountTable(() => {
}, map[params.tableName],context);
accountTable.getRdbStore(() => {
accountTable.query('0', async (result) => {
if (result.length != 0) {
resolve();
return
} else {
const date = new Date()
if(!reqParam?.paraKdid){
prompt.showToast({
@ -146,22 +153,46 @@ export async function getDataBaseTable(params, reqParam) {
resolve();
return
}
let INSERT_SQL = "INSERT INTO "+params.tableName
+ " ("+ map[params.tableName].ACCOUNT_TABLE.columns.toString()+") VALUES "
if(params.tableName=='MA_SYSSET'){
res.body[params.tableName]= res.body[params.tableName].filter(res=>{
return res['v_no']>=300&&res['v_no']<=700
})
}
sqlInsertCommonFn(param.tableName, res.body[params.tableName]).then((val) => {
reslove(val)
res.body[params.tableName].map((data,i) => {
// data.id=`${i}`
data.id=i
let str='('
map[params.tableName].ACCOUNT_TABLE.columns.map((res,index)=>{
if(map[params.tableName].ACCOUNT_TABLE.columns.length-1==index){
str+=data[res]?`"${data[res]}"`:'NULL'
}else{
str+=(data[res]?`"${data[res]}"`:'NULL')+','
}
})
if(i==res.body[params.tableName].length-1){
str+=')'
}else{
str+='),'
}
INSERT_SQL+=str
})
accountTable.sqlOperate(INSERT_SQL,params.tableName,()=>{
resolve(true)
})
}
}, true);
},reqParam.context);
})
}
//依据数组和表名更新sql表
export async function upDateTableByArray(tableName,arr) {
sqlInsertCommonFn(tableName,arr)
}
//更新双中心表
export async function upDateTable(params,reqParam) {
return new Promise((resolve, reject) => {
@ -227,7 +258,7 @@ export async function getMySystemSetTable(params, reqParam) {
return res['v_no']<300 || res['v_no']>700
})
}
sqlInsertCommonFn(params.tableName, res.body[params.tableName], reqParam.context, false).then((result) => {
sqlInsertCommonFn(params.tableName,res.body[params.tableName],reqParam.context).then((result)=>{
resolve(result)
})
})
@ -359,7 +390,6 @@ export async function upDataZhongxinginitialization(param) {
})
})
}
function setSyncCenterSqlData(key,res,param){
return new Promise((resolve,reject)=>{
const mapName={

View File

@ -1,13 +1,12 @@
import TcpClient from './TcpClient';
import { getSyncData } from '../service/initable';
import { getSyncData} from '../service/initable'
import hilog from '@ohos.hilog';
export async function getTCP() {
getSyncData('IpConfigTable').then(async (result:Array<any>)=>{
console.log('result222',JSON.stringify(result))
if(result.length){
if (globalThis.TcpClient && globalThis.TcpClient.closeTcp) {
if(globalThis.TcpClient&&globalThis.getCloseTcp){
globalThis.TcpClient.closeTcp(async ()=>{
// const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
// globalThis.TcpClient = tcpClient
@ -69,8 +68,7 @@ export async function getTCP() {
}else{
globalThis.TcpClient={}
globalThis.TcpClient.onMessage = () => {
}
globalThis.TcpClient.onMessage=()=>{}
}
})
}

View File

@ -1,7 +1,9 @@
import socket from '@ohos.net.socket';
import hilog from '@ohos.hilog';
import buffer from '@ohos.buffer';
const TAG = 'socketTag[TcpDemo.TcpClient]'
import prompt from '@ohos.prompt'
import hilog from '@ohos.hilog';
export default class TcpClient {
private localIp: string = ''
@ -19,7 +21,6 @@ export default class TcpClient {
console.log(TAG,'new Tcp',this.localIp,this.localIpPort,this.oppositeIp,this.oppositeIpPort)
this.tcp = socket.constructTCPSocketInstance();
}
onError(callback?){
this.tcp.on('error', err => {
console.log(TAG,'tcpOnerror', JSON.stringify(err))
@ -33,7 +34,6 @@ export default class TcpClient {
// })
});
}
rebindTcp(localIp: string, localIpPort:string,oppositeIp: string,oppositeIpPort:string){
return new Promise((resolve, reject)=>{
this.localIp = localIp
@ -41,9 +41,7 @@ export default class TcpClient {
this.localIpPort = localIpPort
this.oppositeIpPort = oppositeIpPort
console.log(TAG,'tcpreBind', this.localIp,this.localIpPort)
let promise = this.tcp.bind({
address: this.localIp, port: parseInt(this.localIpPort), family: 1
}, err => {
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => {
if (err) {
globalThis.getCloseTcp=true
hilog.info(0x0000, 'testTag', "tcpreBinderror:" + JSON.stringify(err));
@ -63,13 +61,10 @@ export default class TcpClient {
// });
}
bindTcp() {
console.log(TAG,'tcpbind',this.localIp,'localIp',this.localIpPort)
return new Promise((resolve,reject)=>{
let promise = this.tcp.bind({
address: this.localIp, port: parseInt(this.localIpPort), family: 1
}, err => {
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => {
if (err) {
console.log('testTag tcp bind faile');
globalThis.getCloseTcp=true
@ -92,15 +87,10 @@ export default class TcpClient {
}
connectTcp(){
console.log(TAG,'tcpConnect',this.oppositeIp,'localIp',this.oppositeIpPort)
return new Promise((resolve,reject)=>{
let promise = this.tcp.connect({
address: {
address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1
}, timeout: 6000
});
let promise = this.tcp.connect({ address: {address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1} , timeout: 6000});
promise.then(() => {
this.tcp.setExtraOptions({
@ -123,7 +113,6 @@ export default class TcpClient {
globalThis.getCloseTcp=true
setTimeout(()=>{
this.connectTcp()
resolve(false)
},2000)
console.log('testTagconnect,error')
@ -164,13 +153,11 @@ export default class TcpClient {
// callback(value.message)
});
}
offTcp(callback) {
console.log(TAG,'tcpofff')
this.tcp.off('testTagofmessg', callback);
}
closeTcp(callback) {
return new Promise((reslove,reject)=>{
console.log(TAG,'tcpClose')

View File

@ -111,7 +111,7 @@ export default struct Index {
carConfigurationInfoFn() {
if (globalThis.singlePlay) {
//
const str = "1:5;2:5;3:5;4:5;5:5;6:5;7:5;8:5;9:5;10:5;11:5;12:5;13:5;14:5;15:5;16:5;17:5;18:5;19:5;20:5;21:5;22:2;23:5;24:5"
const str = "1:5;2:5;3:5;4:5;5:5;6:5;7:5;8:5;9:5;10:5;11:5;12:5;13:5;14:5;15:5;16:5;17:5;18:5;19:5;20:5;21:5;22:2;23:5;24:5;25:5;"
const data = str.split(';')
this.checkList = []
const list = data
@ -166,7 +166,7 @@ export default struct Index {
getPLCInfo() {
const that = this
globalThis.udpClient.onMessage_1 && globalThis.udpClient.onMessage_1((msg) => {
globalThis.udpClient && globalThis.udpClient.onMessage_1((msg) => {
if (!this.breakFlag) {
return
}