Forráskód Böngészése

'火运纳入框计算'

HUJIANGUO 3 éve
szülő
commit
19039565d9

+ 70 - 6
src/main/java/com/steerinfo/dil/controller/BmstrainDetailsOrderController.java

@@ -1,5 +1,7 @@
 package com.steerinfo.dil.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.steerinfo.dil.feign.ESFeign;
 import com.steerinfo.dil.service.impl.BmstrainDetailsOrderServiceImpl;
 import com.steerinfo.dil.util.BaseRESTfulController;
 import com.steerinfo.dil.util.ColumnDataUtil;
@@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -32,6 +35,8 @@ public class BmstrainDetailsOrderController extends BaseRESTfulController {
     BmstrainDetailsOrderServiceImpl bmstrainDetailsOrderService;
     @Autowired
     ColumnDataUtil columnDataUtil;
+    @Autowired
+    ESFeign esFeign;
 
     /**
      * 展示火运详单列表
@@ -52,12 +57,42 @@ public class BmstrainDetailsOrderController extends BaseRESTfulController {
     public RESTfulResult getTrainDetailsOrderList(@RequestBody(required = false) Map<String, Object> mapValue,
                                                   Integer pageNum,
                                                   Integer pageSize,
-                                                  Integer apiId) {
-        List<Map<String, Object>> list = bmstrainDetailsOrderService.getTrainDetailsOrderList(mapValue);
+                                                  Integer apiId,
+                                                  String con) {
+
+        if (con != null) {
+            if (!"undefined".equals(con)) {
+                //设置要查询的索引名称
+                String index = "get_train_details_list";
+                //获取查询结果
+                return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con));
+            }
+        }
+        //初始化过滤
+        List<Map<String, Object>> trainDetailListTotal = null;
+        //如果有条件查询则跳过初始化,和创建索引
+        if (mapValue.size() == 0) {
+            //将查询结果存入索引中
+            trainDetailListTotal = bmstrainDetailsOrderService.getTrainDetailsOrderList(null);
+            Map<String, Object> map = new HashMap<>();
+            //添加索引
+            map.put("index", "get_train_details_list");
+            //添加id
+            map.put("indexId", "detailsId");
+            trainDetailListTotal.add(map);
+            //新建索引
+            String s = JSON.toJSONString(trainDetailListTotal);
+            esFeign.insertIndex(trainDetailListTotal);
+            //删除
+            trainDetailListTotal.remove(trainDetailListTotal.size() - 1);
+        }
+        if (trainDetailListTotal == null) {
+            trainDetailListTotal = bmstrainDetailsOrderService.getTrainDetailsOrderList(mapValue);
+        }
         PageHelper.startPage(pageNum, pageSize);
         //分页查询数据
         List<Map<String, Object>> columnList = bmstrainDetailsOrderService.getTrainDetailsOrderList(mapValue);
-        PageListAdd data = columnDataUtil.tableColumnData(apiId, list, columnList);
+        PageListAdd data = columnDataUtil.tableColumnData(apiId, trainDetailListTotal, columnList);
         return success(data);
     }
 
@@ -80,12 +115,41 @@ public class BmstrainDetailsOrderController extends BaseRESTfulController {
     public RESTfulResult getUncomplateTrainDetailsList(@RequestBody(required = false) Map<String, Object> mapValue,
                                                        Integer pageNum,
                                                        Integer pageSize,
-                                                       Integer apiId) {
-        List<Map<String, Object>> list = bmstrainDetailsOrderService.getUmcomplateTrainDetailsList(mapValue);
+                                                       Integer apiId,
+                                                       String con) {
+        if (con != null) {
+            if (!"undefined".equals(con)) {
+                //设置要查询的索引名称
+                String index = "get_uncomplate_train_details_list";
+                //获取查询结果
+                return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con));
+            }
+        }
+        //初始化过滤
+        List<Map<String, Object>> trainDetailListTotal = null;
+        //如果有条件查询则跳过初始化,和创建索引
+        if (mapValue.size() == 0) {
+            //将查询结果存入索引中
+            trainDetailListTotal = bmstrainDetailsOrderService.getTrainDetailsOrderList(null);
+            Map<String, Object> map = new HashMap<>();
+            //添加索引
+            map.put("index", "get_uncomplate_train_details_list");
+            //添加id
+            map.put("indexId", "detailsId");
+            trainDetailListTotal.add(map);
+            //新建索引
+            String s = JSON.toJSONString(trainDetailListTotal);
+            esFeign.insertIndex(trainDetailListTotal);
+            //删除
+            trainDetailListTotal.remove(trainDetailListTotal.size() - 1);
+        }
+        if (trainDetailListTotal == null) {
+            trainDetailListTotal = bmstrainDetailsOrderService.getTrainDetailsOrderList(mapValue);
+        }
         PageHelper.startPage(pageNum, pageSize);
         //分页查询数据
         List<Map<String, Object>> columnList = bmstrainDetailsOrderService.getUmcomplateTrainDetailsList(mapValue);
-        PageListAdd data = columnDataUtil.tableColumnData(apiId, list, columnList);
+        PageListAdd data = columnDataUtil.tableColumnData(apiId, trainDetailListTotal, columnList);
         return success(data);
     }
 

+ 46 - 7
src/main/java/com/steerinfo/dil/controller/BmstrainSettlementController.java

@@ -1,5 +1,7 @@
 package com.steerinfo.dil.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.steerinfo.dil.feign.ESFeign;
 import com.steerinfo.dil.model.BmstrainSettlement;
 import com.steerinfo.dil.service.impl.BmstrainSettlementServiceImpl;
 import com.steerinfo.dil.util.BaseRESTfulController;
@@ -14,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -30,9 +33,12 @@ public class BmstrainSettlementController extends BaseRESTfulController {
     BmstrainSettlementServiceImpl bmstrainSettlementService;
     @Autowired
     ColumnDataUtil columnDataUtil;
+    @Autowired
+    ESFeign esFeign;
 
     /**
      * 展示火运结算列表
+     *
      * @param mapValue
      * @param pageNum
      * @param pageSize
@@ -46,21 +52,51 @@ public class BmstrainSettlementController extends BaseRESTfulController {
             @ApiImplicitParam(name = "apiId", value = "180", required = false, dataType = "BigDecimal")
     })
     @PostMapping("/getSettlementList")
-    public RESTfulResult getSettlementList(@RequestBody(required = false) Map<String,Object> mapValue,
-                                          Integer pageNum,
-                                          Integer pageSize,
-                                          Integer apiId) {
-        List<Map<String, Object>> list = bmstrainSettlementService.getSettlementList(mapValue);
+    public RESTfulResult getSettlementList(@RequestBody(required = false) Map<String, Object> mapValue,
+                                           Integer pageNum,
+                                           Integer pageSize,
+                                           Integer apiId,
+                                           String con) {
+        if (con != null) {
+            if (!"undefined".equals(con)) {
+                //设置要查询的索引名称
+                String index = "get_train_settlement_list";
+                //获取查询结果
+                return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con));
+            }
+        }
+        //初始化过滤
+        List<Map<String, Object>> trainSettlementList = null;
+        //如果有条件查询则跳过初始化,和创建索引
+        if (mapValue.size() == 0) {
+            //将查询结果存入索引中
+            trainSettlementList = bmstrainSettlementService.getSettlementList(mapValue);
+            Map<String, Object> map = new HashMap<>();
+            //添加索引
+            map.put("index", "get_train_settlement_list");
+            //添加id
+            map.put("indexId", "settlementId");
+            trainSettlementList.add(map);
+            //新建索引
+            String s = JSON.toJSONString(trainSettlementList);
+            esFeign.insertIndex(trainSettlementList);
+            //删除
+            trainSettlementList.remove(trainSettlementList.size() - 1);
+        }
+        if (trainSettlementList == null) {
+            trainSettlementList = bmstrainSettlementService.getSettlementList(mapValue);
+        }
         PageHelper.startPage(pageNum, pageSize);
         //分页查询数据
         List<Map<String, Object>> columnList = bmstrainSettlementService.getSettlementList(mapValue);
-        PageListAdd data = columnDataUtil.tableColumnData(apiId, list, columnList);
+        PageListAdd data = columnDataUtil.tableColumnData(apiId, trainSettlementList, columnList);
         return success(data);
     }
 
 
     /**
      * 新增火运结算
+     *
      * @param bmstrainSettlement
      * @return
      */
@@ -76,6 +112,7 @@ public class BmstrainSettlementController extends BaseRESTfulController {
 
     /**
      * 逻辑删除火运结算
+     *
      * @param settlementId
      * @return
      */
@@ -91,6 +128,7 @@ public class BmstrainSettlementController extends BaseRESTfulController {
 
     /**
      * 修改火运结算
+     *
      * @param bmstrainSettlement
      * @return
      */
@@ -106,6 +144,7 @@ public class BmstrainSettlementController extends BaseRESTfulController {
 
     /**
      * 得到修改渲染
+     *
      * @param settlementId
      * @return
      */
@@ -115,7 +154,7 @@ public class BmstrainSettlementController extends BaseRESTfulController {
     })
     @PostMapping("/selectTrainSettlement/{settlementId}")
     public RESTfulResult selectTrainSettlement(@PathVariable("settlementId") BigDecimal settlementId) {
-        List<Map<String,Object>> bmstrainSettlement = bmstrainSettlementService.selectTrainSettlement(settlementId);
+        List<Map<String, Object>> bmstrainSettlement = bmstrainSettlementService.selectTrainSettlement(settlementId);
         return success(bmstrainSettlement);
     }
 

+ 72 - 13
src/main/java/com/steerinfo/dil/controller/BmstrainStatementController.java

@@ -1,5 +1,7 @@
 package com.steerinfo.dil.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.steerinfo.dil.feign.ESFeign;
 import com.steerinfo.dil.service.impl.BmstrainDetailsOrderServiceImpl;
 import com.steerinfo.dil.service.impl.BmstrainStatementServiceImpl;
 import com.steerinfo.dil.util.BaseRESTfulController;
@@ -36,6 +38,8 @@ public class BmstrainStatementController extends BaseRESTfulController {
     BmstrainStatementServiceImpl bmstrainStatementService;
     @Autowired
     ColumnDataUtil columnDataUtil;
+    @Autowired
+    ESFeign esFeign;
 
     /**
      * 展示火运账单列表
@@ -56,12 +60,41 @@ public class BmstrainStatementController extends BaseRESTfulController {
     public RESTfulResult getTrainStatementList(@RequestBody(required = false) Map<String, Object> mapValue,
                                                Integer pageNum,
                                                Integer pageSize,
-                                               Integer apiId) {
-        List<Map<String, Object>> list = bmstrainStatementService.getTrainStatementList(mapValue);
+                                               Integer apiId,
+                                               String con) {
+        if (con != null) {
+            if (!"undefined".equals(con)) {
+                //设置要查询的索引名称
+                String index = "get_train_statement_list";
+                //获取查询结果
+                return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con));
+            }
+        }
+        //初始化过滤
+        List<Map<String, Object>> trainStatementList = null;
+        //如果有条件查询则跳过初始化,和创建索引
+        if (mapValue.size() == 0) {
+            //将查询结果存入索引中
+            trainStatementList = bmstrainStatementService.getTrainStatementList(null);
+            Map<String, Object> map = new HashMap<>();
+            //添加索引
+            map.put("index", "get_train_statement_list");
+            //添加id
+            map.put("indexId", "statementId");
+            trainStatementList.add(map);
+            //新建索引
+            String s = JSON.toJSONString(trainStatementList);
+            esFeign.insertIndex(trainStatementList);
+            //删除
+            trainStatementList.remove(trainStatementList.size() - 1);
+        }
+        if (trainStatementList == null) {
+            trainStatementList = bmstrainStatementService.getTrainStatementList(mapValue);
+        }
         PageHelper.startPage(pageNum, pageSize);
         //分页查询数据
         List<Map<String, Object>> columnList = bmstrainStatementService.getTrainStatementList(mapValue);
-        PageListAdd data = columnDataUtil.tableColumnData(apiId, list, columnList);
+        PageListAdd data = columnDataUtil.tableColumnData(apiId, trainStatementList, columnList);
         return success(data);
     }
 
@@ -85,7 +118,7 @@ public class BmstrainStatementController extends BaseRESTfulController {
      * 展示账单下的详单
      *
      * @param batchId
-     * @param mapVal
+     * @param mapValue
      * @param pageNum
      * @param pageSize
      * @param apiId
@@ -101,21 +134,47 @@ public class BmstrainStatementController extends BaseRESTfulController {
     })
     @PostMapping(value = "/getComplateTrainDetailsList")
     public RESTfulResult getComplateTrainDetailsList(BigDecimal batchId,
-                                                     @RequestBody(required = false) Map<String, Object> mapVal,
+                                                     @RequestBody(required = false) Map<String, Object> mapValue,
                                                      Integer pageNum,
                                                      Integer pageSize,
                                                      Integer apiId,
-                                                     BigDecimal statementId) {
-        if (mapVal == null) {
-            mapVal = new HashMap<>();
+                                                     BigDecimal statementId,
+                                                     String con) {
+        if (con != null) {
+            if (!"undefined".equals(con)) {
+                //设置要查询的索引名称
+                String index = "get_uncomplate_train_details_list";
+                //获取查询结果
+                return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con));
+            }
+        }
+        mapValue.put("batchId", batchId);
+        mapValue.put("statementId", statementId);
+        //初始化过滤
+        List<Map<String, Object>> trainComplateDetailList = null;
+        //如果有条件查询则跳过初始化,和创建索引
+        if (mapValue.size() == 2) {
+            //将查询结果存入索引中
+            trainComplateDetailList = bmstrainStatementService.getComplateTrainDetailsList(mapValue);
+            Map<String, Object> map = new HashMap<>();
+            //添加索引
+            map.put("index", "get_uncomplate_train_details_list");
+            //添加id
+            map.put("indexId", "detailsId");
+            trainComplateDetailList.add(map);
+            //新建索引
+            String s = JSON.toJSONString(trainComplateDetailList);
+            esFeign.insertIndex(trainComplateDetailList);
+            //删除
+            trainComplateDetailList.remove(trainComplateDetailList.size() - 1);
+        }
+        if (trainComplateDetailList == null) {
+            trainComplateDetailList = bmstrainStatementService.getComplateTrainDetailsList(mapValue);
         }
-        mapVal.put("batchId", batchId);
-        mapVal.put("statementId", statementId);
-        List<Map<String, Object>> list = bmstrainStatementService.getComplateTrainDetailsList(mapVal);
         PageHelper.startPage(pageNum, pageSize);
         //分页查询数据
-        List<Map<String, Object>> columnList = bmstrainStatementService.getComplateTrainDetailsList(mapVal);
-        PageListAdd data = columnDataUtil.tableColumnData(apiId, list, columnList);
+        List<Map<String, Object>> columnList = bmstrainStatementService.getComplateTrainDetailsList(mapValue);
+        PageListAdd data = columnDataUtil.tableColumnData(apiId, trainComplateDetailList, columnList);
         return success(data);
     }
 

+ 30 - 0
src/main/java/com/steerinfo/dil/feign/ESFeign.java

@@ -0,0 +1,30 @@
+package com.steerinfo.dil.feign;
+
+import com.steerinfo.dil.util.PageListAdd;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author zhangnan
+ * @Date 2021/7/27 15:49
+ * @Version 1.0
+ */
+
+@FeignClient(value = "DIL-ES-DEV",url = "172.16.33.161:8089/api/v1/es")
+public interface ESFeign {
+    @PostMapping("getConResult")
+    PageListAdd getConResult(@RequestBody(required = false) Map<String, Object> mapValue,
+                             @RequestParam String index,
+                             @RequestParam Integer apiId,
+                             @RequestParam Integer pageNum,
+                             @RequestParam Integer pageSize,
+                             @RequestParam String con);
+
+    @PostMapping( value = "insertIndex",consumes = "application/json", produces = "application/json")
+    void insertIndex(@RequestBody List<Map<String, Object>> detailListTotal);
+}