Commit 5e699372 by chenjinjing

no message

parent afdfa2c5
......@@ -5,5 +5,6 @@
/public
/logs
/video
/files
*.logs
*.zip
<config>
<port>9098</port>
<sign>xxx90909082fsdahfjosadjfpoiwausjorip2hjklrhn1ioud0u124rx0qwejfokasjfolksaujfoas</sign>
<dbServer>http://192.168.0.105:40012</dbServer>
<SECRET_TOKEN>Ngz86cuAKxblwXR9OiKSWbfkj7oZ8R0lMU8pTfpVYBDCkvtUb0ZwbaBvwWyfv2O9</SECRET_TOKEN>
<dbServer>http://192.168.0.71:40012</dbServer>
<imgUrl>http://192.168.0.71:9098</imgUrl>
<imgFileUrl>http://192.168.0.71:9097</imgFileUrl>
<unZipFileUrl>http://127.0.0.1:9097</unZipFileUrl>
<fileUrl>/yuyi/files/1/</fileUrl>
<qcc>
<key>2b14555ce89346e8b96684e2e2a1c7c2</key>
......
......@@ -1178,7 +1178,8 @@ export async function qiyeRenZheng(enterpriseName, page) {
if (item[imgKey]) {
let imgArr = parseAndAddUrlPrefix(item[imgKey]); //JSON.parse(item[imgKey]);
for (let k = 0; k < imgArr.length; k++) {
addItem[imgKey].push(`${systemConfig.imgFileUrl}${imgArr[k]}`);
// addItem[imgKey].push(`${systemConfig.imgFileUrl}${imgArr[k]}`);
addItem[imgKey].push(`${imgArr[k]}`);
}
}
}
......
......@@ -15,6 +15,359 @@ const moment = require("moment");
const fetch = require('node-fetch');
export async function newDow(eIds, options) {
/**拼excel表格数据 */
let selectParam: any = {
// state: enumConfig.CHANGESTATE.已通过,
eId: { "%in%": eIds } // 只查询选中的企业
};
// 主表字段
let filesList = ["eId", "enterpriseName", "uscc", "logonTime", "logonAddress", "qiYeGuiMo"];
let manyTableInfo: any = {};
// let rufuSelectParam = { state: { "%between%": [enumConfig.FUHUASTATE.实体孵化, enumConfig.FUHUASTATE.虚拟孵化] } };
manyTableInfo[TABLENAME.企业孵化信息] = { column: ["moveOutTime", "moveOutType", "startTime", "endTime"], where: {} };
// 执行多表联查
let resInfo = await selectManyTableData(OPERATIONALDATATYPE.多表联查, TABLENAME.企业基础信息表, selectParam, filesList, manyTableInfo);
/**查询租赁表信息 */
let leaseWhere: any = { eId: { "%in%": eIds } };
let zuLingList = await selectData(OPERATIONALDATATYPE.查询多个, TABLENAME.租赁信息, leaseWhere, ["eId", "area", "startTime", "endTime", "building", "roomNumber"]);
let zaifuMap = {};
if (zuLingList.length) {
zuLingList.forEach(info => {
zaifuMap[info.eId] = info;
});
}
let titleConfig = [
{
typeName:'基础信息',
keyList:[
{ key: '企业名称', value: 'enterpriseName' },
{ key: '统一信用代码', value: 'uscc' },
{ key: '注册时间', value: 'logonTime' },
{ key: '行业领域', value: 'industry' },
{ key: '注册地址', value: 'logonAddress' },
{ key: '联系人', value: 'liaison' },
{ key: '联系电话', value: 'liaisonPhone' },
{ key: '企业规模', value: 'qiYeGuiMo' },
{ key: '实缴资本', value: 'shijiaoziben' },
{ key: '简介', value: 'jianJie' },
{ key: '注册资本', value: 'zhuceziben' },
{ key: '经营地址', value: 'operatingAddress' },
{ key: '经营范围', value: 'jingYingFanWei' },
{ key: '孵化时间', value: 'fuhuaTime' },
{ key: '租赁面积', value: 'area' },
{ key: '楼号', value: 'building' },
{ key: '室号', value: 'roomNumber' }
]
},
{
typeName:'经营数据',
keyList:[
{ key: '营收(万元)', value: 'BI' },
{ key: '纳税(万元)', value: 'TXP' },
{ key: '研发投入(万元)', value: 'RD' },
{ key: '年度', value: 'annual' },
{ key: '季度', value: 'quarter' }
]
},
{
typeName:'融资情况',
keyList:[
{ key: '融资金额(万元)', value: 'financingAmount' },
{ key: '融资轮次', value: 'financingRounds' },
{ key: '孵化器是否参与投资', value: 'fuHuaQiInvestment' },
{ key: '孵化器投资方式', value: 'fuHuaQiInvestmentStyle' },
{ key: '孵化器投资金额', value: 'fuHuaQiInvestmentAmount' },
{ key: '获得投资时间', value: 'investmentDate' },
{ key: '投资机构名称', value: 'investmentInstitutionsName' },
{ key: '估值', value: 'valuation' },
]
},{
typeName:'荣誉奖项',
keyList:[
{ key: '荣誉奖项数量', value: 'awardCount' },
// { key: '奖项名称', value: 'awardName' },
// { key: '颁奖单位', value: 'awardingUnit' },
// { key: '获奖日期', value: 'awardTime' },
// { key: '奖项等级', value: 'awardLevel' }
]
}
];
let titleList = [];//拼接表头
for (let i = 0; i < titleConfig[0].keyList.length; i++) {
titleList.push(titleConfig[0].keyList[i].key);
}
let dataList = [];//结构:[{eId:"", subList:[数据...]}]
//拼接基础信息
let enterpriseNameMap = {};//用来给文件目录映射名称用 {eId:"名称"}
for (let info of resInfo) {
let { eId, enterpriseName, uscc, logonTime, logonAddress, qiYeGuiMo, enterprise_fuhuas } = info;
enterpriseNameMap[eId] = enterpriseName;
let leasesTime = '-';
if (zaifuMap[eId]?.startTime) {
leasesTime = `${moment(zaifuMap[eId].startTime).format("YYYY-MM-DD")}${moment(zaifuMap[eId].endTime).format("YYYY-MM-DD")}`;
}
let fuhuaTime = '-';
if (enterprise_fuhuas[0]?.startTime) {
fuhuaTime = `${moment(enterprise_fuhuas[0].startTime).format("YYYY-MM-DD")}${moment(enterprise_fuhuas[0].endTime).format("YYYY-MM-DD")}`;
}
let itemData = {
eId, enterpriseName, uscc, logonTime: moment(logonTime).format("YYYY-MM-DD"), logonAddress: changeAdd(JSON.parse(logonAddress)), qiYeGuiMo, fuhuaTime, leasesTime, area: zaifuMap[eId]?.area ? `${zaifuMap[eId].area}㎡` : '-', building: zaifuMap[eId]?.building || '-', roomNumber: zaifuMap[eId]?.roomNumber || '-'
}
let subList = [];
for (let i = 0; i < titleConfig[0].keyList.length; i++) {
subList.push(itemData[titleConfig[0].keyList[i].value]||"");
}
dataList.push({eId, subList});
}
//拼接第经营数据 写法参考第一个拼接基础信息,但是需要注意的是,赋值的时候不能使用excelDataList.push(), 要用下标赋值,做到这里的时候来问我
/**查询经营表信息 */
let jinyingWhere: any = { eId: { "%in%": eIds }, isSubmit:enumConfig.STATE.};
let jinyingList = await selectData(OPERATIONALDATATYPE.查询多个, TABLENAME.企业经营信息, jinyingWhere, ["eId", "annual", "quarter", "BI", "TXP", "RD", "createTime"]);
// 根据年度季度获取最新一条已提交经营数据 // a.1 b.1 a.2 c.1
let jinyingListToTimeMap:any = {};
jinyingList.forEach(info => {
let {eId} = info;
if (!jinyingListToTimeMap[eId]) jinyingListToTimeMap[eId] = [];
jinyingListToTimeMap[eId].push(info);
});
let jinyingMap = {};//结构:{"eId":数据字段}
for (let eId in jinyingListToTimeMap) {
let thisEidJinyingList = jinyingListToTimeMap[eId];
thisEidJinyingList.sort((a, b) => {
//先按年度比较
if (b.annual !== a.annual) {
return new Date(b.annual).valueOf() - new Date(a.annual).valueOf();
}
//年度相同则按季度比较
return b.quarter - a.quarter;
});
//将数据进行格式化:枚举转换 时间格式转换
let thisjingyinInfo = thisEidJinyingList[0];
thisjingyinInfo.quarter = changeEnumValue(enumConfig.QUARTER, thisjingyinInfo.quarter);
thisjingyinInfo.annual = moment(thisjingyinInfo.annual).format("YYYY");
jinyingMap[eId] = thisjingyinInfo;
}
//拼接经营数据的表头
for (let i = 0; i < titleConfig[1].keyList.length; i++) {
titleList.push(titleConfig[1].keyList[i].key);
}
for (let i = 0; i< dataList.length; i++) {
let {eId, subList} = dataList[i];
for (let i = 0; i < titleConfig[1].keyList.length; i++) {//取经营数据的配置 按配置将jinyinMap的数据映射到 subList
if (!jinyingMap[eId]) {
subList.push("");
} else {
subList.push(jinyingMap[eId][titleConfig[1].keyList[i].value] || "");
}
}
}
/**查询融资信息 拼接融资信息 同上注释*/
let rongziWhere:any = { eId: { "%in%": eIds } };
let rongziColumn = ["eId", "financingAmount", "financingRounds", "fuHuaQiInvestment", "fuHuaQiInvestmentStyle", "fuHuaQiInvestmentAmount",
"investmentDate", "investmentInstitutionsName", "valuation"];
let rongziList = await selectData(OPERATIONALDATATYPE.查询多个, TABLENAME.企业融资, rongziWhere, rongziColumn);
// 根据获得投资时间获取最新一条数据
let rongziListToTimeMap:any = {};
rongziList.forEach( info => {
let {eId} = info;
if (!rongziListToTimeMap[eId]) rongziListToTimeMap[eId] = [];
rongziListToTimeMap[eId].push(info);
});
let rongziMap = {};
for (let eId in rongziListToTimeMap) {
let thisEidRongZiList = rongziListToTimeMap[eId];
thisEidRongZiList.sort((a, b) => {
return new Date(b.investmentDate).valueOf() - new Date(a.investmentDate).valueOf();
})
//将数据格式化
let thisRongZiInfo = thisEidRongZiList[0];
thisRongZiInfo.financingRounds = changeEnumValue(enumConfig.FINANCINGROUNDS, thisRongZiInfo.financingRounds);
thisRongZiInfo.fuHuaQiInvestmentStyle = changeEnumValue(enumConfig.FUHUAQILNVESTMENTSTYLE, thisRongZiInfo.fuHuaQiInvestmentStyle);
thisRongZiInfo.investmentDate = moment(thisRongZiInfo.investmentDate).format("YYYY-MM-DD");
rongziMap[eId] = thisRongZiInfo;
}
//拼接融资数据的表头
for (let i = 0; i < titleConfig[2].keyList.length; i++) {
titleList.push(titleConfig[2].keyList[i].key);
}
for (let i = 0; i< dataList.length; i++) {
let {eId, subList} = dataList[i];
for (let i = 0; i < titleConfig[2].keyList.length; i++) {//取融资数据的配置 按配置将rongziMap的数据映射到 subList
if (!rongziMap[eId]) {
subList.push("");
} else {
subList.push(rongziMap[eId][titleConfig[2].keyList[i].value] || "");
}
}
}
/**查询荣誉奖项信息 拼接荣誉奖项信息 同上注释*/
let rongyuWhere:any = {eId: { "%in%": eIds}};
let rongyuList = await selectData(OPERATIONALDATATYPE.查询多个, TABLENAME.企业荣誉, rongyuWhere, ["eId", "awardName", "awardingUnit", "awardTime", "awardLevel"]);
//统计荣誉奖项数量
let rongyuMap = {}
if (rongyuList.length) {
rongyuList.forEach(info => {
let {eId} = info;
if (!rongyuMap[eId]) rongyuMap[eId] = {"awardCount": 0};
else rongyuMap[eId]["awardCount"] += 1;
});
} else {
for (let i = 0; i < eIds.length; i++) {
if (!rongyuMap[eIds[i]]) rongyuMap[eIds[i]] = {"awardCount": 0};
else rongyuMap[eIds[i]]["awardCount"] += 1;
}
}
//拼接荣誉奖项的表头
for (let i = 0; i < titleConfig[3].keyList.length; i++) {
titleList.push(titleConfig[3].keyList[i].key);
}
for (let i = 0; i< dataList.length; i++) {
let {eId, subList} = dataList[i];
for (let i = 0; i < titleConfig[3].keyList.length; i++) {//取荣誉奖项的配置 按配置将rongyuMap的数据映射到 subList
subList.push(rongyuMap[eId][titleConfig[3].keyList[i].value || ""]);
}
}
//得到了excelDataList列表
let excelDataList = [ titleList ];//[[标题...],[数据...]]
dataList.forEach(info => {
let {eId, subList} = info;
excelDataList.push(subList);
});
/**接下来要获取对应的文件目录 */
console.log();
//1.首先要知道要获取一些什么文件 商标=>字段
let getFilesConf = {};//如果无需使用库中的命名,就用中文
getFilesConf[DOWNLOADTYPE.知识产权] = {
cheName:"知识产权",
itemConfList:[
{tableName:TABLENAME.专利, filesConfMap:{"iprUrl":"title"}},
{tableName:TABLENAME.软件著作权, filesConfMap:{"iprUrl":"name"}},
{tableName:TABLENAME.作品著作权, filesConfMap:{"iprUrl":"name"}},
{tableName:TABLENAME.商标, filesConfMap:{"imageUrl":"name"}}
]
};
getFilesConf[DOWNLOADTYPE.租赁信息] = {
cheName:"租赁信息",
itemConfList:[{tableName:TABLENAME.租赁信息, filesConfMap:{
"sanFangXieYi":"三方协议",
"fuHuaXieYi":"孵化协议",
"fangWuZuLing":"房屋租赁合同",
"fuHuaXieYiBuChong":"孵化协议补充协议书",
"chengXinChengNuoHan":"诚信承诺函",
"yingYeZhiZhao":"营业执照复印件",
"ruFuZiLiao":"入孵资料明细",
"ruZhuJiHua":"入驻计划复印件",
"yaJinZhiFu":"押金支付凭证",
"cardCopy":"身份证复印件地址",
}}]
};
getFilesConf[DOWNLOADTYPE.资质证书] = {
cheName:"资质证书",
itemConfList:[{tableName:TABLENAME.企业资质, filesConfMap:{
"kxImg":"科技型中小企业证书",
"gaoXinJiShuImg":"高新技术证书",
"zjtxImg":"专精特新证书",
"xjrPyImg":"小巨人培育证书",
"cxImg":"创新型中小企业证书",
}}]
};
//2.拼接成 filesServer 需要的数据结构
let filesServerFileList = [];//[ {enterpriseName:"", thisEnterpriseFilesList:[{dirName:"商标", subList:[{fileName:"商标名1", url:"" }] }, {}] }]
let enterpriseFilesMap = {};//{"企业名称":{"商标", subList:[{fileName:"商标名1", url:"" }]} }
for (let dowType in getFilesConf) {
let {itemConfList, cheName} = getFilesConf[dowType];
for (let i = 0; i < itemConfList.length; i++) {
let {tableName, filesConfMap} = itemConfList[i];
let itemSelectFiles = ["eId"];
for (let filesConfKey in filesConfMap) {
if (/^[A-Za-z]+$/.test(filesConfMap[filesConfKey])) {
itemSelectFiles.push(filesConfMap[filesConfKey]);
}
itemSelectFiles.push(filesConfKey);
}
let itemDBList = await selectData(OPERATIONALDATATYPE.查询多个, tableName, {eId: { "%in%": eIds}}, itemSelectFiles);
itemDBList.forEach(info => {
//多个企业的待会在这里做判断 用名称做区分
if (!enterpriseFilesMap[info.eId]) enterpriseFilesMap[info.eId] = {};
if (!enterpriseFilesMap[info.eId][cheName]) enterpriseFilesMap[info.eId][cheName] = [];
for (let filesConfKey in filesConfMap) { // url:名称
let infofileName = filesConfMap[filesConfKey];
if (/^[A-Za-z]+$/.test(infofileName)) {
infofileName = info[infofileName];
}
let thisInfoFileUrlList = [];
if (info[filesConfKey]) {
thisInfoFileUrlList = JSON.parse(info[filesConfKey])
}
thisInfoFileUrlList.forEach((subFileUrl, subFileUrlIndex) => {
let subFileName = infofileName;
if (subFileUrlIndex) {
subFileName += `_${subFileUrlIndex+1}`;
}
enterpriseFilesMap[info.eId][cheName].push({
fileName:subFileName,
url:subFileUrl
});
})
}
});
}
}
//[ {enterpriseName:"", thisEnterpriseFilesList:[{dirName:"商标", subList:[{fileName:"商标名1", url:"" }] }, {}] }]
for (let eId in enterpriseFilesMap) {
let thisEnterpriseFilesList = [];
for (let cheName in enterpriseFilesMap[eId]) {
let subList = enterpriseFilesMap[eId][cheName];
thisEnterpriseFilesList.push({
dirName:cheName,
subList
});
}
filesServerFileList.push({
enterpriseName:enterpriseNameMap[eId],
thisEnterpriseFilesList
});
}
let reqData = {
excelDataList:{name:"sheet1", data:excelDataList},//{ name:"sheet1", data:[[]]} ];
fileList:filesServerFileList,
zipFileName:`企业数据合并_${eIds.length}家_${moment().format('YYYYMMDDHHmmss')}`
};
let fileReqRes = await post(`${systemConfig.unZipFileUrl}/file/admin/zipdownload/consolidated`, reqData , {sign:"isdfalfdjasoiufoisjdlnad29230428029014i23mlkdslkf"});
return fileReqRes;
}
/**
* 下载选中企业的zip包文件(最多10个)- 直接包含文件夹版本
*/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -12,6 +12,9 @@ import { BizError } from "../util/bizError";
import { ERRORENUM } from "../config/enum/errorEnum";
import { convertFilesToObjectArray, getMySqlMs, getPwdMd5 } from "../tools/system";
import { BUILDING } from "../config/enum/enum";
import { convertObjectFileFieldsToDb, LEASE_FILE_FIELDS } from "./migrateSingleFileToArray";
import { eccFormParam } from "../util/verificationParam";
import { AdminRegisterUpdateConfig } from "../config/eccParam/enterprise";
// /**
......@@ -323,176 +326,197 @@ export async function ledgerList(enterpriseName:string, logonStartTime:Number, l
/**
* 企业台账文件补充上传
* @param eId 企业ID(必传)
* @param filesData 文件数据对象(数组类型)
* @param param 文件数据对象(数组类型)
* @returns
*/
export async function supplementLedgerFiles(
eId: string,
filesData: {
sanFangXieYi?: string[], // 三方协议
fuHuaXieYi?: string[], // 孵化协议
fangWuZuLing?: string[], // 房屋租赁
fuHuaXieYiBuChong?: string[], // 孵化协议补充
chengXinChengNuoHan?: string[],// 诚信承诺函
yingYeZhiZhao?: string[], // 营业执照
ruFuZiLiao?: string[], // 入孵资料
ruZhuJiHua?: string[], // 入驻计划
yaJinZhiFu?: string[], // 押金支付
cardCopy?: string[] // 身份证复印件
export async function supplementLedgerFiles(eId, param) {
const FuncName = "管理员修改企业台账文件信息";
eccFormParam(FuncName, AdminRegisterUpdateConfig, param );
let filesList = ["eId", "enterpriseName", "uscc", "logonTime", "state"];
let resInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.企业基础信息表, {eId}, filesList);
if (!resInfo || !resInfo.eId) {
throw new BizError(ERRORENUM.数据不存在);
}
) {
try {
// 1. 验证企业是否存在
const enterpriseExists = await selectData(
OPERATIONALDATATYPE.查询单个,
TABLENAME.企业基础信息表,
{ eId },
["eId"]
);
if (!enterpriseExists) {
return {
success: false,
code: 404,
message: `企业ID ${eId} 不存在`
};
}
// 2. 查询企业现有的租赁信息
const existingLeaseInfo = await selectData(
OPERATIONALDATATYPE.查询单个,
TABLENAME.租赁信息,
{ eId },
[
"leaseId", "eId", "sanFangXieYi", "fuHuaXieYi", "fangWuZuLing",
"fuHuaXieYiBuChong", "chengXinChengNuoHan", "yingYeZhiZhao",
"ruFuZiLiao", "ruZhuJiHua", "yaJinZhiFu", "cardCopy"
]
);
// 3. 准备更新的数据
const updateData: any = {};
let hasUpdates = false;
// 定义所有可更新的文件字段
const fileFields = [
'sanFangXieYi', 'fuHuaXieYi', 'fangWuZuLing',
'fuHuaXieYiBuChong', 'chengXinChengNuoHan', 'yingYeZhiZhao',
'ruFuZiLiao', 'ruZhuJiHua', 'yaJinZhiFu', 'cardCopy'
];
// 使用工具函数转换文件字段为数据库格式
const updateData = convertObjectFileFieldsToDb(param, LEASE_FILE_FIELDS);
await operationalData(OPERATIONALDATATYPE.修改, TABLENAME.租赁信息, updateData, {eId})
return {isSuccess:true};
}
// export async function supplementLedgerFiles(
// eId: string,
// param: {
// sanFangXieYi?: string[], // 三方协议
// fuHuaXieYi?: string[], // 孵化协议
// fangWuZuLing?: string[], // 房屋租赁
// fuHuaXieYiBuChong?: string[], // 孵化协议补充
// chengXinChengNuoHan?: string[],// 诚信承诺函
// yingYeZhiZhao?: string[], // 营业执照
// ruFuZiLiao?: string[], // 入孵资料
// ruZhuJiHua?: string[], // 入驻计划
// yaJinZhiFu?: string[], // 押金支付
// cardCopy?: string[] // 身份证复印件
// }
// ) {
// try {
// // 1. 验证企业是否存在
// const enterpriseExists = await selectData(
// OPERATIONALDATATYPE.查询单个,
// TABLENAME.企业基础信息表,
// { eId },
// ["eId"]
// );
// if (!enterpriseExists) {
// return {
// success: false,
// code: 404,
// message: `企业ID ${eId} 不存在`
// };
// }
// 遍历所有文件字段,合并新旧数据
for (const field of fileFields) {
if (filesData[field] !== undefined && Array.isArray(filesData[field])) {
const newFiles = filesData[field];
// // 2. 查询企业现有的租赁信息
// const existingLeaseInfo = await selectData(
// OPERATIONALDATATYPE.查询单个,
// TABLENAME.租赁信息,
// { eId },
// [
// "leaseId", "eId", "sanFangXieYi", "fuHuaXieYi", "fangWuZuLing",
// "fuHuaXieYiBuChong", "chengXinChengNuoHan", "yingYeZhiZhao",
// "ruFuZiLiao", "ruZhuJiHua", "yaJinZhiFu", "cardCopy"
// ]
// );
// // 3. 准备更新的数据
// const updateData = convertObjectFileFieldsToDb(param, LEASE_FILE_FIELDS);
// // await operationalData(OPERATIONALDATATYPE.修改, TABLENAME.租赁信息, updateData, {eId});
// // const updateData: any = {};
// // let hasUpdates = false;
// // 定义所有可更新的文件字段
// // const fileFields = [
// // 'sanFangXieYi', 'fuHuaXieYi', 'fangWuZuLing',
// // 'fuHuaXieYiBuChong', 'chengXinChengNuoHan', 'yingYeZhiZhao',
// // 'ruFuZiLiao', 'ruZhuJiHua', 'yaJinZhiFu', 'cardCopy'
// // ];
// // 遍历所有文件字段,合并新旧数据
// // for (const field of fileFields) {
// // if (filesData[field] !== undefined && Array.isArray(filesData[field])) {
// // const newFiles = filesData[field];
if (newFiles.length > 0) {
let existingFiles: string[] = [];
// // if (newFiles.length > 0) {
// // let existingFiles: string[] = [];
// 解析现有的文件数据(存储为JSON字符串)
if (existingLeaseInfo && existingLeaseInfo[field]) {
try {
const parsed = JSON.parse(existingLeaseInfo[field]);
if (Array.isArray(parsed)) {
existingFiles = parsed;
}
} catch (e) {
// 如果不是JSON格式,尝试作为字符串处理
if (typeof existingLeaseInfo[field] === 'string') {
existingFiles = [existingLeaseInfo[field]];
}
}
}
// // // 解析现有的文件数据(存储为JSON字符串)
// // if (existingLeaseInfo && existingLeaseInfo[field]) {
// // try {
// // const parsed = JSON.parse(existingLeaseInfo[field]);
// // if (Array.isArray(parsed)) {
// // existingFiles = parsed;
// // }
// // } catch (e) {
// // // 如果不是JSON格式,尝试作为字符串处理
// // if (typeof existingLeaseInfo[field] === 'string') {
// // existingFiles = [existingLeaseInfo[field]];
// // }
// // }
// // }
// 合并新旧文件数组(去重)
const mergedFiles = mergeFileArrays(existingFiles, newFiles);
// // // 合并新旧文件数组(去重)
// // const mergedFiles = mergeFileArrays(existingFiles, newFiles);
// 转换为JSON字符串存储
updateData[field] = JSON.stringify(mergedFiles);
hasUpdates = true;
}
}
}
// 4. 如果没有可更新的数据,直接返回
if (!hasUpdates) {
return {
success: false,
code: 400,
message: "未提供有效的文件数据或文件数据格式不正确"
};
}
// 5. 添加更新时间
// updateData.updateTime = new Date();
let result;
if (existingLeaseInfo) {
// 6a. 如果已存在租赁信息,则更新
result = await operationalData(
OPERATIONALDATATYPE.修改,
TABLENAME.租赁信息,
updateData,
{ eId }
);
} else {
// 6b. 如果不存在租赁信息,则创建新的记录
updateData.eId = eId;
// updateData.createTime = new Date();
// // // 转换为JSON字符串存储
// // updateData[field] = JSON.stringify(mergedFiles);
// // hasUpdates = true;
// // }
// // }
// // }
// // 4. 如果没有可更新的数据,直接返回
// // if (!hasUpdates) {
// // return {
// // success: false,
// // code: 400,
// // message: "未提供有效的文件数据或文件数据格式不正确"
// // };
// // }
// // 5. 添加更新时间
// // updateData.updateTime = new Date();
// let result;
// if (existingLeaseInfo) {
// // 6a. 如果已存在租赁信息,则更新
// result = await operationalData(
// OPERATIONALDATATYPE.修改,
// TABLENAME.租赁信息,
// updateData,
// { eId }
// );
// } else {
// // 6b. 如果不存在租赁信息,则创建新的记录
// updateData.eId = eId;
// // updateData.createTime = new Date();
result = await operationalData(
OPERATIONALDATATYPE.增加,
TABLENAME.租赁信息,
updateData,
{}
);
}
if (!result) {
return {
success: false,
code: 500,
message: "数据库操作失败"
};
}
// 7. 返回更新后的完整数据
const updatedLeaseInfo = await selectData(
OPERATIONALDATATYPE.查询单个,
TABLENAME.租赁信息,
{ eId },
fileFields
);
// 转换文件格式为前端可用的对象数组
const formattedData: any = {};
fileFields.forEach(field => {
if (updatedLeaseInfo && updatedLeaseInfo[field]) {
formattedData[field] = convertFilesToObjectArray(updatedLeaseInfo[field]);
} else {
formattedData[field] = [];
}
});
// result = await operationalData(
// OPERATIONALDATATYPE.增加,
// TABLENAME.租赁信息,
// updateData,
// {}
// );
// }
return {
success: true,
code: 200,
message: "文件补充上传成功",
data: {
eId,
...formattedData
}
};
// if (!result) {
// return {
// success: false,
// code: 500,
// message: "数据库操作失败"
// };
// }
} catch (error) {
console.error('补充文件上传失败:', error);
return {
success: false,
code: 500,
message: `服务器内部错误: ${error.message}`
};
}
}
// // 7. 返回更新后的完整数据
// const updatedLeaseInfo = await selectData(
// OPERATIONALDATATYPE.查询单个,
// TABLENAME.租赁信息,
// { eId },
// updateData
// );
// // 转换文件格式为前端可用的对象数组
// const formattedData: any = {};
// updateData.forEach(field => {
// if (updatedLeaseInfo && updatedLeaseInfo[field]) {
// formattedData[field] = convertFilesToObjectArray(updatedLeaseInfo[field]);
// } else {
// formattedData[field] = [];
// }
// });
// return {
// success: true,
// code: 200,
// message: "文件补充上传成功",
// data: {
// eId,
// ...formattedData
// }
// };
// } catch (error) {
// console.error('补充文件上传失败:', error);
// return {
// success: false,
// code: 500,
// message: `服务器内部错误: ${error.message}`
// };
// }
// }
/**
......
......@@ -78,8 +78,7 @@ export async function getNotificationList(msgTitle:string, msgType:number, eId:s
if (allEnterpriseIds.size > 0) {
const enterpriseIdsArray = Array.from(allEnterpriseIds);
// 假设企业表中有 eId 和 eName 字段
const enterpriseFields = ["eId", "eName"];
const enterpriseFields = ["eId", "enterpriseName"];
const enterpriseParam = {
eId: { "%in%": enterpriseIdsArray }
};
......@@ -93,7 +92,7 @@ export async function getNotificationList(msgTitle:string, msgType:number, eId:s
// 构建企业ID到企业名称的映射
enterpriseList.forEach(enterprise => {
enterpriseMap.set(enterprise.eId, enterprise.eName || enterprise.eId);
enterpriseMap.set(enterprise.eId, enterprise.enterpriseName || enterprise.eId);
});
}
......@@ -122,7 +121,7 @@ export async function getNotificationList(msgTitle:string, msgType:number, eId:s
}
} else {
// 如果不是数组,保持原值
targetEnterpriseInfo = item.eId;
targetEnterpriseInfo = item.enterpriseName;
}
} else {
// 如果eId为空,表示全部企业
......@@ -136,6 +135,7 @@ export async function getNotificationList(msgTitle:string, msgType:number, eId:s
return {
...item,
msgType:changeEnumValue(MSGTYPE, item.msgType),
effectiveTime:moment(item.effectiveTime).format("YYYY-MM-DD"),
eId: targetEnterpriseInfo
};
});
......
......@@ -387,12 +387,14 @@ export async function settleInEnterpriseOut(eId:string, descType, desc:string) {
*/
export async function getNewApplicationCount() {
let selectParam = {
register: enumConfig.CHANGESTATE.未审核,
register:enumConfig.CHANGESTATE.已通过,
"%or%":[{state:enumConfig.CHANGESTATE.未审核}, {state:enumConfig.CHANGESTATE.已驳回}],
// register: enumConfig.CHANGESTATE.未审核,
isNewApplication: enumConfig.STATE., // 只统计未查看的新申请
"%or%": [
{ register: enumConfig.CHANGESTATE.未审核 },
{ register: enumConfig.CHANGESTATE.已驳回 }
]
// "%or%": [
// { register: enumConfig.CHANGESTATE.未审核 },
// { register: enumConfig.CHANGESTATE.已驳回 }
// ]
};
let count = await selectData(
......
......@@ -10,7 +10,7 @@ import { OPERATIONALDATATYPE, TABLEID, TABLENAME } from "../config/enum/dbEnum";
import { operationalData, selectData, selectManyTableData } from "../data/operationalData";
import { BizError } from "../util/bizError";
import { ERRORENUM } from "../config/enum/errorEnum";
import { getMySqlMs, getPinyinInitials, getToken, randomId } from "../tools/system";
import { getMySqlMs, getPinyinInitials, getPwdMd5, getToken, randomId } from "../tools/system";
import { changeAdd, extractData } from "../util/piecemeal";
import { EnterpriseApplyForConfig } from "../config/splitResult/enterprise";
import { CHANGESTATE, CHANGETYPE, FUHUASTATE, RUFUSTATE, STATE } from "../config/enum/enum";
......@@ -31,11 +31,14 @@ import { createMessageReminder } from "./message";
let userInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.企业用户表, {phone}, ["uId"]);
if (userInfo && userInfo.uId) throw new BizError(ERRORENUM.手机号码重复);
let uId = randomId(TABLEID.企业用户表);
const encryptedPwd = getPwdMd5(uId, pwd);
let addUInfo = {
uId:randomId(TABLEID.企业用户表),
uId,
userName,
phone,
pwd
pwd:encryptedPwd
};
await operationalData(OPERATIONALDATATYPE.增加, TABLENAME.企业用户表, addUInfo, {});
......@@ -53,7 +56,9 @@ export async function enterpriseLogin(phone:string, pwd:string) {
let enterpriseUserInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.企业用户表, {phone}, ["uId", "phone", "pwd", "eId"]);
if (!enterpriseUserInfo || !enterpriseUserInfo.uId) throw new BizError(ERRORENUM.账号不存在);
if (enterpriseUserInfo.pwd != pwd) throw new BizError(ERRORENUM.账号或密码错误);
const encryptedPwd = getPwdMd5(enterpriseUserInfo.uId, pwd);
console.log(enterpriseUserInfo.pwd + "===>" + encryptedPwd)
if (enterpriseUserInfo.pwd != encryptedPwd) throw new BizError(ERRORENUM.账号或密码错误);
let updateUserInfo = {
token : getToken(enterpriseUserInfo.uId),
......@@ -429,7 +434,12 @@ export async function updateRuFu(eId:string, param) {
}
await operationalData(OPERATIONALDATATYPE.修改, TABLENAME.企业基础信息表, {state:CHANGESTATE.未审核, isNewApplication: STATE.}, {eId});
await operationalData(OPERATIONALDATATYPE.修改, TABLENAME.租赁信息, param, {eId});
let updataParam = {};
for (let key in param) {
updataParam[key] = JSON.stringify(param[key]);
}
await operationalData(OPERATIONALDATATYPE.修改, TABLENAME.租赁信息, updataParam, {eId});
// 检查是否是重新提交(之前被驳回过)
const wasRejected = resInfo.state === CHANGESTATE.已驳回;
......
......@@ -513,6 +513,19 @@ export enum DOWNLOADTYPE {
}
// 下载类型枚举
export enum DOWNLOADCLIENTTYPE {
// 全部数据 = 'all',
资质证书 = 'qualification',
知识产权 = 'intellectualProperty',
租赁信息 = 'lease',
// 商标 = 'trademark',
// 作品著作权 = 'copyright',
// 软件著作权 = 'softwareCopyright',
// 专利 = 'patent'
}
// 企业消息状态枚举
export enum MSGTYPE {
// 季度填报相关
......
......@@ -85,22 +85,27 @@ export enum DOWNLOADCOLS {
// 通信地址 = "tongXinDiZhi",
联系人 = "liaison",
联系电话 = "liaisonPhone",
登记机关 = "dengJiJiGuan",
// 登记机关 = "dengJiJiGuan",
企业规模 = "qiYeGuiMo",
登记状态 = "RAS",
官网地址 = "guanWang",
营业期限 = "yingYeQiXian",
注销时间 = "logOffMS",
// 登记状态 = "RAS",
// 官网地址 = "guanWang",
// 营业期限 = "yingYeQiXian",
// 注销时间 = "logOffMS",
实缴资本 = "shijiaoziben",
企业机构类型 = "enterpriseType",
// 企业机构类型 = "enterpriseType",
简介 = "jianJie",
注册资本 = "zhuceziben",
纳税人资质 = "naShuiRenZiZhi",
// 纳税人资质 = "naShuiRenZiZhi",
经营地址 = "operatingAddress",
迁入前注册地址 = "oldLogonAddress",
税号 = "shuiHao",
税务局 = "shuiWuJu",
// 迁入前注册地址 = "oldLogonAddress",
// 税号 = "shuiHao",
// 税务局 = "shuiWuJu",
经营范围 = "jingYingFanWei",
/**其他表 */
孵化时间 = "fuhuaTime",
租赁面积 = "area",
楼号 = "building",
室号 = "roomNumber",
}
......@@ -129,10 +134,11 @@ export enum FINANCINGCOLS {
/**荣誉奖项下载列 */
export enum HONORCOLS {
奖项名称 = "awardName",
颁奖单位 = "awardingUnit",
获奖日期 = "awardTime",
奖项等级 = "awardLevel",
荣誉奖项数量 = "awardCount"
// 奖项名称 = "awardName",
// 颁奖单位 = "awardingUnit",
// 获奖日期 = "awardTime",
// 奖项等级 = "awardLevel",
}
......
......@@ -16,9 +16,11 @@ export async function initConfig() {
if (!configInfo || !configInfo.config) throw new BizError('xml中无配置');
else {
let {port, sign, dbServer, imgUrl, imgFileUrl, qcc } = configInfo.config;
let {port, sign, SECRET_TOKEN, dbServer, imgUrl, imgFileUrl, qcc, unZipFileUrl } = configInfo.config;
systemConfig.port = parseInt(port[0]);
systemConfig.secretToken = SECRET_TOKEN[0];
systemConfig.dbSign = sign[0];
systemConfig.dbPath = dbServer[0];
......@@ -28,6 +30,7 @@ export async function initConfig() {
systemConfig.qccKey = qcc[0].key[0];
systemConfig.qccSecretKey = qcc[0].SecretKey[0];
systemConfig.unZipFileUrl = unZipFileUrl[0];
}
......
......@@ -6,12 +6,14 @@
export class ServerConfig {
/**系统配置 */
port:number;
dbSign:String;
dbPath:String;
secretToken:string;
dbSign:string;
dbPath:string;
imgPath:string;
imgUrl:String;
imgFileUrl:String;
imgUrl:string;
imgFileUrl:string;
/**企查查 */
qccKey:string;
qccSecretKey:string;
unZipFileUrl:string;
}
\ No newline at end of file
import { newDow } from "./biz/createZip";
import { integration } from "./biz/dataAsync";
import { migrateAdminPasswords, migrateEnterpriseUserPasswords } from "./biz/dataInit";
import { migrateSingleFileToArray } from "./biz/migrateSingleFileToArray";
......@@ -15,12 +16,22 @@ async function lanuch() {
// await initApiDataStorage();
console.log("更新加密后密码格式...");
// console.log("更新加密后密码格式...");
// await migrateEnterpriseUserPasswords();
// await migrateAdminPasswords();
console.log("更新业务函数以兼容新的文件存储格式...");
// console.log("更新业务函数以兼容新的文件存储格式...");
// migrateSingleFileToArray();
// await integration();
// let eIds = ["e_ea892413d62a108e7a9517443668ddcf","e_08ae2d8974e752b3e251de1764274baa", "e_8f554f5254d9775484802ad0b2e96731"];
// let options = {exportFileTypes: ["all"], customColumns:{
// "经营数据":[
// { key: '营收(万元)', value: 'BI' },
// { key: '纳税(万元)', value: 'TXP' },
// { key: '季度', value: 'quarter' }
// ]
// }};
// await newDow(eIds, options);
}
......
......@@ -30,6 +30,7 @@ export class httpServer {
// httpServer.use(bodyParser.json({limit:'5mb'}));
// httpServer.use(bodyParser.urlencoded({limit:'5mb', extends:true}));
// httpServer.use(express.static("./temp"));
httpServer.use(express.static("./static") );
httpServer.use(express.static("./files") );
httpServer.use(express.static("./img") );
......@@ -38,7 +39,7 @@ export class httpServer {
httpServer.use(fallback('index.html', { root }));
httpServer.use(compression());
httpServer.use(watch);
httpServer.use(bodyParser.json({limit:"5000kb"}));
httpServer.use(bodyParser.json({limit:"50000kb"}));
routers.setRouter(httpServer);
httpServer.use(httpErrorHandler);
......
......@@ -32,7 +32,7 @@ const config = {
"/public/desctypeclient":enumConfig.DESCTYPECLIENT, //入孵申请审批驳回
"/public/filedesctypeclient":enumConfig.FILEDESCTYPECLIENT, //入孵材料审批驳回
/**二期 */
"/public/downloadtype":enumConfig.DOWNLOADTYPE, //下载类型
"/public/downloadtype":enumConfig.DOWNLOADCLIENTTYPE, //下载类型
"/public/downloadcols":outputEnumConfig.DOWNLOADCOLS, //基础数据下载列
"/public/operationcols":outputEnumConfig.OPERATIONCOLS, //经营数据下载列
"/public/financingcols":outputEnumConfig.FINANCINGCOLS, //融资数据下载列
......
......@@ -5,11 +5,15 @@
import asyncHandler = require("express-async-handler");
import { checkUser } from "../middleware/user";
import * as fs from "fs-extra";
import { downloadConsolidatedDataSimple, downloadEnterpriseData } from "../biz/createZip";
import { downloadConsolidatedDataSimple, downloadEnterpriseData, newDow } from "../biz/createZip";
import { DOWNLOADTYPE } from "../config/enum/enum";
import { systemConfig } from "../config/serverConfig";
export function setRouter(httpServer) {
// 按配置下载压缩包数据
httpServer.post("/admin/enterprise/zipdownload/newdow", checkUser, asyncHandler(newDowZipDownload));
// 下载全部数据
httpServer.post("/admin/enterprise/zipdownload/consolidated", checkUser, asyncHandler(downloadConsolidated));
......@@ -27,6 +31,44 @@ export function setRouter(httpServer) {
}
async function newDowZipDownload(req, res) {
try {
console.log("收到下载全部数据请求,参数:", req.body);
const { eIds, options } = req.body;
if (!eIds) {
return res.status(400).json({ error: "缺少必要参数eIds" });
}
if (!options) {
return res.status(400).json({ error: "缺少必要参数options" });
}
if (!options.exportFileTypes) {
return res.status(400).json({ error: "缺少必要参数options.exportFileTypes" });
}
console.log(`开始下载全部数据,企业ID: ${JSON.stringify(eIds)}, 数据类型: ${JSON.stringify(options.exportDataTypes)}, 文件类型: ${JSON.stringify(options.exportFileTypes)}`);
let result = await newDow(eIds, options);
res.success(result);
} catch (error) {
console.error("下载全部数据失败:", error);
if (!res.headersSent) {
res.status(500).json({
error: "下载全部数据失败",
message: error.message,
stack: process.env.NODE_ENV === "development" ? error.stack : undefined
});
}
}
}
/**
* 下载
......@@ -55,6 +97,19 @@ export function setRouter(httpServer) {
}
*/
async function downloadConsolidated(req, res) {
/**
* 现有逻辑:
* 1.去filesServer 获取文件 鉴权
* 2.拿到文件的二进制文件写入到 temp
* 3.压缩
* 4.返回压缩包的文件目录
*
* 1.通知filesserver 有人下载,xuya
* 2.filesServer 去处理压缩包
* 3.filseServer返回目录名称和目录地址
* 4.本接口返回
*
*/
try {
console.log("收到下载全部数据请求,参数:", req.body);
const { eIds, options } = req.body;
......@@ -80,12 +135,7 @@ async function downloadConsolidated(req, res) {
let result = await downloadConsolidatedDataSimple(eIds, options);
console.log("全部数据ZIP文件创建成功: ", result.fileName);
console.log("处理统计:", result.statistics);
// 设置响应头
res.setHeader("Content-Type", "application/zip");
res.setHeader("Content-Disposition", `attachment; filename=${encodeURIComponent(result.fileName)}`);
res.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
// 检查文件是否存在
if (!await fs.pathExists(result.filePath)) {
throw new Error("ZIP文件未找到: " + result.filePath);
......@@ -96,21 +146,24 @@ async function downloadConsolidated(req, res) {
res.setHeader("Content-Length", stats.size);
console.log(`准备发送文件: ${result.fileName}, 大小: ${stats.size} bytes`);
res.success({fileDir:result.fileDir, filename:result.fileName});
// 发送文件
res.sendFile(result.filePath, async (err) => {
if (err) {
console.error("发送文件失败:", err);
if (!res.headersSent) {
res.status(500).json({ error: "文件发送失败", message: err.message });
}
} else {
console.log("全部数据文件发送成功");
}
// // 发送文件
// res.sendFile(result.filePath, async (err) => {
// if (err) {
// console.error("发送文件失败:", err);
// if (!res.headersSent) {
// res.status(500).json({ error: "文件发送失败", message: err.message });
// }
// } else {
// console.log("全部数据文件发送成功");
// }
// 清理临时文件
await cleanupTempFile(result.filePath);
});
// // 清理临时文件
// // await cleanupTempFile(result.filePath);
// });
} catch (error) {
console.error("下载全部数据失败:", error);
if (!res.headersSent) {
......@@ -176,7 +229,7 @@ async function handleDownload(req, res, downloadType: DOWNLOADTYPE, typeName: st
}
// 清理临时文件
await cleanupTempFile(result.filePath);
// await cleanupTempFile(result.filePath);
});
} catch (error) {
......
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