You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2018-10-18 09:00:54,334 INFO 15542 egg-sequelize Executed (default): CREATE TABLE IF NOT EXISTS cashier_printer_config (id INTEGER auto_increment UNIQUE , admin_id VARCHAR(20) NOT NULL, json_config VARCHAR(2000) NOT NULL, modify_time DATETIME NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;
2018-10-18 09:00:54,336 INFO 15542 egg-sequelize Executed (default): SHOW INDEX FROM cashier_printer_config
2018-10-18 09:00:54,348 INFO 15542 egg-sequelize Executed (default): INSERT INTO cashier_printer_config (id,admin_id,json_config,modify_time) VALUES (186,'A882080','{"printMode":"manual","state":1,"deviceType":"wifi"}','2018-10-18 09:00:54') ON DUPLICATE KEY UPDATE admin_id=VALUES(admin_id), id=VALUES(id), json_config=VALUES(json_config), modify_time=VALUES(modify_time);
2018-10-18 09:00:54,335 INFO 15541 egg-sequelize Executed (default): CREATE TABLE IF NOT EXISTS cashier_printer_config (id INTEGER auto_increment UNIQUE , admin_id VARCHAR(20) NOT NULL, json_config VARCHAR(2000) NOT NULL, modify_time DATETIME NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;
2018-10-18 09:00:54,337 INFO 15541 egg-sequelize Executed (default): SHOW INDEX FROM cashier_printer_config
2018-10-18 09:00:54,339 INFO 15541 egg-sequelize Executed (default): SELECT id, admin_id AS adminId, json_config AS jsonConfig, modify_time AS modifyTime, modify_time FROM cashier_printer_config AS cashier_printer_config WHERE cashier_printer_config.admin_id = 'A882080';
结果还是:
[{"id":186,"config":{"printMode":"auto","state":1,"deviceType":"wifi"}}]
2018-10-18 09:02:49,889 INFO 15542 egg-sequelize Executed (default): CREATE TABLE IF NOT EXISTS cashier_printer_config (id INTEGER auto_increment UNIQUE , admin_id VARCHAR(20) NOT NULL, json_config VARCHAR(2000) NOT NULL, modify_time DATETIME NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;
2018-10-18 09:02:49,890 INFO 15542 egg-sequelize Executed (default): SHOW INDEX FROM cashier_printer_config
2018-10-18 09:02:49,892 INFO 15542 egg-sequelize Executed (default): SELECT id, admin_id AS adminId, json_config AS jsonConfig, modify_time AS modifyTime, modify_time FROM cashier_printer_config AS cashier_printer_config WHERE cashier_printer_config.admin_id = 'A882080';
过一会查就正常了
[{"id":186,"config":{"printMode":"manual","state":1,"deviceType":"wifi"}}]
The text was updated successfully, but these errors were encountered:
public async updateConfig(param: IPrinterConfigParam) {
await this.ctx.model.CashierPrinterConfig.sync();
if (param && param.id) {
// 修改
await this.ctx.model.CashierPrinterConfig.upsert({
adminId: param.adminId,
id: param.id,
jsonConfig: param.configJson,
});
} else {
// 新增;
let printerConfig: PlainObject[] = [];
// 查询所有记录
const sqlIntstance = await this.ctx.model.CashierPrinterConfig.findAll({
where: {
adminId: param.adminId,
},
});
if (sqlIntstance) {
sqlIntstance.map(ins => {
let temp = (ins as PlainObject).dataValues;
// 判断当前设备是否已经保存过 deviceNo key
let tempJson = JSON.parse(temp.jsonConfig);
let newJson = JSON.parse(param.configJson);
if (tempJson.deviceNo === newJson.deviceNo && tempJson.key === newJson.key) {
printerConfig.push(temp);
}
});
// 不存在记录
if (printerConfig.length == 0) {
await this.ctx.model.CashierPrinterConfig.create({
adminId: param.adminId,
jsonConfig: param.configJson,
});
} else {
await this.ctx.model.CashierPrinterConfig.upsert({
adminId: param.adminId,
id: printerConfig[0].id,
jsonConfig: param.configJson,
});
}
}
}
}
public async getConfigByAmdinId(adminId: string) {
console.log('getConfigByAmdinId', adminId);
let printerConfig: PlainObject[] = [];
}
2018-10-18 09:00:54,334 INFO 15542 egg-sequelize Executed (default): CREATE TABLE IF NOT EXISTS
cashier_printer_config
(id
INTEGER auto_increment UNIQUE ,admin_id
VARCHAR(20) NOT NULL,json_config
VARCHAR(2000) NOT NULL,modify_time
DATETIME NOT NULL, PRIMARY KEY (id
)) ENGINE=InnoDB;2018-10-18 09:00:54,336 INFO 15542 egg-sequelize Executed (default): SHOW INDEX FROM
cashier_printer_config
2018-10-18 09:00:54,348 INFO 15542 egg-sequelize Executed (default): INSERT INTO
cashier_printer_config
(id
,admin_id
,json_config
,modify_time
) VALUES (186,'A882080','{"printMode":"manual","state":1,"deviceType":"wifi"}','2018-10-18 09:00:54') ON DUPLICATE KEY UPDATEadmin_id
=VALUES(admin_id
),id
=VALUES(id
),json_config
=VALUES(json_config
),modify_time
=VALUES(modify_time
);2018-10-18 09:00:54,335 INFO 15541 egg-sequelize Executed (default): CREATE TABLE IF NOT EXISTS
cashier_printer_config
(id
INTEGER auto_increment UNIQUE ,admin_id
VARCHAR(20) NOT NULL,json_config
VARCHAR(2000) NOT NULL,modify_time
DATETIME NOT NULL, PRIMARY KEY (id
)) ENGINE=InnoDB;2018-10-18 09:00:54,337 INFO 15541 egg-sequelize Executed (default): SHOW INDEX FROM
cashier_printer_config
2018-10-18 09:00:54,339 INFO 15541 egg-sequelize Executed (default): SELECT
id
,admin_id
ASadminId
,json_config
ASjsonConfig
,modify_time
ASmodifyTime
,modify_time
FROMcashier_printer_config
AScashier_printer_config
WHEREcashier_printer_config
.admin_id
= 'A882080';结果还是:
[{"id":186,"config":{"printMode":"auto","state":1,"deviceType":"wifi"}}]
2018-10-18 09:02:49,889 INFO 15542 egg-sequelize Executed (default): CREATE TABLE IF NOT EXISTS
cashier_printer_config
(id
INTEGER auto_increment UNIQUE ,admin_id
VARCHAR(20) NOT NULL,json_config
VARCHAR(2000) NOT NULL,modify_time
DATETIME NOT NULL, PRIMARY KEY (id
)) ENGINE=InnoDB;2018-10-18 09:02:49,890 INFO 15542 egg-sequelize Executed (default): SHOW INDEX FROM
cashier_printer_config
2018-10-18 09:02:49,892 INFO 15542 egg-sequelize Executed (default): SELECT
id
,admin_id
ASadminId
,json_config
ASjsonConfig
,modify_time
ASmodifyTime
,modify_time
FROMcashier_printer_config
AScashier_printer_config
WHEREcashier_printer_config
.admin_id
= 'A882080';过一会查就正常了
[{"id":186,"config":{"printMode":"manual","state":1,"deviceType":"wifi"}}]
The text was updated successfully, but these errors were encountered: