|
|
@@ -17,6 +17,7 @@ const fs = require("fs");
|
|
|
// excel解析
|
|
|
const excel = require("node-xlsx");
|
|
|
const rationItem = require("../models/ration_item");
|
|
|
+const rationSectionTree = require('../models/ration_section_tree');
|
|
|
const rationLibModel = mongoose.model('std_ration_lib_map');
|
|
|
const rationItemModel = mongoose.model('std_ration_lib_ration_items');
|
|
|
import STDGLJListModel from '../../std_glj_lib/models/gljModel';
|
|
|
@@ -195,9 +196,21 @@ class RationRepositoryController extends baseController {
|
|
|
if (sheet[0] === undefined || sheet[0].data === undefined) {
|
|
|
throw 'excel没有对应数据';
|
|
|
}
|
|
|
- const failGLJList = type === 'source_file' ?
|
|
|
- await rationItem.batchAddFromExcel(rationRepId, sheet[0].data) :
|
|
|
- await rationItem.batchUpdateSectionIdFromExcel(sheet[0].data);
|
|
|
+ let failGLJList;
|
|
|
+ switch (type) {
|
|
|
+ // 导入原始数据
|
|
|
+ case 'source_file':
|
|
|
+ failGLJList = await rationItem.batchAddFromExcel(rationRepId, sheet[0].data);
|
|
|
+ break;
|
|
|
+ // 导入内部数据
|
|
|
+ case 'import_data':
|
|
|
+ failGLJList = await rationItem.batchUpdateSectionIdFromExcel(sheet[0].data);
|
|
|
+ break;
|
|
|
+ // 导入章节数据(一列文本,生成兄弟节点树)
|
|
|
+ case 'section_file':
|
|
|
+ await rationSectionTree.importSection(rationRepId, sheet[0].data);
|
|
|
+ break;
|
|
|
+ }
|
|
|
if (Array.isArray(failGLJList) && failGLJList.length > 0) {
|
|
|
responseData.msg = failGLJList.join("<br/>");
|
|
|
}
|
|
|
@@ -301,65 +314,3 @@ class RationRepositoryController extends baseController {
|
|
|
}
|
|
|
|
|
|
export default RationRepositoryController;
|
|
|
-/*
|
|
|
-module.exports = {
|
|
|
- addRationRepository:function(req,res){
|
|
|
- var rationObj = JSON.parse(req.body.rationRepObj);
|
|
|
- rationRepository.addRationRepository(rationObj,function(err,data){
|
|
|
- if (data) {
|
|
|
- callback(req, res, err, "has data", data);
|
|
|
- } else {
|
|
|
- callback(req, res, err, "no data", null);
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- getDisPlayRationLibs: function(req, res){
|
|
|
- rationRepository.getDisplayRationLibs(function(err, data){
|
|
|
- if (data) {
|
|
|
- callback(req, res, err, "has data",data);
|
|
|
- } else {
|
|
|
- callback(req, res, err, "no data", null);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- getRealLibName:function(req,res){
|
|
|
- var libName = req.body.rationName;
|
|
|
- rationRepository.getRealLibName(libName,function(err,data){
|
|
|
- if (data) {
|
|
|
- callback(req, res, err, "has data", data);
|
|
|
- } else {
|
|
|
- callback(req, res, err, "no data", null);
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- getLibIDByName:function(req,res){
|
|
|
- rationRepository.getLibIDByName(req.body.libName, function(err,data){
|
|
|
- if (data) {
|
|
|
- callback(req, res, err, "has ID", data);
|
|
|
- } else {
|
|
|
- callback(req, res, err, "no ID", null);
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- deleteRationLib:function(req,res){
|
|
|
- var rationName = req.body.rationName;
|
|
|
- rationRepository.deleteRationLib(rationName,function(err,data){
|
|
|
- if (data) {
|
|
|
- callback(req, res, err, "has data", data);
|
|
|
- } else {
|
|
|
- callback(req, res, err, "no data", null);
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- updateRationRepositoryName: function(req, res) {
|
|
|
- var orgName = req.body.rationName;
|
|
|
- var newName = req.body.newName;
|
|
|
- rationRepository.updateName(orgName, newName, function(err, data){
|
|
|
- if (data) {
|
|
|
- callback(req, res, err, "has data", data);
|
|
|
- } else {
|
|
|
- callback(req, res, err, "no data", null);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-}*/
|