Commit 04f51f3b by chenjinjing

no message

parent 7d48d9de
...@@ -332,6 +332,26 @@ export async function enterpriseManageList(enterpriseName:string, year:number, q ...@@ -332,6 +332,26 @@ export async function enterpriseManageList(enterpriseName:string, year:number, q
} }
// 管理后台新增函数:为企业指定年度、季度插入一条全0记录
async function initDefaultRevenueRecord(eId, year, quarter) {
const mId = randomId(TABLEID.企业经营信息); // 生成唯一ID
const annualStr = `${year}-01-01 00:00:00`;
const addInfo = {
mId,
eId,
createTime: getMySqlMs(),
annual: getMySqlMs(annualStr),
quarter, // 季度值(1,2,3,4)
BI: 0,
TXP: 0,
RD: 0,
state: 0
};
await operationalData(OPERATIONALDATATYPE.增加, TABLENAME.企业经营信息, addInfo, {});
}
export async function outPutEnterpriseManageList(enterpriseName:string, year:number, type:number, files) { export async function outPutEnterpriseManageList(enterpriseName:string, year:number, type:number, files) {
let selectParam:any = {isSubmit:enumConfig.STATE.}; let selectParam:any = {isSubmit:enumConfig.STATE.};
let manyTableInfo:any = {}; let manyTableInfo:any = {};
......
...@@ -590,7 +590,7 @@ export async function autoLogin(mobile: string, timestamp: string, usersign: str ...@@ -590,7 +590,7 @@ export async function autoLogin(mobile: string, timestamp: string, usersign: str
// 8. 直接返回登录成功信息 // 8. 直接返回登录成功信息
return { return {
isSuccess: true, isSuccess: true,
message: "自动登录成功", message: "自动登录成功",
dataInfo: userInfo dataInfo: userInfo
}; };
} }
......
...@@ -25,7 +25,7 @@ import { BUILDING } from "../config/enum/enum"; ...@@ -25,7 +25,7 @@ import { BUILDING } from "../config/enum/enum";
* @param building 园区楼号 * @param building 园区楼号
* @returns * @returns
*/ */
export async function enterpriseList(enterpriseName:string, page:number, logonStartTime:Number, logonEndTime:Number, startTime:Number, endTime:Number, building: number ) { export async function enterpriseList(enterpriseName:string, page:number, logonStartTime:Number, logonEndTime:Number, startTime:Number, endTime:Number, building: number ) {
let selectParam: any = {state: enumConfig.CHANGESTATE.已通过}; let selectParam: any = {state: enumConfig.CHANGESTATE.已通过};
if (enterpriseName) { if (enterpriseName) {
selectParam.enterpriseName = { "%like%": enterpriseName }; selectParam.enterpriseName = { "%like%": enterpriseName };
...@@ -60,7 +60,17 @@ import { BUILDING } from "../config/enum/enum"; ...@@ -60,7 +60,17 @@ import { BUILDING } from "../config/enum/enum";
zaifuMap[info.eId] = info; zaifuMap[info.eId] = info;
}) })
} }
// ========== 新增:批量初始化营收记录 ==========
// 提取所有通过筛选的企业ID
const allEids = resInfo.map(item => item.eId).filter(eId => zaifuMap[eId]); // 仅保留有租赁记录的企业(与原逻辑一致)
if (allEids.length > 0) {
const currentYear = moment().year(); // 使用当前年度,也可根据业务需求调整
await batchEnsureQuarterRevenueRecords(allEids, currentYear);
}
// ==========================================
let zaifuList = []; let zaifuList = [];
for (let info of resInfo) { for (let info of resInfo) {
let { let {
...@@ -112,6 +122,62 @@ import { BUILDING } from "../config/enum/enum"; ...@@ -112,6 +122,62 @@ import { BUILDING } from "../config/enum/enum";
/** /**
* 批量确保多个企业在指定年度的所有季度都有营收记录(缺失则创建全0记录)
* @param {Array<string>} eIds 企业ID数组
* @param {number} year 年度(如 2026)
* @returns {Promise<void>}
*/
async function batchEnsureQuarterRevenueRecords(eIds, year) {
if (!eIds || eIds.length === 0) return;
const annualCondition = getMySqlMs(`${year}-01-01 00:00:00`);
// 1. 一次性查询所有企业在当前年度的现有记录(仅季度字段)
let existingAll = await selectData(
OPERATIONALDATATYPE.查询多个,
TABLENAME.企业经营信息,
{ annual: annualCondition, eId: { "%in%": eIds } },
["eId", "quarter"]
);
// 2. 构建 Map:企业ID -> 已存在的季度Set
const existingMap = new Map();
existingAll.forEach(rec => {
if (!existingMap.has(rec.eId)) existingMap.set(rec.eId, new Set());
existingMap.get(rec.eId).add(rec.quarter);
});
// 3. 收集需要创建的记录
const newRecords = [];
for (const eId of eIds) {
const existingQuarters = existingMap.get(eId) || new Set();
for (let q = 1; q <= 4; q++) {
if (!existingQuarters.has(q)) {
newRecords.push({
eId,
mId: randomId(TABLEID.企业经营信息),
annual: annualCondition,
quarter: q,
BI: 0,
TXP: 0,
RD: 0,
createTime: getMySqlMs(),
state: 1,
isSubmit: 0,
isUpdate: 0
});
}
}
}
// 4. 批量插入缺失的记录
if (newRecords.length > 0) {
await operationalData(OPERATIONALDATATYPE.增加, TABLENAME.企业经营信息, newRecords, {});
}
}
/**
* 新增在孵企业迁出功能 * 新增在孵企业迁出功能
* @param eId 企业ID * @param eId 企业ID
* @param moveOutType 迁出类型 毕业迁出,毕业未迁出 * @param moveOutType 迁出类型 毕业迁出,毕业未迁出
......
...@@ -11,7 +11,7 @@ import { getPwdMd5 } from "./tools/system"; ...@@ -11,7 +11,7 @@ import { getPwdMd5 } from "./tools/system";
async function lanuch() { async function lanuch() {
const encryptedPwd = getPwdMd5("ur_50e39e678e8bc8d19fd4b5aa98196a27", "123456"); const encryptedPwd = getPwdMd5("ur_1d9e40b7cdb9a8226b191446f57ff739", "111111");
console.log(); console.log();
await initConfig(); await initConfig();
......
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