|
@@ -166,14 +166,14 @@ async function handleCopyItems(sourceGuideLibID, sourceBillsLibID, targetGuideLi
|
|
|
|
|
|
}
|
|
|
|
|
|
-async function getCompilationList() {
|
|
|
+async function getCompilationList(req) {
|
|
|
let compilationModel = new CompilationModel();
|
|
|
- return await compilationModel.getCompilationList();
|
|
|
+ return await compilationModel.getPermissionCompilationList(req);
|
|
|
}
|
|
|
|
|
|
-async function getComBillsLibInfo() {
|
|
|
+async function getComBillsLibInfo(req) {
|
|
|
let rst = { compilationList: [], billsLibs: [] };
|
|
|
- let compilationList = await getCompilationList();
|
|
|
+ let compilationList = await getCompilationList(req);
|
|
|
if (compilationList.length <= 0) {
|
|
|
throw '没有数据';
|
|
|
}
|
|
@@ -398,13 +398,13 @@ async function checkItems(items) {
|
|
|
}
|
|
|
|
|
|
async function getItemsBybills(guidanceLibID, billsID) {
|
|
|
- let items = await billsGuideItemsModel.find({ libID: guidanceLibID, billsID: billsID});
|
|
|
+ let items = await billsGuideItemsModel.find({ libID: guidanceLibID, billsID: billsID });
|
|
|
await checkItems(items);
|
|
|
return items;
|
|
|
}
|
|
|
|
|
|
async function getItemsByBillIDs(guidanceLibID, billIDs) {
|
|
|
- let items = await billsGuideItemsModel.find({ libID: guidanceLibID, billsID: { $in: billIDs }});
|
|
|
+ let items = await billsGuideItemsModel.find({ libID: guidanceLibID, billsID: { $in: billIDs } });
|
|
|
await checkItems(items);
|
|
|
return items;
|
|
|
}
|
|
@@ -551,27 +551,27 @@ function getOptionalData(node, list = []) {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- // 获取必填项下的ID和name的键值对
|
|
|
- function getClassCodeStrData(nodes,data={classGroups:{},keyGroup:{}}){
|
|
|
- nodes.forEach(node=>{
|
|
|
- if (isProcessNode(node)&&node.data.required) {
|
|
|
- node.children.forEach(subNode=>{
|
|
|
- data.classGroups[subNode.data.ID]=subNode.data.name;
|
|
|
- data.keyGroup[subNode.data.ID]=`${subNode.parent.data.name}:${subNode.data.name}`;
|
|
|
- })
|
|
|
- }
|
|
|
- getClassCodeStrData(node.children,data);
|
|
|
+// 获取必填项下的ID和name的键值对
|
|
|
+function getClassCodeStrData(nodes, data = { classGroups: {}, keyGroup: {} }) {
|
|
|
+ nodes.forEach(node => {
|
|
|
+ if (isProcessNode(node) && node.data.required) {
|
|
|
+ node.children.forEach(subNode => {
|
|
|
+ data.classGroups[subNode.data.ID] = subNode.data.name;
|
|
|
+ data.keyGroup[subNode.data.ID] = `${subNode.parent.data.name}:${subNode.data.name}`;
|
|
|
+ })
|
|
|
+ }
|
|
|
+ getClassCodeStrData(node.children, data);
|
|
|
})
|
|
|
- return data;
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
|
|
|
//获取定额数据
|
|
|
- // requireRationData必套定额对象
|
|
|
- // optionalRationData 选逃定额对象
|
|
|
- // classGroups classCode文字和id键值对
|
|
|
- // classCodeList 各个classCode的pID和ID的关系
|
|
|
-function getItemData(nodes, requireRationData = {}, optionalRationData = {}, classGroups = {}, prefixID = '', prefixSonID = '', IDData = {}, keyGroup={}) {
|
|
|
+// requireRationData必套定额对象
|
|
|
+// optionalRationData 选逃定额对象
|
|
|
+// classGroups classCode文字和id键值对
|
|
|
+// classCodeList 各个classCode的pID和ID的关系
|
|
|
+function getItemData(nodes, requireRationData = {}, optionalRationData = {}, classGroups = {}, prefixID = '', prefixSonID = '', IDData = {}, keyGroup = {}) {
|
|
|
const processNodes = nodes.filter(node => isProcessNode(node));
|
|
|
// const classGroups = []; // 同层必填选项的数组(二维数组)
|
|
|
processNodes.forEach(processNode => {
|
|
@@ -596,17 +596,17 @@ function getItemData(nodes, requireRationData = {}, optionalRationData = {}, cla
|
|
|
kV[optionNode.data.ID] = optionNode.data.name;
|
|
|
Object.assign(classGroups, kV);
|
|
|
|
|
|
- const keyData={};
|
|
|
+ const keyData = {};
|
|
|
keyData[optionNode.data.ID] = `${optionNode.parent.data.name}:${optionNode.data.name}`;
|
|
|
- Object.assign(keyGroup,keyData);
|
|
|
+ Object.assign(keyGroup, keyData);
|
|
|
} else {
|
|
|
const kV = {};
|
|
|
kV[optionNode.data.ID] = optionNode.data.name;
|
|
|
Object.assign(classGroups, kV);
|
|
|
|
|
|
- const keyData={};
|
|
|
+ const keyData = {};
|
|
|
keyData[optionNode.data.ID] = `${optionNode.parent.data.name}:${optionNode.data.name}`;
|
|
|
- Object.assign(keyGroup,keyData);
|
|
|
+ Object.assign(keyGroup, keyData);
|
|
|
// 后代项是否有必填
|
|
|
if (hasRequireData(optionNode)) {
|
|
|
//后代项有必填
|
|
@@ -654,18 +654,18 @@ function getItemData(nodes, requireRationData = {}, optionalRationData = {}, cla
|
|
|
})
|
|
|
})
|
|
|
} else {
|
|
|
- // 全部选套就不用走循环了,直接按照选套执行
|
|
|
- let key = processNode.data.ID;
|
|
|
- if (prefixID) key = prefixID;
|
|
|
- if (prefixSonID) key = prefixSonID;
|
|
|
- if (!optionalRationData[key]) optionalRationData[key] = [];
|
|
|
- optionalRationData[key].push(...getOptionalData(processNode));
|
|
|
- // 因为这里没有按照走整个流程,所以文字和ID的关系需要获取补充
|
|
|
- if(hasRequireData(processNode)){
|
|
|
- const result =getClassCodeStrData(processNode.children)
|
|
|
- Object.assign(classGroups,result.classGroups);
|
|
|
- Object.assign(keyGroup,result.keyGroup);
|
|
|
- }
|
|
|
+ // 全部选套就不用走循环了,直接按照选套执行
|
|
|
+ let key = processNode.data.ID;
|
|
|
+ if (prefixID) key = prefixID;
|
|
|
+ if (prefixSonID) key = prefixSonID;
|
|
|
+ if (!optionalRationData[key]) optionalRationData[key] = [];
|
|
|
+ optionalRationData[key].push(...getOptionalData(processNode));
|
|
|
+ // 因为这里没有按照走整个流程,所以文字和ID的关系需要获取补充
|
|
|
+ if (hasRequireData(processNode)) {
|
|
|
+ const result = getClassCodeStrData(processNode.children)
|
|
|
+ Object.assign(classGroups, result.classGroups);
|
|
|
+ Object.assign(keyGroup, result.keyGroup);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -683,7 +683,7 @@ function getItemData(nodes, requireRationData = {}, optionalRationData = {}, cla
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- return { requireRationData, optionalRationData, classGroups, IDData, keyGroup}
|
|
|
+ return { requireRationData, optionalRationData, classGroups, IDData, keyGroup }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -822,7 +822,7 @@ function combineData(codeData, requireRationData, optionalRationData, classGroup
|
|
|
const optionalRationIDs = [];
|
|
|
const requiredRationIDs = [];
|
|
|
let name = '';
|
|
|
- let key = '';
|
|
|
+ let key = '';
|
|
|
const classCodeIDs = classCodeData.ID;
|
|
|
if (/@/.test(classCodeIDs)) {
|
|
|
classCodeIDs.split('@').forEach((classCodeID) => {
|
|
@@ -835,7 +835,7 @@ function combineData(codeData, requireRationData, optionalRationData, classGroup
|
|
|
};
|
|
|
// 一组的必套定额,先去重
|
|
|
const unitRation = [];
|
|
|
-
|
|
|
+
|
|
|
// 这里是必填选项下绑定必套定额
|
|
|
if (requireRationData[classCodeID] && requireRationData[classCodeID].length) {
|
|
|
requireRationData[classCodeID].forEach(subItem => {
|
|
@@ -869,19 +869,19 @@ function combineData(codeData, requireRationData, optionalRationData, classGroup
|
|
|
const unitRation = [];
|
|
|
name = classGroups[classCodeIDs];
|
|
|
key = keyGroup[classCodeIDs];
|
|
|
- if (requireRationData[classCodeIDs] && requireRationData[classCodeIDs].length){
|
|
|
+ if (requireRationData[classCodeIDs] && requireRationData[classCodeIDs].length) {
|
|
|
requireRationData[classCodeIDs].forEach(subItem => {
|
|
|
unitRation.push(...new Set(subItem));
|
|
|
})
|
|
|
- requiredRationIDs.push(unitRation);
|
|
|
+ requiredRationIDs.push(unitRation);
|
|
|
// 这里也要把用过的必套定额先存起来
|
|
|
matchRationList.push(...unitRation);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (requireCombineData[classCodeIDs] && requireCombineData[classCodeIDs].size) {
|
|
|
requiredRationIDs.push([...requireCombineData[classCodeIDs]])
|
|
|
- // 这里也要把用过的必套定额先存起来
|
|
|
- matchRationList.push(...requireCombineData[classCodeIDs]);
|
|
|
+ // 这里也要把用过的必套定额先存起来
|
|
|
+ matchRationList.push(...requireCombineData[classCodeIDs]);
|
|
|
};
|
|
|
|
|
|
if (optionalRationData[classCodeIDs] && optionalRationData[classCodeIDs].length) {
|
|
@@ -892,7 +892,7 @@ function combineData(codeData, requireRationData, optionalRationData, classGroup
|
|
|
optionalRationIDs.push(...optionCombineData[classCodeIDs]);
|
|
|
matchRationList.push(...optionalRationData[classCodeIDs]);
|
|
|
}
|
|
|
- return { name,key, requiredRationIDs, optionalRationIDs: [...new Set(optionalRationIDs)], errorRationIDs }
|
|
|
+ return { name, key, requiredRationIDs, optionalRationIDs: [...new Set(optionalRationIDs)], errorRationIDs }
|
|
|
}
|
|
|
})
|
|
|
const unMatchRation = [];
|
|
@@ -906,7 +906,7 @@ function combineData(codeData, requireRationData, optionalRationData, classGroup
|
|
|
// 这里把没有使用过的必套定额也丢到了选套里面
|
|
|
Object.values(requireRationData).forEach(data => {
|
|
|
data.forEach((rationData) => {
|
|
|
- rationData.forEach(rationID=>{
|
|
|
+ rationData.forEach(rationID => {
|
|
|
if (!matchRationList.includes(rationID)) {
|
|
|
unMatchRation.push(rationID);
|
|
|
}
|
|
@@ -978,16 +978,16 @@ async function generateClassData(libID) {
|
|
|
if (data.length) optionalRationIDs.push(...data);
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
const errorRationIDs = getErrorRationIDs([], optionalRationIDs, allRationIDs);
|
|
|
-
|
|
|
+
|
|
|
billClassData.push({
|
|
|
itemCharacter: '',
|
|
|
class: classNum++,
|
|
|
classCode: `${billNode.data.code}`,
|
|
|
compilationID: lib.compilationId,
|
|
|
name: billNode.data.name,
|
|
|
- key:`${billNode.data.code}${billNode.data.name}${billNode.data.unit}`,
|
|
|
+ key: `${billNode.data.code}${billNode.data.name}${billNode.data.unit}`,
|
|
|
code: billNode.data.code,
|
|
|
requiredRationIDs: [],
|
|
|
optionalRationIDs: optionalRationIDs || [],
|
|
@@ -1019,7 +1019,7 @@ async function getClassExcelData(libID) {
|
|
|
const classData = await billClassModel.find({ compilationID: lib.compilationId }).lean();
|
|
|
console.log('end');
|
|
|
console.log(Date.now() - date);
|
|
|
- const excelData = [['类别', '编码', '清单名称', '必填特征排列组合', '类别别名', '必套定额', '选套定额', '错套定额','基础样本']];
|
|
|
+ const excelData = [['类别', '编码', '清单名称', '必填特征排列组合', '类别别名', '必套定额', '选套定额', '错套定额', '基础样本']];
|
|
|
classData.forEach(item => {
|
|
|
const excelItem = [
|
|
|
item.class,
|