Commit 59db59e9 by Sxy

fix: 未分配bug

parent ba6f4a8e
...@@ -2,260 +2,267 @@ const system = require("../../../system"); ...@@ -2,260 +2,267 @@ const system = require("../../../system");
const Dao = require("../../dao.base"); const Dao = require("../../dao.base");
const url = require("url"); const url = require("url");
class DeliverDao extends Dao { class DeliverDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(DeliverDao)); super(Dao.getModelName(DeliverDao));
} }
orderBy() { orderBy() {
return [["updated_at", "DESC"]]; return [["updated_at", "DESC"]];
} }
extraWhere(qobj, qw, qc) { extraWhere(qobj, qw, qc) {
// 权限添加 // 权限添加
//需要添加公司查询条件 //需要添加公司查询条件
qc.where["facilitator_id"] = Number(qobj.company_id || -1); qc.where["facilitator_id"] = Number(qobj.company_id || -1);
// 组织结构 // 组织结构
if (qobj.opath && qobj.opath != "") { if (qobj.opath && qobj.opath != "") {
qc.where['$or'] = [ qc.where['$or'] = [
{ {
delivery_man_opcode: { [this.db.Op.like]: `%${qobj.opath}%` }, delivery_man_opcode: { [this.db.Op.like]: `%${qobj.opath}%` },
}, },
{ {
salesman_opcode: { [this.db.Op.like]: `%${qobj.opath}%` }, salesman_opcode: { [this.db.Op.like]: `%${qobj.opath}%` },
}
]
} }
]
}
qc.raw = true; qc.raw = true;
let type = qobj.bizpath.split('/')[1]; let type = qobj.bizpath.split('/')[1];
if (type === 'deliveryManagement') { if (type === 'deliveryManagement') {
qc.where.product_code = qc.where.product_code && [system.SERVICECODE.EDI, system.SERVICECODE.ICP].includes(qc.where.product_code) ? qc.where.product_code : { qc.where.product_code = qc.where.product_code && [system.SERVICECODE.EDI, system.SERVICECODE.ICP].includes(qc.where.product_code) ? qc.where.product_code : {
$in: [system.SERVICECODE.EDI, system.SERVICECODE.ICP] $in: [system.SERVICECODE.EDI, system.SERVICECODE.ICP]
} }
switch (qobj.bizpath) { switch (qobj.bizpath) {
case "/deliveryManagement/wait": case "/deliveryManagement/wait":
qc.where.delivery_status = qc.where.delivery_status || { qc.where.delivery_status = qc.where.delivery_status || {
$notIn: [system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.CLOSED] $notIn: [system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.CLOSED]
} }
break break
case "/deliveryManagement/deliveryAllocated": case "/deliveryManagement/deliveryAllocated":
qc.where.delivery_man_id = qc.where.delivery_man_id || { qc.where.delivery_man_id = qc.where.delivery_man_id || {
$and: [{ $not: null }, { $not: "" }] $and: [{ $not: null }, { $not: "" }]
} }
break break
case "/deliveryManagement/deliveryNoAllocate": case "/deliveryManagement/deliveryNoAllocate":
qc.where.delivery_man_id = qc.where.delivery_man_id || { if (!qc.where['$or']) {
$or: [{ $eq: null }, { $eq: "" }] qc.where['$or'] = []
} }
if (qc.where['$or']) { qc.where['$or'].push({
qc.where['$or'].push({ delivery_man_opcode: {
salesman_opcode: { $eq: null
$eq: null
}
})
}
break
case "/deliveryManagement/all":
break
}
} else if (type === "annualReport") {
qc.where.product_code = qc.where.product_code && [system.SERVICECODE.ICPANNUALREPORT, system.SERVICECODE.EDIANNUALREPORT].includes(qc.where.product_code) ? qc.where.product_code : {
$in: [system.SERVICECODE.EDIANNUALREPORT, system.SERVICECODE.ICPANNUALREPORT]
} }
})
break
case "/deliveryManagement/all":
break
}
} else if (type === "annualReport") {
qc.where.product_code = qc.where.product_code && [system.SERVICECODE.ICPANNUALREPORT, system.SERVICECODE.EDIANNUALREPORT].includes(qc.where.product_code) ? qc.where.product_code : {
$in: [system.SERVICECODE.EDIANNUALREPORT, system.SERVICECODE.ICPANNUALREPORT]
}
// ---- 兼容 年报 状态 未申报、已申报 start // ---- 兼容 年报 状态 未申报、已申报 start
let status; let status;
if ([system.ANNUALREPORT.WAITDECLARE, system.ANNUALREPORT.DECLARESUCCESS].includes(qc.where.delivery_status)) { if ([system.ANNUALREPORT.WAITDECLARE, system.ANNUALREPORT.DECLARESUCCESS].includes(qc.where.delivery_status)) {
status = qc.where.delivery_status; status = qc.where.delivery_status;
delete qc.where.delivery_status; delete qc.where.delivery_status;
qobj.bizpath = "/annualReport/wait"; qobj.bizpath = "/annualReport/wait";
}
let include = {
model: this.db.models.annualreport,
attributes: ['status', "year"],
where: {
year: {
$or: [
new Date().getFullYear(),
null
]
},
},
required: false
}
if (status) {
include.where.status = status;
delete include.required;
}
qc.include = [
include
]
// ---- 兼容 年报 状态 未申报、已申报 end
switch (qobj.bizpath) {
case "/annualReport/wait":
qc.where.delivery_status = qc.where.delivery_status || {
$in: [system.ANNUALREPORT.TAKEEFFECT]
}
break
case "/annualReport/all":
qc.where.delivery_status = qc.where.delivery_status || {
$in: [system.ANNUALREPORT.TAKEEFFECT, system.ANNUALREPORT.SUCCESS]
}
break
}
} else if (type === "wangwenManagement") {
let filters = [];
filters.push({
product_code: "wangwen"
})
switch (qobj.bizpath) {
case "/wangwenManagement/wait":
filters.push({
delivery_status: {
$notIn: [system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.CLOSED]
} }
let include = { });
model: this.db.models.annualreport, break
attributes: ['status', "year"], case "/wangwenManagement/deliveryAllocated":
where: { filters.push({
year: { delivery_man_opcode: {
$or: [ $ne: null
new Date().getFullYear(),
null
]
},
},
required: false
} }
if (status) { });
include.where.status = status; break
delete include.required; case "/wangwenManagement/deliveryNoAllocate":
if (!qc.where['$or']) {
qc.where['$or'] = []
}
qc.where['$or'].push({
delivery_man_opcode: {
$eq: null
} }
})
qc.include = [ break
include case "/wangwenManagement/all":
] break
// ---- 兼容 年报 状态 未申报、已申报 end }
qc.where["$and"] = filters;
switch (qobj.bizpath) { } else if (type === "foodManagement") {
case "/annualReport/wait": let filters = [];
qc.where.delivery_status = qc.where.delivery_status || { filters.push({
$in: [system.ANNUALREPORT.TAKEEFFECT] product_code: "food"
} })
break switch (qobj.bizpath) {
case "/annualReport/all": case "/foodManagement/wait":
qc.where.delivery_status = qc.where.delivery_status || { filters.push({
$in: [system.ANNUALREPORT.TAKEEFFECT, system.ANNUALREPORT.SUCCESS] delivery_status: {
} $notIn: [system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.CLOSED]
break
} }
});
} else if (type === "wangwenManagement") { break
let filters = []; case "/foodManagement/deliveryAllocated":
filters.push({ filters.push({
product_code: "wangwen" delivery_man_opcode: {
}) $ne: null
switch (qobj.bizpath) {
case "/wangwenManagement/wait":
filters.push({
delivery_status: {
$notIn: [system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.CLOSED]
}
});
break
case "/wangwenManagement/deliveryAllocated":
filters.push({
delivery_man_opcode: {
$ne: null
}
});
break
case "/wangwenManagement/deliveryNoAllocate":
filters.push({
delivery_man_opcode: {
$eq: null
}
});
break
case "/wangwenManagement/all":
break
} }
qc.where["$and"] = filters; });
} else if (type === "foodManagement") { break
let filters = []; case "/foodManagement/deliveryNoAllocate":
filters.push({ if (!qc.where['$or']) {
product_code: "food" qc.where['$or'] = []
}) }
switch (qobj.bizpath) { qc.where['$or'].push({
case "/foodManagement/wait": delivery_man_opcode: {
filters.push({ $eq: null
delivery_status: {
$notIn: [system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.CLOSED]
}
});
break
case "/foodManagement/deliveryAllocated":
filters.push({
delivery_man_opcode: {
$ne: null
}
});
break
case "/foodManagement/deliveryNoAllocate":
filters.push({
delivery_man_opcode: {
$eq: null
}
});
break
case "/foodManagement/all":
break
} }
qc.where["$and"] = filters; })
} else if (type === "guangboManagement") { break
let filters = []; case "/foodManagement/all":
filters.push({ break
product_code: "guangbo" }
}) qc.where["$and"] = filters;
switch (qobj.bizpath) { } else if (type === "guangboManagement") {
case "/guangboManagement/wait": let filters = [];
filters.push({ filters.push({
delivery_status: { product_code: "guangbo"
$notIn: [system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.CLOSED] })
} switch (qobj.bizpath) {
}); case "/guangboManagement/wait":
break filters.push({
case "/guangboManagement/deliveryAllocated": delivery_status: {
filters.push({ $notIn: [system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.CLOSED]
delivery_man_opcode: {
$ne: null
}
});
break
case "/guangboManagement/deliveryNoAllocate":
filters.push({
delivery_man_opcode: {
$eq: null
}
});
break
case "/guangboManagement/all":
break
} }
qc.where["$and"] = filters; });
} else { break
throw new Error("页面路径错误") case "/guangboManagement/deliveryAllocated":
} filters.push({
return qw; delivery_man_opcode: {
$ne: null
}
});
break
case "/guangboManagement/deliveryNoAllocate":
if (!qc.where['$or']) {
qc.where['$or'] = []
}
qc.where['$or'].push({
delivery_man_opcode: {
$eq: null
}
})
break
case "/guangboManagement/all":
break
}
qc.where["$and"] = filters;
} else {
throw new Error("页面路径错误")
} }
return qw;
}
async findInfo(pobj) { async findInfo(pobj) {
const result = await this.model.findOne({ const result = await this.model.findOne({
where: { where: {
id: pobj.id id: pobj.id
}, },
include: [ include: [
{ {
model: this.db.models.qualification, model: this.db.models.qualification,
// attributes: ['id', 'certificateNumber', 'businessTypes', 'businessScope', 'serviceProject', 'startAt', 'endAt', 'file'], // attributes: ['id', 'certificateNumber', 'businessTypes', 'businessScope', 'serviceProject', 'startAt', 'endAt', 'file'],
raw: false raw: false
}, { }, {
model: this.db.models.material, model: this.db.models.material,
raw: false raw: false
} }
], ],
raw: false raw: false
}); });
return result; return result;
} }
async findAnnualReportInfo(pobj) { async findAnnualReportInfo(pobj) {
const result = await this.model.findOne({ const result = await this.model.findOne({
where: { where: {
id: pobj.id id: pobj.id
}, },
include: [ include: [
{ {
model: this.db.models.annualreport, model: this.db.models.annualreport,
// attributes: ['id', 'certificateNumber', 'businessTypes', 'businessScope', 'serviceProject', 'startAt', 'endAt', 'file'], // attributes: ['id', 'certificateNumber', 'businessTypes', 'businessScope', 'serviceProject', 'startAt', 'endAt', 'file'],
} }
], ],
raw: false raw: false
}); });
return result; return result;
} }
async newFindInfo(pobj) { async newFindInfo(pobj) {
const result = await this.model.findOne({ const result = await this.model.findOne({
where: { where: {
id: pobj.id id: pobj.id
}, },
include: [ include: [
{ {
model: this.db.models.newmaterial, model: this.db.models.newmaterial,
raw: false raw: false
} }
], ],
raw: false raw: false
}); });
return result; return result;
} }
} }
module.exports = DeliverDao; module.exports = DeliverDao;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment