From c8aee7b9bfd79cfd741d7e5692520f4f51a31a86 Mon Sep 17 00:00:00 2001
From: kimi <kimi42345@gmail.com>
Date: 星期一, 18 五月 2020 18:30:01 +0800
Subject: [PATCH] bak  修改 获取版本数据前

---
 src/main/java/com/highdatas/mdm/controller/DispenseController.java |  400 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 389 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/highdatas/mdm/controller/DispenseController.java b/src/main/java/com/highdatas/mdm/controller/DispenseController.java
index 441f536..fc7b5b2 100644
--- a/src/main/java/com/highdatas/mdm/controller/DispenseController.java
+++ b/src/main/java/com/highdatas/mdm/controller/DispenseController.java
@@ -3,15 +3,19 @@
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.mapper.Wrapper;
+import com.baomidou.mybatisplus.plugins.Page;
 import com.highdatas.mdm.entity.*;
+import com.highdatas.mdm.entity.Character;
 import com.highdatas.mdm.pojo.CodeMsg;
-import com.highdatas.mdm.util.pool.MqEntity;
+import com.highdatas.mdm.pojo.DispenseField;
 import com.highdatas.mdm.pojo.Result;
 import com.highdatas.mdm.pojo.SubscribeEntity;
 import com.highdatas.mdm.service.*;
 import com.highdatas.mdm.util.Constant;
 import com.highdatas.mdm.util.DbUtils;
 import com.highdatas.mdm.util.RedisClient;
+import com.highdatas.mdm.util.pool.MqEntity;
 import com.highdatas.mdm.util.pool.MqMessage;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,8 +23,9 @@
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.List;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -47,6 +52,10 @@
     @Autowired
     IMaintainService maintainService;
     @Autowired
+    IMenuMappingService menuMappingService;
+    @Autowired
+    IMasterAuthorSubscribeService subscribeService;
+    @Autowired
     ISysMenuService menuService;
     @Autowired
     ISysViewService viewService;
@@ -56,11 +65,247 @@
     IMasterAuthorUnactiveService masterAuthorUnactiveService;
     @Autowired
     ISysDispenseLogsService dispenseLogsService;
+    @Autowired
+    ISysFieldService fieldService;
+
 
     @RequestMapping(value = "/dispense/surface", method = RequestMethod.GET)
     public Result surface(@RequestParam String userId, @RequestParam String type, @RequestParam String dataId, HttpServletRequest request, HttpServletResponse response) {
         String versionId = request.getParameter("versionId");
         return addPassiveMq(userId, type, dataId, versionId, request, "surface");
+    }
+
+    @RequestMapping(value = "/api/count", method = RequestMethod.POST)
+    public Result count(@RequestBody JSONObject reqObj) {
+        String token = reqObj.getString("token");
+        String type = reqObj.getString("type");
+        String dataId = reqObj.getString("dataId");
+        String versionId = reqObj.getString("versionId");
+        String incrementStr = reqObj.getString("increment");
+        if (StringUtils.isEmpty(token) || StringUtils.isEmpty(type) || StringUtils.isEmpty(dataId)) {
+            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+        }
+        String userId = redisClient.getRedisVal(token);
+        if (StringUtils.isEmpty(userId)) {
+            return Result.error(CodeMsg.ERROR_FIND_TOKEN);
+        }
+
+        boolean increment = true;
+        if (!StringUtils.isEmpty(incrementStr)) {
+            increment = Boolean.valueOf(incrementStr);
+        }
+        if (type.equalsIgnoreCase(Constant.Master)) {
+            if (StringUtils.isEmpty(versionId)) {
+                return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+            }
+            Maintain maintain = maintainService.selectById(versionId);
+            if (maintain == null) {
+                return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+            }
+            SysMenu sysMenu = menuService.selectById(dataId);
+            if (sysMenu == null) {
+                return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND);
+            }
+            int subscribeCnt = subscribeService.selectCount(new EntityWrapper<MasterAuthorSubscribe>().eq("menu_id", dataId).eq("user_id", userId));
+            if (subscribeCnt < 1) {
+                return Result.error(CodeMsg.SUBSCRIBE_UN_ERROR);
+            }
+            int i = masterAuthorUnactiveService.selectCount(new EntityWrapper<MasterAuthorUnactive>().eq("maintain_id", versionId).eq("user_id", userId));
+            if (i > 0) {
+                return Result.error(CodeMsg.Active_UN_ERROR);
+            }
+            MasterAuthor masterAuthor = new MasterAuthor().setTableName(maintain.getTableName());
+            TUser user = new TUser().setUserId(userId);
+            com.highdatas.mdm.pojo.Page initPageInfo = DbUtils.masterAuthorService.getInitPageInfo(masterAuthor, maintain, user, increment);
+            if (initPageInfo != null) {
+                return Result.success(initPageInfo.getRecordCount());
+            }
+            return Result.success(0);
+        } else if (type.equalsIgnoreCase(Constant.View)) {
+            SysView sysView = viewService.selectById(dataId);
+            if (sysView == null) {
+                return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND);
+            }
+            Boolean active = sysView.getActive();
+            if (!active) {
+                return Result.error(CodeMsg.Active_UN_ERROR);
+            }
+            long viewCount = viewService.getViewCount(sysView);
+            return Result.success(viewCount);
+        } else {
+            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+        }
+    }
+
+    @RequestMapping(value = "/api/data", method = RequestMethod.POST)
+    public Result data(@RequestBody JSONObject reqObj) {
+        SysDispenseLogs logs = new SysDispenseLogs().setId(DbUtils.getUUID()).setCreateTime(new Date());
+        logs.setTouchType("rest");
+        logs.insert();
+        String token = reqObj.getString("token");
+        String type = reqObj.getString("type");
+        String dataId = reqObj.getString("dataId");
+        String versionId = reqObj.getString("versionId");
+        String incrementStr = reqObj.getString("increment");
+        Integer beginNo = reqObj.getInteger("beginNo");
+        Integer endNo = reqObj.getInteger("endNo");
+        logs.setTopicId(type).setTagId(dataId).setDataType(type);
+        if (beginNo == null || endNo == null) {
+            logs.setErrorInfo("beginNo or endNo not exists").setStatus("false").updateById();
+            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+        } else if (endNo < beginNo) {
+            logs.setErrorInfo("beginNo > endNo ").setStatus("false").updateById();
+            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+        }
+        if (beginNo < 0 || endNo < 0) {
+            logs.setErrorInfo("beginNo or endNo  < 0").setStatus("false").updateById();
+            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+        }
+        if (StringUtils.isEmpty(token) || StringUtils.isEmpty(type) || StringUtils.isEmpty(dataId)) {
+            logs.setErrorInfo("token or type or dataId not found").setStatus("false").updateById();
+            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+        }
+        String userId = redisClient.getRedisVal(token);
+        if (StringUtils.isEmpty(userId)) {
+            logs.setErrorInfo(CodeMsg.ERROR_FIND_TOKEN.getMsg()).setStatus("false").updateById();
+            return Result.error(CodeMsg.ERROR_FIND_TOKEN);
+        }
+        TUser userById = DbUtils.getUserById(userId);
+        logs.setUserName(userById.getUserName());
+        logs.setUserId(userId).updateById();
+        boolean increment = true;
+        if (!StringUtils.isEmpty(incrementStr)) {
+            increment = Boolean.valueOf(incrementStr);
+        }
+        com.highdatas.mdm.pojo.Page initPageInfo = null;
+        if (type.equalsIgnoreCase(Constant.Master)) {
+            if (StringUtils.isEmpty(versionId)) {
+                logs.setErrorInfo("versionId not exists").setStatus("false").updateById();
+                return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+            }
+            Maintain maintain = maintainService.selectById(versionId);
+            if (maintain == null) {
+                return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+            }
+            logs.setMaintainId(maintain.getId()).setVersion(maintain.getVersion());
+            logs.updateById();
+            SysMenu sysMenu = menuService.selectById(dataId);
+            if (sysMenu == null) {
+                return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND);
+            }
+            logs.setName(sysMenu.getName());
+            logs.updateById();
+            int subscribeCnt = subscribeService.selectCount(new EntityWrapper<MasterAuthorSubscribe>().eq("menu_id", dataId).eq("user_id", userId));
+            if (subscribeCnt < 1) {
+                logs.setErrorInfo(CodeMsg.SUBSCRIBE_UN_ERROR.getMsg()).updateById();
+                return Result.error(CodeMsg.SUBSCRIBE_UN_ERROR);
+            }
+            int i = masterAuthorUnactiveService.selectCount(new EntityWrapper<MasterAuthorUnactive>().eq("maintain_id", versionId).eq("user_id", userId));
+            if (i > 0) {
+                logs.setErrorInfo(CodeMsg.Active_UN_ERROR.getMsg()).updateById();
+                return Result.error(CodeMsg.Active_UN_ERROR);
+            }
+            MasterAuthor masterAuthor = new MasterAuthor().setTableName(maintain.getTableName());
+            TUser user = new TUser().setUserId(userId);
+            initPageInfo = masterAuthorService.getInitPageInfo(masterAuthor, maintain, user, increment);
+            if (initPageInfo == null) {
+                return Result.success(null);
+            }
+            boolean b = refreshInitPage(initPageInfo, beginNo, endNo);
+            if(!b) {
+                return Result.error(CodeMsg.ERROR_SIZE_TOO_LONG);
+            }
+            if (increment) {
+                String maintainTableName = maintain.getTableName();
+                String tempTableName = maintainTableName + Constant.RECORD;
+                List<SysField> fieldByMaintain = DbUtils.fieldService.getFieldByMaintain(maintain.getId());
+                List<String> fieldList = fieldByMaintain.stream().map(sysField -> sysField.getField()).collect(Collectors.toList());
+                String fields = fieldByMaintain.stream().map(sysField -> sysField.getField()).collect(Collectors.joining(Constant.COMMA));
+
+                String filter = DbUtils.masterAuthorService.getFilter(user, maintain.getId());
+                if (StringUtils.isEmpty(filter)) {
+                    filter = Constant.WHERE_DEFAULT;
+                }
+                List<Map<String, Object>> maps = DbUtils.maintainDetailMapper.selectMaintainDetail(fields, tempTableName, maintain.getId(), filter, initPageInfo.getLimitSQL());
+
+                Map<String, AntianaphylaxisResult> helpfulField = DbUtils.antianaphylaxisClient.getHelpfulField(fields, maintainTableName);
+                DbUtils.antianaphylaxisClient.fixMasterData(maps,helpfulField);
+
+                JSONObject object = new JSONObject();
+
+                object.fluentPut("records", maps);
+
+                List<SysField> sysFields = masterAuthorService.getField(user, versionId);
+                List<DispenseField> collect = sysFields.stream().map(sysField -> new DispenseField().setField(sysField.getField()).setAlias(sysField.getAlias())).collect(Collectors.toList());
+                object.fluentPut("fields", collect);
+                long time = new Date().getTime();
+                logs.setSchedule(time - logs.getCreateTime().getTime()).setStatus("true").setTotal(Long.valueOf(initPageInfo.getRecordCount()).intValue()).updateById();
+                return Result.success(object);
+            } else {
+                Result result = masterDataService.selectListByPageByVersion(user, maintain.getTableName(), null, Constant.WHERE_DEFAULT, null, null, maintain.getVersion(), false, null, initPageInfo);
+                Object data = result.getData();
+                JSONObject masterResult = new JSONObject();
+                JSONObject dataResult = (JSONObject) JSONObject.toJSON(data);
+                JSONObject grid = dataResult.getJSONObject("grid");
+                masterResult.fluentPut("records", grid.getJSONArray("record"));
+                JSONArray fields = dataResult.getJSONArray("fields");
+                ArrayList<DispenseField> dispenseFields = new ArrayList<>();
+                for (Object field : fields) {
+                    JSONObject one = (JSONObject) JSONObject.toJSON(field);
+                    dispenseFields.add(new DispenseField().setAlias(one.getString("alias")).setField(one.getString("field")));
+                }
+                grid.remove("record");
+                masterResult.fluentPut("fields", dispenseFields);
+
+                long time = new Date().getTime();
+                logs.setSchedule(time - logs.getCreateTime().getTime()).setStatus("true").setTotal(Long.valueOf(initPageInfo.getRecordCount()).intValue()).updateById();
+
+                return Result.success(masterResult);
+            }
+        } else if (type.equalsIgnoreCase(Constant.View)) {
+            SysView sysView = viewService.selectById(dataId);
+            if (sysView == null) {
+                return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND);
+            }
+            logs.setName(sysView.getName());
+            logs.updateById();
+            Boolean active = sysView.getActive();
+            if (!active) {
+                return Result.error(CodeMsg.Active_UN_ERROR);
+            }
+            initPageInfo = viewService.getInitPageInfo(sysView.getId());
+            if (initPageInfo == null) {
+                long time = new Date().getTime();
+                logs.setSchedule(time - logs.getCreateTime().getTime()).setStatus("true").setTotal(Long.valueOf(initPageInfo.getRecordCount()).intValue()).updateById();
+                return Result.success(null);
+            }
+            boolean b = refreshInitPage(initPageInfo, beginNo, endNo);
+            if(!b) {
+                logs.setErrorInfo(CodeMsg.ERROR_SIZE_TOO_LONG.getMsg()).updateById();
+                return Result.error(CodeMsg.ERROR_SIZE_TOO_LONG);
+            }
+
+            Result viewData = viewService.getViewData(sysView, null, 0, initPageInfo);
+            long time = new Date().getTime();
+            logs.setSchedule(time - logs.getCreateTime().getTime()).setStatus("true").setTotal(Long.valueOf(initPageInfo.getRecordCount()).intValue()).updateById();
+            return  viewData;
+        } else {
+            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+        }
+
+    }
+
+    private boolean refreshInitPage(com.highdatas.mdm.pojo.Page initPageInfo, Integer beginNo, Integer endNo) {
+        int size = endNo - beginNo;
+        int pageSize = initPageInfo.getPageSize();
+        if (pageSize < size) {
+            return false;
+        }
+        initPageInfo.setBeginNo(beginNo);
+        initPageInfo.setEndNo(endNo);
+        initPageInfo.setPageSize(size);
+        initPageInfo.setRecordCount(size);
+        return true;
     }
 
     @RequestMapping(value = "/dispense/surface/muti", method = RequestMethod.POST)
@@ -81,10 +326,22 @@
     }
 
     private Result addPassiveMq(@RequestParam String userId, @RequestParam String type, @RequestParam String dataId, String versionId, HttpServletRequest request, String touchType) {
+        SysDispenseLogs logs = new SysDispenseLogs()
+                .setId(DbUtils.getUUID())
+                .setTouchType(touchType)
+                .setDataType(type)
+                .setCreateTime(new Date())
+                .setTopicId(type)
+                .setTagId(dataId)
+                .setMaintainId(versionId);
+            logs.insert();
         TUser user = DbUtils.getUserById(userId);
         if (user == null) {
+            logs.setResult(CodeMsg.USER_NOT_MATHED.getMsg()).updateById();
             return Result.error(CodeMsg.USER_NOT_MATHED);
         }
+        logs.setUserName(user.getUserName());
+        logs.updateById();
         String incrementStr = request.getParameter("increment");
         boolean increment = true;
         if (!StringUtils.isEmpty(incrementStr)) {
@@ -95,19 +352,33 @@
         mqEntity.setIncrement(increment);
         mqEntity.setMsgTopicName(type);
         mqEntity.setType(type);
+        mqEntity.setLogId(logs.getId());
         mqEntity.setDataId(dataId);
         if(type.equalsIgnoreCase(Constant.Master)) {
 
             if (StringUtils.isEmpty(versionId)) {
+                logs.setResult(CodeMsg.ERROR_PARAMS_NOT_MATHED.getMsg()).updateById();
                 return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
             }
+            Maintain maintain = maintainService.selectById(versionId);
+            if (maintain == null) {
+                logs.setResult(CodeMsg.ERROR_PARAMS_NOT_MATHED.getMsg()).updateById();
+                return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+            }
+            logs.setVersion(maintain.getVersion());
+            logs.updateById();
             mqEntity.setMaintainId(versionId);
+
             SysMenu sysMenu = menuService.selectById(dataId);
             if (sysMenu == null) {
-                return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+                logs.setResult(CodeMsg.SELECT_ERROR_NOTFOUND.getMsg()).updateById();
+                return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND);
             }
+            logs.setName(sysMenu.getName());
+            logs.updateById();
             int i = masterAuthorUnactiveService.selectCount(new EntityWrapper<MasterAuthorUnactive>().eq("maintain_id", versionId).eq("user_id", userId));
             if (i > 0) {
+                logs.setResult(CodeMsg.Active_UN_ERROR.getMsg()).updateById();
                 return Result.error(CodeMsg.Active_UN_ERROR);
             }
 
@@ -115,25 +386,29 @@
         } else if (type.equalsIgnoreCase(Constant.View)) {
             SysView sysView = viewService.selectById(dataId);
             if (sysView == null) {
-                return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
+                logs.setResult(CodeMsg.SELECT_ERROR_NOTFOUND.getMsg()).updateById();
+                return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND);
             }
+            logs.setName(sysView.getName());
+            logs.updateById();
             Boolean active = sysView.getActive();
             if (!active) {
+                logs.setResult(CodeMsg.Active_UN_ERROR.getMsg()).updateById();
                 return Result.error(CodeMsg.Active_UN_ERROR);
             }
             mqEntity.setMsgTagName(sysView.getId());
         } else {
+            logs.setResult(CodeMsg.ERROR_PARAMS_NOT_MATHED.getMsg()).updateById();
             return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
         }
         mqEntity.setMsgKey(DbUtils.getUUID(16));
         MqEntity.MsgBodyBean msgBody = mqEntity.getMsgBody();
+        msgBody.setTo(userId);
         msgBody.setVersion(versionId);
         MqMessage mqMessage = new MqMessage(mqEntity);
-
-        dispenseService.pushPassiveMq(mqMessage,touchType);  //琚姩杩斿洖
+        mqEntity.setLogId(logs.getId());
+        return dispenseService.pushPassiveMq(mqMessage, touchType, logs);//琚姩杩斿洖
 //        dispenseService.pushActiveMq(mqMessage);  涓诲姩鎺�
-        return Result.success(CodeMsg.ADDQUEUE_SUCCESS);
-
     }
 
     @RequestMapping(value = "/dispense/api", method = RequestMethod.GET)
@@ -313,13 +588,30 @@
 
             for (MasterAuthor masterAuthor : userAuthor) {
                 SubscribeEntity subscribeEntity = new SubscribeEntity();
-                subscribeEntity.setId(masterAuthor.getId());
+                List<Maintain> versionList = maintainFieldService.getMaintainByMaintainField(masterAuthor.getMaintainFieldId(), masterAuthor.getTableName());
+                if (versionList != null && !versionList.isEmpty()) {
+                    Collections.sort(versionList, new Comparator<Maintain>() {
+                        @Override
+                        public int compare(Maintain o1, Maintain o2) {
+                            return o2.getOrderNo().compareTo(o1.getOrderNo());
+                        }
+                    });
+                    ArrayList<JSONObject> jsonObjects = new ArrayList<>();
+                    for (Maintain maintain : versionList) {
+                        JSONObject object = new JSONObject();
+                        object.fluentPut("id", maintain.getId());
+                        object.fluentPut("version", maintain.getVersion());
+                        jsonObjects.add(object);
+                    }
+                   subscribeEntity.setVersionList(jsonObjects);
+                }
                 subscribeEntity.setType(Constant.Master);
                 String menuId = masterAuthor.getMenuId();
                 SysMenu sysMenu = menuService.selectById(menuId);
                 if (sysMenu == null) {
                     continue;
                 }
+                subscribeEntity.setId(sysMenu.getId());
                 subscribeEntity.setName(sysMenu.getName());
                 String maintainFieldId = masterAuthor.getMaintainFieldId();
                 String tableName = masterAuthor.getTableName();
@@ -371,7 +663,7 @@
     public String test(@RequestParam String tableName,  HttpServletRequest request) {
         TUser user = DbUtils.getUser(request);
         List<String> size = new ArrayList<>();
-        String s = masterDataService.selectByVersionSql(user, tableName, size, Constant.WHERE_DEFAULT, "V1.0", false);
+        String s = masterDataService.selectByVersionSql(user, tableName, size, Constant.WHERE_DEFAULT, "V1.1", false);
         return s;
     }
 
@@ -385,6 +677,23 @@
         }else {
             return Result.success(CodeMsg.ERROR_SAVE_TOKEN);
         }
