added iris code db support
This commit is contained in:
@@ -44,6 +44,13 @@ function Enums() {
|
|||||||
|
|
||||||
this.ADMIN_TYPE_IREXT = 1;
|
this.ADMIN_TYPE_IREXT = 1;
|
||||||
this.ADMIN_TYPE_EXTERNAL = 2;
|
this.ADMIN_TYPE_EXTERNAL = 2;
|
||||||
|
|
||||||
|
this.COLLECT_REMOTE_STATUS_INIT = 0;
|
||||||
|
this.COLLECT_REMOTE_STATUS_GENERATED = 1;
|
||||||
|
this.COLLECT_REMOTE_STATUS_CONFIRMED = 2;
|
||||||
|
this.COLLECT_REMOTE_STATUS_UPLOADED = 3;
|
||||||
|
this.COLLECT_REMOTE_STATUS_PUBLISHED = 4;
|
||||||
|
this.COLLECT_REMOTE_STATUS_DUPLICATED = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Enums;
|
module.exports = Enums;
|
||||||
174
console/model/collect_remote_dao.js
Normal file
174
console/model/collect_remote_dao.js
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
/**
|
||||||
|
* Created by strawmanbobi
|
||||||
|
* 2020-05-07
|
||||||
|
*/
|
||||||
|
|
||||||
|
// global inclusion
|
||||||
|
var orm = require('orm');
|
||||||
|
var dbOrm = require('../mini_poem/db/mysql/mysql_connection').mysqlDB;
|
||||||
|
var logger = require('../mini_poem/logging/logger4js').helper;
|
||||||
|
|
||||||
|
// local inclusion
|
||||||
|
var ErrorCode = require('../constants/error_code');
|
||||||
|
var Enums = require('../constants/enums');
|
||||||
|
|
||||||
|
var errorCode = new ErrorCode();
|
||||||
|
var enums = new Enums();
|
||||||
|
|
||||||
|
var CollectRemote = dbOrm.define('collect_remote',
|
||||||
|
{
|
||||||
|
id: Number,
|
||||||
|
name: String,
|
||||||
|
category_id: Number,
|
||||||
|
category_name: String,
|
||||||
|
brand_id: Number,
|
||||||
|
brand_name: String,
|
||||||
|
city_code: String,
|
||||||
|
city_name: String,
|
||||||
|
operator_id: Number,
|
||||||
|
operator_name: String,
|
||||||
|
protocol: String,
|
||||||
|
remote: String,
|
||||||
|
remote_map: String,
|
||||||
|
status: Number,
|
||||||
|
update_time: String,
|
||||||
|
contributor: String,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cache: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
CollectRemote.createCollectRemote = function(collectRemote, callback) {
|
||||||
|
var date = dateUtils.formatDate(new Date(), "yyyy-MM-dd hh:mm:ss");
|
||||||
|
var newCollectRemote = new CollectRemote({
|
||||||
|
name: collectRemote.name,
|
||||||
|
category_id: collectRemote.category_id,
|
||||||
|
category_name: collectRemote.category_name,
|
||||||
|
brand_id: collectRemote.brand_id,
|
||||||
|
brand_name: collectRemote.brand_name,
|
||||||
|
city_code: collectRemote.city_code,
|
||||||
|
city_name: collectRemote.city_name,
|
||||||
|
operator_id: collectRemote.operator_id,
|
||||||
|
operator_name: collectRemote.operator_name,
|
||||||
|
protocol: collectRemote.protocol,
|
||||||
|
remote: collectRemote.remote,
|
||||||
|
remote_map: collectRemote.remote_map,
|
||||||
|
status: enums.COLLECT_REMOTE_STATUS_INIT,
|
||||||
|
update_time: date,
|
||||||
|
contributor: collectRemote.contributor,
|
||||||
|
});
|
||||||
|
newCollectRemote.save(function(error, createdCollectRemote) {
|
||||||
|
if(error) {
|
||||||
|
logger.error('failed to create collectRemote : ' + error);
|
||||||
|
callback(errorCode.FAILED, null);
|
||||||
|
} else {
|
||||||
|
callback(errorCode.SUCCESS, createdCollectRemote);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
CollectRemote.deleteCollectRemote = function(collectRemoteID, callback) {
|
||||||
|
CollectRemote.get(collectRemoteID, function (err, collectRemote) {
|
||||||
|
if (null !== collectRemote) {
|
||||||
|
collectRemote.remove(function (err) {
|
||||||
|
if(err) {
|
||||||
|
logger.error('failed to remove collectRemote ' + collectRemoteID);
|
||||||
|
callback(errorCode.FAILED);
|
||||||
|
} else {
|
||||||
|
callback(errorCode.SUCCESS);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
logger.error('remove collectRemote successfully ' + collectRemoteID);
|
||||||
|
callback(errorCode.SUCCESS);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
CollectRemote.findCollectRemotesByCondition = function(conditions, callback) {
|
||||||
|
CollectRemote.find(conditions)
|
||||||
|
.run(function (error, collectRemotes) {
|
||||||
|
if (error) {
|
||||||
|
logger.error("find collectRemote error : " + error);
|
||||||
|
callback(errorCode.FAILED, null);
|
||||||
|
} else {
|
||||||
|
callback(errorCode.SUCCESS, collectRemotes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
CollectRemote.listCollectRemotes = function(conditions, from, count, sortField, callback) {
|
||||||
|
if("id" === sortField && 0 !== from) {
|
||||||
|
conditions.id = orm.lt(from);
|
||||||
|
CollectRemote.find(conditions).limit(parseInt(count)).orderRaw("?? DESC", [sortField])
|
||||||
|
.run(function (listCollectRemotesErr, collectRemotes) {
|
||||||
|
if (listCollectRemotesErr) {
|
||||||
|
logger.error("list collectRemotes error : " + listCollectRemotesErr);
|
||||||
|
callback(errorCode.FAILED, null);
|
||||||
|
} else {
|
||||||
|
callback(errorCode.SUCCESS, collectRemotes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
CollectRemote.find(conditions).limit(parseInt(count)).offset(parseInt(from)).orderRaw("?? ASC", [sortField])
|
||||||
|
.run(function (listCollectRemotesErr, collectRemotes) {
|
||||||
|
if (listCollectRemotesErr) {
|
||||||
|
logger.error("list remoteIndexes error : " + listCollectRemotesErr);
|
||||||
|
callback(errorCode.FAILED, null);
|
||||||
|
} else {
|
||||||
|
callback(errorCode.SUCCESS, collectRemotes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
CollectRemote.countCollectRemotes = function(conditions, callback) {
|
||||||
|
CollectRemote.count(conditions, function(countCollectRemotesErr, collectRemotesCount) {
|
||||||
|
if (countCollectRemotesErr) {
|
||||||
|
logger.error("count collectRemotes error : " + countCollectRemotesErr);
|
||||||
|
callback(errorCode.FAILED, 0);
|
||||||
|
} else {
|
||||||
|
callback(errorCode.SUCCESS, collectRemotesCount);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
CollectRemote.getCollectRemoteByID = function(collectRemoteID, callback) {
|
||||||
|
CollectRemote.get(collectRemoteID, function(error, collectRemote) {
|
||||||
|
if (error) {
|
||||||
|
logger.error("get collectRemote by ID error : " + error);
|
||||||
|
callback(errorCode.FAILED, null);
|
||||||
|
} else {
|
||||||
|
callback(errorCode.SUCCESS, collectRemote);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
CollectRemote.updateCollectRemote = function(collectRemoteID, newCollectRemote, callback) {
|
||||||
|
CollectRemote.get(collectRemoteID, function(error, collectRemote) {
|
||||||
|
if (error) {
|
||||||
|
logger.error("get collectRemote by ID error in update collectRemote : " + error);
|
||||||
|
callback(errorCode.FAILED, null);
|
||||||
|
} else {
|
||||||
|
logger.info("get collectRemote by ID successfully in update collectRemote");
|
||||||
|
|
||||||
|
for (var prop in collectRemote) {
|
||||||
|
if (undefined !== newCollectRemote[prop] && null !== newCollectRemote[prop]) {
|
||||||
|
collectRemote[prop] = newCollectRemote[prop];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
collectRemote.save(function(error, updatedCollectRemote) {
|
||||||
|
if(error) {
|
||||||
|
logger.error('failed to update collectRemote : ' + error);
|
||||||
|
callback(errorCode.FAILED, null);
|
||||||
|
} else {
|
||||||
|
callback(errorCode.SUCCESS, updatedCollectRemote);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = CollectRemote;
|
||||||
@@ -70,7 +70,6 @@ $(document).ready(function() {
|
|||||||
token = localStorage.getItem(LS_KEY_TOKEN);
|
token = localStorage.getItem(LS_KEY_TOKEN);
|
||||||
client = getParameter('client');
|
client = getParameter('client');
|
||||||
|
|
||||||
// showMenu(id, token, 'remote');
|
|
||||||
initializeSelectors();
|
initializeSelectors();
|
||||||
|
|
||||||
$('#remote_file').change(function() {
|
$('#remote_file').change(function() {
|
||||||
@@ -192,38 +191,35 @@ function loadRemoteList(isSearch, remoteMap) {
|
|||||||
valign: 'middle',
|
valign: 'middle',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
clickToSelect: true
|
clickToSelect: true
|
||||||
}, {
|
|
||||||
field: 'contributor',
|
|
||||||
title: '贡献者',
|
|
||||||
align: 'left',
|
|
||||||
valign: 'middle',
|
|
||||||
sortable: true,
|
|
||||||
clickToSelect: true,
|
|
||||||
visible: false
|
|
||||||
}]
|
}]
|
||||||
}).on('check.bs.table', function (e, row) {
|
}).on('check.bs.table', function (e, row) {
|
||||||
onSelectRemote(row);
|
onSelectRemote(row);
|
||||||
}).on('uncheck.bs.table', function (e, row) {
|
}).on('uncheck.bs.table', function (e, row) {
|
||||||
selectedRemote = null;
|
selectedRemote = null;
|
||||||
}).on('load-success.bs.table', function (e, data) {
|
}).on('load-success.bs.table', function (e, data) {
|
||||||
var i = 0;
|
var i;
|
||||||
for (i = 0; i < data.length; i++) {
|
for (i = 0; i < data.length; i++) {
|
||||||
if(data[i].status == '1') {
|
if (data[i].para === 0) {
|
||||||
data[i].status = '已发布';
|
if (data[i].status == '1') {
|
||||||
} else if(data[i].status == '2') {
|
data[i].status = '已发布';
|
||||||
data[i].status = '待验证';
|
} else if (data[i].status == '2') {
|
||||||
} else if(data[i].status == '3') {
|
data[i].status = '待验证';
|
||||||
data[i].status = '通过';
|
} else if (data[i].status == '3') {
|
||||||
} else if(data[i].status == '4') {
|
data[i].status = '通过';
|
||||||
data[i].status = '未通过';
|
} else if (data[i].status == '4') {
|
||||||
} else if(data[i].status == '5') {
|
data[i].status = '未通过';
|
||||||
data[i].status = '重复'
|
} else if (data[i].status == '5') {
|
||||||
|
data[i].status = '重复'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data[i].status = 'From IRIS';
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#remote_table').bootstrapTable('updateRow', {
|
$('#remote_table').bootstrapTable('updateRow', {
|
||||||
index: i,
|
index: i,
|
||||||
row: {
|
row: {
|
||||||
status: data[i].status
|
status: data[i].status,
|
||||||
|
para: data[i].para,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -233,30 +229,36 @@ function loadRemoteList(isSearch, remoteMap) {
|
|||||||
|
|
||||||
function rowStyle(row, index) {
|
function rowStyle(row, index) {
|
||||||
var style = null;
|
var style = null;
|
||||||
if (row.status == '已发布') {
|
if (row.para === 0) {
|
||||||
style = {
|
if (row.status == '已发布') {
|
||||||
classes: 'default'
|
style = {
|
||||||
};
|
classes: 'default'
|
||||||
} else if (row.status == '待验证') {
|
};
|
||||||
|
} else if (row.status == '待验证') {
|
||||||
|
style = {
|
||||||
|
classes: 'info'
|
||||||
|
};
|
||||||
|
} else if (row.status == '通过') {
|
||||||
|
style = {
|
||||||
|
classes: 'success'
|
||||||
|
};
|
||||||
|
} else if (row.status == '未通过') {
|
||||||
|
style = {
|
||||||
|
classes: 'danger'
|
||||||
|
};
|
||||||
|
} else if (row.status == '重复') {
|
||||||
|
style = {
|
||||||
|
classes: 'warning'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
style = {
|
||||||
|
classes: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
style = {
|
style = {
|
||||||
classes: 'info'
|
classes: 'info'
|
||||||
};
|
};
|
||||||
} else if (row.status == '通过') {
|
|
||||||
style = {
|
|
||||||
classes: 'success'
|
|
||||||
};
|
|
||||||
} else if (row.status == '未通过') {
|
|
||||||
style = {
|
|
||||||
classes: 'danger'
|
|
||||||
};
|
|
||||||
} else if (row.status == '重复') {
|
|
||||||
style = {
|
|
||||||
classes: 'warning'
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
style = {
|
|
||||||
classes: ''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ var IRProtocol = require('../model/ir_protocol_dao.js');
|
|||||||
var City = require('../model/city_dao.js');
|
var City = require('../model/city_dao.js');
|
||||||
var RemoteIndex = require('../model/remote_index_dao.js');
|
var RemoteIndex = require('../model/remote_index_dao.js');
|
||||||
var StbOperator = require('../model/stb_operator_dao.js');
|
var StbOperator = require('../model/stb_operator_dao.js');
|
||||||
|
var CollectRemote = require('../model/collect_remote_dao.js');
|
||||||
|
|
||||||
var RequestSender = require('../mini_poem/http/request.js');
|
var RequestSender = require('../mini_poem/http/request.js');
|
||||||
var Map = require('../mini_poem/mem/map.js');
|
var Map = require('../mini_poem/mem/map.js');
|
||||||
@@ -95,8 +96,9 @@ exports.listOperatorsWorkUnit = function (cityCode, from, count, callback) {
|
|||||||
|
|
||||||
exports.listRemoteIndexesWorkUnit = function (categoryID, brandID, cityCode, operatorID, from, count, callback) {
|
exports.listRemoteIndexesWorkUnit = function (categoryID, brandID, cityCode, operatorID, from, count, callback) {
|
||||||
var conditions;
|
var conditions;
|
||||||
|
var listCollectRemotesConditions;
|
||||||
|
|
||||||
if (categoryID == enums.CATEGORY_STB) {
|
if (parseInt(categoryID) === enums.CATEGORY_STB) {
|
||||||
if (null == operatorID) {
|
if (null == operatorID) {
|
||||||
conditions = {
|
conditions = {
|
||||||
category_id: categoryID,
|
category_id: categoryID,
|
||||||
@@ -111,33 +113,80 @@ exports.listRemoteIndexesWorkUnit = function (categoryID, brandID, cityCode, ope
|
|||||||
status: orm.gt(enums.ITEM_INVALID)
|
status: orm.gt(enums.ITEM_INVALID)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
RemoteIndex.listRemoteIndexes(conditions, from, count, "priority",
|
||||||
} else if (categoryID == enums.CATEGORY_AC ||
|
function(listRemoteIndexesErr, remoteIndexes) {
|
||||||
categoryID == enums.CATEGORY_TV ||
|
for (var i = 0; i < remoteIndexes.length; i++) {
|
||||||
categoryID == enums.CATEGORY_NW ||
|
remoteIndexes[i].para = 0;
|
||||||
categoryID == enums.CATEGORY_IPTV ||
|
}
|
||||||
categoryID == enums.CATEGORY_DVD ||
|
if (!operatorID) {
|
||||||
categoryID == enums.CATEGORY_FAN ||
|
listCollectRemotesConditions = {
|
||||||
categoryID == enums.CATEGORY_PROJECTOR ||
|
category_id: parseInt(categoryID),
|
||||||
categoryID == enums.CATEGORY_STEREO ||
|
city_code: cityCode,
|
||||||
categoryID == enums.CATEGORY_LIGHT_BULB ||
|
status: parseInt(enums.COLLECT_REMOTE_STATUS_CONFIRMED)
|
||||||
categoryID == enums.CATEGORY_BSTB ||
|
};
|
||||||
categoryID == enums.CATEGORY_CLEANING_ROBOT ||
|
} else {
|
||||||
categoryID == enums.CATEGORY_AIR_CLEANER ||
|
listCollectRemotesConditions = {
|
||||||
categoryID == enums.CATEGORY_DYSON) {
|
category_id: parseInt(categoryID),
|
||||||
|
city_code: cityCode,
|
||||||
|
operator_id: operatorID,
|
||||||
|
status: parseInt(enums.COLLECT_REMOTE_STATUS_CONFIRMED)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
CollectRemote.listCollectRemotes(listCollectRemotesConditions,
|
||||||
|
from, count, "update_time", function(listCollectRemotesErr, collectRemotes) {
|
||||||
|
if (null != collectRemotes && collectRemotes.length > 0) {
|
||||||
|
for (var i = 0; i < collectRemotes.length; i++) {
|
||||||
|
collectRemotes[i].para = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
remoteIndexes.push.apply(remoteIndexes, collectRemotes);
|
||||||
|
callback(listRemoteIndexesErr, remoteIndexes);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (parseInt(categoryID) === enums.CATEGORY_AC ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_TV ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_NW ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_IPTV ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_DVD ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_FAN ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_PROJECTOR ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_STEREO ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_LIGHT_BULB ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_BSTB ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_CLEANING_ROBOT ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_AIR_CLEANER ||
|
||||||
|
parseInt(categoryID) === enums.CATEGORY_DYSON) {
|
||||||
conditions = {
|
conditions = {
|
||||||
category_id: categoryID,
|
category_id: categoryID,
|
||||||
brand_id: brandID,
|
brand_id: brandID,
|
||||||
status: orm.gt(enums.ITEM_INVALID)
|
status: orm.gt(enums.ITEM_INVALID)
|
||||||
};
|
};
|
||||||
|
RemoteIndex.listRemoteIndexes(conditions, from, count, "priority",
|
||||||
|
function(listRemoteIndexesErr, remoteIndexes) {
|
||||||
|
for (var i = 0; i < remoteIndexes.length; i++) {
|
||||||
|
remoteIndexes[i].para = 0;
|
||||||
|
}
|
||||||
|
// append IRIS indexes
|
||||||
|
listCollectRemotesConditions = {
|
||||||
|
category_id: parseInt(categoryID),
|
||||||
|
brand_id: parseInt(brandID),
|
||||||
|
status: parseInt(enums.COLLECT_REMOTE_STATUS_CONFIRMED)
|
||||||
|
}
|
||||||
|
CollectRemote.listCollectRemotes(listCollectRemotesConditions,
|
||||||
|
from, count, "update_time",
|
||||||
|
function(listCollectRemotesErr, collectRemotes) {
|
||||||
|
if (null != collectRemotes && collectRemotes.length > 0) {
|
||||||
|
for (var i = 0; i < collectRemotes.length; i++) {
|
||||||
|
collectRemotes[i].para = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
remoteIndexes.push.apply(remoteIndexes, collectRemotes);
|
||||||
|
callback(listRemoteIndexesErr, remoteIndexes);
|
||||||
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(errorCode.INVALID_CATEGORY, null);
|
callback(errorCode.INVALID_CATEGORY, null);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteIndex.listRemoteIndexes(conditions, from, count, "priority", function(listRemoteIndexesErr, remoteIndexes) {
|
|
||||||
callback(listRemoteIndexesErr, remoteIndexes);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.searchRemoteIndexesWorkUnit = function (remoteMap, from, count, callback) {
|
exports.searchRemoteIndexesWorkUnit = function (remoteMap, from, count, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user