瀏覽代碼

feat: 信息价库增加批量匹配总表

vian 11 月之前
父節點
當前提交
7c1a1586eb

+ 10 - 0
modules/price_info_lib/controllers/index.js

@@ -112,6 +112,16 @@ class PriceInfoController extends BaseController {
         }
     }
 
+    async getAllLibs(req, res) {
+        try {
+            const data = await facade.getAllLibs();
+            res.json({ error: 0, message: 'getAreas success', data });
+        } catch (err) {
+            console.log(err);
+            res.json({ error: 1, message: err.toString() });
+        }
+    }
+
     async processChecking(req, res) {
         try {
             const { key } = JSON.parse(req.body.data);

+ 14 - 0
modules/price_info_lib/facade/index.js

@@ -380,6 +380,19 @@ async function getAreas(compilationID) {
     return await priceInfoAreaModel.find({ compilationID }, '-_id ID name serialNo').sort({ serialNo: 1 }).lean();
 }
 
+// 获取费用定额的信息价库
+async function getAllLibs() {
+    const libs = await priceInfoLibModel.find({}, '-_id').lean();
+    const groupData = _.groupBy(libs, 'compilationID');
+    const rst = [];
+    Object.keys(groupData).forEach(key => {
+        const items = groupData[key];
+        items.sort((a, b) => a.period.localeCompare(b.period));
+        rst.push(...items);
+    });
+    return rst;
+}
+
 async function updateAres(updateData) {
     const bulks = [];
     updateData.forEach(({ ID, field, value }) => bulks.push({
@@ -782,4 +795,5 @@ module.exports = {
     matchSummary,
     getPriceEmptyData,
     getRecommendPriceSummaryData,
+    getAllLibs,
 }

+ 1 - 0
modules/price_info_lib/routes/index.js

@@ -29,6 +29,7 @@ module.exports = function (app) {
     router.post("/matchSummary", priceInfoController.auth, priceInfoController.init, priceInfoController.matchSummary);
     router.post("/getPriceEmptyData", priceInfoController.auth, priceInfoController.init, priceInfoController.getPriceEmptyData);
     router.post("/getRecommendPriceSummaryData", priceInfoController.auth, priceInfoController.init, priceInfoController.getRecommendPriceSummaryData);
+    router.post("/getAllLibs", priceInfoController.auth, priceInfoController.init, priceInfoController.getAllLibs);
 
     router.get("/export", priceInfoController.auth, priceInfoController.init, priceInfoController.exportPriceData);
     router.get("/exportInfoPriceByLib", priceInfoController.auth, priceInfoController.init, priceInfoController.exportInfoPriceByLib);

+ 1 - 0
web/maintain/price_info_lib/html/edit.html

@@ -21,6 +21,7 @@
                     class="fa fa-angle-right fa-fw"></i><%= libName  %>
                <button id="calc-price-index">计算指数</button>     
                <button id="match-summary">匹配总表</button> 
+               <button id="batch-match-summary">批量匹配总表</button> 
                <button id="show-empty">显示空数据</button> 
                <button id="check-repeat">检测重复别名编码</button>
                <div class="form-check" id="match-all">

+ 39 - 1
web/maintain/price_info_lib/js/priceClass.js

@@ -1,4 +1,15 @@
 // 分类表
+function setTimeoutSync(handle, time) {
+  return new Promise(function (resolve, reject) {
+    setTimeout(function () {
+      if (handle && typeof handle === 'function') {
+        handle();
+      }
+      resolve();
+    }, time);
+  });
+}
+
 const CLASS_BOOK = (() => {
   const setting = {
     header: [{ headerName: '分类', headerWidth: $('#area-spread').width(), dataCode: 'name', dataType: 'String', hAlign: 'left', vAlign: 'center' }],
@@ -104,8 +115,10 @@ const CLASS_BOOK = (() => {
   const $upMove = $('#tree-up-move');
   const $calcPriceIndex = $('#calc-price-index');
   const $matchSummary = $('#match-summary');
+  const $batchMatchSummary = $('#batch-match-summary');
   const $showEmpty = $('#show-empty');
 
+
   // 插入
   let canInsert = true;
   async function insert() {
@@ -457,6 +470,10 @@ const CLASS_BOOK = (() => {
 
   }, DEBOUNCE_TIME, { leading: true }));
 
+  const doMatchSummary = async (libID, compilationID, areaID) => {
+    await ajaxPost('/priceInfo/matchSummary', { libID, compilationID, areaID }, 1000 * 60 * 10);
+  }
+
   // 匹配总表
   $matchSummary.click(_.debounce(async () => {
     $.bootstrapLoading.progressStart('匹配总表', true);
@@ -464,7 +481,7 @@ const CLASS_BOOK = (() => {
     try {
       const matchAll = $('#match-all-input')[0].checked;
       const areaID = matchAll ? '' : AREA_BOOK.curArea?.ID;
-      await ajaxPost('/priceInfo/matchSummary', { libID, compilationID, areaID }, 1000 * 60 * 10);
+      await doMatchSummary(libID, compilationID, areaID);
       setTimeout(() => {
         $.bootstrapLoading.progressEnd();
         window.location.reload()
@@ -476,6 +493,27 @@ const CLASS_BOOK = (() => {
     }
   }, DEBOUNCE_TIME, { leading: true }));
 
+  // 批量匹配总表
+  $batchMatchSummary.click(_.debounce(async () => {
+    $.bootstrapLoading.progressStart('批量匹配总表', true);
+    try {
+      const libs = await ajaxPost('/priceInfo/getAllLibs');
+      for (const lib of libs) {
+        $("#progress_modal_body").text(`${lib.name},正在匹配总表,请稍后(${libs.indexOf(lib) + 1}/${libs.length})...`);
+        await doMatchSummary(lib.ID, lib.compilationID, '');
+        await setTimeoutSync(() => { }, 100);
+      }
+      await setTimeoutSync(() => {
+        $.bootstrapLoading.progressEnd();
+        window.location.reload()
+      }, 1000);
+    } catch (error) {
+      alert(error)
+      console.log(error);
+      $.bootstrapLoading.progressEnd();
+    }
+  }, DEBOUNCE_TIME, { leading: true }));
+
   // 显示空数据
   $showEmpty.click(() => {
     $('#empty-area').modal('show');