Jelajahi Sumber

fix: 导出信息价应只导出珠海,多价备注缺失问题

vian 2 tahun lalu
induk
melakukan
78c29e8408

+ 1 - 1
modules/price_info_lib/controllers/index.js

@@ -265,7 +265,7 @@ class PriceInfoController extends BaseController {
     async exportPriceData(request, response) {
         const libID = request.query.libID;
         try {
-            const excelData = await facade.exportExcelData(libID);
+            const excelData = await facade.exportExcelData(libID, '珠海市-珠海市');
             const buffer = excel.build([{ name: "信息价主表", data: excelData }]);
             const filePath = './public/exportInfo.xlsx';
             fs.writeFileSync(filePath, buffer, 'binary');

+ 7 - 3
modules/price_info_lib/facade/index.js

@@ -616,12 +616,16 @@ async function calcPriceIndex(libID, period, areaID, compilationID) {
     return message;
 }
 
-async function exportExcelData(libID) {
-    const priceItems = await priceInfoItemModel.find({ libID }).lean();
+async function exportExcelData(libID, areaName) {
+    const area = await priceInfoAreaModel.findOne({ name: areaName }).lean();
+    if (!area) {
+        return [];
+    }
+    const priceItems = await priceInfoItemModel.find({ libID, areaID: area.ID }).lean();
     // 整理数据
     let priceData = [];
     for (const tmp of priceItems) {
-        const item = [tmp.code || '', tmp.classCode || '', tmp.name || '', tmp.specs || '', tmp.unit || '', tmp.taxPrice || '', tmp.noTaxPrice || '', tmp.remark || '', tmp.expString || ''];
+        const item = [tmp.code || '', tmp.classCode || '', tmp.name || '', tmp.specs || '', tmp.unit || '', tmp.taxPrice || '', tmp.noTaxPrice || '', tmp.dateRemark || '', tmp.expString || ''];
         priceData.push(item);
     }
     const excelData = [['主从对应码', '别名编码', '材料名称', '规格型号', '单位', '含税价(元)', '除税价(元)', '多价备注', '计算式']];

+ 4 - 2
web/over_write/crawler/guangdong_2018_price_crawler.js

@@ -248,13 +248,13 @@ function getDateForApi(journalList, period) {
     return matchQuater.date;
   }
   // 没匹配到季度数据,去匹配半年数据
-  if (month / 6 <= 1 ) {
+  if (month / 6 <= 1) {
     const firstHalfYear = journalList.find(dateItem => dateItem.date === `${year}-06-25`);
     if (firstHalfYear) {
       return firstHalfYear.date;
     }
   }
-  if (month /6 > 1) {
+  if (month / 6 > 1) {
     const secondHalfYear = journalList.find(dateItem => dateItem.date === `${year}-12-25`);
     if (secondHalfYear) {
       return secondHalfYear.date;
@@ -310,6 +310,7 @@ async function getPriceInfoSource(token, period, city, county) {
     taxPrice: item.tax_price,
     noTaxPrice: item.no_tax_price,
     specs: item.spec,
+    dateRemark: item.notes,
     remark: item.notes,
   }));
   /* if (insertData.length) {
@@ -442,6 +443,7 @@ async function saveData(compilationID, period, areaID, sourceData, classNameMap)
       unit: sourceItem.unit,
       specs: sourceItem.specs,
       taxPrice: sourceItem.taxPrice,
+      dateRemark: sourceItem.dateRemark,
       remark: sourceItem.remark,
     };
   }