|
@@ -2,12 +2,14 @@ import Cursor from 'android.database.Cursor';
|
|
|
import SQLiteDatabase from 'android.database.sqlite.SQLiteDatabase';
|
|
import SQLiteDatabase from 'android.database.sqlite.SQLiteDatabase';
|
|
|
import SQLiteOpenHelper from 'android.database.sqlite.SQLiteOpenHelper';
|
|
import SQLiteOpenHelper from 'android.database.sqlite.SQLiteOpenHelper';
|
|
|
import Environment from 'android.os.Environment';
|
|
import Environment from 'android.os.Environment';
|
|
|
|
|
+//import { globalConfig } from '@/config';
|
|
|
|
|
|
|
|
import { createSQLiteContextOptions, executeSqlOptions, selectSqlOptions, executeSqlOptionsResult, selectSqlOptionsResult, CreateSQLiteContext, transactionOptions, transactionResult, ICreateSQLiteContextError } from '../interface.uts';
|
|
import { createSQLiteContextOptions, executeSqlOptions, selectSqlOptions, executeSqlOptionsResult, selectSqlOptionsResult, CreateSQLiteContext, transactionOptions, transactionResult, ICreateSQLiteContextError } from '../interface.uts';
|
|
|
//import { createSQLiteContextOptions, executeSqlOptions, selectSqlOptions, transactionOptions } from '../interface.uts';
|
|
//import { createSQLiteContextOptions, executeSqlOptions, selectSqlOptions, transactionOptions } from '../interface.uts';
|
|
|
import { createSQLiteContextFailImpl } from '../unierror.uts';
|
|
import { createSQLiteContextFailImpl } from '../unierror.uts';
|
|
|
|
|
|
|
|
class SQLiteContext extends SQLiteOpenHelper {
|
|
class SQLiteContext extends SQLiteOpenHelper {
|
|
|
|
|
+
|
|
|
private dbName : string | null;
|
|
private dbName : string | null;
|
|
|
private forceRecreateTables : boolean;
|
|
private forceRecreateTables : boolean;
|
|
|
|
|
|
|
@@ -343,7 +345,7 @@ class SQLiteContext extends SQLiteOpenHelper {
|
|
|
|
|
|
|
|
// 插入初始数据
|
|
// 插入初始数据
|
|
|
console.log("Inserting initial data into app_user table");
|
|
console.log("Inserting initial data into app_user table");
|
|
|
- const insertDataSQLs = [
|
|
|
|
|
|
|
+ let insertDataSQLs = [
|
|
|
`INSERT INTO "app_user" ("id", "username", "name", "userno", "password", "token", "status", "avatar", "createtime", "createuser", "updatetime", "updateuser", "role")
|
|
`INSERT INTO "app_user" ("id", "username", "name", "userno", "password", "token", "status", "avatar", "createtime", "createuser", "updatetime", "updateuser", "role")
|
|
|
VALUES (1, 'admin', '管理员', 1, 'admin123', 'token1', 1, NULL, NULL, 1, NULL, 1, 'admin');`,
|
|
VALUES (1, 'admin', '管理员', 1, 'admin123', 'token1', 1, NULL, NULL, 1, NULL, 1, 'admin');`,
|
|
|
|
|
|
|
@@ -362,8 +364,31 @@ class SQLiteContext extends SQLiteOpenHelper {
|
|
|
`INSERT INTO "app_user" ("id", "username", "name", "userno", "password", "token", "status", "avatar", "createtime", "createuser", "updatetime", "updateuser", "role")
|
|
`INSERT INTO "app_user" ("id", "username", "name", "userno", "password", "token", "status", "avatar", "createtime", "createuser", "updatetime", "updateuser", "role")
|
|
|
VALUES (6, 'luyongjun', '陆永俊', 6, '123456', 'token1', 1, NULL, NULL, 1, NULL, 1, 'user');`
|
|
VALUES (6, 'luyongjun', '陆永俊', 6, '123456', 'token1', 1, NULL, NULL, 1, NULL, 1, 'user');`
|
|
|
];
|
|
];
|
|
|
|
|
+ let testBizData = [
|
|
|
|
|
+ `INSERT INTO "app_media_info" ("pdid", "workorder", "invname", "productno", "cardno", "model", "graphid", "ver", "phase", "processno", "progress", "status", "createtime", "createuser", "updatetime", "updateuser", "uploadFlag", "uploadtime") VALUES (1, '632-P-01', '箱间段', 'YH0001', 'LK20230707070012', NULL, '1CFA1040-02', NULL, NULL, 'Pb/XXX-E11', '0/2', 1, NULL, '1', '2025-06-23', '1', 0, NULL);`,
|
|
|
|
|
+ `INSERT INTO "app_media_record" ("sxid", "senum", "photoitem", "productno", "part", "partno", "pk", "exampleid", "descb", "num", "status", "date", "urlspl", "imgname", "urlpdt", "createtime", "createuser", "updatetime", "updateuser", "pid", "uploadFlag") VALUES (1, '1', '前底-外侧', 'YH0001', '角焊缝', 'TD10-01', '1', NULL, '角片角焊缝', 2, 1, '2025-06-05', '/static/images/demo.png,/static/images/demo.png', '', '', NULL, '1', NULL, '1', 1, 0);`,
|
|
|
|
|
+ `INSERT INTO "app_media_record" ("sxid", "senum", "photoitem", "productno", "part", "partno", "pk", "exampleid", "descb", "num", "status", "date", "urlspl", "imgname", "urlpdt", "createtime", "createuser", "updatetime", "updateuser", "pid", "uploadFlag") VALUES (2, '1', '后底-外侧', 'YH0001', '角焊缝', 'TD10-02', '2', NULL, '角片角焊缝', 3, 1, '2025-06-05', '/static/images/demo.png,/static/images/demo.png,/static/images/demo.png', '', '', NULL, '1', NULL, '1', 1, 0);`,
|
|
|
|
|
+ `INSERT INTO "app_task_info" ("pdid", "gxpk", "pk_serial", "cardno", "productcode", "model", "workorder", "invname", "graphid", "processno", "gxno", "ver", "lastupdatetime", "updateuser", "uploadFlag", "uploadtime") VALUES (1, 'PI02297172', '1b93d201-8430-41a4-b462-4bbedef28cab', 'LK202407290121G01', 'YHZJ240442TD', '718', '718-SY-YZ-03', '一层段', '1020#S', 'Pb/1020-E7', '230检验', 'B.1', NULL, NULL, 0, NULL);`,
|
|
|
|
|
+ `INSERT INTO "app_task_record" ("sxid", "pdid", "pk", "fk_invcode", "no", "invcode", "invname", "processStep", "fk_processTask", "checkTarget", "checknum", "oknum", "ngnum", "status", "result", "checkTime", "fk_creator", "cs", "ts") VALUES (1, 1, 'af90ef8a-9979-42d7-9a2e-3b3a6ecfe3cb', '1002N11000000012X3K8', '检验工序_LK202407290121G01_23', '1020', '一层段', '230检验', 'PI02297172', '检验工序', 1, 1, 0, '已检验', '合格', '2024-09-29 09:45:21', '060080000199', '2024-09-29 09:41:56', '2024-09-29 09:45:21');`,
|
|
|
|
|
+ `INSERT INTO "app_task_record_item" ("sxid", "psxid", "pk", "fk_qcRecord", "fk_prodcode", "prodno", "name", "no", "nature", "unit", "maxNum", "minNum", "status", "memo", "measuredvalue", "measuredvaluemax", "result", "cs", "ts", "recorder") VALUES (1, 1, 'f50678b6898446d088686f4be3e06a4c', 'af90ef8a-9979-42d7-9a2e-3b3a6ecfe3cb', '76697df1-5058-40f3-b753-855a53caf2c3', 'YHZJ240442TD', '位置', '1', '定性', '-', NULL, NULL, '有效', '相互位置', '0', NULL, '0', '2024-09-29 09:41:56', '2024-09-29 09:45:21', NULL);`,
|
|
|
|
|
+ `INSERT INTO "app_task_record_item" ("sxid", "psxid", "pk", "fk_qcRecord", "fk_prodcode", "prodno", "name", "no", "nature", "unit", "maxNum", "minNum", "status", "memo", "measuredvalue", "measuredvaluemax", "result", "cs", "ts", "recorder") VALUES (2, 1, 'b76126adad9f466e9e1cb74dfbf9ad56', 'af90ef8a-9979-42d7-9a2e-3b3a6ecfe3cb', '76697df1-5058-40f3-b753-855a53caf2c3', 'YHZJ240442TD', '装配间隙', '2', '定量', 'mm', NULL, NULL, '有效', '装配间隙', '0.3', NULL, '0', '2024-09-29 09:41:56', '2024-09-29 09:45:21', NULL);`,
|
|
|
|
|
+ `INSERT INTO "app_task_record_item" ("sxid", "psxid", "pk", "fk_qcRecord", "fk_prodcode", "prodno", "name", "no", "nature", "unit", "maxNum", "minNum", "status", "memo", "measuredvalue", "measuredvaluemax", "result", "cs", "ts", "recorder") VALUES (3, 1, '3d060a2a314f4f23b0e19dc318950fec', 'af90ef8a-9979-42d7-9a2e-3b3a6ecfe3cb', '76697df1-5058-40f3-b753-855a53caf2c3', 'YHZJ240442TD', '错边量', '3', '定量', 'mm', NULL, NULL, '有效', '错边量', '0.3', NULL, '0', '2024-09-29 09:41:56', '2024-09-29 09:45:21', NULL);`,
|
|
|
|
|
+ `INSERT INTO "app_task_record_item" ("sxid", "psxid", "pk", "fk_qcRecord", "fk_prodcode", "prodno", "name", "no", "nature", "unit", "maxNum", "minNum", "status", "memo", "measuredvalue", "measuredvaluemax", "result", "cs", "ts", "recorder") VALUES (4, 1, '47c321d7a1fc4c44a688b2c270cda83e', 'af90ef8a-9979-42d7-9a2e-3b3a6ecfe3cb', '76697df1-5058-40f3-b753-855a53caf2c3', 'YHZJ240442TD', '对齐', '4', '定量', 'mm', NULL, NULL, '有效', '网格对齐', '0', NULL, '0', '2024-09-29 09:41:56', '2024-09-29 09:45:21', NULL);`,
|
|
|
|
|
+ `INSERT INTO "app_task_record_item" ("sxid", "psxid", "pk", "fk_qcRecord", "fk_prodcode", "prodno", "name", "no", "nature", "unit", "maxNum", "minNum", "status", "memo", "measuredvalue", "measuredvaluemax", "result", "cs", "ts", "recorder") VALUES (5, 1, '535e0a2805b04d409054beac2f9f2c09', 'af90ef8a-9979-42d7-9a2e-3b3a6ecfe3cb', '76697df1-5058-40f3-b753-855a53caf2c3', 'YHZJ240442TD', '对中偏移量', '5', '定量', 'mm', NULL, NULL, '有效', '对中偏移量', '0', NULL, '0', '2024-09-29 09:41:56', '2024-09-29 09:45:21', NULL);`,
|
|
|
|
|
+ `INSERT INTO "app_media_task" ("id", "pid", "name", "num", "step", "status", "createtime", "createuser", "updatetime", "updateuser") VALUES (1, 1, '前底-外侧', 5, 5, 3, NULL, 1, NULL, 1);`,
|
|
|
|
|
+ `INSERT INTO "app_media_task" ("id", "pid", "name", "num", "step", "status", "createtime", "createuser", "updatetime", "updateuser") VALUES (2, 1, '后底-外侧', 3, 3, 4, NULL, 1, NULL, 1);`,
|
|
|
|
|
+ `INSERT INTO "app_media_task" ("id", "pid", "name", "num", "step", "status", "createtime", "createuser", "updatetime", "updateuser") VALUES (3, 1, '简段-外侧', 12, 2, 2, NULL, 1, NULL, 1);`,
|
|
|
|
|
+ `INSERT INTO "app_product_task" ("id", "pid", "name", "num", "step", "status", "createtime", "createuser", "updatetime", "updateuser") VALUES (1, 1, '前底-外侧', 5, 5, 3, NULL, 1, NULL, 1);`,
|
|
|
|
|
+ `INSERT INTO "app_product_task" ("id", "pid", "name", "num", "step", "status", "createtime", "createuser", "updatetime", "updateuser") VALUES (2, 1, '后底-外侧', 3, 3, 4, NULL, 1, NULL, 1);`,
|
|
|
|
|
+ `INSERT INTO "app_product_task" ("id", "pid", "name", "num", "step", "status", "createtime", "createuser", "updatetime", "updateuser") VALUES (3, 1, '简段-外侧', 12, 2, 2, NULL, 1, NULL, 1);`,
|
|
|
|
|
+ `INSERT INTO "app_task_keyprocess" ("sxid", "pdid", "pk", "testapparatus", "tableid", "testrequirelower", "testrequireupper", "parametername", "parameterorder", "measureunit", "parameterinstruction", "parameterid", "fk_creator", "fk_prodcode", "prodno", "processstep", "fk_processtask", "measuredvaluemin", "measuredvaluemax", "result", "memo", "fks_operator", "cs", "ts", "operator") VALUES (1, 1, '9e3903b8a0654220aa511d912fca146a', '螺纹环规(6h)', '16026721389362', '定性(只能编辑上限值)', NULL, '螺纹', '1', '/', '外螺纹', '188418860506145', '060080003348', 'e2eca140-55d5-42db-b9a6-347ea3d5c8cf', 'WQ01202505000160-1', '30车削', 'b7d8fcc5dc0640f387c7c9e99e8cf88a', '合格', '合格', NULL, NULL, '060080003348', '2025-09-26 08:23:26', '2025-09-26 14:42:38', NULL);`,
|
|
|
|
|
+ `INSERT INTO "app_task_keyprocess" ("sxid", "pdid", "pk", "testapparatus", "tableid", "testrequirelower", "testrequireupper", "parametername", "parameterorder", "measureunit", "parameterinstruction", "parameterid", "fk_creator", "fk_prodcode", "prodno", "processstep", "fk_processtask", "measuredvaluemin", "measuredvaluemax", "result", "memo", "fks_operator", "cs", "ts", "operator") VALUES (2, 1, '9d153531d48c4161ba34932826856800', '游标卡尺(0-200mm)', '16026721389362', '5.8', NULL, '长度', '2', 'mm', '螺纹长度', '439121372420532', '060080003348', 'e2eca140-55d5-42db-b9a6-347ea3d5c8cf', 'WQ01202505000160-1', '30车削', 'b7d8fcc5dc0640f387c7c9e99e8cf88a', '5.8', '5.81', NULL, NULL, '060080003348', '2025-09-26 08:23:26', '2025-09-26 14:42:38', NULL);`
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ ];
|
|
|
|
|
+ const mergeDataSQLs = insertDataSQLs.concat(testBizData);
|
|
|
|
|
|
|
|
- for (const sql of insertDataSQLs) {
|
|
|
|
|
|
|
+ for (const sql of mergeDataSQLs) {
|
|
|
try {
|
|
try {
|
|
|
// 使用INSERT OR IGNORE避免重复插入
|
|
// 使用INSERT OR IGNORE避免重复插入
|
|
|
const safeSql = sql.replace("INSERT INTO", "INSERT OR IGNORE INTO");
|
|
const safeSql = sql.replace("INSERT INTO", "INSERT OR IGNORE INTO");
|