|
|
@@ -5,7 +5,6 @@ const mongoose = require('mongoose');
|
|
|
const gljMapModel = mongoose.model('std_glj_lib_map');
|
|
|
const gljModel = mongoose.model('std_glj_lib_gljList');
|
|
|
const gljClassModel = mongoose.model('std_glj_lib_gljClass');
|
|
|
-const gljClassTemplateModel = mongoose.model('std_glj_lib_gljClassTemplate');
|
|
|
const compilationModel = mongoose.model('compilation');
|
|
|
const scMathUtil = require('../../../public/scMathUtil').getUtil();
|
|
|
const rationModel = mongoose.model('std_ration_lib_ration_items');
|
|
|
@@ -15,48 +14,6 @@ import counter from "../../../public/counter/counter";
|
|
|
import async from "async";
|
|
|
|
|
|
class GljDao extends OprDao{
|
|
|
- //test
|
|
|
- async deSomething (libID){
|
|
|
- let pClass = await gljClassModel.find({repositoryId: libID, Name: '2013全省材料预算价格'});
|
|
|
- let classIDs = [],
|
|
|
- pClassIDs = [];
|
|
|
- for (let p of pClass) {
|
|
|
- let p1Class = await gljClassModel.find({repositoryId: libID, ParentID: p.ID});
|
|
|
- for (let c of p1Class) {
|
|
|
- pClassIDs.push(c.ID);
|
|
|
- }
|
|
|
- }
|
|
|
- let subClass = await gljClassModel.find({repositoryId: libID, ParentID: {$in: pClassIDs}});
|
|
|
- for (let s of subClass) {
|
|
|
- classIDs.push(s.ID);
|
|
|
- }
|
|
|
- let subSonClass = await gljClassModel.find({repositoryId: libID, ParentID: {$in: classIDs}});
|
|
|
- for (let ss of subSonClass){
|
|
|
- classIDs.push(ss.ID);
|
|
|
- }
|
|
|
- classIDs = Array.from(new Set(classIDs));
|
|
|
- //相关人材机
|
|
|
- let gljs = await gljModel.find({repositoryId: libID, gljClass: {$in: classIDs}}, '-_id gljClass ID');
|
|
|
- let gljIDs = [];
|
|
|
- for (let g of gljs) {
|
|
|
- gljIDs.push(g.ID);
|
|
|
- }
|
|
|
- let gljLib = await gljMapModel.findOne({ID: libID});
|
|
|
- let refRationLibIDs = [];
|
|
|
- for (let rl of gljLib.rationLibs) {
|
|
|
- refRationLibIDs.push(rl.ID);
|
|
|
- }
|
|
|
- let i = 0;
|
|
|
- for (let rationLibID of refRationLibIDs) {
|
|
|
- await rationModel.update({rationRepId: rationLibID, 'rationGljList.gljId': {$in: gljIDs}}, {$pull: {rationGljList: {gljId: {$in: gljIDs}}}}, {multi: true});
|
|
|
- console.log(`i++======================`);
|
|
|
- console.log(i++);
|
|
|
- }
|
|
|
- await gljModel.remove({ID: {$in: gljIDs}});
|
|
|
- console.log('end');
|
|
|
-
|
|
|
- }
|
|
|
- //test
|
|
|
getGljTypes (gljLibId, callback){
|
|
|
gljClassModel.find({"repositoryId": gljLibId, "$or": [{"isDeleted": null}, {"isDeleted": false}, {deleted: false} ]},function(err,data){
|
|
|
if(err) callback("获取工料机类型错误!",false)
|