Merge pull request 'lv_chengmai' (#38) from lv_chengmai into main
Reviewed-on: #38
This commit is contained in:
commit
b987bac5f0
@ -3,20 +3,22 @@ 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, deleteAllFileByPiC } from '../../common/service/videoService'
|
||||
import AccountTable from '../../common/database/tables/AccountTable'
|
||||
import MA_SYSSET from '../../common/constants/MA_SYSSET'
|
||||
import { takePhoto } from '../../common/service/videoService'
|
||||
|
||||
import {
|
||||
getDataBaseTable,
|
||||
upDateTable,
|
||||
getMySystemSetTable,
|
||||
delSyncTable,
|
||||
upDataZhongxinginitialization
|
||||
getDataBaseTable,
|
||||
getMySystemSetTable,
|
||||
upDataZhongxinginitialization,
|
||||
upDateTable
|
||||
} 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)
|
||||
@ -39,6 +41,7 @@ export async function getliushuiNum(context){
|
||||
// return str
|
||||
}
|
||||
}
|
||||
|
||||
//配置流水号
|
||||
export async function setliushuiNum(context) {
|
||||
const fileUtil = new FileUtil(context)
|
||||
@ -78,21 +81,11 @@ export async function setliushuiNum(context) {
|
||||
export async function getDoubleCeneterTable(param) {
|
||||
return new Promise(async (reslove, reject) => {
|
||||
// MA_SYSSET双中心下做合并表格操作
|
||||
const db = new AccountTable(() => {
|
||||
}, MA_SYSSET);
|
||||
db.getRdbStore(() => {
|
||||
db.query('0', async (array) => {
|
||||
if (array.length) {
|
||||
delSyncTable('MA_SYSSET').then(async () => {
|
||||
delSyncTable('MA_SYSSET', param.context).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,
|
||||
@ -130,6 +123,7 @@ export async function getDoubleCeneterTable(param) {
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//单中心存表
|
||||
export async function getSingleCenterTable(param) {
|
||||
return new Promise((reslove, reject) => {
|
||||
@ -259,8 +253,10 @@ export async function takePhotoFn(context) {
|
||||
}
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
let fd
|
||||
const devPath = "/dev/ttyS3"
|
||||
|
||||
function openChuankouFn(callback) {
|
||||
console.log('SerialOpen in indexservice, path=' + devPath)
|
||||
|
||||
@ -323,7 +319,9 @@ function getChuankouFnMsg() {
|
||||
// let revTestInfo = testNapi?.SerialRecv(globalThis.fd, timeout);
|
||||
|
||||
}
|
||||
|
||||
let chuankou
|
||||
|
||||
export async function getChuankouFn() {
|
||||
if (globalThis.fd) {
|
||||
return
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import data_rdb from '@ohos.data.rdb';
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import { initCenterCache,initCenterCacheByKSPT,initEsModel,initialization } from '../../api/index'
|
||||
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';
|
||||
@ -23,12 +21,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
|
||||
//读表
|
||||
//参数平台
|
||||
@ -79,7 +77,7 @@ const centerToMap={
|
||||
// 'ES_CAR_VIDEO_PARAMETER':ES_CAR_VIDE0pO_PARAMETER
|
||||
}
|
||||
|
||||
function sqlInsertCommonFn(tableName,resultArr,context?){
|
||||
function sqlInsertCommonFn(tableName, resultArr, context?, delFlag = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const accountTable = new AccountTable(() => {
|
||||
}, map[tableName], context);
|
||||
@ -113,7 +111,9 @@ function sqlInsertCommonFn(tableName,resultArr,context?){
|
||||
})
|
||||
}
|
||||
else {
|
||||
if (delFlag) {
|
||||
await delSyncTable(tableName, context)
|
||||
}
|
||||
const result = await sqlInsertCommonFn(tableName, resultArr, context)
|
||||
resolve(result)
|
||||
}
|
||||
@ -121,17 +121,10 @@ function sqlInsertCommonFn(tableName,resultArr,context?){
|
||||
}, context);
|
||||
})
|
||||
}
|
||||
|
||||
//参数平台
|
||||
export async function getDataBaseTable(params, reqParam) {
|
||||
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 {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const date = new Date()
|
||||
if (!reqParam?.paraKdid) {
|
||||
prompt.showToast({
|
||||
@ -153,46 +146,22 @@ 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) => {
|
||||
@ -258,7 +227,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).then((result)=>{
|
||||
sqlInsertCommonFn(params.tableName, res.body[params.tableName], reqParam.context, false).then((result) => {
|
||||
resolve(result)
|
||||
})
|
||||
})
|
||||
@ -390,6 +359,7 @@ export async function upDataZhongxinginitialization(param){
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function setSyncCenterSqlData(key, res, param) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const mapName = {
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
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.getCloseTcp){
|
||||
if (globalThis.TcpClient && globalThis.TcpClient.closeTcp) {
|
||||
globalThis.TcpClient.closeTcp(async () => {
|
||||
// const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
|
||||
// globalThis.TcpClient = tcpClient
|
||||
@ -68,7 +69,8 @@ export async function getTCP() {
|
||||
|
||||
} else {
|
||||
globalThis.TcpClient = {}
|
||||
globalThis.TcpClient.onMessage=()=>{}
|
||||
globalThis.TcpClient.onMessage = () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
import socket from '@ohos.net.socket';
|
||||
import buffer from '@ohos.buffer';
|
||||
import hilog from '@ohos.hilog';
|
||||
|
||||
const TAG = 'socketTag[TcpDemo.TcpClient]'
|
||||
import prompt from '@ohos.prompt'
|
||||
import hilog from '@ohos.hilog';
|
||||
|
||||
export default class TcpClient {
|
||||
private localIp: string = ''
|
||||
@ -21,6 +19,7 @@ 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))
|
||||
@ -34,6 +33,7 @@ export default class TcpClient {
|
||||
// })
|
||||
});
|
||||
}
|
||||
|
||||
rebindTcp(localIp: string, localIpPort: string, oppositeIp: string, oppositeIpPort: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.localIp = localIp
|
||||
@ -41,7 +41,9 @@ 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));
|
||||
@ -61,10 +63,13 @@ 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
|
||||
@ -87,10 +92,15 @@ 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({
|
||||
@ -113,6 +123,7 @@ export default class TcpClient {
|
||||
globalThis.getCloseTcp = true
|
||||
setTimeout(() => {
|
||||
this.connectTcp()
|
||||
resolve(false)
|
||||
}, 2000)
|
||||
console.log('testTagconnect,error')
|
||||
|
||||
@ -153,11 +164,13 @@ 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')
|
||||
|
||||
@ -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;25: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"
|
||||
const data = str.split(';')
|
||||
this.checkList = []
|
||||
const list = data
|
||||
@ -166,7 +166,7 @@ export default struct Index {
|
||||
|
||||
getPLCInfo() {
|
||||
const that = this
|
||||
globalThis.udpClient && globalThis.udpClient.onMessage_1((msg) => {
|
||||
globalThis.udpClient.onMessage_1 && globalThis.udpClient.onMessage_1((msg) => {
|
||||
if (!this.breakFlag) {
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user