+    }
+
+    @RequestMapping(value = "/config/update", method = RequestMethod.GET)
+    public Result configUpdate(@RequestParam String token, HttpServletRequest request) {
+        try{
+            String redisVal = redisClient.getRedisVal(token);
+            if (StringUtils.isEmpty(redisVal)) {
+                return Result.error(CodeMsg.ERROR_FIND_TOKEN);
+            }
+            //todo aes KEY;
+            return null;
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            return Result.error(CodeMsg.ERROR_SAVE_TOKEN);
+        }
+
     }
 
 
@@ -404,4 +713,73 @@
         }
 
     }
+
+
+
+    @RequestMapping(value = "/log/all/{pageNo}", method = RequestMethod.GET)
+    public Result login( @PathVariable int pageNo, HttpServletRequest request) throws ParseException {
+        String pageSizeStr = request.getParameter("pageSize");
+        String touchType = request.getParameter("touchType");
+        int pageSize = 15;
+        if (!StringUtils.isEmpty(pageSizeStr)) {
+            pageSize = Integer.valueOf(pageSizeStr);
+        }
+        Wrapper<SysDispenseLogs> wrapper = new EntityWrapper<SysDispenseLogs>();
+        if (!StringUtils.isEmpty(touchType)) {
+            if ("sys".equalsIgnoreCase(touchType)) {
+                ArrayList<String> strings = new ArrayList<>();
+                strings.add("muti");
+                strings.add("surface");
+                wrapper.in("touch_type", strings);
+            } else {
+                ArrayList<String> strings = new ArrayList<>();
+                strings.add("api");
+                strings.add("rest");
+                wrapper.in("touch_type", strings);
+            }
+        }
+
+        String dataType = request.getParameter("dataType");
+        if (!StringUtils.isEmpty(dataType)) {
+            wrapper.eq("data_type", dataType);
+        }
+        String userId = request.getParameter("userId");
+        if (!StringUtils.isEmpty(userId)) {
+            wrapper.eq("user_id", userId);
+        }
+        String name = request.getParameter("name");
+        if (!StringUtils.isEmpty(name)) {
+            wrapper.like("name", name);
+        }
+        String tagId = request.getParameter("tagId");
+        if (!StringUtils.isEmpty(tagId)) {
+            wrapper.eq("tag_id", tagId);
+        }
+        String maintainId = request.getParameter("maintainId");
+        if (!StringUtils.isEmpty(maintainId)) {
+            wrapper.eq("maintain_id", maintainId);
+        }
+        String status = request.getParameter("status");
+        if (!StringUtils.isEmpty(status)) {
+            wrapper.eq("status", status);
+        }
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        String startTime = request.getParameter("startTime");
+        if (!StringUtils.isEmpty(startTime)) {
+            Date start = simpleDateFormat.parse(startTime);
+            wrapper.ge("create_time", start);
+        }
+        String endTime = request.getParameter("endTime");
+        if (!StringUtils.isEmpty(endTime)) {
+            Date end = simpleDateFormat.parse(endTime);
+            wrapper.le("create_time", end);
+        }
+
+        Page<SysDispenseLogs> page = new Page<>(pageNo, pageSize);
+        wrapper.orderBy("create_time desc");
+        Page<SysDispenseLogs> sysDispenseLogsPage = dispenseLogsService.selectPage(page, wrapper);
+
+        return Result.success(sysDispenseLogsPage);
+    }
 }

--
Gitblit v1.8.0