Commit bd25b882 by chenjinjing

no message

parent 2a92cb38
...@@ -881,8 +881,9 @@ ...@@ -881,8 +881,9 @@
}, },
"node_modules/express-history-api-fallback": { "node_modules/express-history-api-fallback": {
"version": "2.2.1", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/express-history-api-fallback/-/express-history-api-fallback-2.2.1.tgz", "resolved": "https://registry.npmmirror.com/express-history-api-fallback/-/express-history-api-fallback-2.2.1.tgz",
"integrity": "sha1-OirSf3vryQ/FM9EQ18bYMJe80Fc=" "integrity": "sha512-swxwm3aP8vrOOvlzOdZvHlSZtJGwHKaY94J6AkrAgCTmcbko3IRwbkhLv2wKV1WeZhjxX58aLMpP3atDBnKuZg==",
"license": "ISC"
}, },
"node_modules/express/node_modules/qs": { "node_modules/express/node_modules/qs": {
"version": "6.7.0", "version": "6.7.0",
...@@ -3634,8 +3635,8 @@ ...@@ -3634,8 +3635,8 @@
}, },
"express-history-api-fallback": { "express-history-api-fallback": {
"version": "2.2.1", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/express-history-api-fallback/-/express-history-api-fallback-2.2.1.tgz", "resolved": "https://registry.npmmirror.com/express-history-api-fallback/-/express-history-api-fallback-2.2.1.tgz",
"integrity": "sha1-OirSf3vryQ/FM9EQ18bYMJe80Fc=" "integrity": "sha512-swxwm3aP8vrOOvlzOdZvHlSZtJGwHKaY94J6AkrAgCTmcbko3IRwbkhLv2wKV1WeZhjxX58aLMpP3atDBnKuZg=="
}, },
"extend": { "extend": {
"version": "3.0.2", "version": "3.0.2",
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
"ws": "^5.2.2", "ws": "^5.2.2",
"xml2js": "^0.4.23" "xml2js": "^0.4.23"
}, },
"devDependencies": {},
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
......
...@@ -104,10 +104,10 @@ export async function caiShouList(zhongYangType:number, dId:string, plantType:nu ...@@ -104,10 +104,10 @@ export async function caiShouList(zhongYangType:number, dId:string, plantType:nu
let {csId, plantType, dIdList, operationTime, weight, ct } = item; let {csId, plantType, dIdList, operationTime, weight, ct } = item;
let dIds = dIdList; let dIds = dIdList;
let didStr = ""; let didStr = "";
let purpose = ""; let purpose = "-";
dIds.forEach(dId => { dIds.forEach(dId => {
didStr += `${diKuaiMap[dId].code} `; didStr += `${diKuaiMap[dId].code} `;
purpose += `${changeEnumValue(PURPOSE, diKuaiMap[dId].purpose)} `; purpose = `${changeEnumValue(PURPOSE, diKuaiMap[dId].purpose)} `;
}); });
let operationTimeNum; let operationTimeNum;
if (operationTime) operationTimeNum = operationTime; if (operationTime) operationTimeNum = operationTime;
...@@ -115,7 +115,7 @@ export async function caiShouList(zhongYangType:number, dId:string, plantType:nu ...@@ -115,7 +115,7 @@ export async function caiShouList(zhongYangType:number, dId:string, plantType:nu
dataList.push({ dataList.push({
csId, csId,
plantType:changeEnumValue(PLANTTYPE, plantType), plantType:changeEnumValue(PLANTTYPE, plantType),
code:didStr, code:didStr || "-",
purpose, purpose,
operationTime:moment(operationTimeNum).format("YYYY-MM-DD"), operationTime:moment(operationTimeNum).format("YYYY-MM-DD"),
weight, weight,
......
...@@ -189,8 +189,8 @@ export async function nongZiListToPage(nzType:number, dId:string, useTime:number ...@@ -189,8 +189,8 @@ export async function nongZiListToPage(nzType:number, dId:string, useTime:number
let dikuaiList = await dikuaiData.selectToParam({}); let dikuaiList = await dikuaiData.selectToParam({});
let diKuaiMap = {}; let diKuaiMap = {};
dikuaiList.forEach(info => { dikuaiList.forEach(info => {
let {dId, code} = info; let {dId, code, purpose} = info;
diKuaiMap[dId] = code; diKuaiMap[dId] = {code, purpose};
}); });
let nongziList = await nongziData.findDataToParamToSortPage( param, {useTime:-1}, pageNumber ); let nongziList = await nongziData.findDataToParamToSortPage( param, {useTime:-1}, pageNumber );
...@@ -204,7 +204,8 @@ export async function nongZiListToPage(nzType:number, dId:string, useTime:number ...@@ -204,7 +204,8 @@ export async function nongZiListToPage(nzType:number, dId:string, useTime:number
let purpose = ""; let purpose = "";
let size = ""; let size = "";
dIdList.forEach(dId => { dIdList.forEach(dId => {
didStr += `${diKuaiMap[dId] || "-"}`; didStr += `${diKuaiMap[dId].code || "-"}`;
purpose = diKuaiMap[dId].purpose;
}) })
dataList.push({ dataList.push({
nzId, nzId,
......
...@@ -54,7 +54,7 @@ export async function adminUserLogin(loginId:string, pwd:string) { ...@@ -54,7 +54,7 @@ export async function adminUserLogin(loginId:string, pwd:string) {
* @param userInfo * @param userInfo
*/ */
export async function adminUserLogout(reqUserInfo) { export async function adminUserLogout(reqUserInfo) {
let userInfo = await findUserInfoByUserId(reqUserInfo.userId); let userInfo = await findUserInfoByUserId(reqUserInfo.userid);
userInfo.adminToken = getToken(userInfo.loginId); userInfo.adminToken = getToken(userInfo.loginId);
userInfo.adminTokenMs = new Date().valueOf(); userInfo.adminTokenMs = new Date().valueOf();
...@@ -65,10 +65,9 @@ export async function adminUserLogout(reqUserInfo) { ...@@ -65,10 +65,9 @@ export async function adminUserLogout(reqUserInfo) {
} }
/** /**
* 统计页产量统计 * 统计页产量统计
* @param type * @param type 统计类型:1-年,2-季度,3-月
* @returns * @returns
*/ */
export async function homePageStatisChanLiang(type:number) { export async function homePageStatisChanLiang(type:number) {
...@@ -82,7 +81,7 @@ export async function homePageStatisChanLiang(type:number) { ...@@ -82,7 +81,7 @@ export async function homePageStatisChanLiang(type:number) {
let {ct, weight} = info; let {ct, weight} = info;
let year = moment(ct).year(); let year = moment(ct).year();
let month = moment(ct).month(); let month = moment(ct).month() + 1;
if (!map1[''+year+''+month]) map1[''+year+''+month] = {month, year, totalWeight:0} if (!map1[''+year+''+month]) map1[''+year+''+month] = {month, year, totalWeight:0}
map1[''+year+''+month].totalWeight += weight; map1[''+year+''+month].totalWeight += weight;
}) })
...@@ -205,5 +204,163 @@ export async function homePageStatisChanLiang(type:number) { ...@@ -205,5 +204,163 @@ export async function homePageStatisChanLiang(type:number) {
/**
* 统计页产量统计
* @param year 年份,如 2025
* @param type 统计类型:1-年,2-季度,3-月
* @returns
*/
// export async function homePageStatisChanLiang(year: number, type: number) {
// // 产量 时间分
// let zuoWuMonthDBList = await caishouData.selectToParam({plantType:{"$lt":PLANTTYPE.鲈鱼}});
// let zuoWuDistinctMap = {};
// let zuoWuCount = 0;
// let map1 = {};
// zuoWuMonthDBList.forEach(info => {
// let {ct, weight} = info;
// let dataYear = moment(ct).year();
// let month = moment(ct).month();
// // 添加年份过滤
// if (year && dataYear !== year) {
// return;
// }
// if (!map1[''+dataYear+''+month]) map1[''+dataYear+''+month] = {month, year: dataYear, totalWeight:0}
// map1[''+dataYear+''+month].totalWeight += weight;
// })
// let list1 = Object.values(map1);
// list1.forEach(info => {
// let {year: dataYear, month, totalWeight}: any = info;
// let strKey: any = "";
// if (type == 1) {//年
// strKey = dataYear;
// } else if (type == 2) {//季度
// let quarter = 1;
// if (month >= 10) quarter = 4;
// else if (month >= 7) quarter = 3;
// else if (month >= 4) quarter = 2;
// strKey = `${dataYear}-${quarter}`;
// } else {//月
// strKey = `${dataYear}-${month}`;
// }
// if (!zuoWuDistinctMap[strKey]) zuoWuDistinctMap[strKey] = {key: strKey, value: 0};
// zuoWuDistinctMap[strKey].value += totalWeight;
// zuoWuCount += totalWeight;
// });
// let nongChanPin = Object.values(zuoWuDistinctMap);
// for (let i = 0; i < nongChanPin.length; i++) {
// nongChanPin[i]["value"] = Math.ceil(nongChanPin[i]["value"] / 10) / 100;
// }
// // 农作物产量 - 添加年份过滤条件
// let zuoWuDBList = await selectChanLiangOfzuoWu({
// plantType: {"$lt": PLANTTYPE.鲈鱼},
// ...(year && {year: year}) // 如果有年份参数,添加过滤条件
// });
// let zuoWu = [];
// zuoWuDBList.forEach(info => {
// let {_id, totalWeight} = info;
// zuoWu.push({
// key: changeEnumValue(PLANTTYPE, _id),
// value: totalWeight / 1000
// });
// });
// zuoWu.sort((a, b) => {return b.value - a.value});
// // 产量
// let shuiChanMonthDBList = await selectChanLiangOfMonth({plantType:{"$gte":PLANTTYPE.鲈鱼}});
// let shuiChanDistinctMap = {};
// let shuiChanCount = 0;
// shuiChanMonthDBList.forEach(info => {
// let {year: dataYear, month, totalWeight} = info;
// // 添加年份过滤
// if (year && dataYear !== year) {
// return;
// }
// let strKey = "";
// if (type == 1) {//年
// strKey = dataYear;
// } else if (type == 2) {//季度
// let quarter = 1;
// if (month >= 10) quarter = 4;
// else if (month >= 7) quarter = 3;
// else if (month >= 4) quarter = 2;
// strKey = `${dataYear}-${quarter}`;
// } else {//月
// strKey = `${dataYear}-${month}`;
// }
// if (!shuiChanDistinctMap[strKey]) shuiChanDistinctMap[strKey] = {key: strKey, value: 0};
// shuiChanDistinctMap[strKey].value += totalWeight;
// shuiChanCount += totalWeight;
// });
// let shuiChanPin = Object.values(shuiChanDistinctMap);
// for (let i = 0; i < shuiChanPin.length; i++) {
// shuiChanPin[i]["value"] = Math.ceil(shuiChanPin[i]["value"] / 100) / 100;
// }
// // 水产品产量 - 添加年份过滤条件
// let shuiChanDBList = await selectChanLiangOfzuoWu({
// plantType: {"$gte": PLANTTYPE.鲈鱼},
// ...(year && {year: year}) // 如果有年份参数,添加过滤条件
// });
// let shuiChan = [];
// shuiChanDBList.forEach(info => {
// let {_id, totalWeight} = info;
// shuiChan.push({
// key: changeEnumValue(PLANTTYPE, _id),
// value: totalWeight / 10000
// });
// });
// shuiChan.sort((a, b) => {return b.value - a.value});
// // 水产品种植统计 - 添加年份过滤条件
// let shuiChanZhognYang = [];
// let shuiChanZhognYangCount = 0;
// let zhognYangDBList = await zhongZhiData.zhongYangTongJiCountByYear(year);
// zhognYangDBList.forEach(info => {
// let {_id, sizeCount} = info;
// shuiChanZhognYang.push({
// key: changeEnumValue(PLANTTYPE, _id),
// value: sizeCount
// });
// shuiChanZhognYangCount += sizeCount;
// });
// let dataInfo = {
// zuoWu: {
// count: Math.ceil(zuoWuCount / 10) / 100,
// nongChanPin,
// zuoWu: zuoWu,
// },
// shuiChan: {
// count: Math.ceil(shuiChanCount / 100) / 100,
// shuiChanPin,
// shuiChan,
// },
// shuiChanZhognYang: {
// shuiChanZhognYangList: shuiChanZhognYang,
// count: shuiChanZhognYangCount,
// }
// };
// return {dataInfo};
// }
...@@ -65,11 +65,11 @@ export async function xiaoShouList(quXiang:number, plantType:number, operationTi ...@@ -65,11 +65,11 @@ export async function xiaoShouList(quXiang:number, plantType:number, operationTi
param.operationTime = {"$gte":startMs, "$lte":endMs}; param.operationTime = {"$gte":startMs, "$lte":endMs};
} }
let nongShiList = await xiaoshouData.findDataToParamToSortPage(param, {operationTime:-1}, pageNumber); let xiaoShouData = await xiaoshouData.findDataToParamToSortPage(param, {operationTime:-1}, pageNumber);
let dataCount = await xiaoshouData.selectCountByParam(param); let dataCount = await xiaoshouData.selectCountByParam(param);
let dataList = []; let dataList = [];
nongShiList.forEach(item => { xiaoShouData.forEach(item => {
let {xsId, plantType, quXiang, operationTime, weight } = item; let {xsId, plantType, quXiang, operationTime, weight } = item;
dataList.push({ dataList.push({
......
...@@ -79,13 +79,19 @@ export async function zhongYangDangQianListToPage(zhongYangType:number, plantTyp ...@@ -79,13 +79,19 @@ export async function zhongYangDangQianListToPage(zhongYangType:number, plantTyp
let dataCount = await zhongzhiData.findDataToParamCouant(param); let dataCount = await zhongzhiData.findDataToParamCouant(param);
let dataList = []; let dataList = [];
zyList.forEach(info => { zyList.forEach(info => {
let code = "-";
let purpose = "-";
if (diKuaiMap[info.dId]) {
code = diKuaiMap[info.dId].code;
purpose = changeEnumValue(PURPOSE, diKuaiMap[info.dId].purpose);
}
let addInfo = { let addInfo = {
zId : info.zId, zId : info.zId,
size : info.size, size : info.size,
plantType : changeEnumValue(PLANTTYPE, info.plantType), plantType : changeEnumValue(PLANTTYPE, info.plantType),
code:diKuaiMap[info.dId].code, code,
plantTime:moment(info.plantTime).format("YYYY-MM-DD"), plantTime:moment(info.plantTime).format("YYYY-MM-DD"),
purpose:changeEnumValue(PURPOSE, diKuaiMap[info.dId].purpose), purpose,
plantTimeNum:info.plantTime, plantTimeNum:info.plantTime,
ctTime:moment(info.ct).format("YYYY-MM-DD"), ctTime:moment(info.ct).format("YYYY-MM-DD"),
}; };
......
...@@ -5,8 +5,9 @@ ...@@ -5,8 +5,9 @@
import moment = require("moment"); import moment = require("moment");
import { TABLENAME } from "../../config/dbEnum"; import { TABLENAME } from "../../config/dbEnum";
import { DiKuaiConfig, ZhongYangConfig } from "../../config/eccParam"; import { DiKuaiConfig, ZhongYangConfig } from "../../config/eccParam";
import { PLANTTYPE, PLOTTYPE, ZHONGYANGTYPE } from "../../config/enum"; import { PLANTTYPE, PLOTTYPE, XIAOSHOUQUXIANG, ZHONGYANGTYPE } from "../../config/enum";
import * as zhongzhiData from "../../data/zhongzhi"; import * as zhongzhiData from "../../data/zhongzhi";
import * as xiaoshouData from "../../data/xiaoshou";
import * as dikuaiData from "../../data/dikuai"; import * as dikuaiData from "../../data/dikuai";
import { randomId, successResult } from "../../tools/system"; import { randomId, successResult } from "../../tools/system";
import { changeEnumValue, eccEnumValue } from "../../util/verificationEnum"; import { changeEnumValue, eccEnumValue } from "../../util/verificationEnum";
...@@ -103,7 +104,9 @@ export async function addZhongYang(reqUser, param) { ...@@ -103,7 +104,9 @@ export async function addZhongYang(reqUser, param) {
//校验地块大小是否符合扣除 //校验地块大小是否符合扣除
let dkInfo = await dikuaiData.selectOne({dId:param.dId}); let dkInfo = await dikuaiData.selectOne({dId:param.dId});
if (!dkInfo || !dkInfo.dId) throw new BizError(ERRORENUM.地块不存在); if (!dkInfo || !dkInfo.dId) throw new BizError(ERRORENUM.地块不存在);
if (dkInfo.size < param.size) throw new BizError(ERRORENUM.地块大小不足); if (param.plantType < PLANTTYPE.鲈鱼 && param.plantType > PLANTTYPE.水稻 ) {
if (dkInfo.size < param.size) throw new BizError(ERRORENUM.地块大小不足);
}
let addInfo = { let addInfo = {
zId:randomId(TABLENAME.种植表), zId:randomId(TABLENAME.种植表),
...@@ -227,3 +230,269 @@ export async function zhongYangJiLu(zhongYangType:number, selectStr:string, plan ...@@ -227,3 +230,269 @@ export async function zhongYangJiLu(zhongYangType:number, selectStr:string, plan
} }
/** =================================供大屏使用==================================== */
/**
* 种养列表
* @param zhongYangType
* @returns
*/
// export async function zhongYangList(zhongYangType:number) {
// let funName = `当前种养列表`;
// let param:any = { };
// // let startTime = moment().subtract(1, 'month').startOf('month').valueOf();
// // let endTime = moment().subtract(1, 'month').endOf('month').valueOf();
// let startTime = moment().subtract(90, 'days').startOf('day').valueOf();
// let endTime = moment().endOf('day').valueOf();
// if (zhongYangType) {
// eccEnumValue(funName, 'zhongYangType', ZHONGYANGTYPE, zhongYangType);
// param.plantType = {"$gte":zhongYangType, "$lt":zhongYangType+99};
// param.isEnd = 0;
// param.plantTime = {"$gte":startTime, "$lte":endTime}
// }
// let zyList = await zhongzhiData.selectToParam(param);
// let dataInfo = {};
// zyList.forEach(info => {
// let addInfo = {
// size : info.size,
// plantType : changeEnumValue(PLANTTYPE, info.plantType),
// plantTime : moment(info.plantTime).format("YYYY-MM-DD"),
// };
// let plantType = changeEnumValue(PLANTTYPE, info.plantType);
// if (!dataInfo[plantType]) dataInfo[plantType] = [];
// dataInfo[plantType].push(addInfo);
// });
// let dataList = [];
// let unit = "亩";
// if (zhongYangType == ZHONGYANGTYPE.水产) unit = "万尾";
// for (let key in dataInfo) {
// let size = 0;
// let zhongyang = dataInfo[key];
// zhongyang.forEach(item => {
// size += item.size;
// });
// dataList.push({
// key:key,
// value:Math.round(size*100)/100,
// unit
// });
// }
// dataList.sort((a, b) => {
// return b.value - a.value;
// })
// return dataList.slice(0, 10);
// }
/**
* 种养列表
* @param zhongYangType
* @returns
*/
export async function zhongYangList(zhongYangType:number) {
let funName = `当前种养列表`;
let param:any = { };
// 根据种养类型设置不同的时间范围
let startTime, endTime;
if (zhongYangType === ZHONGYANGTYPE.水产) {
// 水产类型:获取近一年的数据
startTime = moment().subtract(1, 'year').startOf('day').valueOf();
endTime = moment().endOf('day').valueOf();
} else {
// 其他类型:保持原来的90天范围
startTime = moment().subtract(90, 'days').startOf('day').valueOf();
endTime = moment().endOf('day').valueOf();
}
if (zhongYangType) {
eccEnumValue(funName, 'zhongYangType', ZHONGYANGTYPE, zhongYangType);
param.plantType = {"$gte":zhongYangType, "$lt":zhongYangType+99};
param.isEnd = 0;
param.plantTime = {"$gte":startTime, "$lte":endTime}
}
let zyList = await zhongzhiData.selectToParam(param);
let dataInfo = {};
zyList.forEach(info => {
let addInfo = {
size : info.size,
plantType : changeEnumValue(PLANTTYPE, info.plantType),
plantTime : moment(info.plantTime).format("YYYY-MM-DD"),
};
let plantType = changeEnumValue(PLANTTYPE, info.plantType);
if (!dataInfo[plantType]) dataInfo[plantType] = [];
dataInfo[plantType].push(addInfo);
});
let dataList = [];
let unit = "亩";
if (zhongYangType == ZHONGYANGTYPE.水产) unit = "万尾";
for (let key in dataInfo) {
let size = 0;
let zhongyang = dataInfo[key];
zhongyang.forEach(item => {
size += item.size;
});
dataList.push({
key:key,
value:Math.round(size*100)/100,
unit
});
}
dataList.sort((a, b) => {
return b.value - a.value;
})
return dataList.slice(0, 10);
}
/**
* 鱼苗数据
* @returns
*/
export async function yuMiaoList() {
/**鱼苗销售记录 */
let param:any = {};
param.plantType = {"$gte":PLANTTYPE.鲈鱼, "$lt":PLANTTYPE.水稻};
// let lastMonth = moment().subtract(1, 'years').format('YYYY-MM-DD');
// let startMs = moment(lastMonth).startOf("day").valueOf();
// let endMs = moment(new Date()).endOf("day").valueOf();
// param.operationTime = {"$gte":startMs, "$lte":endMs};
let xiaoShouData = await xiaoshouData.selectToParam(param);
console.log(`xiaoShouData: ${JSON.stringify(xiaoShouData)}`);
xiaoShouData.sort( (a, b) => {
return b.operationTime - a.operationTime;
})
let xiaoShouList = [];
xiaoShouData.forEach(item => {
let {plantType, quXiang, operationTime, weight } = item;
xiaoShouList.push({
plantType:changeEnumValue(PLANTTYPE, plantType),
quXiang:changeEnumValue(XIAOSHOUQUXIANG, quXiang),
weight,
unit:"尾",
operationTime:moment(operationTime).format("YYYY-MM-DD"),
});
});
/**鱼苗养殖记录 */
let param2:any = {};
param2.plantType = {"$gte":PLANTTYPE.鲈鱼, "$lt":PLANTTYPE.水稻};
param2.isEnd = 0;
// param2.plantTime = {"$gte":startMs, "$lte":endMs};
let yangZhiData = await zhongzhiData.selectToParam(param2);
let yangZhiList = [];
yangZhiData.forEach(item => {
let {plantType, size, plantTime } = item;
yangZhiList.push({
plantType:changeEnumValue(PLANTTYPE, plantType),
size,
plantTime:moment(plantTime).format("YYYY-MM-DD"),
plantTimeNum:plantTime
});
});
yangZhiList.sort( (a, b) => {
return b.plantTimeNum - a.plantTimeNum;
})
/**各类鱼苗库存数量:养殖-销售 */
let kuCunData = calculateKuCun(yangZhiList, xiaoShouList);
let dataList = {
鱼苗销售记录:xiaoShouList,
鱼苗养殖记录:yangZhiList,
鱼苗库存数据:kuCunData
}
return dataList;
}
/**
* 计算各类鱼苗库存
* @param {Array} yangZhiList 养殖记录
* @param {Array} xiaoShouList 销售记录
* @returns {Array} 库存数据
*/
function calculateKuCun(yangZhiList, xiaoShouList) {
// 按鱼苗类型统计总养殖量
let yangZhiTotal = {};
yangZhiList.forEach(item => {
const type = item.plantType;
const size = parseFloat(item.size) || 0;
if (!yangZhiTotal[type]) {
yangZhiTotal[type] = 0;
}
yangZhiTotal[type] += size;
});
// 按鱼苗类型统计总销售量
let xiaoShouTotal = {};
xiaoShouList.forEach(item => {
const type = item.plantType;
const weight = parseFloat(item.weight) * 10000 || 0; //单位转换为万尾
if (!xiaoShouTotal[type]) {
xiaoShouTotal[type] = 0;
}
xiaoShouTotal[type] += weight;
});
// 计算库存并格式化结果
let kuCunList = [];
const allTypes = new Set([
...Object.keys(yangZhiTotal),
...Object.keys(xiaoShouTotal)
]);
allTypes.forEach(type => {
const yangZhi = yangZhiTotal[type] || 0;
const xiaoShou = xiaoShouTotal[type] || 0;
let kuCun = yangZhi - xiaoShou;
// 如果库存为负数,直接置零
if (kuCun < 0) {
kuCun = 0;
}
kuCunList.push({
plantType: type,
yangZhiTotal: yangZhi,
xiaoShouTotal: xiaoShou,
kuCun: kuCun,
unit: "万尾",
updateTime: moment().format("YYYY-MM-DD HH:mm:ss")
});
});
// 按库存量降序排列
kuCunList.sort((a, b) => b.kuCun - a.kuCun);
return kuCunList;
}
/** /**
* * 种植
*
*/ */
import {Schema} from 'mongoose'; import {Schema} from 'mongoose';
...@@ -122,3 +121,74 @@ export async function zhongYangTongJiCount() { ...@@ -122,3 +121,74 @@ export async function zhongYangTongJiCount() {
return list; return list;
} }
/**
* 按年份统计种植面积
* @param year 年份,可选
* @returns 按种植类型分组的面积统计
*/
export async function zhongYangTongJiCountByYear(year?: number) {
// 构建基础查询条件
let matchCondition: any = { plantType: {"$gt": 100, "$lt": 200} };
// 如果传入了年份参数,添加时间过滤
if (year) {
const startTime = new Date(year, 0, 1).getTime(); // 年份开始时间戳
const endTime = new Date(year + 1, 0, 1).getTime(); // 年份结束时间戳
matchCondition.plantTime = {
"$gte": startTime,
"$lt": endTime
};
}
let list = await zhongzhiModel.aggregate([
{ $match: matchCondition },
{
"$group": {
_id: "$plantType",
sizeCount: {"$sum": "$size"}
}
}
]);
return list;
}
/**
* 按年份统计种植数量
* @param year 年份,可选
* @returns 按种植类型分组的数量统计
*/
export async function pingZhongCountByYear(year?: number) {
let matchCondition: any = {};
// 如果传入了年份参数,添加时间过滤
if (year) {
const startTime = new Date(year, 0, 1).getTime(); // 年份开始时间戳
const endTime = new Date(year + 1, 0, 1).getTime(); // 年份结束时间戳
matchCondition.plantTime = {
"$gte": startTime,
"$lt": endTime
};
}
let list = await zhongzhiModel.aggregate([
{ $match: matchCondition },
{
"$group": {
_id: "$plantType",
count: {"$sum": 1}
}
}
]);
return list;
}
...@@ -4,7 +4,7 @@ import { httpServer } from "./net/http_server"; ...@@ -4,7 +4,7 @@ import { httpServer } from "./net/http_server";
import { initDB } from "./db/dbInit"; import { initDB } from "./db/dbInit";
import { dataInit0516, dataInit, dataInit0508, yjDataInit0508, dataInit0522, dataInit0604, dataInit0609, dataInit0618 } from "./biz/dataInt"; import { dataInit0516, dataInit, dataInit0508, yjDataInit0508, dataInit0522, dataInit0604, dataInit0609, dataInit0618 } from "./biz/dataInt";
import { getDataOut, getGuiYuOut } from "./biz/dataOut"; import { getDataOut, getGuiYuOut } from "./biz/dataOut";
import { homePageStatisChanLiang } from "./biz/xcx/user"; import { homePageStatisChanLiangWithYear, homePageStatisXiaoShou } from "./biz/xcx/user";
import { getPwdMd5, md5PwdStr } from "./tools/system"; import { getPwdMd5, md5PwdStr } from "./tools/system";
async function lanuch() { async function lanuch() {
...@@ -17,7 +17,8 @@ async function lanuch() { ...@@ -17,7 +17,8 @@ async function lanuch() {
httpServer.createServer(systemConfig.port); httpServer.createServer(systemConfig.port);
console.log('This indicates that the server is started successfully.'); console.log('This indicates that the server is started successfully.');
// await homePageStatisChanLiang(1); // await homePageStatisXiaoShou(1, 2025);
// await homePageStatisChanLiangWithYear(2025, 1);
// await dataInit(); // await dataInit();
await getDataOut(); await getDataOut();
// await dataInit0508(); // await dataInit0508();
......
...@@ -5,7 +5,7 @@ import compression = require('compression'); ...@@ -5,7 +5,7 @@ import compression = require('compression');
import { watch } from '../middleware/watch'; import { watch } from '../middleware/watch';
import { httpErrorHandler } from '../middleware/httpErrorHandler'; import { httpErrorHandler } from '../middleware/httpErrorHandler';
import * as path from "path"; import * as path from "path";
import * as fallback from 'express-history-api-fallback'; import fallback from 'express-history-api-fallback';
export class httpServer { export class httpServer {
static createServer(port:number) { static createServer(port:number) {
......
...@@ -26,7 +26,7 @@ export function setRouter(httpServer){ ...@@ -26,7 +26,7 @@ export function setRouter(httpServer){
httpServer.post('/zjnt/xcx/zhongyang/dangqian/list', checkUserToken, asyncHandler(zhongyang_dangqian_list));//当前列表 httpServer.post('/zjnt/xcx/zhongyang/dangqian/list', checkUserToken, asyncHandler(zhongyang_dangqian_list));//当前列表
httpServer.post('/zjnt/xcx/zhongyang/jilu/list', checkUserToken, asyncHandler(zhongyang_jilu_list));//种养记录 httpServer.post('/zjnt/xcx/zhongyang/jilu/list', checkUserToken, asyncHandler(zhongyang_jilu_list));//种养记录
httpServer.post('/zjnt/xcx/zhongyang/add', checkUserToken, asyncHandler(zhongyang_add));//添加种养 httpServer.post('/zjnt/xcx/zhongyang/add', checkUserToken, asyncHandler(zhongyang_add));//添加种养
/**农资 */ /**农资 */
httpServer.post('/zjnt/xcx/nongzi/list', checkUserToken, asyncHandler(nongzi_list)); httpServer.post('/zjnt/xcx/nongzi/list', checkUserToken, asyncHandler(nongzi_list));
httpServer.post('/zjnt/xcx/nongzi/add', checkUserToken, asyncHandler(nongzi_add)); httpServer.post('/zjnt/xcx/nongzi/add', checkUserToken, asyncHandler(nongzi_add));
...@@ -55,9 +55,11 @@ export function setRouter(httpServer){ ...@@ -55,9 +55,11 @@ export function setRouter(httpServer){
httpServer.post('/zjnt/xcx/user/login', asyncHandler(user_login));//登录 httpServer.post('/zjnt/xcx/user/login', asyncHandler(user_login));//登录
httpServer.post('/zjnt/xcx/user/logout', checkUserToken, asyncHandler(user_logout));//登出 httpServer.post('/zjnt/xcx/user/logout', checkUserToken, asyncHandler(user_logout));//登出
/**大屏用 */
httpServer.post('/zjnt/xcx/dataout/zzzmj', asyncHandler(data_out));// httpServer.post('/zjnt/xcx/dataout/zzzmj', asyncHandler(data_out));//
httpServer.post('/zjnt/xcx/dataout/guiyu', asyncHandler(data_out_guiyu));// httpServer.post('/zjnt/xcx/dataout/guiyu', asyncHandler(data_out_guiyu));//鳜鱼
httpServer.post('/zjnt/xcx/dataout/zhongyang', asyncHandler(zhongyang_list));//种养列表
httpServer.post('/zjnt/xcx/dataout/yumiao', asyncHandler(yuMiao_list));//鱼苗销售列表
/**公用 */ /**公用 */
...@@ -79,14 +81,16 @@ async function data_out_guiyu(req, res) { ...@@ -79,14 +81,16 @@ async function data_out_guiyu(req, res) {
/**================================================================首页 */ /**================================================================首页 */
async function home_statis_chanliang(req, res) { async function home_statis_chanliang(req, res) {
let reqConf = {type:'Number'}; let reqConf = {type:'Number', year:'Number'};
let { type } = eccReqParamater(reqConf, req.body); let { type, year } = eccReqParamater(reqConf, req.body);
let result = await userBiz.homePageStatisChanLiang(type); let result = await userBiz.homePageStatisChanLiang(year, type);
res.success(result); res.success(result);
} }
async function home_statis_xiaoshou(req, res) { async function home_statis_xiaoshou(req, res) {
let result = await userBiz.homePageStatisXiaoShou(); let reqConf = {year:'Number'};
let { year } = eccReqParamater(reqConf, req.body);
let result = await userBiz.homePageStatisXiaoShou(year);
res.success(result); res.success(result);
} }
...@@ -286,6 +290,26 @@ async function zhongyang_jilu_list(req, res) { ...@@ -286,6 +290,26 @@ async function zhongyang_jilu_list(req, res) {
res.success(result); res.success(result);
} }
async function zhongyang_list(req, res) {
let reqConf = {zhongYangType:"Number"};
const NotMustHaveKeys = [];
let { zhongYangType } = eccReqParamater(reqConf, req.body, NotMustHaveKeys);
const UserInfo = req.userInfo;
let result = await zhongYangBiz.zhongYangList(zhongYangType);
res.success(result);
}
async function yuMiao_list(req, res) {
const UserInfo = req.userInfo;
let result = await zhongYangBiz.yuMiaoList();
res.success(result);
}
/**================================================================地块 */ /**================================================================地块 */
async function dikuai_add(req, res) { async function dikuai_add(req, res) {
......
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
"target": "es2017", "target": "es2017",
"sourceMap": true, "sourceMap": true,
"rootDir":"./src", "rootDir":"./src",
"outDir":"./out" "outDir":"./out",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
}, },
"exclude": [ "exclude": [
"node_modules" "node_modules",
"public"
] ]
} }
\ No newline at end of file
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