Fix serial checker bug
This commit is contained in:
@@ -101,7 +101,7 @@ module.exports.checkSerial = [
|
|||||||
try {
|
try {
|
||||||
const { serial, type, g } = req.body
|
const { serial, type, g } = req.body
|
||||||
const serialStatus = await serialChecker(serial, type, g)
|
const serialStatus = await serialChecker(serial, type, g)
|
||||||
console.log("s");
|
console.log(serialStatus);
|
||||||
|
|
||||||
let okMsg
|
let okMsg
|
||||||
if (type === 'guaranteeSerial') okMsg = serialStatus
|
if (type === 'guaranteeSerial') okMsg = serialStatus
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ const inHostUrl = 'mongodb://root:KPTt76tImNBBMm4Kor8QA9gB@asan-service:27017/as
|
|||||||
const outHostUrl = 'mongodb://root:KPTt76tImNBBMm4Kor8QA9gB@hotaka.liara.cloud:33794/asanserv_database?authSource=admin'
|
const outHostUrl = 'mongodb://root:KPTt76tImNBBMm4Kor8QA9gB@hotaka.liara.cloud:33794/asanserv_database?authSource=admin'
|
||||||
const init = ()=>{
|
const init = ()=>{
|
||||||
try {
|
try {
|
||||||
mongoose.connect(outHostUrl, {
|
mongoose.connect(inHostUrl, {
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
useFindAndModify: false,
|
useFindAndModify: false,
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ const serialChecker = (serial, type = 'guaranteeSerial', g = 1) => {
|
|||||||
if (type === 'guaranteeSerial') exelsPath = guaranteeSerialsPath + `/${g}`;
|
if (type === 'guaranteeSerial') exelsPath = guaranteeSerialsPath + `/${g}`;
|
||||||
if (type === 'orginality') exelsPath = productSerialsPath + `/${g}`;
|
if (type === 'orginality') exelsPath = productSerialsPath + `/${g}`;
|
||||||
|
|
||||||
console.log("s");
|
|
||||||
|
|
||||||
const lowerSerial = serial.toString().toLowerCase().trim().replace("-","")
|
|
||||||
|
const lowerSerial = serial.toString().toLowerCase().trim().replace("-", "")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const serialFiles = await fs.readdirSync(exelsPath);
|
const serialFiles = await fs.readdirSync(exelsPath);
|
||||||
@@ -19,14 +19,14 @@ console.log("s");
|
|||||||
// eslint-disable-next-line prefer-promise-reject-errors
|
// eslint-disable-next-line prefer-promise-reject-errors
|
||||||
reject("این کد در سامانه موجود نیست")
|
reject("این کد در سامانه موجود نیست")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
serialFiles.forEach(async (file, i) => {
|
serialFiles.forEach(async (file, i) => {
|
||||||
if(file.split('.').some(item => ['xlsx', 'xltx', 'xlsm', 'xlsb'].includes(item))){
|
if (file.split('.').some(item => ['xlsx', 'xltx', 'xlsm', 'xlsb'].includes(item))) {
|
||||||
const exelFile = await readXlsxFile(`${exelsPath}/${file}`);
|
const exelFile = await readXlsxFile(`${exelsPath}/${file}`);
|
||||||
console.log(file);
|
console.log(file);
|
||||||
|
|
||||||
for (const row of exelFile) {
|
for (const row of exelFile) {
|
||||||
console.log(row);
|
|
||||||
|
|
||||||
// eslint-disable-next-line eqeqeq
|
// eslint-disable-next-line eqeqeq
|
||||||
if ((row[1].toString()).toLowerCase().trim() == lowerSerial) {
|
if ((row[1].toString()).toLowerCase().trim() == lowerSerial) {
|
||||||
resolve(row[2]);
|
resolve(row[2]);
|
||||||
|
|||||||
Reference in New Issue
Block a user