add 分发 master_author 添加字段 subscribe increment, 添加7个表 master_author_subscribe master_author_unactive sys_dispense_config sys_dispense_logs sys_view sys_view_join sys_view_logic
| | |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>cglib</groupId> |
| | | <artifactId>cglib</artifactId> |
| | | <version>3.2.6</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-jdbc</artifactId> |
| | | </dependency> |
| | |
| | | <classifier>sources</classifier> |
| | | <type>java-source</type> |
| | | </dependency> |
| | | <!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on --> |
| | | <dependency> |
| | | <groupId>org.bouncycastle</groupId> |
| | | <artifactId>bcprov-jdk15on</artifactId> |
| | | <version>1.60</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.phoenix</groupId> |
| | |
| | | <artifactId>hbase-client</artifactId> |
| | | <version>1.1.2</version> |
| | | </dependency> |
| | | <!-- poi --> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi</artifactId> |
| | | <version>3.16</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml</artifactId> |
| | | <version>3.16</version> |
| | | </dependency> |
| | | <!--<dependency>--> |
| | | <!--<groupId>pentaho</groupId>--> |
| | | <!--<artifactId>pentaho-mongo-utils</artifactId>--> |
New file |
| | |
| | | package com.highdatas.mdm.controller;
|
| | |
|
| | | import com.alibaba.fastjson.JSONArray;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
| | | import com.highdatas.mdm.entity.Flows;
|
| | | import com.highdatas.mdm.entity.Maintain;
|
| | | import com.highdatas.mdm.entity.MaintainField;
|
| | | import com.highdatas.mdm.entity.TUser;
|
| | | import com.highdatas.mdm.mapper.FlowsMapper;
|
| | | import com.highdatas.mdm.pojo.*;
|
| | | import com.highdatas.mdm.service.*;
|
| | | import com.highdatas.mdm.service.act.*;
|
| | | import com.highdatas.mdm.util.Constant;
|
| | | import com.highdatas.mdm.util.DbUtils;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.activiti.engine.history.HistoricActivityInstance;
|
| | | import org.activiti.engine.history.HistoricProcessInstance;
|
| | | import org.activiti.engine.task.Task;
|
| | | import org.apache.commons.lang3.StringUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import javax.servlet.http.HttpSession;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.OutputStream;
|
| | | import java.util.*;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2019-12-13 10:57
|
| | | */
|
| | |
|
| | | @Slf4j
|
| | | @RestController
|
| | | @RequestMapping("/actbak")
|
| | | public class ActController {
|
| | |
|
| | | @Autowired
|
| | | IdentityService identityService;
|
| | |
|
| | | @Autowired
|
| | | IFlowsService flowsService;
|
| | | @Autowired
|
| | | FlowsMapper flowsMapper;
|
| | |
|
| | | @Autowired
|
| | | HistoryService historyService;
|
| | |
|
| | | @Autowired
|
| | | RepositoryService repositoryService;
|
| | |
|
| | | @Autowired
|
| | | RuntimeService runtimeService;
|
| | |
|
| | | @Autowired
|
| | | TaskService taskService;
|
| | |
|
| | | @Autowired
|
| | | ActivitiService activitiService;
|
| | |
|
| | | @Autowired
|
| | | IMaintainService maintainService;
|
| | |
|
| | | @Autowired
|
| | | IMasterModifiedService masterModifiedService;
|
| | |
|
| | | @Autowired
|
| | | IMaintainFieldService maintainFieldService;
|
| | | @Autowired
|
| | | ISysFieldService fieldService;
|
| | |
|
| | | @RequestMapping(value = "/list/{pageNo}", method = RequestMethod.GET)
|
| | | public Result<List<Map<String, Object>>> list(@PathVariable Integer pageNo, HttpServletRequest request) {
|
| | | String filterSegment = request.getParameter("filterSegment");
|
| | | String pageSize = request.getParameter("pageSize");
|
| | | if (StringUtils.isEmpty(filterSegment)) {
|
| | | filterSegment = Constant.WHERE_DEFAULT;
|
| | | }
|
| | | List<Map<String, Object>> list = flowsMapper.selectVersion(filterSegment);
|
| | | for (Map<String, Object> one : list) {
|
| | | String newModelId = (String) one.get(Constant.ID);
|
| | | String url = "act/img/" + newModelId;
|
| | | one.put("imgurl",url);
|
| | | }
|
| | | Integer size;
|
| | | if(StringUtils.isEmpty(pageSize)){
|
| | | size = 15;
|
| | | }else {
|
| | | size = Integer.valueOf(pageSize);
|
| | | }
|
| | | return fieldService.getPagedDataByList(list, pageNo, size);
|
| | | }
|
| | | @RequestMapping(value = "/img/{modelId}", method = RequestMethod.GET)
|
| | | public void image(@PathVariable String modelId, HttpServletResponse response) {
|
| | | InputStream is = repositoryService.getModelImg(modelId);
|
| | |
|
| | | response.setHeader("Content-Type", "image/png");
|
| | | try{
|
| | | OutputStream outputStream = response.getOutputStream();
|
| | | byte[] b = new byte[1024];
|
| | | int len;
|
| | | while ((len = is.read(b, 0, 1024)) != -1) {
|
| | | outputStream.write(b, 0, len);
|
| | | }
|
| | | }
|
| | | catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | finally {
|
| | | if (is != null) {
|
| | | try {
|
| | | is.close();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | @RequestMapping(value = "/deleteModel/{modelId}", method = RequestMethod.GET)
|
| | | public Result deleteModel(@PathVariable String modelId) {
|
| | | boolean b = repositoryService.deleteModel(modelId);
|
| | | if (b) {
|
| | | return Result.success(null);
|
| | | } else {
|
| | | return Result.error(CodeMsg.DELETE_ERROR);
|
| | | }
|
| | | }
|
| | | @RequestMapping(value = "/processlist", method = RequestMethod.GET)
|
| | | public Result<Result<JSONArray>> processlist(HttpServletRequest request) {
|
| | | Result<JSONArray> processList = repositoryService.getProcessList();
|
| | | return Result.success(processList);
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/modellist", method = RequestMethod.GET)
|
| | | public Result<Result<JSONArray>> modellist(HttpServletRequest request) {
|
| | | Result<JSONArray> processList = repositoryService.getProcessList();
|
| | | return Result.success(processList);
|
| | | }
|
| | |
|
| | |
|
| | | @RequestMapping(value = "/start/{key}", method = RequestMethod.GET)
|
| | | public Result<Object> start(@PathVariable String key,@RequestParam String businessId, HttpServletRequest request) {
|
| | | if (StringUtils.isEmpty(key)) {
|
| | | return Result.error(new CodeMsg(1000, "key is not found"));
|
| | | }
|
| | | String desp = request.getParameter("desp");
|
| | | String businessType = request.getParameter("businessType");
|
| | | ActivitiBusinessType type;
|
| | | if (StringUtils.isEmpty(businessType)) {
|
| | | type = ActivitiBusinessType.maintain;
|
| | | } else {
|
| | | type = ActivitiBusinessType.valueOf(businessType);
|
| | | }
|
| | | HttpSession session = request.getSession();
|
| | | Flows flows = activitiService.start(key, session, businessId, type);
|
| | | if (flows == null) {
|
| | | return Result.error(CodeMsg.INSERT_ERROR);
|
| | | } else {
|
| | | if (type.equals(ActivitiBusinessType.field)) {
|
| | | MaintainField maintainField = maintainFieldService.selectById(businessId);
|
| | | maintainField.setFlowId(flows.getId());
|
| | | maintainField.setDesp(desp);
|
| | | maintainField.updateById();
|
| | | return Result.success(flows.getId());
|
| | | }
|
| | | else if (type.equals(ActivitiBusinessType.maintain)) {
|
| | | Maintain maintain = maintainService.selectById(businessId);
|
| | | maintain.setFlowId(flows.getId());
|
| | | maintain.setDesp(desp);
|
| | | maintain.updateById();
|
| | | return Result.success(flows.getId());
|
| | | }else if (type.equals(ActivitiBusinessType.exists)) {
|
| | | HashMap<String, Object> body=new HashMap();
|
| | | NextTaskUserInfo nestTaskAssignee = taskService.getNestTaskAssignee(flows.getWorkflowId());
|
| | |
|
| | | body.put("activitiId", flows.getId());
|
| | | if (nestTaskAssignee == null) {
|
| | | body.put("roleIdList", null);
|
| | | body.put("userIdList", null);
|
| | | } else {
|
| | | body.put("roleIdList", nestTaskAssignee.getRoleIdList());
|
| | | body.put("userIdList", nestTaskAssignee.getUserIdList());
|
| | | }
|
| | | return Result.success(body);
|
| | | }
|
| | | }
|
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/status/{flowid}", method = RequestMethod.GET)
|
| | | public ArrayList<HistoricActivityInstance> status(@PathVariable String flowid, HttpServletRequest request) {
|
| | | if (StringUtils.isEmpty(flowid)) {
|
| | | return null;
|
| | | }
|
| | | historyService.setSession(request.getSession());
|
| | | Flows flows = flowsService.selectById(flowid);
|
| | | if (flows == null) {
|
| | | return null;
|
| | | }
|
| | | String workflowid = flows.getWorkflowId();
|
| | | ArrayList<HistoricActivityInstance> historyAction = historyService.getHistoryAction(workflowid);
|
| | | return historyAction;
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "{tableName}/history/{pageNo}", method = RequestMethod.GET)
|
| | | public Result history(@PathVariable String tableName, @PathVariable Integer pageNo, HttpServletRequest request) {
|
| | | historyService.setSession(request.getSession());
|
| | | String pageSizeStr = request.getParameter("pageSize");
|
| | |
|
| | | List<HistoricProcessInstance> processInstanceList = historyService.getHistoryTask();
|
| | | List<HistoricProcessInstance> subList = new ArrayList<>();
|
| | | for (HistoricProcessInstance historicProcessInstance : processInstanceList) {
|
| | | Flows flows = flowsService.selectOne(new EntityWrapper<Flows>().eq("workflow_id", historicProcessInstance.getId()));
|
| | | if (flows == null) {
|
| | | continue;
|
| | | }
|
| | | ActivitiBusinessType businessType = flows.getBusinessType();
|
| | | if (ActivitiBusinessType.maintain.equals(businessType)) {
|
| | | String businessId = flows.getBusinessId();
|
| | | Maintain maintain = maintainService.selectById(businessId);
|
| | | if (maintain == null) {
|
| | | continue;
|
| | | }
|
| | | String maintainTableName = maintain.getTableName();
|
| | | if (maintainTableName.equalsIgnoreCase(tableName)) {
|
| | | subList.add(historicProcessInstance);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | Page page = new Page(subList.size());
|
| | | page.setPageNo(pageNo);
|
| | | if (!StringUtils.isEmpty(pageSizeStr)) {
|
| | | page.setPageSize(Integer.valueOf(pageSizeStr));
|
| | | }
|
| | |
|
| | | subList = subList.stream().skip(page.getBeginRecordNo_1()).limit(page.getPageSize()).collect(Collectors.toList());
|
| | | ArrayList<Map<String, Object>> result = new ArrayList<>();
|
| | | for (HistoricProcessInstance historicProcessInstance : subList) {
|
| | | HashMap<String, Object> one = new HashMap<>();
|
| | | String workflowId = historicProcessInstance.getId();
|
| | | String startUserId = historicProcessInstance.getStartUserId();
|
| | | TUser user = DbUtils.getUserById(startUserId);
|
| | | Flows flows = flowsService.selectOne(new EntityWrapper<Flows>().eq("workflow_id", workflowId));
|
| | | Maintain maintain = maintainService.selectById(flows.getBusinessId());
|
| | | one.put("userName", user.getUserName());
|
| | | one.put("id", flows.getId());
|
| | | one.put("status", flows.getStatus());
|
| | | one.put("createTime", flows.getCreateTime());
|
| | | result.add(one);
|
| | | }
|
| | |
|
| | | Collections.sort(result, new Comparator<Map<String, Object>>() {
|
| | | @Override
|
| | | public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
| | | Date o1Date = (Date) o1.get("createTime");
|
| | | Date o2Date = (Date) o2.get("createTime");
|
| | | return o2Date.compareTo(o1Date);
|
| | | }
|
| | | });
|
| | |
|
| | | JSONObject object = new JSONObject();
|
| | | object.fluentPut("total", page.getRecordCount());
|
| | | object.fluentPut("size", page.getPageSize());
|
| | | object.fluentPut("pages", page.getPageCount());
|
| | | object.fluentPut("current", page.getPageNo());
|
| | | object.fluentPut("record", result);
|
| | |
|
| | | return Result.success(object);
|
| | | }
|
| | |
|
| | |
|
| | | @RequestMapping(value = "/diagram/{flowid}", method = RequestMethod.GET)
|
| | | public void getDiagram(@PathVariable String flowid, HttpServletResponse response) {
|
| | | if (StringUtils.isEmpty(flowid)) {
|
| | | return;
|
| | | }
|
| | | Flows flows = flowsService.selectById(flowid);
|
| | | if (flows == null) {
|
| | | return;
|
| | | }
|
| | | String workflowid = flows.getWorkflowId();
|
| | | runtimeService.getDiagram(workflowid, response);
|
| | | }
|
| | | @RequestMapping(value = "/run", method = RequestMethod.GET)
|
| | | public List<Map<String, String>> runTask(HttpServletRequest request){
|
| | | historyService.setSession(request.getSession());
|
| | | List<Map<String, String>> myRunTask = historyService.getMyRunTask();
|
| | | return myRunTask;
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/todo", method = RequestMethod.GET)
|
| | | public Result todoTask(HttpServletRequest request){
|
| | | String pageNo = request.getParameter("pageNo");
|
| | | String pageSize = request.getParameter("pageSize");
|
| | | if (StringUtils.isEmpty(pageNo)) {
|
| | | return activitiService.todoTask(request.getSession(), request.getParameter(Constant.tableName), 1, 15);
|
| | | }
|
| | | if (StringUtils.isEmpty(pageSize)) {
|
| | | return activitiService.todoTask(request.getSession(), request.getParameter(Constant.tableName), Integer.valueOf(pageNo), 15);
|
| | | }
|
| | | return activitiService.todoTask(request.getSession(), request.getParameter(Constant.tableName), Integer.valueOf(pageNo), Integer.valueOf(pageSize));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/deal/{flowid}", method = RequestMethod.GET)
|
| | | public Result doTask(@PathVariable String flowid, @RequestParam boolean pass, HttpServletRequest request) {
|
| | | if (StringUtils.isEmpty(flowid)) {
|
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
|
| | | }
|
| | | Flows flows = flowsService.selectById(flowid);
|
| | | if (flows == null) {
|
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
|
| | | }
|
| | | HttpSession session = request.getSession();
|
| | | //todo 判断当前task是否是当前人能审批的
|
| | |
|
| | | taskService.setSession(session);
|
| | | ActivitiStatus status = flows.getStatus();
|
| | |
|
| | | String workflowId = flows.getWorkflowId();
|
| | | // Task task = TimeTaskService.geTask(workflowId);
|
| | | // String id = task.getId();
|
| | | String taskId = null;
|
| | | if (taskService.checkClaim(workflowId)) {
|
| | | taskId = taskService.claimTask(workflowId);
|
| | | }
|
| | |
|
| | | String reason;
|
| | | reason = request.getParameter("reason");
|
| | | if (StringUtils.isEmpty(reason)) {
|
| | | reason = "确认处理";
|
| | | }
|
| | | if (taskId == null) {
|
| | | Task task = taskService.geTask(workflowId);
|
| | | if (task == null) {
|
| | | return Result.error(CodeMsg.ERROR_ACTIVITI_NEXTTASK);
|
| | | }
|
| | | taskId = task.getId();
|
| | | }
|
| | |
|
| | | boolean completed = taskService.completeTask(taskId, pass, reason);
|
| | |
|
| | | if (completed) {
|
| | | NextTaskUserInfo nextTaskDefinition = null;
|
| | | boolean taskFinished = historyService.isTaskFinished(workflowId);
|
| | | if (taskFinished) {
|
| | | if (ActivitiStatus.refuse.equals(status)) {
|
| | | flows.setStatus(ActivitiStatus.close);
|
| | | } else {
|
| | | flows.setStatus(ActivitiStatus.open);
|
| | | }
|
| | |
|
| | | if (!pass) {
|
| | | flows.setStatus(ActivitiStatus.close);
|
| | | }
|
| | |
|
| | |
|
| | | flowsService.aduitFinish(flows);
|
| | |
|
| | | } else {
|
| | | if (pass && flows.getStatus().equals(ActivitiStatus.refuse)) {
|
| | | flows.setStatus(ActivitiStatus.working);
|
| | | } else if(!pass && flows.getStatus().equals(ActivitiStatus.working)){
|
| | | flows.setStatus(ActivitiStatus.refuse);
|
| | | }
|
| | | nextTaskDefinition = taskService.getNestTaskAssignee(workflowId);
|
| | |
|
| | | }
|
| | | HashMap<String, Object> body=new HashMap();
|
| | | if (flows.getBusinessType().equals(ActivitiBusinessType.exists)){
|
| | | body.put("status", flows.getStatus().name());
|
| | | if (nextTaskDefinition == null) {
|
| | | body.put("roleIdList", null);
|
| | | body.put("userIdList", null);
|
| | | } else {
|
| | | body.put("roleIdList", nextTaskDefinition.getRoleIdList());
|
| | | body.put("userIdList", nextTaskDefinition.getUserIdList());
|
| | | }
|
| | | }
|
| | |
|
| | | flows.setUpdateTime(new Date());
|
| | | flowsService.updateById(flows);
|
| | | return Result.success(body);
|
| | | }else {
|
| | | return Result.success(CodeMsg.INSERT_ERROR);
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/addActUser")
|
| | | public Result addActUser(@RequestParam String userId){
|
| | | return identityService.addUser(userId);
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/addActRole")
|
| | | public Result addActRole(@RequestParam String roleId){
|
| | | return identityService.addRole(roleId);
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/addActUserRole")
|
| | | public Result addActUserRole(@RequestParam String roleId, @RequestParam String userId){
|
| | | return identityService.addUserRole(roleId,userId);
|
| | | }
|
| | | @RequestMapping(value = "/deleteActUserRole")
|
| | | public Result deleteActUserRole(@RequestParam String roleId, @RequestParam String userId){
|
| | | return identityService.deleteUserRole(roleId,userId);
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/deleteActRole")
|
| | | public Result deleteActRole(@RequestParam String roleId){
|
| | | return identityService.deleteRole(roleId);
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/deleteActUser")
|
| | | public Result deleteActUser(@RequestParam String userId){
|
| | | return identityService.deleteUser(userId);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", result); |
| | |
| | | JSONObject o = (JSONObject) JSON.toJSON(record);
|
| | |
|
| | | SysAssembleParams sysAssembleParams = paramsService.selectOne(eq);
|
| | | if(sysAssembleParams != null) {
|
| | | String val = sysAssembleParams.getVal();
|
| | | o.fluentPut("nextTime", val);
|
| | | }
|
| | |
|
| | |
|
| | | String realMenuId = record.getMenuId();
|
| | | if (!StringUtils.isEmpty(realMenuId)) {
|
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.util.pool.MqEntity; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.DispenseService; |
| | | import com.highdatas.mdm.service.MasterDataService; |
| | | 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.MqMessage; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2019-12-31 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/dispense") |
| | | @RequestMapping("/subscribe") |
| | | public class DispenseController { |
| | | @Autowired |
| | | DispenseService dispenseService; |
| | |
| | | RedisClient redisClient; |
| | | @Autowired |
| | | MasterDataService masterDataService; |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | ISysMenuService menuService; |
| | | @Autowired |
| | | ISysViewService viewService; |
| | | @Autowired |
| | | IMasterAuthorSubscribeService masterAuthorSubscribeService; |
| | | @Autowired |
| | | IMasterAuthorUnactiveService masterAuthorUnactiveService; |
| | | @Autowired |
| | | ISysDispenseLogsService dispenseLogsService; |
| | | |
| | | @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 = "/dispense/surface/muti", method = RequestMethod.POST) |
| | | public Result surface(@RequestBody JSONObject objectList, HttpServletRequest request, HttpServletResponse response) { |
| | | String userId = objectList.getString("userId"); |
| | | JSONArray datas = objectList.getJSONArray("datas"); |
| | | ArrayList<Result> results = new ArrayList<>(); |
| | | for (int i = 0; i < datas.size(); i++) { |
| | | JSONObject oneRequest = datas.getJSONObject(i); |
| | | String type = oneRequest.getString("type"); |
| | | String dataId = oneRequest.getString("dataId"); |
| | | String versionId = oneRequest.getString("versionId"); |
| | | Result result = addPassiveMq(userId, type, dataId, versionId, request, "muti"); |
| | | results.add(result); |
| | | } |
| | | return Result.success(results); |
| | | |
| | | } |
| | | |
| | | private Result addPassiveMq(@RequestParam String userId, @RequestParam String type, @RequestParam String dataId, String versionId, HttpServletRequest request, String touchType) { |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.USER_NOT_MATHED); |
| | | } |
| | | String incrementStr = request.getParameter("increment"); |
| | | boolean increment = true; |
| | | if (!StringUtils.isEmpty(incrementStr)) { |
| | | increment = Boolean.valueOf(incrementStr); |
| | | } |
| | | MqEntity mqEntity = new MqEntity(); |
| | | mqEntity.setUserId(userId); |
| | | mqEntity.setIncrement(increment); |
| | | mqEntity.setMsgTopicName(type); |
| | | mqEntity.setType(type); |
| | | mqEntity.setDataId(dataId); |
| | | if(type.equalsIgnoreCase(Constant.Master)) { |
| | | |
| | | if (StringUtils.isEmpty(versionId)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | mqEntity.setMaintainId(versionId); |
| | | SysMenu sysMenu = menuService.selectById(dataId); |
| | | if (sysMenu == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | 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); |
| | | } |
| | | |
| | | mqEntity.setMsgTagName(sysMenu.getId()); |
| | | } else if (type.equalsIgnoreCase(Constant.View)) { |
| | | SysView sysView = viewService.selectById(dataId); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | Boolean active = sysView.getActive(); |
| | | if (!active) { |
| | | return Result.error(CodeMsg.Active_UN_ERROR); |
| | | } |
| | | mqEntity.setMsgTagName(sysView.getId()); |
| | | } else { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | mqEntity.setMsgKey(DbUtils.getUUID(16)); |
| | | MqEntity.MsgBodyBean msgBody = mqEntity.getMsgBody(); |
| | | msgBody.setVersion(versionId); |
| | | MqMessage mqMessage = new MqMessage(mqEntity); |
| | | |
| | | dispenseService.pushPassiveMq(mqMessage,touchType); //被动返回 |
| | | // dispenseService.pushActiveMq(mqMessage); 主动推 |
| | | return Result.success(CodeMsg.ADDQUEUE_SUCCESS); |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/dispense/api", method = RequestMethod.GET) |
| | | public Result api(@RequestParam String token, @RequestParam String type, @RequestParam String dataId, HttpServletRequest request, HttpServletResponse response) { |
| | | String userId = redisClient.getRedisVal(token); |
| | | if (StringUtils.isEmpty(userId)) { |
| | | return Result.error(CodeMsg.ERROR_FIND_TOKEN); |
| | | } |
| | | String versionId = request.getParameter("versionId"); |
| | | return addPassiveMq(userId, type, dataId, versionId, request, "api"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/add", method = RequestMethod.GET) |
| | | public void getAll(@RequestParam String code, HttpServletResponse response) { |
| | | dispenseService.pushPassiveMq(new MqMessage( code, response)); |
| | | public Result add(@RequestParam String token, @RequestParam String type, @RequestParam String dataId) { |
| | | try{ |
| | | String redisVal = redisClient.getRedisVal(token); |
| | | if (StringUtils.isEmpty(redisVal)) { |
| | | return Result.error(CodeMsg.ERROR_FIND_TOKEN); |
| | | } |
| | | if(type.equalsIgnoreCase(Constant.Master)) { |
| | | MasterAuthor masterAuthor = masterAuthorService.selectById(dataId); |
| | | if (masterAuthor == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean updated = new MasterAuthorSubscribe().setId(DbUtils.getUUID()).setMenuId(masterAuthor.getId()).setUserId(redisVal).insert(); |
| | | if (updated) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.SUBSCRIBE_SAVE_ERROR); |
| | | } |
| | | } else if (type.equalsIgnoreCase(Constant.View)) { |
| | | SysView sysView = viewService.selectById(dataId); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean updated = sysView.setSubscribe(true).updateById(); |
| | | if (updated) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.SUBSCRIBE_SAVE_ERROR); |
| | | } |
| | | } else { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return Result.error(CodeMsg.ERROR_SAVE_TOKEN); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/refreshList", method = RequestMethod.POST) |
| | | public Result refreshList(@RequestBody JSONObject requestBody) { |
| | | String token = requestBody.getString(Constant.Token); |
| | | if (StringUtils.isEmpty(token)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | try{ |
| | | String userId = redisClient.getRedisVal(token); |
| | | if (StringUtils.isEmpty(userId)) { |
| | | return Result.error(CodeMsg.ERROR_FIND_TOKEN); |
| | | } |
| | | JSONArray dataList = requestBody.getJSONArray("dataList"); |
| | | if (dataList == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | //un subscribe |
| | | List<SysView> sysViews = viewService.selectList(new EntityWrapper<SysView>().eq(Constant.USERID, userId)); |
| | | for (SysView sysView : sysViews) { |
| | | sysView.setSubscribe(false).updateById(); |
| | | } |
| | | |
| | | masterAuthorSubscribeService.delete(new EntityWrapper<MasterAuthorSubscribe>().eq(Constant.USERID, userId)); |
| | | |
| | | for (int i = 0; i < dataList.size(); i++) { |
| | | JSONObject oneObj = dataList.getJSONObject(i); |
| | | String dataId = oneObj.getString("dataId"); |
| | | String type = oneObj.getString("type"); |
| | | if (StringUtils.isEmpty(dataId) || StringUtils.isEmpty(type)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | if(type.equalsIgnoreCase(Constant.Master)) { |
| | | MasterAuthor masterAuthor = masterAuthorService.selectById(dataId); |
| | | if (masterAuthor == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean updated = new MasterAuthorSubscribe().setId(DbUtils.getUUID()).setMenuId(masterAuthor.getId()).setUserId(userId).insert(); |
| | | if (updated) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.SUBSCRIBE_SAVE_ERROR); |
| | | } |
| | | } else if (type.equalsIgnoreCase(Constant.View)) { |
| | | SysView sysView = viewService.selectById(dataId); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean updated = sysView.setSubscribe(true).updateById(); |
| | | if (updated) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.SUBSCRIBE_SAVE_ERROR); |
| | | } |
| | | } else { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | } |
| | | return Result.success(null); |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return Result.error(CodeMsg.ERROR_SAVE_TOKEN); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/delete", method = RequestMethod.GET) |
| | | public Result delete(@RequestParam String token, @RequestParam String type, @RequestParam String dataId) { |
| | | try{ |
| | | String redisVal = redisClient.getRedisVal(token); |
| | | if (StringUtils.isEmpty(redisVal)) { |
| | | return Result.error(CodeMsg.ERROR_FIND_TOKEN); |
| | | } |
| | | if(type.equalsIgnoreCase(Constant.Master)) { |
| | | MasterAuthor masterAuthor = masterAuthorService.selectById(dataId); |
| | | if (masterAuthor == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean updated = masterAuthorSubscribeService.delete(new EntityWrapper<MasterAuthorSubscribe>().eq("master_author_id", masterAuthor.getId()).eq(Constant.USERID, redisVal)); |
| | | |
| | | if (updated) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.SUBSCRIBE_SAVE_ERROR); |
| | | } |
| | | } else if (type.equalsIgnoreCase(Constant.View)) { |
| | | SysView sysView = viewService.selectById(dataId); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean updated = sysView.setSubscribe(false).updateById(); |
| | | if (updated) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.SUBSCRIBE_SAVE_ERROR); |
| | | } |
| | | } else { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return Result.error(CodeMsg.ERROR_SAVE_TOKEN); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/authors", method = RequestMethod.GET) |
| | | public Result authors(@RequestParam String token) { |
| | | try{ |
| | | String userId = redisClient.getRedisVal(token); |
| | | if (StringUtils.isEmpty(userId)) { |
| | | return Result.error(CodeMsg.ERROR_FIND_TOKEN); |
| | | } |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.USER_NOT_MATHED); |
| | | } |
| | | List<SubscribeEntity> result = new ArrayList<>(); |
| | | |
| | | // author 只有拥有最新权限的才能订阅 |
| | | List<MasterAuthor> userAuthor = masterAuthorService.getUserAuthor(userId, null); |
| | | userAuthor = userAuthor.stream() |
| | | .filter(masterAuthor -> !StringUtils.isEmpty(masterAuthor.getMaintainFieldId())) |
| | | // .filter(masterAuthor -> masterAuthor.getMaintainFieldId().equalsIgnoreCase(Constant.All)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | for (MasterAuthor masterAuthor : userAuthor) { |
| | | SubscribeEntity subscribeEntity = new SubscribeEntity(); |
| | | subscribeEntity.setId(masterAuthor.getId()); |
| | | subscribeEntity.setType(Constant.Master); |
| | | String menuId = masterAuthor.getMenuId(); |
| | | SysMenu sysMenu = menuService.selectById(menuId); |
| | | if (sysMenu == null) { |
| | | continue; |
| | | } |
| | | subscribeEntity.setName(sysMenu.getName()); |
| | | String maintainFieldId = masterAuthor.getMaintainFieldId(); |
| | | String tableName = masterAuthor.getTableName(); |
| | | Maintain nowVersion = maintainService.getNowVersion(tableName); |
| | | if (nowVersion == null) { |
| | | continue; |
| | | } |
| | | List<Maintain> maintainByMaintainField = maintainFieldService.getMaintainByMaintainField(maintainFieldId, tableName); |
| | | long count = maintainByMaintainField.stream().filter(maintain -> maintain.getId().equalsIgnoreCase(nowVersion.getId())).count(); |
| | | if (count == 1) { |
| | | result.add(subscribeEntity); |
| | | } |
| | | |
| | | } |
| | | |
| | | //view |
| | | List<SysView> sysViews = viewService.selectList(new EntityWrapper<SysView>().eq(Constant.USERID, userId)); |
| | | List<SubscribeEntity> viewList = sysViews.stream() |
| | | .map(view -> new SubscribeEntity().setId(view.getId()).setName(view.getName()).setType(Constant.View)) |
| | | .collect(Collectors.toList()); |
| | | result.addAll(viewList); |
| | | |
| | | return Result.success(result); |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return Result.error(CodeMsg.ERROR_SAVE_TOKEN); |
| | | } |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/getSubscribeList", method = RequestMethod.GET) |
| | | public Result getSubscribeList(@RequestParam String token, HttpServletResponse response) { |
| | | String userId = redisClient.getRedisVal(token); |
| | | if (StringUtils.isEmpty(userId)) { |
| | | return Result.error(CodeMsg.ERROR_FIND_TOKEN); |
| | | } |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.USER_NOT_MATHED); |
| | | } |
| | | List<SysMenu> menuList = masterAuthorService.getMenu(user); |
| | | |
| | | // maintainFieldService.getMaintainByMaintainField() |
| | | return null; |
| | | } |
| | | |
| | | @RequestMapping(value = "/test", method = RequestMethod.GET) |
| | | public String test(@RequestParam String tableName, HttpServletRequest request) { |
| | | TUser user = DbUtils.getUser(request); |
| | |
| | | public Result login(HttpServletRequest request) { |
| | | TUser user = DbUtils.getUser(request); |
| | | String token = DbUtils.getUUID(32); |
| | | boolean b = redisClient.putRedisVal(user.getId(), token); |
| | | boolean b = redisClient.putRedisVal(token, user.getId()); |
| | | if (b) { |
| | | return Result.success(token); |
| | | }else { |
| | | return Result.success(CodeMsg.ERROR_SAVE_TOKEN); |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/key", method = RequestMethod.GET) |
| | | public Result key(@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); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.highdatas.mdm.entity.SysAssemble; |
| | | import com.highdatas.mdm.entity.SysAssembleParams; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.SysViewMapper; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.ISysAssembleDbService; |
| | | import com.highdatas.mdm.service.ISysAssembleParamsService; |
| | | import com.highdatas.mdm.service.ISysAssembleService; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import com.highdatas.mdm.util.RedisClient; |
| | | import com.highdatas.mdm.pojo.Segment; |
| | | import com.highdatas.mdm.pojo.kettle.UnBigDataDataSourceInfo; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.*; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.ibatis.session.ExecutorType; |
| | | import org.apache.ibatis.session.SqlSession; |
| | | import org.mybatis.spring.SqlSessionTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | /** |
| | | * @author kimi |
| | |
| | | ISysAssembleParamsService paramsService; |
| | | @Autowired |
| | | RedisClient redisClient; |
| | | @Autowired |
| | | ISysViewService viewService; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | @Autowired |
| | | TableInfoMapper tableInfoMapper; |
| | | @Autowired |
| | | private SqlSessionTemplate sqlSessionTemplate; |
| | | @Autowired |
| | | UnBigDataDataSourceInfo unBigDataDataSourceInfo; |
| | | |
| | | @RequestMapping(value = "/loadSqlTable", method = RequestMethod.POST) |
| | | @ResponseBody |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/loadMappingFile", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | public Result loadMappingFile(@RequestParam("file")MultipartFile file,@RequestParam String id, @RequestParam String menuId, @RequestParam String field, HttpServletRequest request) { |
| | | |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null){ |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | String mappingTable = sysView.getMappingTable(); |
| | | if (StringUtils.isEmpty(mappingTable)){ |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean exists = unBigDataDataSourceInfo.checkTableExists(mappingTable); |
| | | if (!exists) { |
| | | ArrayList<String> fields = new ArrayList<>(); |
| | | fields.add(Constant.ID); |
| | | fields.add(Constant.Code); |
| | | fields.add("pre"); |
| | | fields.add("fix"); |
| | | boolean created = unBigDataDataSourceInfo.createTable(mappingTable, fields); |
| | | if (!created) { |
| | | return Result.error(CodeMsg.CREATE_ERROR); |
| | | } |
| | | } |
| | | |
| | | SqlSession session = null; |
| | | try { |
| | | String name = file.getOriginalFilename(); |
| | | List<ViewMappingItem> viewMappingByExcel = ExcelUtil.getViewMappingByExcel(file.getInputStream(), name); |
| | | if (viewMappingByExcel.isEmpty()) { |
| | | return Result.error(CodeMsg.EMPTY_ERROR); |
| | | } |
| | | Maintain maintainByMenu = viewService.getMaintainByMenu(sysView, menuId); |
| | | if (maintainByMenu == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | String changeFieldName = viewService.changeFieldName(maintainByMenu.getTableName(), field); |
| | | Segment segment = new Segment(Constant.Code, changeFieldName); |
| | | tableInfoMapper.delete(mappingTable, segment.toString()); |
| | | session = sqlSessionTemplate.getSqlSessionFactory().openSession(ExecutorType.BATCH, false);//关闭session的自动提交 |
| | | |
| | | SysViewMapper mapper = session.getMapper(SysViewMapper.class); |
| | | AtomicInteger idx = new AtomicInteger(0); |
| | | ContentBuilder builder = new ContentBuilder(Constant.COMMA); |
| | | for (ViewMappingItem viewMappingItem : viewMappingByExcel) { |
| | | builder.clear(); |
| | | builder.append(DbUtils.quotedStr(changeFieldName)); |
| | | builder.append(DbUtils.quotedStr(viewMappingItem.getPre())).append(DbUtils.quotedStr(viewMappingItem.getFix())); |
| | | mapper.insertViewMapping(mappingTable, builder.toString()); |
| | | int i = idx.get(); |
| | | if (i % 1000 == 0 || i == viewMappingByExcel.size()-1) { |
| | | //手动每1000个一提交,提交后无法回滚 |
| | | session.commit(); |
| | | session.clearCache();//注意,如果没有这个动作,可能会导致内存崩溃。 |
| | | } |
| | | idx.getAndIncrement(); |
| | | } |
| | | |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | if (session != null) { |
| | | session.rollback(); |
| | | } |
| | | |
| | | return Result.error(new CodeMsg(6002, e.getMessage())); |
| | | }finally { |
| | | if (session != null) { |
| | | session.close(); |
| | | } |
| | | } |
| | | return Result.success(null); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.MasterAuthorMapper; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | import com.highdatas.mdm.pojo.Result; |
| | |
| | | IMenuMappingService menuMappingService; |
| | | @Autowired |
| | | ISysMenuService menuService; |
| | | @Autowired |
| | | MasterAuthorMapper masterAuthorMapper; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | IMasterAuthorUnactiveService masterAuthorUnactiveService; |
| | | @Autowired |
| | | IMasterAuthorSubscribeService masterAuthorSubscribeService; |
| | | |
| | | public static final String masterAuthorType = "masterAuthorType"; |
| | | public static final String masterId = "masterId"; |
| | |
| | | |
| | | @RequestMapping(value = "/get/{characterId}", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String characterId,@RequestParam boolean isGroup, @RequestParam MasterAuthorType type, HttpServletRequest request){ |
| | | |
| | | List<MasterAuthor> masterAuthorList = authorService.selectList(new EntityWrapper<MasterAuthor>().eq("user_group", isGroup).eq("type", type.name()).eq("character_id", characterId)); |
| | | if (type.equals(MasterAuthorType.role) && masterAuthorList.isEmpty()) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | |
| | | |
| | | Set<String> collect = list.stream().map(masterAuthor -> masterAuthor.getMenuId()).collect(Collectors.toSet()); |
| | | LinkedHashSet<String> menuIds= new LinkedHashSet<>(collect); |
| | | LinkedHashSet<String> byParentId = menuService.getByParentId(menuIds); |
| | | if (byParentId == null) { |
| | | List<SysMenu> sysMenus = menuService.getMenuByParentId(menuIds); |
| | | if (sysMenus == null) { |
| | | return Result.success(object); |
| | | } |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | object.fluentPut("audit",sysMenus); |
| | | return Result.success(object); |
| | | } |
| | |
| | | |
| | | Set<String> collect = masterAuthorList.stream().map(masterAuthor -> masterAuthor.getMenuId()).collect(Collectors.toSet()); |
| | | LinkedHashSet<String> menuIds= new LinkedHashSet<>(collect); |
| | | LinkedHashSet<String> byParentId = menuService.getByParentId(menuIds); |
| | | if (byParentId == null) { |
| | | List<SysMenu> sysMenus = menuService.getMenuByParentId(menuIds); |
| | | if (sysMenus == null) { |
| | | return Result.success(object); |
| | | } |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | |
| | | object.fluentPut("audit",sysMenus); |
| | | return Result.success(object); |
| | |
| | | return Result.success(tableMasterAuthor.values()); |
| | | } |
| | | |
| | | @RequestMapping(value = "/subscribeList/{userId}", method = RequestMethod.GET) |
| | | public Result subscribeList(@PathVariable String userId, HttpServletRequest request){ |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null){ |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | |
| | | List<SysMenu> menuList = authorService.getMenuUnParent(user, true); |
| | | if (menuList == null) { |
| | | return Result.success(null); |
| | | } |
| | | List<MasterAuthor> userAuthor = authorService.getUserAuthor(userId, null); |
| | | |
| | | ArrayList<SysMenu> result = new ArrayList<>(); |
| | | for (SysMenu sysMenu : menuList) { |
| | | long count = userAuthor.stream().filter(masterAuthor -> masterAuthor.getMenuId().equalsIgnoreCase(sysMenu.getId())).count(); |
| | | if (count > 0) { |
| | | result.add(sysMenu); |
| | | } |
| | | } |
| | | LinkedHashSet<String> parentSet = new LinkedHashSet<>(); |
| | | |
| | | for (SysMenu menu : result) { |
| | | menu.setShow(false); |
| | | String menuId = menu.getId(); |
| | | String tableNameByMenu = menuMappingService.getTableNameByMenu(menuId); |
| | | menu.setTableName(tableNameByMenu); |
| | | parentSet.clear(); |
| | | parentSet.add(menuId); |
| | | List<SysMenu> sysMenus = menuService.getMenuByParentId(parentSet); |
| | | |
| | | menu.setParentMenuList(sysMenus); |
| | | int i = masterAuthorSubscribeService.selectCount(new EntityWrapper<MasterAuthorSubscribe>().eq("menu_id", menuId).eq("user_id", userId)); |
| | | if (i > 0) { |
| | | menu.setSubscribe(true); |
| | | } |
| | | |
| | | } |
| | | |
| | | return Result.success(result); |
| | | } |
| | | @RequestMapping(value = "/menu/{userId}", method = RequestMethod.GET) |
| | | public Result<List<SysMenu>> menuList(@PathVariable String userId, HttpServletRequest request) { |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.USER_NOT_MATHED); |
| | | } |
| | | |
| | | List<SysMenu> menu = authorService.getMenu(user, true); |
| | | return Result.success(menu) ; |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/getCnt/{userId}", method = RequestMethod.GET) |
| | | public Result cnt(@PathVariable String userId, HttpServletRequest request) { |
| | | //TODO active |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | List<MasterAuthor> userAuthor = authorService.getUserAuthor(userId, null); |
| | | |
| | | List<SysMenu> menuList = authorService.getMenuUnParent(user, true); |
| | | int totalCnt = 0; |
| | | int subscribeCnt = 0; |
| | | int activeCnt = 0; |
| | | if (menuList == null) { |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("totalCnt", 0); |
| | | object.fluentPut("activeCnt", 0); |
| | | object.fluentPut("subscribeCnt", 0); |
| | | return Result.success(object); |
| | | } |
| | | for (SysMenu sysMenu : menuList) { |
| | | List<MasterAuthor> authorMaintainFieldList = userAuthor.stream() |
| | | .filter(masterAuthor -> masterAuthor.getMenuId().equalsIgnoreCase(sysMenu.getId())) |
| | | .collect(Collectors.toList()); |
| | | int count = authorMaintainFieldList.size(); |
| | | if (count > 0) { |
| | | totalCnt++; |
| | | HashSet<Maintain> maintainSet = new HashSet<>(); |
| | | for (MasterAuthor masterAuthor : authorMaintainFieldList) { |
| | | String maintainFieldId = masterAuthor.getMaintainFieldId(); |
| | | String tableName = masterAuthor.getTableName(); |
| | | List<Maintain> maintainByMaintainField = maintainFieldService.getMaintainByMaintainField(maintainFieldId, tableName); |
| | | maintainSet.addAll(maintainByMaintainField); |
| | | } |
| | | int unActiveCnt = masterAuthorUnactiveService.selectCount(new EntityWrapper<MasterAuthorUnactive>().in("maintain_id", maintainSet).eq("user_id", userId)); |
| | | if (maintainSet.size() != unActiveCnt) { |
| | | activeCnt++; |
| | | } |
| | | int oneSubscribeCnt = masterAuthorSubscribeService.selectCount(new EntityWrapper<MasterAuthorSubscribe>().eq("user_id", userId).eq("menu_id", sysMenu.getId())); |
| | | if (oneSubscribeCnt > 0){ |
| | | subscribeCnt++; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("totalCnt", totalCnt); |
| | | object.fluentPut("activeCnt", activeCnt); |
| | | object.fluentPut("subscribeCnt", subscribeCnt); |
| | | return Result.success(object); |
| | | } |
| | | |
| | | @RequestMapping(value = "/active/{maintainId}", method = RequestMethod.GET) |
| | | public Result active(@PathVariable String maintainId, @RequestParam String userId, @RequestParam Boolean active) { |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.USER_NOT_MATHED); |
| | | } |
| | | MasterAuthorUnactive masterAuthorUnactive = masterAuthorUnactiveService.selectOne(new EntityWrapper<MasterAuthorUnactive>().eq(Constant.USERID, userId).eq("maintain_id", maintainId)); |
| | | if (masterAuthorUnactive == null && active) { |
| | | return Result.success(null); |
| | | } else if (masterAuthorUnactive == null && !active) { |
| | | boolean insert = new MasterAuthorUnactive().setId(DbUtils.getUUID()).setMaintainId(maintainId).setUserId(userId).insert(); |
| | | if (insert) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(null); |
| | | } |
| | | } else if (active) { |
| | | boolean delete = masterAuthorUnactive.deleteById(); |
| | | if (delete) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(null); |
| | | } |
| | | } else { |
| | | return Result.success(null); |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/cntList", method = RequestMethod.GET) |
| | | public Result cntList() { |
| | | HashMap<String, Long> result = new HashMap<>(); |
| | | //user |
| | | |
| | | Set<TUser> allUser = DbUtils.getAllUser(); |
| | | for (TUser user : allUser) { |
| | | int activeCnt = 0; |
| | | List<MasterAuthor> userAuthor = authorService.getUserAuthor(user.getUserId(), null); |
| | | |
| | | List<SysMenu> menuList = authorService.getMenuUnParent(user, true); |
| | | |
| | | if (menuList == null) { |
| | | continue; |
| | | } |
| | | for (SysMenu sysMenu : menuList) { |
| | | List<MasterAuthor> authorMaintainFieldList = userAuthor.stream() |
| | | .filter(masterAuthor -> masterAuthor.getMenuId().equalsIgnoreCase(sysMenu.getId())) |
| | | .collect(Collectors.toList()); |
| | | int count = authorMaintainFieldList.size(); |
| | | if (count > 0) { |
| | | HashSet<Maintain> maintainSet = new HashSet<>(); |
| | | for (MasterAuthor masterAuthor : authorMaintainFieldList) { |
| | | String maintainFieldId = masterAuthor.getMaintainFieldId(); |
| | | String tableName = masterAuthor.getTableName(); |
| | | List<Maintain> maintainByMaintainField = maintainFieldService.getMaintainByMaintainField(maintainFieldId, tableName); |
| | | maintainSet.addAll(maintainByMaintainField); |
| | | } |
| | | int unActiveCnt = masterAuthorUnactiveService.selectCount(new EntityWrapper<MasterAuthorUnactive>().in("maintain_id", maintainSet).eq("user_id", user.getUserId())); |
| | | if (maintainSet.size() != unActiveCnt) { |
| | | activeCnt++; |
| | | } |
| | | |
| | | } |
| | | result.put(user.getUserId(), Long.valueOf(activeCnt)); |
| | | } |
| | | } |
| | | |
| | | List<Map<String, Object>> userMapList = masterAuthorMapper.selectViewCnt(); |
| | | merageUserCnt(result, userMapList); |
| | | if (result.isEmpty()) { |
| | | return Result.success(null); |
| | | } |
| | | return Result.success(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/maintainList/{userId}", method = RequestMethod.GET) |
| | | public Result maintainList(@PathVariable String userId, @RequestParam String tableName) { |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.USER_NOT_MATHED); |
| | | } |
| | | Set<Maintain> maintainSet = authorService.getMaintainSet(tableName, user); |
| | | List<MasterAuthorUnactive> masterAuthorUnactives = masterAuthorUnactiveService.selectList(new EntityWrapper<MasterAuthorUnactive>().eq(Constant.USERID, userId)); |
| | | for (Maintain maintain : maintainSet) { |
| | | long count = masterAuthorUnactives.stream() |
| | | .filter(masterAuthorUnactive -> !StringUtils.isEmpty(masterAuthorUnactive.getMaintainId())) |
| | | .filter(masterAuthorUnactive -> masterAuthorUnactive.getMaintainId().equalsIgnoreCase(maintain.getId())) |
| | | .count(); |
| | | if (count > 0) { |
| | | maintain.setActive(false); |
| | | } else { |
| | | maintain.setActive(true); |
| | | } |
| | | } |
| | | return Result.success(maintainSet); |
| | | } |
| | | |
| | | |
| | | private void merageUserCnt(HashMap<String, Long> result, List<Map<String, Object>> masterUserMapList) { |
| | | for (Map<String, Object> stringStringMap : masterUserMapList) { |
| | | String user = stringStringMap.get(Constant.USERID).toString(); |
| | | long cnt = (long)(stringStringMap.get(Constant.CNT)); |
| | | |
| | | Long val = result.get(user); |
| | | if (val == null) { |
| | | result.put(user, Long.valueOf(cnt)); |
| | | } else { |
| | | val += Long.valueOf(cnt); |
| | | result.put(user, val); |
| | | } |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | import com.highdatas.mdm.entity.SysDispenseConfig; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.ISysDispenseConfigService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-20 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/dispense/config") |
| | | public class SysDispenseConfigController { |
| | | @Autowired |
| | | ISysDispenseConfigService dispenseConfigService; |
| | | |
| | | @RequestMapping(value = "/get", method = RequestMethod.POST) |
| | | public Result getId() { |
| | | SysDispenseConfig sysDispenseConfig = dispenseConfigService.selectById("001"); |
| | | return Result.success(sysDispenseConfig); |
| | | } |
| | | |
| | | @RequestMapping(value = "/update", method = RequestMethod.POST) |
| | | public Result update(@RequestBody SysDispenseConfig config) { |
| | | String id = config.getId(); |
| | | if (StringUtils.isEmpty(id)) { |
| | | Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean b = config.updateById(); |
| | | if (b) { |
| | | return Result.success(b); |
| | | } else { |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | | } |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/timeout/{time}", method = RequestMethod.GET) |
| | | public Result timeout(@PathVariable Integer time) { |
| | | SysDispenseConfig sysDispenseConfig = dispenseConfigService.selectById("001"); |
| | | if (sysDispenseConfig == null) { |
| | | Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | sysDispenseConfig.setTimeout(time).updateById(); |
| | | return Result.success(sysDispenseConfig); |
| | | } |
| | | @RequestMapping(value = "/resend/{cnt}", method = RequestMethod.GET) |
| | | public Result resend(@PathVariable Integer cnt) { |
| | | SysDispenseConfig sysDispenseConfig = dispenseConfigService.selectById("001"); |
| | | if (sysDispenseConfig == null) { |
| | | Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | sysDispenseConfig.setResendCnt(cnt).updateById(); |
| | | return Result.success(sysDispenseConfig); |
| | | } |
| | | @RequestMapping(value = "/error", method = RequestMethod.GET) |
| | | public Result error(@RequestParam Boolean isContinue) { |
| | | SysDispenseConfig sysDispenseConfig = dispenseConfigService.selectById("001"); |
| | | if (sysDispenseConfig == null) { |
| | | Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | sysDispenseConfig.setErrorContinue(isContinue).updateById(); |
| | | return Result.success(sysDispenseConfig); |
| | | } |
| | | } |
| | |
| | | return Result.success(null); |
| | | } |
| | | LinkedHashSet<String> parentIdSet = new LinkedHashSet<>(menuIds); |
| | | Set<String> byParentId = menuService.getByParentId(parentIdSet); |
| | | |
| | | if (byParentId == null || byParentId.isEmpty()) { |
| | | List<SysMenu> parentList = menuService.getMenuByParentId(parentIdSet); |
| | | if (parentList == null) { |
| | | return Result.success(null); |
| | | } |
| | | List<SysMenu> parentList = menuService.selectBatchIds(byParentId); |
| | | |
| | | return Result.success(parentList); |
| | | } |
| | |
| | | } |
| | | parentIdSet.add(sysMenu.getId()); |
| | | } |
| | | Set<String> byParentId = menuService.getByParentId(parentIdSet); |
| | | List<SysMenu> parentList = menuService.selectBatchIds(byParentId); |
| | | List<SysMenu> parentList = menuService.getMenuByParentId(parentIdSet); |
| | | |
| | | return Result.success(parentList) ; |
| | | } |
| | |
| | | menu.setId(uuid); |
| | | menu.setParentId(parentId); |
| | | menu.setOrderNo(orderno); |
| | | menu.setMenuType(menuType); |
| | | menu.setMenuType(menuType).setCreateTime(new Date()); |
| | | boolean inserted = menuService.insert(menu); |
| | | if (inserted) { |
| | | return Result.success(menu); |
| | |
| | | }else { |
| | | orderno = Integer.valueOf(ordernoStr); |
| | | } |
| | | menu = new SysMenu().setId(id).setParentId(parentId).setMenuType(menuType).setName(name).setOrderNo(orderno); |
| | | menu = new SysMenu().setCreateTime(new Date()).setId(id).setParentId(parentId).setMenuType(menuType).setName(name).setOrderNo(orderno); |
| | | menu.insert(); |
| | | } |
| | | |
| | |
| | | @RequestMapping(value = "/update", method = RequestMethod.GET) |
| | | public Result<Object> update(@RequestParam String id, HttpServletRequest request) { |
| | | SysMenu menu = menuService.selectById(id); |
| | | |
| | | if (menu == null) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | | } |
| | | menu.setUpdateTime(new Date()); |
| | | String ordernoStr = request.getParameter("orderNo"); |
| | | String parentId = request.getParameter("parentId"); |
| | | String menuType = request.getParameter("menuType"); |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.mapper.UserMapper; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.pojo.ViewMapFieldItem; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.AESUtil; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import lombok.SneakyThrows; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | @Controller |
| | | @RestController |
| | | @RequestMapping("/sysView") |
| | | public class SysViewController { |
| | | @Autowired |
| | | ISysViewService viewService; |
| | | @Autowired |
| | | ISysViewJoinService sysViewJoinService; |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | ISysMenuService menuService; |
| | | @Autowired |
| | | UserMapper mapper; |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | @Autowired |
| | | MasterDataService masterDataService; |
| | | @Autowired |
| | | TableInfoMapper tableInfoMapper; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | |
| | | @SneakyThrows |
| | | @RequestMapping(value = "/test", method = RequestMethod.GET) |
| | | public Result test(HttpServletRequest request) throws Exception { |
| | | List<Map<String, Object>> test = mapper.test(); |
| | | String keys = "ismytestkeys"; |
| | | byte[] secretKey = AESUtil.getSecretKey(keys); |
| | | String content = JSONArray.toJSONString(test); |
| | | long start = System.currentTimeMillis(); |
| | | byte[] bytes = content.getBytes("utf-8"); |
| | | int length = bytes.length; |
| | | System.out.println(length + "K"); |
| | | String s = AESUtil.aesPKCS7PaddingEncrypt(content, secretKey.toString()); |
| | | long end = System.currentTimeMillis(); |
| | | float time = (end - start) ; |
| | | System.out.println(time + "s"); |
| | | return Result.success(s); |
| | | } |
| | | |
| | | @RequestMapping(value = "/test1", method = RequestMethod.GET) |
| | | public Result test1(HttpServletRequest request) throws InterruptedException { |
| | | Thread.sleep(3000); |
| | | return Result.success(null); |
| | | } |
| | | |
| | | @RequestMapping(value = "/all/{userId}", method = RequestMethod.GET) |
| | | public Result getAll(@PathVariable String userId, HttpServletRequest request) { |
| | | //TODO |
| | | Wrapper<SysView> eq = new EntityWrapper<SysView>().eq(Constant.USERID, userId); |
| | | List<SysView> records = viewService.selectList(eq); |
| | | for (SysView record : records) { |
| | | String id = record.getId(); |
| | | String baseMaintainStr = record.getBaseMaintain(); |
| | | |
| | | Maintain baseMaintain = viewService.getBaseMaintain(record); |
| | | if (baseMaintain == null) { |
| | | continue; |
| | | } |
| | | record.setBaseTableName(baseMaintain.getTableName()); |
| | | record.setBaseVersion(baseMaintain.getVersion()); |
| | | String menuId = record.getMenuId(); |
| | | SysMenu sysMenu = menuService.selectById(menuId); |
| | | if (sysMenu == null) { |
| | | continue; |
| | | } |
| | | record.setMenuName(sysMenu.getName()); |
| | | List<SysViewJoin> sysViewJoins = sysViewJoinService.selectList(new EntityWrapper<SysViewJoin>().eq(Constant.PARENT_ID, id)); |
| | | List<String> menuIds = sysViewJoins.stream() |
| | | .map(sysViewJoin -> sysViewJoin.getMenuId()) |
| | | .collect(Collectors.toList()); |
| | | if (!menuIds.isEmpty()) { |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(menuIds); |
| | | Collections.reverse(sysMenus); |
| | | String subMenuName = sysMenus.stream().map(subMenu -> subMenu.getName()).collect(Collectors.joining(Constant.SEMICOLON)); |
| | | record.setSubMenuName(subMenuName); |
| | | } |
| | | |
| | | } |
| | | return Result.success(records); |
| | | } |
| | | |
| | | @RequestMapping(value = "/refreshData/{id}", method = RequestMethod.GET) |
| | | public Result createView(@RequestParam String id, @RequestParam Boolean active) { |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | viewService.createView(sysView.getId()); |
| | | return Result.success(sysView); |
| | | } |
| | | |
| | | @RequestMapping(value = "/saveMapField/{id}", method = RequestMethod.GET) |
| | | public Result saveMapField(@RequestParam String id, @RequestParam String mapField) { |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | sysView.setMappingField(mapField).updateById(); |
| | | return Result.success(sysView); |
| | | } |
| | | |
| | | @RequestMapping(value = "/createView/{id}", method = RequestMethod.GET) |
| | | public Result createView(@PathVariable String id) { |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean view = viewService.createView(sysView.getId()); |
| | | if (view) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.CREATE_ERROR); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/active/{id}", method = RequestMethod.GET) |
| | | public Result active(@PathVariable String id, @RequestParam Boolean active) { |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | sysView.setActive(active).updateById(); |
| | | return Result.success(sysView); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getViewData/{id}/page/{pageNo}", method = RequestMethod.GET) |
| | | public Result getViewData(@PathVariable String id, @PathVariable Integer pageNo, HttpServletRequest request) { |
| | | String pageSizeStr = request.getParameter("pageSize"); |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | int pageSize = 15; |
| | | if (!StringUtils.isEmpty(pageSizeStr)) { |
| | | pageSize = Integer.valueOf(pageSizeStr); |
| | | } |
| | | return viewService.getViewData(sysView, pageNo, pageSize); |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/getMapData/{id}/page/{pageNo}", method = RequestMethod.GET) |
| | | public Result getMapData(@PathVariable String id, @PathVariable Integer pageNo, @RequestParam String changedField, HttpServletRequest request) { |
| | | String pageSizeStr = request.getParameter("pageSize"); |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | int pageSize = 15; |
| | | if (!StringUtils.isEmpty(pageSizeStr)) { |
| | | pageSize = Integer.valueOf(pageSizeStr); |
| | | } |
| | | return viewService.getMapData(sysView, changedField, pageNo, pageSize); |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/field/{userId}", method = RequestMethod.GET) |
| | | public Result<List<SysField>> fieldList(@PathVariable String userId, @RequestParam boolean needUpdate, @RequestParam String maintainId, HttpServletRequest request) { |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.USER_NOT_MATHED); |
| | | } |
| | | if (needUpdate) { |
| | | Maintain nowVersion = maintainService.getNowVersion(maintainId); |
| | | List<SysField> field = masterAuthorService.getField(user, nowVersion.getId()); |
| | | return Result.success(field) ; |
| | | } |
| | | List<SysField> field = masterAuthorService.getField(user, maintainId); |
| | | return Result.success(field) ; |
| | | } |
| | | |
| | | @RequestMapping(value = "/mapFieldList/{id}", method = RequestMethod.GET) |
| | | public Result active(@PathVariable String id) { |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | |
| | | List<ViewMapFieldItem> mapField = viewService.getMapField(sysView); |
| | | return Result.success(mapField); |
| | | } |
| | | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String id) { |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | String menuId = sysView.getMenuId(); |
| | | LinkedHashSet<String> parentIdSet = new LinkedHashSet<>(); |
| | | parentIdSet.add(menuId); |
| | | LinkedHashSet<String> byParentId = menuService.getByParentId(parentIdSet); |
| | | ArrayList<String> strings = new ArrayList<>(byParentId); |
| | | Collections.reverse(strings); |
| | | String collect = strings.stream().collect(Collectors.joining(Constant.SEMICOLON)); |
| | | sysView.setMenuName(collect); |
| | | List<SysViewJoin> sysViewJoins = sysViewJoinService.selectList(new EntityWrapper<SysViewJoin>().eq(Constant.PARENT_ID, id)); |
| | | for (SysViewJoin sysViewJoin : sysViewJoins) { |
| | | parentIdSet.clear(); |
| | | parentIdSet.add(sysViewJoin.getMenuId()); |
| | | LinkedHashSet<String> subParent = menuService.getByParentId(parentIdSet); |
| | | ArrayList<String> subList = new ArrayList<>(subParent); |
| | | Collections.reverse(subList); |
| | | String subMenuName = subList.stream().collect(Collectors.joining(Constant.SEMICOLON)); |
| | | sysViewJoin.setMenuName(subMenuName); |
| | | } |
| | | sysView.setViewJoinList(sysViewJoins); |
| | | return Result.success(sysView); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getCnt/{userId}", method = RequestMethod.GET) |
| | | public Result cnt(@PathVariable String userId, HttpServletRequest request) { |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | Wrapper<SysView> userWrapper = new EntityWrapper<SysView>().eq("user_id", userId); |
| | | int totalCnt = viewService.selectCount(userWrapper); |
| | | userWrapper.eq("active", true); |
| | | int activeCnt = viewService.selectCount(userWrapper); |
| | | userWrapper.eq("subscribe", true); |
| | | int subscribeCnt = viewService.selectCount(userWrapper); |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("totalCnt", totalCnt); |
| | | object.fluentPut("activeCnt", activeCnt); |
| | | object.fluentPut("subscribeCnt", subscribeCnt); |
| | | return Result.success(object); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/create/{userId}", method = RequestMethod.GET) |
| | | public Result add(@PathVariable String userId, HttpServletRequest request) { |
| | | SysView sysView = new SysView(); |
| | | sysView.setId(DbUtils.getUUID()) |
| | | .setUserId(userId) |
| | | .setCreateTime(new Date()) |
| | | .setStatus(ViewStatus.edit) |
| | | .setEmptyData(true) |
| | | .insert(); |
| | | viewService.getMappingTableName(sysView); |
| | | return Result.success(sysView); |
| | | } |
| | | |
| | | @SneakyThrows |
| | | @RequestMapping(value = "/deleteMap/{id}", method = RequestMethod.GET) |
| | | public Result deleteMap(@PathVariable String id, @RequestParam String changedField) { |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | |
| | | boolean b = viewService.deleteMapField(sysView, changedField); |
| | | if (!b) { |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | | } |
| | | return Result.success(sysView); |
| | | } |
| | | @SneakyThrows |
| | | @RequestMapping(value = "/delete/detail/{id}", method = RequestMethod.GET) |
| | | public Result deleteDetail(@PathVariable String id) { |
| | | SysViewJoin sysViewJoin = sysViewJoinService.selectById(id); |
| | | if (sysViewJoin == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | String parentId = sysViewJoin.getParentId(); |
| | | SysView sysView = viewService.selectById(parentId); |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | |
| | | Maintain joinMaintain = viewService.getJoinMaintain(sysViewJoin); |
| | | List<String> subFieldList = viewService.getSubFieldList(sysViewJoin, user); |
| | | boolean delete = false; |
| | | for (String subField: subFieldList) { |
| | | String changeFieldName = viewService.changeFieldName(joinMaintain.getTableName(), subField); |
| | | delete = viewService.deleteMapField(sysView, changeFieldName); |
| | | } |
| | | if (delete) { |
| | | return Result.success(CodeMsg.DELETE_SUCCESS); |
| | | } else { |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | | } |
| | | } |
| | | |
| | | |
| | | @SneakyThrows |
| | | @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) |
| | | public Result delete(@PathVariable String id) { |
| | | return viewService.deleteView(id); |
| | | } |
| | | |
| | | @RequestMapping(value = "/maintainList/{userId}", method = RequestMethod.GET) |
| | | public Result add(@PathVariable String userId, @RequestParam String menuId, HttpServletRequest request) { |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.USER_NOT_MATHED); |
| | | } |
| | | String tableNameByMenu = menuMappingService.getTableNameByMenu(menuId); |
| | | if (StringUtils.isEmpty(tableNameByMenu)) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | | } |
| | | LinkedHashSet<Maintain> maintainSet = masterAuthorService.getMaintainSet(tableNameByMenu, user); |
| | | ArrayList<Maintain> maintains = new ArrayList<>(maintainSet); |
| | | for (Maintain maintain : maintains) { |
| | | maintain.setNeedUpdate(false); |
| | | } |
| | | Maintain max = new Maintain(); |
| | | max.setId(tableNameByMenu); |
| | | max.setTableName(tableNameByMenu); |
| | | max.setNeedUpdate(true); |
| | | maintains.add(0, max); |
| | | return Result.success(maintains); |
| | | } |
| | | |
| | | @RequestMapping(value = "/update", method = RequestMethod.POST) |
| | | public Result add(@RequestBody SysView view) { |
| | | if (StringUtils.isEmpty(view.getId())) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | | } |
| | | if (StringUtils.isEmpty(view.getMenuId()) || StringUtils.isEmpty(view.getBaseMaintain()) ) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | |
| | | view.setEmptyData(false).setStatus(ViewStatus.edit); |
| | | //delete |
| | | sysViewJoinService.delete(new EntityWrapper<SysViewJoin>().eq(Constant.PARENT_ID, view.getId())); |
| | | |
| | | List<SysViewJoin> viewJoinList = view.getViewJoinList(); |
| | | boolean insert; |
| | | for (SysViewJoin sysViewJoin : viewJoinList) { |
| | | insert = sysViewJoin.setId(DbUtils.getUUID()).insert(); |
| | | if (!insert) { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } |
| | | } |
| | | view.setUpdateTime(new Date()); |
| | | view.updateById(); |
| | | return Result.success(view); |
| | | } |
| | | @SneakyThrows |
| | | @RequestMapping(value = "/download/{id}", method = RequestMethod.GET) |
| | | public void download(@PathVariable String id, @RequestParam String menuId, @RequestParam String field, HttpServletResponse response) { |
| | | |
| | | SysView sysView = viewService.selectById(id); |
| | | if (sysView == null) { |
| | | return; |
| | | } |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return; |
| | | } |
| | | viewService.downlodMap(sysView,user, response, field, menuId); |
| | | } |
| | | } |
| | |
| | | private Date createTime; |
| | | |
| | | private transient Integer maintainType; |
| | | private transient boolean active; |
| | | private transient boolean needUpdate; |
| | | |
| | | private transient Integer recordCount; |
| | | |
| | |
| | | |
| | | private Boolean active; |
| | | |
| | | private Boolean subscribe; |
| | | private Boolean increment; |
| | | |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | | |
| | |
| | | private Date updateTime; |
| | | |
| | | private transient List<MasterAuthorDetail> fields; |
| | | private transient String menuName; |
| | | private transient Boolean isShow; |
| | | private transient List<SysMenu> parentMenuList; |
| | | |
| | | |
| | | public Boolean getIncrement() { |
| | | return increment; |
| | | } |
| | | |
| | | public MasterAuthor setIncrement(Boolean increment) { |
| | | this.increment = increment; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getShow() { |
| | | return isShow; |
| | | } |
| | | |
| | | public MasterAuthor setShow(Boolean show) { |
| | | isShow = show; |
| | | return this; |
| | | } |
| | | |
| | | public String getMenuName() { |
| | | return menuName; |
| | | } |
| | | |
| | | public MasterAuthor setMenuName(String menuName) { |
| | | this.menuName = menuName; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getSubscribe() { |
| | | return subscribe; |
| | | } |
| | | |
| | | public MasterAuthor setSubscribe(Boolean subscribe) { |
| | | this.subscribe = subscribe; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getUserGroup() { |
| | | return userGroup; |
| | |
| | | ", updateTime=" + updateTime + |
| | | "}"; |
| | | } |
| | | |
| | | public MasterAuthor setParentMenuList(List<SysMenu> parentMenuList) { |
| | | this.parentMenuList = parentMenuList; |
| | | return this; |
| | | } |
| | | |
| | | public List<SysMenu> getParentMenuList() { |
| | | return parentMenuList; |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-20 |
| | | */ |
| | | @TableName("master_author_subscribe") |
| | | public class MasterAuthorSubscribe extends Model<MasterAuthorSubscribe> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | @TableField("menu_id") |
| | | private String menuId; |
| | | |
| | | @TableField("user_id") |
| | | private String userId; |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public MasterAuthorSubscribe setId(String id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | |
| | | public String getMenuId() { |
| | | return menuId; |
| | | } |
| | | |
| | | public MasterAuthorSubscribe setMenuId(String menuId) { |
| | | this.menuId = menuId; |
| | | return this; |
| | | } |
| | | |
| | | public String getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public MasterAuthorSubscribe setUserId(String userId) { |
| | | this.userId = userId; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "MasterAuthorSubscribe{" + |
| | | "id=" + id + |
| | | ", menuId=" + menuId + |
| | | ", userId=" + userId + |
| | | "}"; |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-18 |
| | | */ |
| | | @TableName("master_author_unactive") |
| | | public class MasterAuthorUnactive extends Model<MasterAuthorUnactive> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | @TableField("maintain_id") |
| | | private String maintainId; |
| | | |
| | | @TableField("user_id") |
| | | private String userId; |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public MasterAuthorUnactive setId(String id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | public String getMaintainId() { |
| | | return maintainId; |
| | | } |
| | | |
| | | public MasterAuthorUnactive setMaintainId(String maintainId) { |
| | | this.maintainId = maintainId; |
| | | return this; |
| | | } |
| | | public String getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public MasterAuthorUnactive setUserId(String userId) { |
| | | this.userId = userId; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "MasterAuthorUnactive{" + |
| | | "id=" + id + |
| | | ", maintainId=" + maintainId + |
| | | ", userId=" + userId + |
| | | "}"; |
| | | } |
| | | } |
| | |
| | | ", url=" + url + |
| | | ", headers=" + headers + |
| | | ", pagination=" + pagination + |
| | | ", passiveQueueSize=" + size + |
| | | ", size=" + size + |
| | | ", pageurl=" + pageurl + |
| | | ", resultfield=" + resultfield + |
| | | "}"; |
New file |
| | |
| | | package com.highdatas.mdm.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-20 |
| | | */ |
| | | @TableName("sys_dispense_config") |
| | | public class SysDispenseConfig extends Model<SysDispenseConfig> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("error_continue") |
| | | private Boolean errorContinue; |
| | | |
| | | private Integer timeout; |
| | | private String id; |
| | | |
| | | @TableField("resend_cnt") |
| | | private Integer resendCnt; |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Boolean getErrorContinue() { |
| | | return errorContinue; |
| | | } |
| | | |
| | | public SysDispenseConfig setErrorContinue(Boolean errorContinue) { |
| | | this.errorContinue = errorContinue; |
| | | return this; |
| | | } |
| | | public Integer getTimeout() { |
| | | return timeout; |
| | | } |
| | | |
| | | public SysDispenseConfig setTimeout(Integer timeout) { |
| | | this.timeout = timeout; |
| | | return this; |
| | | } |
| | | public Integer getResendCnt() { |
| | | return resendCnt; |
| | | } |
| | | |
| | | public SysDispenseConfig setResendCnt(Integer resendCnt) { |
| | | this.resendCnt = resendCnt; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SysDispenseConfig{" + |
| | | "errorContinue=" + errorContinue + |
| | | ", timeout=" + timeout + |
| | | ", resendCnt=" + resendCnt + |
| | | "}"; |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.entity; |
| | | |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-21 |
| | | */ |
| | | @TableName("sys_dispense_logs") |
| | | public class SysDispenseLogs extends Model<SysDispenseLogs> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | /** |
| | | * 数据类型 |
| | | */ |
| | | @TableField("data_type") |
| | | private String dataType; |
| | | |
| | | /** |
| | | * 触发方式 |
| | | */ |
| | | @TableField("touch_type") |
| | | private String touchType; |
| | | |
| | | /** |
| | | * mq topic 默认type |
| | | */ |
| | | @TableField("topic_id") |
| | | private String topicId; |
| | | |
| | | /** |
| | | * mq tag 默认主数据 menuid,视图 id |
| | | */ |
| | | @TableField("tag_id") |
| | | private String tagId; |
| | | |
| | | /** |
| | | * 本次传输 key 自动生成 |
| | | */ |
| | | @TableField("key_id") |
| | | private String keyId; |
| | | |
| | | /** |
| | | * 总数 |
| | | */ |
| | | private Integer total; |
| | | |
| | | /** |
| | | * 总页数 |
| | | */ |
| | | private Integer pages; |
| | | |
| | | /** |
| | | * 当前传到第几个 |
| | | */ |
| | | @TableField("page_no") |
| | | private Integer pageNo; |
| | | |
| | | @TableField("page_size") |
| | | private Integer pageSize; |
| | | |
| | | /** |
| | | * 状态,是否整个传输成功 |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 最后一次请求的返回值 |
| | | */ |
| | | @TableField("msg_code") |
| | | private String msgCode; |
| | | |
| | | /** |
| | | * 最后一次请求的msgid |
| | | */ |
| | | @TableField("msg_id") |
| | | private String msgId; |
| | | |
| | | /** |
| | | * 系统错误信息 |
| | | */ |
| | | @TableField("error_info") |
| | | private String errorInfo; |
| | | |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | | |
| | | |
| | | public Integer getPageSize() { |
| | | return pageSize; |
| | | } |
| | | |
| | | public SysDispenseLogs setPageSize(Integer pageSize) { |
| | | this.pageSize = pageSize; |
| | | return this; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public SysDispenseLogs setId(String id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | public String getDataType() { |
| | | return dataType; |
| | | } |
| | | |
| | | public SysDispenseLogs setDataType(String dataType) { |
| | | this.dataType = dataType; |
| | | return this; |
| | | } |
| | | public String getTouchType() { |
| | | return touchType; |
| | | } |
| | | |
| | | public SysDispenseLogs setTouchType(String touchType) { |
| | | this.touchType = touchType; |
| | | return this; |
| | | } |
| | | public String getTopicId() { |
| | | return topicId; |
| | | } |
| | | |
| | | public SysDispenseLogs setTopicId(String topicId) { |
| | | this.topicId = topicId; |
| | | return this; |
| | | } |
| | | public String getTagId() { |
| | | return tagId; |
| | | } |
| | | |
| | | public SysDispenseLogs setTagId(String tagId) { |
| | | this.tagId = tagId; |
| | | return this; |
| | | } |
| | | public String getKeyId() { |
| | | return keyId; |
| | | } |
| | | |
| | | public SysDispenseLogs setKeyId(String keyId) { |
| | | this.keyId = keyId; |
| | | return this; |
| | | } |
| | | public Integer getTotal() { |
| | | return total; |
| | | } |
| | | |
| | | public SysDispenseLogs setTotal(Integer total) { |
| | | this.total = total; |
| | | return this; |
| | | } |
| | | public Integer getPages() { |
| | | return pages; |
| | | } |
| | | |
| | | public SysDispenseLogs setPages(Integer pages) { |
| | | this.pages = pages; |
| | | return this; |
| | | } |
| | | public Integer getPageNo() { |
| | | return pageNo; |
| | | } |
| | | |
| | | public SysDispenseLogs setPageNo(Integer pageNo) { |
| | | this.pageNo = pageNo; |
| | | return this; |
| | | } |
| | | public String getStatus() { |
| | | return status; |
| | | } |
| | | |
| | | public SysDispenseLogs setStatus(String status) { |
| | | this.status = status; |
| | | return this; |
| | | } |
| | | public String getMsgCode() { |
| | | return msgCode; |
| | | } |
| | | |
| | | public SysDispenseLogs setMsgCode(String msgCode) { |
| | | this.msgCode = msgCode; |
| | | return this; |
| | | } |
| | | public String getMsgId() { |
| | | return msgId; |
| | | } |
| | | |
| | | public SysDispenseLogs setMsgId(String msgId) { |
| | | this.msgId = msgId; |
| | | return this; |
| | | } |
| | | public String getErrorInfo() { |
| | | return errorInfo; |
| | | } |
| | | |
| | | public SysDispenseLogs setErrorInfo(String errorInfo) { |
| | | this.errorInfo = errorInfo; |
| | | return this; |
| | | } |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public SysDispenseLogs setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SysDispenseLogs{" + |
| | | "id=" + id + |
| | | ", dataType=" + dataType + |
| | | ", touchType=" + touchType + |
| | | ", topicId=" + topicId + |
| | | ", tagId=" + tagId + |
| | | ", keyId=" + keyId + |
| | | ", total=" + total + |
| | | ", pages=" + pages + |
| | | ", pageNo=" + pageNo + |
| | | ", status=" + status + |
| | | ", msgCode=" + msgCode + |
| | | ", msgId=" + msgId + |
| | | ", errorInfo=" + errorInfo + |
| | | ", createTime=" + createTime + |
| | | "}"; |
| | | } |
| | | } |
| | |
| | | |
| | | private Boolean editble; |
| | | private transient Boolean refused; |
| | | private transient String menuName; |
| | | private transient String menuId; |
| | | |
| | | public String getMenuName() { |
| | | return menuName; |
| | | } |
| | | |
| | | public SysField setMenuName(String menuName) { |
| | | this.menuName = menuName; |
| | | return this; |
| | | } |
| | | |
| | | public String getMenuId() { |
| | | return menuId; |
| | | } |
| | | |
| | | public SysField setMenuId(String menuId) { |
| | | this.menuId = menuId; |
| | | return this; |
| | | } |
| | | |
| | | @TableField(strategy = FieldStrategy.IGNORED) |
| | | private Operate operate; |
| | |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @TableField("menu_type") |
| | | private String menuType; |
| | | |
| | | @TableField(exist = false) |
| | | private List<SysMenu> parentMenuList; |
| | | @TableField(exist = false) |
| | | private boolean subscribe; |
| | | @TableField(exist = false) |
| | | private boolean show; |
| | | @TableField(exist = false) |
| | | private String tableName; |
| | | |
| | | |
| | | public String getMenuType() { |
| | |
| | | ", updateTime=" + updateTime + |
| | | "}"; |
| | | } |
| | | |
| | | public List<SysMenu> getParentMenuList() { |
| | | return parentMenuList; |
| | | } |
| | | |
| | | public void setParentMenuList(List<SysMenu> parentMenuList) { |
| | | this.parentMenuList = parentMenuList; |
| | | } |
| | | |
| | | public boolean isSubscribe() { |
| | | return subscribe; |
| | | } |
| | | |
| | | public void setSubscribe(boolean subscribe) { |
| | | this.subscribe = subscribe; |
| | | } |
| | | |
| | | public boolean isShow() { |
| | | return show; |
| | | } |
| | | |
| | | public void setShow(boolean show) { |
| | | this.show = show; |
| | | } |
| | | |
| | | public String getTableName() { |
| | | return tableName; |
| | | } |
| | | |
| | | public void setTableName(String tableName) { |
| | | this.tableName = tableName; |
| | | } |
| | | } |
| | |
| | | package com.highdatas.mdm.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.highdatas.mdm.pojo.SysAssembleCheckType; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private String baseMaintain; |
| | | |
| | | private String fields; |
| | | private ViewStatus status; |
| | | |
| | | @TableField("mapping_table") |
| | | private String mappingTable; |
| | | @TableField("mapping_field") |
| | | private String mappingField; |
| | | |
| | | @TableField("empty_data") |
| | | private Boolean emptyData; |
| | | |
| | | private Boolean increment; |
| | | |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | | @TableField("update_time") |
| | | private Date updateTime; |
| | | |
| | | @TableField("user_id") |
| | | private String userId; |
| | | @TableField("menu_id") |
| | | private String menuId; |
| | | |
| | | @TableField("view_table_name") |
| | | private String viewTableName; |
| | | |
| | | @TableField("check_type") |
| | | private SysAssembleCheckType checkType; |
| | | @TableField("check_field") |
| | | private String checkField; |
| | | |
| | | |
| | | private Boolean subscribe; |
| | | private Boolean active; |
| | | @TableField("need_update") |
| | | private Boolean needUpdate; |
| | | |
| | | private transient String userName; |
| | | private transient String baseTableName; |
| | | private transient String baseVersion; |
| | | private transient List<SysViewJoin> viewJoinList; |
| | | private transient String subMenuName; |
| | | private transient String menuName; |
| | | |
| | | public String getCheckField() { |
| | | return checkField; |
| | | } |
| | | |
| | | public SysView setCheckField(String checkField) { |
| | | this.checkField = checkField; |
| | | return this; |
| | | } |
| | | |
| | | public String getMenuId() { |
| | | return menuId; |
| | | } |
| | | |
| | | public SysView setMenuId(String menuId) { |
| | | this.menuId = menuId; |
| | | return this; |
| | | } |
| | | |
| | | public String getMenuName() { |
| | | return menuName; |
| | | } |
| | | |
| | | public void setMenuName(String menuName) { |
| | | this.menuName = menuName; |
| | | } |
| | | |
| | | public ViewStatus getStatus() { |
| | | return status; |
| | | } |
| | | |
| | | public SysView setStatus(ViewStatus status) { |
| | | this.status = status; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getIncrement() { |
| | | return increment; |
| | | } |
| | | |
| | | public SysView setIncrement(Boolean increment) { |
| | | this.increment = increment; |
| | | return this; |
| | | } |
| | | |
| | | public String getViewTableName() { |
| | | return viewTableName; |
| | | } |
| | | |
| | | public SysView setViewTableName(String viewTableName) { |
| | | this.viewTableName = viewTableName; |
| | | return this; |
| | | } |
| | | |
| | | public SysAssembleCheckType getCheckType() { |
| | | return checkType; |
| | | } |
| | | |
| | | public SysView setCheckType(SysAssembleCheckType checkType) { |
| | | this.checkType = checkType; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getNeedUpdate() { |
| | | return needUpdate; |
| | | } |
| | | |
| | | public SysView setNeedUpdate(Boolean needUpdate) { |
| | | this.needUpdate = needUpdate; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getEmptyData() { |
| | | return emptyData; |
| | | } |
| | | |
| | | public SysView setEmptyData(Boolean emptyData) { |
| | | this.emptyData = emptyData; |
| | | return this; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public SysView setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | return this; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public SysView setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getSubscribe() { |
| | | return subscribe; |
| | | } |
| | | |
| | | public SysView setSubscribe(Boolean subscribe) { |
| | | this.subscribe = subscribe; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getActive() { |
| | | return active; |
| | | } |
| | | |
| | | public SysView setActive(Boolean active) { |
| | | this.active = active; |
| | | return this; |
| | | } |
| | | |
| | | public String getMappingField() { |
| | | return mappingField; |
| | | } |
| | | |
| | | public SysView setMappingField(String mappingField) { |
| | | this.mappingField = mappingField; |
| | | return this; |
| | | } |
| | | |
| | | public String getUserName() { |
| | | return userName; |
| | | } |
| | | |
| | | public void setUserName(String userName) { |
| | | this.userName = userName; |
| | | } |
| | | |
| | | public String getBaseTableName() { |
| | | return baseTableName; |
| | | } |
| | | |
| | | public void setBaseTableName(String baseTableName) { |
| | | this.baseTableName = baseTableName; |
| | | } |
| | | |
| | | public String getBaseVersion() { |
| | | return baseVersion; |
| | | } |
| | | |
| | | public void setBaseVersion(String baseVersion) { |
| | | this.baseVersion = baseVersion; |
| | | } |
| | | |
| | | public List<SysViewJoin> getViewJoinList() { |
| | | return viewJoinList; |
| | | } |
| | | |
| | | public void setViewJoinList(List<SysViewJoin> viewJoinList) { |
| | | this.viewJoinList = viewJoinList; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | |
| | | ", userId=" + userId + |
| | | "}"; |
| | | } |
| | | |
| | | public void setSubMenuName(String subMenuName) { |
| | | this.subMenuName = subMenuName; |
| | | } |
| | | |
| | | public String getSubMenuName() { |
| | | return subMenuName; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.highdatas.mdm.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.highdatas.mdm.pojo.Segment; |
| | | import com.highdatas.mdm.pojo.ViewJoinType; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.ContentBuilder; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import java.io.Serializable; |
| | | import java.text.MessageFormat; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | private String id; |
| | | |
| | | @TableField("view_id") |
| | | private String viewId; |
| | | @TableField("parent_id") |
| | | private String parentId; |
| | | |
| | | @TableField("menu_id") |
| | | private String menuId; |
| | | |
| | | private String fields; |
| | | |
| | | @TableField("join_maintain") |
| | | private String joinMaintain; |
| | | |
| | | @TableField("join_field") |
| | | private String joinField; |
| | | |
| | | @TableField("base_field") |
| | | private String baseField; |
| | | |
| | | @TableField("join_segment") |
| | | private String joinSegment; |
| | | |
| | | @TableField("join_type") |
| | | private ViewJoinType joinType; |
| | | |
| | | @TableField("need_update") |
| | | private Boolean needUpdate; |
| | | |
| | | private transient String joinTableName; |
| | | private transient String baseTableName; |
| | | private transient String joinVersion; |
| | | private transient String menuName; |
| | | |
| | | public String getMenuName() { |
| | | return menuName; |
| | | } |
| | | |
| | | public SysViewJoin setMenuName(String menuName) { |
| | | this.menuName = menuName; |
| | | return this; |
| | | } |
| | | |
| | | public ViewJoinType getJoinType() { |
| | | return joinType; |
| | | } |
| | | |
| | | public SysViewJoin setJoinType(ViewJoinType joinType) { |
| | | this.joinType = joinType; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getNeedUpdate() { |
| | | return needUpdate; |
| | | } |
| | | |
| | | public SysViewJoin setNeedUpdate(Boolean needUpdate) { |
| | | this.needUpdate = needUpdate; |
| | | return this; |
| | | } |
| | | |
| | | public String getMenuId() { |
| | | return menuId; |
| | | } |
| | | |
| | | public SysViewJoin setMenuId(String menuId) { |
| | | this.menuId = menuId; |
| | | return this; |
| | | } |
| | | |
| | | public String getJoinTableName() { |
| | | return joinTableName; |
| | | } |
| | | |
| | | public void setJoinTableName(String joinTableName) { |
| | | this.joinTableName = joinTableName; |
| | | } |
| | | |
| | | public String getJoinVersion() { |
| | | return joinVersion; |
| | | } |
| | | |
| | | public void setJoinVersion(String joinVersion) { |
| | | this.joinVersion = joinVersion; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | public String getViewId() { |
| | | return viewId; |
| | | |
| | | public String getParentId() { |
| | | return parentId; |
| | | } |
| | | |
| | | public SysViewJoin setViewId(String viewId) { |
| | | this.viewId = viewId; |
| | | public SysViewJoin setParentId(String parentId) { |
| | | this.parentId = parentId; |
| | | return this; |
| | | } |
| | | |
| | | public String getFields() { |
| | | return fields; |
| | | } |
| | | |
| | | public SysViewJoin setFields(String fields) { |
| | | this.fields = fields; |
| | | return this; |
| | | } |
| | | public String getJoinMaintain() { |
| | |
| | | |
| | | public SysViewJoin setJoinMaintain(String joinMaintain) { |
| | | this.joinMaintain = joinMaintain; |
| | | return this; |
| | | } |
| | | public String getJoinField() { |
| | | return joinField; |
| | | } |
| | | |
| | | public SysViewJoin setJoinField(String joinField) { |
| | | this.joinField = joinField; |
| | | return this; |
| | | } |
| | | public String getBaseField() { |
| | | return baseField; |
| | | } |
| | | |
| | | public SysViewJoin setBaseField(String baseField) { |
| | | this.baseField = baseField; |
| | | return this; |
| | | } |
| | | public String getJoinSegment() { |
| | |
| | | public String toString() { |
| | | return "SysViewJoin{" + |
| | | "id=" + id + |
| | | ", viewId=" + viewId + |
| | | ", parentId=" + parentId + |
| | | ", fields=" + fields + |
| | | ", joinMaintain=" + joinMaintain + |
| | | ", joinField=" + joinField + |
| | | ", baseField=" + baseField + |
| | | ", joinSegment=" + joinSegment + |
| | | "}"; |
| | | } |
| | | |
| | | public String createJoinStr() { |
| | | if (StringUtils.isEmpty(joinTableName)) { |
| | | return null; |
| | | } |
| | | if (StringUtils.isEmpty(baseTableName)) { |
| | | return null; |
| | | } |
| | | List<String> baseFieldList = DbUtils.split(baseField); |
| | | List<String> joinFieldList = DbUtils.split(joinField); |
| | | ContentBuilder builder = new ContentBuilder(Constant.AND); |
| | | for (int i = 0; i < baseFieldList.size(); i++) { |
| | | String oneBase = baseFieldList.get(i); |
| | | String oneJoin = joinFieldList.get(i); |
| | | String base = MessageFormat.format(Constant.Alias, baseTableName, oneBase); |
| | | String join = MessageFormat.format(Constant.Alias, joinTableName, oneJoin); |
| | | Segment segment = new Segment(base, join); |
| | | builder.append(segment.toRawString()); |
| | | } |
| | | |
| | | return MessageFormat.format(Constant.InnerJoinTemplate, joinType.toString(), joinTableName, builder.toString()); |
| | | } |
| | | |
| | | public String getBaseTableName() { |
| | | return baseTableName; |
| | | } |
| | | |
| | | public SysViewJoin setBaseTableName(String baseTableName) { |
| | | this.baseTableName = baseTableName; |
| | | return this; |
| | | } |
| | | } |
| | |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @TableField("update_time") |
| | | private Date updateTime; |
| | | |
| | | private List<String> roleId; |
| | | private List<String> groupId; |
| | | |
| | | public List<String> getRoleId() { |
| | | return roleId; |
| | | } |
| | | |
| | | public void setRoleId(List<String> roleId) { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | public List<String> getGroupId() { |
| | | return groupId; |
| | | } |
| | | |
| | | public void setGroupId(List<String> groupId) { |
| | | this.groupId = groupId; |
| | | } |
| | | |
| | | public String getUserId() { |
| | | return userId; |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.entity;
|
| | |
|
| | | public interface TableInfo {
|
| | | String getTable();
|
| | | }
|
| | |
| | | public class TableSchemaResult { |
| | | private String fieldName; |
| | | private String dbType; |
| | | private int length; |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.entity;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-17 12:20
|
| | | */
|
| | |
|
| | |
|
| | | public class ViewMappingItem {
|
| | | private String pre;
|
| | | private String fix;
|
| | |
|
| | | public ViewMappingItem(String pre, String fix) {
|
| | | this.pre = pre;
|
| | | this.fix = fix;
|
| | | }
|
| | |
|
| | | public ViewMappingItem() {
|
| | | }
|
| | |
|
| | | public String getPre() {
|
| | | return pre;
|
| | | }
|
| | |
|
| | | public void setPre(String pre) {
|
| | | this.pre = pre;
|
| | | }
|
| | |
|
| | | public String getFix() {
|
| | | return fix;
|
| | | }
|
| | |
|
| | | public void setFix(String fix) {
|
| | | this.fix = fix;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.entity; |
| | | |
| | | /** |
| | | * @author kimi |
| | | * @description |
| | | * @date 2020-04-18 15:47 |
| | | */ |
| | | |
| | | |
| | | public enum ViewStatus { |
| | | edit,working,dispensing,creating |
| | | } |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.MaintainDetail; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.highdatas.mdm.entity.MaintainDetail; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public interface MaintainDetailMapper extends BaseMapper<MaintainDetail> { |
| | | |
| | | void updateDeal(@Param("maintainId") String maintainId); |
| | | |
| | | List<Map<String,Object>> selectMaintainDetail(@Param("fields")String fields, @Param("tempTableName")String tempTableName, @Param("maintainId") String maintainId, @Param("where") String where, @Param("limit") String limit); |
| | | |
| | | } |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.MasterAuthor; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.highdatas.mdm.entity.MasterAuthor; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface MasterAuthorMapper extends BaseMapper<MasterAuthor> { |
| | | |
| | | List<Map<String, Object>> selectAuthorUserCnt(); |
| | | List<Map<String, Object>> selectAuthorRoleCnt(); |
| | | |
| | | List<Map<String, Object>> selectViewCnt(); |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.MasterAuthorSubscribe; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-20 |
| | | */ |
| | | public interface MasterAuthorSubscribeMapper extends BaseMapper<MasterAuthorSubscribe> { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.MasterAuthorUnactive; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-18 |
| | | */ |
| | | public interface MasterAuthorUnactiveMapper extends BaseMapper<MasterAuthorUnactive> { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.SysDispenseConfig; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-20 |
| | | */ |
| | | public interface SysDispenseConfigMapper extends BaseMapper<SysDispenseConfig> { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.SysDispenseLogs; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-21 |
| | | */ |
| | | public interface SysDispenseLogsMapper extends BaseMapper<SysDispenseLogs> { |
| | | |
| | | } |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.SysView; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.highdatas.mdm.entity.SysView; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface SysViewMapper extends BaseMapper<SysView> { |
| | | |
| | | void insertViewMapping(@Param("tableName") String tableName, @Param("values") String values); |
| | | List<Map<String,Object>> selectMapVal(@Param("tableName") String tableName, @Param("field") String field,@Param("where") String where,@Param("mapTableName") String mapTableName,@Param("changeField") String changeField); |
| | | } |
| | |
| | | |
| | | String selectTableByName(@Param("tableName")String tableName); |
| | | |
| | | void insertOneSelect(@Param("tableName")String tableName, @Param("fields")String fields, @Param("selectFields")String selectFields, @Param("selectSql")String selectSql); |
| | | |
| | | List<TableSchemaResult> getTableField(@Param("tableName")String tableName); |
| | | |
| | | List<TableSchemaResult> getTableFieldFromDb(@Param("tableName")String tableName, @Param("dbName")String dbName); |
| | | |
| | | List<Map<String,Object>> selectByPage(@Param("tableName") String tableName, @Param("fields") String fields, @Param("where") String where, @Param("limit") String limit); |
| | | |
| | | List<Map<String,Object>> selectDistinct(@Param("tableName") String tableName, @Param("fields") String fields, @Param("where") String where); |
| | | |
| | | List<Map<String,Object>> selectByPageByVersion(@Param("tableName") String tableName,@Param("tableTempName") String tableTempName, @Param("fields") String fields, @Param("tempFields") String tempFields,@Param("Hfields") String Hfields, @Param("A1fields") String A1fields, @Param("A2fields") String A2fields, @Param("tempHFields") String tempHFields, @Param("fromOrderNo") Integer fromOrderNo, @Param("toOrderNo") Integer toOrderNo, @Param("maintainId") String maintainId, @Param("where") String where, @Param("limit") String limit); |
| | | |
| | |
| | | |
| | | void update(@Param("tableName") String tableName, @Param("updateSegment") String updateSegment, @Param("where") String where); |
| | | |
| | | void updateJoin(@Param("tableName") String tableName, @Param("joinTableSegment") String joinTableSegment, @Param("updateSegment") String updateSegment, @Param("where") String where); |
| | | |
| | | void delete(@Param("tableName") String tableName, @Param("where") String where); |
| | | |
| | | void deleteTempByMaintainId(@Param("tableTempName") String tableTempName, @Param("maintainId") String maintainId); |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.User; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.highdatas.mdm.entity.User; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2019-12-16 |
| | | */ |
| | | public interface UserMapper extends BaseMapper<User> { |
| | | |
| | | List<Map<String, Object>> test(); |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.highdatas.mdm.mapper.MasterAuthorSubscribeMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.MasterAuthorSubscribe"> |
| | | <id column="id" property="id" /> |
| | | <result column="master_author_id" property="masterAuthorId" /> |
| | | <result column="user_id" property="userId" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.highdatas.mdm.mapper.MasterAuthorUnactiveMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.MasterAuthorUnactive"> |
| | | <id column="id" property="id" /> |
| | | <result column="maintain_id" property="maintainId" /> |
| | | <result column="user_id" property="userId" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.highdatas.mdm.mapper.SysDispenseConfigMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.SysDispenseConfig"> |
| | | <result column="error_continue" property="errorContinue" /> |
| | | <result column="timeout" property="timeout" /> |
| | | <result column="resend_cnt" property="resendCnt" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.highdatas.mdm.mapper.SysDispenseLogsMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.SysDispenseLogs"> |
| | | <id column="id" property="id" /> |
| | | <result column="data_type" property="dataType" /> |
| | | <result column="touch_type" property="touchType" /> |
| | | <result column="topic_id" property="topicId" /> |
| | | <result column="tag_id" property="tagId" /> |
| | | <result column="key_id" property="keyId" /> |
| | | <result column="total" property="total" /> |
| | | <result column="pages" property="pages" /> |
| | | <result column="page_no" property="pageNo" /> |
| | | <result column="status" property="status" /> |
| | | <result column="msg_code" property="msgCode" /> |
| | | <result column="msg_id" property="msgId" /> |
| | | <result column="error_info" property="errorInfo" /> |
| | | <result column="create_time" property="createTime" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | |
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.SysViewJoin"> |
| | | <id column="id" property="id" /> |
| | | <result column="view_id" property="viewId" /> |
| | | <result column="fields" property="fields" /> |
| | | <result column="join_maintain" property="joinMaintain" /> |
| | | <result column="join_field" property="joinField" /> |
| | | <result column="base_field" property="baseField" /> |
| | | <result column="join_segment" property="joinSegment" /> |
| | | </resultMap> |
| | | |
| | |
| | | public static CodeMsg SUCCESS = new CodeMsg(2000,"success", true); |
| | | public static CodeMsg Client_fail = new CodeMsg(7001,"请求外部链接失败"); |
| | | public static CodeMsg ERROR_TOKEN = new CodeMsg(1000,"找不到token"); |
| | | public static CodeMsg ERROR_SAVE_TOKEN = new CodeMsg(9002,"连接redis失败"); |
| | | public static CodeMsg ERROR_SAVE_TOKEN = new CodeMsg(4001,"连接redis失败"); |
| | | public static CodeMsg ERROR_FIND_TOKEN = new CodeMsg(4002,"校验token失败,token已失效"); |
| | | public static CodeMsg INSERT_SUCCESS = new CodeMsg(1001,"插入成功"); |
| | | public static CodeMsg INSERT_ERROR = new CodeMsg(1002,"插入失败"); |
| | | public static CodeMsg SELECT_ERROR = new CodeMsg(1003,"查询失败"); |
| | |
| | | public static CodeMsg USER_NOT_MATHED = new CodeMsg(1010,"找不到登陆用户"); |
| | | public static CodeMsg ERROR_ACTIVITI_NEXTTASK = new CodeMsg(1011,"审批流出现错误,未获取到下一节点"); |
| | | public static CodeMsg OPERATR_ERROR = new CodeMsg(2001,"操作失败"); |
| | | public static CodeMsg TIMOUT_ERROR = new CodeMsg(9001,"等待时间过长"); |
| | | public static CodeMsg REPEAT_ERROR = new CodeMsg(9001,"重复提交"); |
| | | public static CodeMsg TIMOUT_ERROR = new CodeMsg(4009,"等待时间过长"); |
| | | public static CodeMsg REPEAT_ERROR = new CodeMsg(4010,"重复提交"); |
| | | public static CodeMsg EMPTY_ERROR = new CodeMsg(10013,"未获取到数据"); |
| | | public static CodeMsg CREATE_ERROR = new CodeMsg(10014,"创建失败"); |
| | | public static CodeMsg AES_ERROR = new CodeMsg(4003,"获取AES密钥失败"); |
| | | public static CodeMsg SUBSCRIBE_SAVE_ERROR = new CodeMsg(4004,"订阅保存失败"); |
| | | public static CodeMsg SUBSCRIBE_DEL_ERROR = new CodeMsg(4006,"订阅删除失败"); |
| | | public static CodeMsg SUBSCRIBE_UPDATE_ERROR = new CodeMsg(4007,"订阅删除失败"); |
| | | public static CodeMsg SUBSCRIBE_UN_ERROR = new CodeMsg(4008,"数据未订阅"); |
| | | public static CodeMsg Active_UN_ERROR = new CodeMsg(4008,"数据未启用"); |
| | | public static CodeMsg ADDQUEUE_SUCCESS = new CodeMsg(4010,"添加到分发队列"); |
| | | public static CodeMsg ADDQUEUE_OVER = new CodeMsg(4012,"分发队列已满,暂不能添加"); |
| | | public static CodeMsg ADDQUEUE_FAIL = new CodeMsg(4011,"添加分发队列失败"); |
| | | public static CodeMsg MAINTAIN_UNFOUND_ERROR = new CodeMsg(4005,"未查到版本数据,或无权限"); |
| | | |
| | | public CodeMsg(int code, String msg) { |
| | | this.code = code; |
| | |
| | | private int pageSize; |
| | | private long recordCount; |
| | | private int pageNo; |
| | | private int pages; |
| | | |
| | | public int getPages() { |
| | | return pages; |
| | | } |
| | | |
| | | public void setPages(int pages) { |
| | | this.pages = pages; |
| | | } |
| | | |
| | | public Page(long recordCount) { |
| | | this.pageSize = 20; |
| | |
| | | this.value = value; |
| | | this.joinStr = Constant.EQUAL; |
| | | } |
| | | |
| | | public String toRawString() { |
| | | return DbUtils.StrJoin(name,joinStr,String.valueOf(value)); |
| | | } |
| | | @Override |
| | | public String toString() { |
| | | if (name == null) { |
New file |
| | |
| | | package com.highdatas.mdm.pojo;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-20 10:26
|
| | | */
|
| | |
|
| | |
|
| | | public class SubscribeEntity {
|
| | | private String id;
|
| | | private String type;
|
| | | private String name;
|
| | |
|
| | | public String getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public SubscribeEntity setId(String id) {
|
| | | this.id = id;
|
| | | return this;
|
| | | }
|
| | |
|
| | | public String getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public SubscribeEntity setType(String type) {
|
| | | this.type = type;
|
| | | return this;
|
| | | }
|
| | |
|
| | | public String getName() {
|
| | | return name;
|
| | | }
|
| | |
|
| | | public SubscribeEntity setName(String name) {
|
| | | this.name = name;
|
| | | return this;
|
| | | }
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.pojo;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-16 13:17
|
| | | */
|
| | |
|
| | |
|
| | | public class SysViewLogicBase {
|
| | | private Map<String, List<String>> tableFieldListMap;
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.pojo;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-18 16:30
|
| | | */
|
| | |
|
| | | @Data
|
| | | public class ViewDictItem {
|
| | | private String menuId;
|
| | | private String rawField;
|
| | | private String viewField;
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.pojo;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-21 15:45
|
| | | */
|
| | |
|
| | | @Data
|
| | | public class ViewField {
|
| | | private String menuId;
|
| | | private String menuName;
|
| | | private String field;
|
| | | private String changedField;
|
| | | private String fieldName;
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.pojo;
|
| | |
|
| | | import com.highdatas.mdm.util.Constant;
|
| | |
|
| | | public enum ViewJoinType {
|
| | | left, inner;
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | if (left.equals(this)) {
|
| | | return Constant.LeftJoin;
|
| | | } else if (inner.equals(this)) {
|
| | | return Constant.InnerJoin;
|
| | | }
|
| | |
|
| | | return super.toString();
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.pojo;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-19 14:02
|
| | | */
|
| | |
|
| | | @Data
|
| | | public class ViewMapFieldItem {
|
| | | private String menuId;
|
| | | private String menuName;
|
| | | private String field;
|
| | | private String fieldName;
|
| | | private String changedField;
|
| | | }
|
| | |
| | | package com.highdatas.mdm.service;
|
| | |
|
| | | import com.highdatas.mdm.pojo.Result;
|
| | | import com.highdatas.mdm.util.pool.MqMessage;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import java.util.concurrent.PriorityBlockingQueue;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | |
| | |
|
| | | boolean pushActiveMq(MqMessage message);
|
| | |
|
| | | boolean pushPassiveMq(MqMessage message);
|
| | | Result pushPassiveMq(MqMessage message, String touchType);
|
| | |
|
| | | PriorityBlockingQueue<Runnable> getQueue();
|
| | |
|
| | | Integer passiveQueueSize();
|
| | |
|
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.pojo.Page; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | |
| | | */ |
| | | public interface IMasterAuthorService extends IService<MasterAuthor> { |
| | | |
| | | Page getInitPageInfo(MasterAuthor masterAuthor, Maintain maintain, TUser user, boolean getIncrement); |
| | | |
| | | HashMap<String, MasterAuthor> merageRoleAuthor(Set<String> roleIds); |
| | | |
| | | List<SysMenu> getMenu(Character character); |
| | | |
| | | List<SysMenu> getMenu(Character character, boolean isTableMenu); |
| | | |
| | | List<SysMenu> getMenuUnParent(Character character); |
| | | |
| | | List<SysMenu> getMenuUnParent(Character character, boolean isTableMenu); |
| | | |
| | | List<MasterAuthor> getUserAuthor(String characterId, MaintainField maintainField); |
| | | |
| | | List<MasterAuthor> getOneGroupAuthors(String groupId, MaintainField maintainField); |
| | | |
| | |
| | | String getFilter(Character character, String maintainId); |
| | | |
| | | Maintain getMaxVersionMaintain(Character character, String tableName); |
| | | |
| | | LinkedHashSet<Maintain> getMaintainSet(String tableName, TUser user); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.MasterAuthorSubscribe; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-20 |
| | | */ |
| | | public interface IMasterAuthorSubscribeService extends IService<MasterAuthorSubscribe> { |
| | | void dealFlow(String maintainId, ActivitiStatus status); |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.MasterAuthorUnactive; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-18 |
| | | */ |
| | | public interface IMasterAuthorUnactiveService extends IService<MasterAuthorUnactive> { |
| | | |
| | | } |
| | |
| | | Result getMapping(HttpSession session, String id); |
| | | |
| | | SysMenu getMenuByTableName(String tableName); |
| | | MenuMapping getMenuMappingByTableName(String tableName); |
| | | |
| | | String getTableNameByMenu(String menuId); |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.SysDispenseConfig; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-20 |
| | | */ |
| | | public interface ISysDispenseConfigService extends IService<SysDispenseConfig> { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.SysDispenseLogs; |
| | | import com.highdatas.mdm.util.pool.MqEntity; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-21 |
| | | */ |
| | | public interface ISysDispenseLogsService extends IService<SysDispenseLogs> { |
| | | SysDispenseLogs getLogByMqEntity(MqEntity mqEntity); |
| | | |
| | | SysDispenseLogs getPreUnSuccessByMqEntity(MqEntity mqEntity); |
| | | |
| | | SysDispenseLogs createLogByMqEntity(MqEntity mqEntity); |
| | | } |
| | |
| | | |
| | | SysField getOneFieldByMaintainField(String maintainFieldId, String field); |
| | | |
| | | SysField getOneFieldByMaintain(String maintainId, String field); |
| | | |
| | | List<SysField> getFieldByMaintainField(String maintainId); |
| | | |
| | | List<SysField> getDefaultTableField(String tableName); |
| | |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | LinkedHashSet<String> getByParentId(LinkedHashSet<String> parentIdSet); |
| | | |
| | | List<SysMenu> getMenuByParentId(LinkedHashSet<String> parentIdSet); |
| | | |
| | | } |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.SysViewJoin; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.SysViewJoin; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.SysView; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.SysView; |
| | | import com.highdatas.mdm.entity.SysViewJoin; |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.pojo.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | public interface ISysViewService extends IService<SysView> { |
| | | |
| | | public interface ISysViewService extends IService<SysView> { |
| | | Page getInitPageInfo(String viewId); |
| | | |
| | | boolean createView(String viewId); |
| | | |
| | | String getViewTableName(SysView view); |
| | | |
| | | String getMappingTableName(SysView view); |
| | | |
| | | List<String> getSubFieldList(SysViewJoin join, TUser user); |
| | | |
| | | List<ViewMapFieldItem> getMapField(SysView sysView); |
| | | |
| | | Maintain getBaseMaintain(SysView view); |
| | | |
| | | Maintain getJoinMaintain(SysViewJoin viewJoin); |
| | | |
| | | String changeFieldName(String baseTableName, String field); |
| | | |
| | | void dealFlow(String maintainId, ActivitiStatus status); |
| | | |
| | | Result deleteView(String id) throws Exception; |
| | | |
| | | List<ViewDictItem> getViewFieldMap(String viewId); |
| | | |
| | | Result getMapData(SysView sysView, String changedField, Integer pageNo, int pageSize); |
| | | |
| | | long getViewCount(SysView sysView); |
| | | |
| | | Result getViewData(SysView sysView, Integer pageNo, int pageSize); |
| | | |
| | | void downlodMap(SysView sysView, TUser user, HttpServletResponse response, String field, String menuId); |
| | | |
| | | Maintain getMaintainByMenu(SysView sysView, String menuId); |
| | | |
| | | boolean deleteMapField(SysView sysView, String changedField); |
| | | } |
| | |
| | | |
| | | String selectByVersionSql(Character character, String tableName, List<String> fieldList, String whereSegment, String version, boolean findMax); |
| | | |
| | | Long getCountByVersion(Character character, String tableName, String whereSegment, String version, boolean findMax); |
| | | |
| | | Result selectListByPageByVersion(Character character, String tableName, List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, String version, boolean findMax); |
| | | |
| | | Maintain uploadedData(String tableName, SysAssembleUpdateType uploadType, String userId); |
| | |
| | | |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.pojo.NextTaskUserInfo; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.activiti.engine.*; |
| | | import org.activiti.engine.delegate.Expression; |
| | |
| | | TaskDefinition taskDef = (TaskDefinition)activityImpl.getProperties().get("taskDefinition"); |
| | | Set<Expression> userCodes = taskDef.getCandidateUserIdExpressions();//候选人 |
| | | Set<Expression> roleCodes = taskDef.getCandidateGroupIdExpressions();//候选组 |
| | | if (userCodes != null) { |
| | | Set<String> userList = userCodes.stream().map(expression -> expression.getExpressionText()).collect(Collectors.toSet()); |
| | | nextTaskUserInfo.addUserList(userList); |
| | | } |
| | | |
| | | if (roleCodes != null) { |
| | | Set<String> roleList = roleCodes.stream().map(expression -> expression.getExpressionText()).collect(Collectors.toSet()); |
| | | nextTaskUserInfo.addRoleList(roleList); |
| | | } |
| | | Set<String> userList = new HashSet<>(); |
| | | if (userCodes != null) { |
| | | Set userSet = userCodes.stream().map(expression -> expression.getExpressionText()).collect(Collectors.toSet()); |
| | | userList.addAll(userSet); |
| | | } |
| | | List<String> roleIdList = nextTaskUserInfo.getRoleIdList(); |
| | | if (roleIdList == null || roleIdList.isEmpty()) { |
| | | nextTaskUserInfo.addUserList(userList); |
| | | return nextTaskUserInfo; |
| | | } |
| | | for (String roleId : roleIdList) { |
| | | Set<String> userByRole = DbUtils.getUserByRole(roleId); |
| | | userList.addAll(userByRole); |
| | | } |
| | | nextTaskUserInfo.addUserList(userList); |
| | | return nextTaskUserInfo; |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", maps); |
| | |
| | | package com.highdatas.mdm.service.impl;
|
| | |
|
| | | import com.highdatas.mdm.entity.Maintain;
|
| | | import com.highdatas.mdm.service.DispenseService;
|
| | | import com.highdatas.mdm.service.MasterDataService;
|
| | | import com.highdatas.mdm.entity.MasterAuthor;
|
| | | import com.highdatas.mdm.entity.SysDispenseLogs;
|
| | | import com.highdatas.mdm.entity.TUser;
|
| | | import com.highdatas.mdm.pojo.CodeMsg;
|
| | | import com.highdatas.mdm.pojo.Page;
|
| | | import com.highdatas.mdm.pojo.Result;
|
| | | import com.highdatas.mdm.service.*;
|
| | | import com.highdatas.mdm.util.Constant;
|
| | | import com.highdatas.mdm.util.pool.MqEntity;
|
| | | import com.highdatas.mdm.util.pool.MqMessage;
|
| | | import com.highdatas.mdm.util.pool.PassiveMqThreadPoolExecutor;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.apache.commons.lang3.StringUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import javax.annotation.PostConstruct;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.concurrent.*;
|
| | | import java.util.concurrent.atomic.AtomicInteger;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | |
| | |
|
| | | @Service
|
| | | @Slf4j
|
| | | @ConfigurationProperties(prefix = "pool")
|
| | | public class DispenseServiceImpl implements DispenseService {
|
| | | @Autowired
|
| | | MasterDataService masterDataService;
|
| | | @Autowired
|
| | | IMasterAuthorService masterAuthorService;
|
| | | @Autowired
|
| | | ISysViewService viewService;
|
| | | @Autowired
|
| | | IMaintainService maintainService;
|
| | | @Autowired
|
| | | IMenuMappingService menuMappingService;
|
| | | @Autowired
|
| | | ISysDispenseLogsService dispenseLogsService;
|
| | |
|
| | | @Value("${pool.coresize}")
|
| | | private Integer coreSize;
|
| | | private ExecutorService executorService;
|
| | | private PriorityBlockingQueue<Runnable> queue;
|
| | | private LinkedBlockingQueue activeQueue;
|
| | | private ThreadPoolExecutor activeExecutorService;
|
| | | private String coreSizeStr;
|
| | | private int coreSize;
|
| | | private Integer queueSize = 5;
|
| | | private ExecutorService priorityExecutorService;
|
| | | private volatile PriorityBlockingQueue<Runnable> priorityQueue;
|
| | | private volatile LinkedBlockingQueue infiniteQueue;
|
| | | private volatile CopyOnWriteArrayList<MqMessage> passiveRequestList;
|
| | | private ThreadPoolExecutor infiniteExecutorService;
|
| | |
|
| | | @PostConstruct
|
| | | public void init() {
|
| | | if (coreSize == null && coreSize == 0) {
|
| | |
|
| | | if (StringUtils.isEmpty(coreSizeStr)) {
|
| | | //IO密集型 设置默认 cpu数量 预留 主动和被动两组线程池
|
| | | coreSize = Double.valueOf(Runtime.getRuntime().availableProcessors()).intValue();
|
| | | } else {
|
| | | coreSize = Integer.valueOf(coreSizeStr);
|
| | | }
|
| | | log.info("Queue_Consume_thread_size:{}",coreSize);
|
| | | this.queue = new PriorityBlockingQueue<>();
|
| | | this.executorService = new PassiveMqThreadPoolExecutor(coreSize, coreSize, 0L, TimeUnit.MILLISECONDS, queue);
|
| | | this.activeQueue = new LinkedBlockingQueue();
|
| | | this.activeExecutorService = new ThreadPoolExecutor(coreSize, coreSize, 0L, TimeUnit.MILLISECONDS, activeQueue,new ThreadPoolExecutor.AbortPolicy());
|
| | | this.priorityQueue = new PriorityBlockingQueue<>(queueSize);
|
| | | this.priorityExecutorService = new PassiveMqThreadPoolExecutor(coreSize, coreSize, 0L, TimeUnit.MILLISECONDS, priorityQueue);
|
| | | this.infiniteQueue = new LinkedBlockingQueue();
|
| | | this.infiniteExecutorService = new ThreadPoolExecutor(coreSize, coreSize, 0L, TimeUnit.MILLISECONDS, infiniteQueue,new ThreadPoolExecutor.AbortPolicy());
|
| | | this.passiveRequestList = new CopyOnWriteArrayList<>();
|
| | | createPassiveListenerThread();
|
| | | }
|
| | |
|
| | |
|
| | | private void createPassiveListenerThread() {
|
| | | new Thread(() -> {
|
| | | log.info("被动接口准备待命。");
|
| | | while (true) {
|
| | | try{
|
| | | if (passiveRequestList.size() == 0) {
|
| | | Thread.sleep(5 * 1000);
|
| | | }
|
| | | List<MqMessage> removedList = new ArrayList<>();
|
| | | for (MqMessage mqMessage : passiveRequestList) {
|
| | | MqEntity mqEntity = mqMessage.getMqEntity();
|
| | | AtomicInteger pageNo = mqEntity.getPageNo();
|
| | | if (pageNo != null && pageNo.get() == mqEntity.getPages().get()) {
|
| | | removedList.add(mqMessage);
|
| | | } else {
|
| | | MqMessage nextSubMq = createNextSubMq(mqEntity);
|
| | | infiniteExecutorService.execute(nextSubMq);
|
| | | }
|
| | |
|
| | | }
|
| | | for (MqMessage mqMessage : removedList) {
|
| | | passiveRequestList.remove(mqMessage);
|
| | | }
|
| | |
|
| | | }
|
| | | catch (Exception e){
|
| | | e.printStackTrace();
|
| | | //log
|
| | | }
|
| | | }
|
| | | }).start();
|
| | | }
|
| | |
|
| | | private MqMessage createNextSubMq(MqEntity mqEntity) {
|
| | | String type = mqEntity.getType();
|
| | | AtomicInteger pageNoAI = mqEntity.getPageNo();
|
| | | if(pageNoAI == null) {
|
| | | if (type.equalsIgnoreCase(Constant.Master)) {
|
| | | String dataId = mqEntity.getDataId();
|
| | | String tableNameByMenu = menuMappingService.getTableNameByMenu(dataId);
|
| | | String userId = mqEntity.getUserId();
|
| | | TUser user = new TUser().setUserId(userId);
|
| | | Maintain maintain = maintainService.selectById(mqEntity.getMaintainId());
|
| | | MasterAuthor masterAuthor = new MasterAuthor().setTableName(tableNameByMenu);
|
| | | masterAuthor.setIncrement(mqEntity.getIncrement());
|
| | | Page initPageInfo = masterAuthorService.getInitPageInfo(masterAuthor, maintain, user, mqEntity.getIncrement());
|
| | | AtomicInteger pagesAI = new AtomicInteger(initPageInfo.getPages());
|
| | | mqEntity.setPages(pagesAI);
|
| | | AtomicInteger pageSizeAI = new AtomicInteger(initPageInfo.getPageSize());
|
| | | mqEntity.setPageSize(pageSizeAI);
|
| | | } else {
|
| | | Page initPageInfo = viewService.getInitPageInfo(mqEntity.getDataId());
|
| | | AtomicInteger pagesAI = new AtomicInteger(initPageInfo.getPages());
|
| | | mqEntity.setPages(pagesAI);
|
| | | AtomicInteger pageSizeAI = new AtomicInteger(initPageInfo.getPageSize());
|
| | | mqEntity.setPageSize(pageSizeAI);
|
| | | }
|
| | | pageNoAI = new AtomicInteger();
|
| | | mqEntity.setPageNo(pageNoAI);
|
| | | }
|
| | | int i = pageNoAI.addAndGet(1);
|
| | | MqMessage mqMessage = new MqMessage(mqEntity);
|
| | | return mqMessage;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean pushActiveMq(MqMessage message) {
|
| | | try{
|
| | | activeExecutorService.execute(message);
|
| | | return true;
|
| | | }catch (Exception e) {
|
| | | log.error(e.getMessage());
|
| | | return false;
|
| | | MqEntity mqEntity = message.getMqEntity();
|
| | | SysDispenseLogs preUnSuccessByMqEntity = dispenseLogsService.getPreUnSuccessByMqEntity(mqEntity);
|
| | | if (preUnSuccessByMqEntity == null) {
|
| | | SysDispenseLogs logByMqEntity = dispenseLogsService.createLogByMqEntity(mqEntity);
|
| | | logByMqEntity.setTouchType("sys").updateById();
|
| | | } else {
|
| | | mqEntity.setMsgKey(preUnSuccessByMqEntity.getKeyId());
|
| | | mqEntity.setPageNo(new AtomicInteger(preUnSuccessByMqEntity.getPageNo()));
|
| | | mqEntity.setPageSize(new AtomicInteger(preUnSuccessByMqEntity.getPageSize()));
|
| | | mqEntity.setPages(new AtomicInteger(preUnSuccessByMqEntity.getPages()));
|
| | | }
|
| | |
|
| | | this.passiveRequestList.add(message);
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean pushPassiveMq(MqMessage message) {
|
| | | public Result pushPassiveMq(MqMessage message, String touchType) {
|
| | | try{
|
| | | MqMessage preMsg = null;
|
| | | for (Runnable runnable : queue) {
|
| | | if (queueSize.equals(priorityQueue.size())) {
|
| | | return Result.error(CodeMsg.ADDQUEUE_OVER);
|
| | | }
|
| | | MqEntity mqEntity = message.getMqEntity();
|
| | | for (Runnable runnable : priorityQueue) {
|
| | | if (!(runnable instanceof MqMessage)) {
|
| | | continue;
|
| | | }
|
| | | MqMessage mqMessage = (MqMessage) runnable;
|
| | | String code = mqMessage.getCode();
|
| | | String code = mqMessage.getMqEntity().getMsgCode();
|
| | | if (StringUtils.isEmpty(code)){
|
| | | continue;
|
| | | }
|
| | | if (code.equalsIgnoreCase(message.getCode())) {
|
| | | if (code.equalsIgnoreCase(mqEntity.getMsgCode())) {
|
| | | preMsg = (MqMessage) runnable;
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (preMsg != null) {
|
| | | int cnt = preMsg.getCnt();
|
| | | preMsg.setCnt(cnt + 1);
|
| | | message.printRepeat();
|
| | | return Result.error(CodeMsg.REPEAT_ERROR);
|
| | |
|
| | | }else {
|
| | | message.setTime(new Date());
|
| | | message.setCnt(0);
|
| | | }
|
| | | executorService.execute(message);
|
| | | return true;
|
| | | priorityExecutorService.execute(message);
|
| | | SysDispenseLogs preUnSuccessByMqEntity = dispenseLogsService.getPreUnSuccessByMqEntity(mqEntity);
|
| | | if (preUnSuccessByMqEntity == null) {
|
| | | SysDispenseLogs logByMqEntity = dispenseLogsService.createLogByMqEntity(mqEntity);
|
| | | logByMqEntity.setTouchType(touchType).updateById();
|
| | | } else {
|
| | | mqEntity.setMsgKey(preUnSuccessByMqEntity.getKeyId());
|
| | | mqEntity.setPageNo(new AtomicInteger(preUnSuccessByMqEntity.getPageNo()));
|
| | | mqEntity.setPageSize(new AtomicInteger(preUnSuccessByMqEntity.getPageSize()));
|
| | | mqEntity.setPages(new AtomicInteger(preUnSuccessByMqEntity.getPages()));
|
| | | }
|
| | |
|
| | | return Result.success(CodeMsg.ADDQUEUE_SUCCESS);
|
| | | }catch (Exception e) {
|
| | | log.error(e.getMessage());
|
| | | return false;
|
| | | return Result.success(CodeMsg.ADDQUEUE_FAIL);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public PriorityBlockingQueue<Runnable> getQueue() {
|
| | | return queue;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Integer passiveQueueSize() {
|
| | | return queue.size();
|
| | | return priorityQueue.size();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Integer avtiveQueueSize() {
|
| | | return activeQueue.size();
|
| | | return infiniteQueue.size();
|
| | | }
|
| | |
|
| | | private void createView(Maintain baseMaintain) {
|
| | | String maintainTableName = baseMaintain.getTableName();
|
| | | String version = baseMaintain.getVersion();
|
| | |
|
| | | }
|
| | | }
|
| | |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | IdentityService identityService; |
| | | @Autowired |
| | | ISysViewService viewService; |
| | | @Autowired |
| | | IMasterAuthorSubscribeService subscribeService; |
| | | |
| | | @Override |
| | | public MaintainField createNowVerion(String tableName, String maintainId, String userId) { |
| | |
| | | |
| | | @Override |
| | | public ActivitiStatus getStatusByBusinessId(String businessId) { |
| | | Flows flows = selectOne(new EntityWrapper<Flows>().eq("business_id", businessId)); |
| | | Flows flows = selectOne(new EntityWrapper<Flows>().eq("business_id", businessId).orderBy("create_time desc")); |
| | | if (flows == null){ |
| | | return null; |
| | | } |
| | |
| | | String maintainId = flows.getBusinessId(); |
| | | masterModifiedService.dealFlow(maintainId, flows.getStatus()); |
| | | maintainService.dealFlow(maintainId, flows.getStatus()); |
| | | viewService.dealFlow(maintainId, flows.getStatus()); |
| | | subscribeService.dealFlow(maintainId, flows.getStatus()); |
| | | } |
| | | if (flows.getBusinessType().equals(ActivitiBusinessType.field)){ |
| | | String maintainId = flows.getBusinessId(); |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.generator.config.querys.AbstractDbQuery; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | |
| | | object.fluentPut("records", maps); |
| | | object.fluentPut("maintainId", maintainId); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | return Result.success(object); |
| | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("record", maps); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | resultObj.fluentPut("grid", object); |
| | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", maps); |
| | |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.MasterAuthorMapper; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | import com.highdatas.mdm.pojo.Page; |
| | | import com.highdatas.mdm.pojo.kettle.UnBigDataDataSourceInfo; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.ContentBuilder; |
| | |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | IFlowsService flowsService; |
| | | @Autowired |
| | | UnBigDataDataSourceInfo unBigDataDataSourceInfo; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | @Autowired |
| | | IMaintainDetailService maintainDetailService; |
| | | @Autowired |
| | | MasterDataService masterDataService; |
| | | @Autowired |
| | | TableInfoMapper tableInfoMapper; |
| | | |
| | | @Override |
| | | public Page getInitPageInfo(MasterAuthor masterAuthor, Maintain maintain, TUser user, boolean getIncrement) { |
| | | Page page = new Page(0); |
| | | List<TableSchemaResult> tableField = tableInfoMapper.getTableField(masterAuthor.getTableName()); |
| | | |
| | | List<SysField> fieldByMaintain = fieldService.getFieldByMaintain(maintain.getId()); |
| | | List<String> authorFieldList = fieldByMaintain.stream().map(sysField -> sysField.getField()).collect(Collectors.toList()); |
| | | int totalLength = 0; |
| | | for (TableSchemaResult tableSchemaResult : tableField) { |
| | | String fieldName = tableSchemaResult.getFieldName(); |
| | | if (!authorFieldList.contains(fieldName)) { |
| | | continue; |
| | | } |
| | | int length = tableSchemaResult.getLength(); |
| | | totalLength += length; |
| | | } |
| | | |
| | | int pageSize = Constant.MaxDispenseSize / totalLength; |
| | | page.setPageSize(pageSize); |
| | | long totalCnt; |
| | | if (getIncrement) { |
| | | totalCnt = maintainDetailService.selectCount(new EntityWrapper<MaintainDetail>().eq(Constant.PARENT_ID, maintain.getId())); |
| | | }else { |
| | | String filter = getFilter(user, maintain.getId()); |
| | | totalCnt = masterDataService.getCountByVersion(user, maintain.getTableName(), filter, maintain.getVersion(), false); |
| | | } |
| | | page.setRecordCount(Long.valueOf(totalCnt).intValue()); |
| | | if (totalCnt == 0) { |
| | | return null; |
| | | } |
| | | int pages; |
| | | if (totalCnt % pageSize == 0) { |
| | | pages = Long.valueOf(totalCnt/pageSize).intValue(); |
| | | }else { |
| | | pages = (Long.valueOf(totalCnt/pageSize).intValue()) + 1; |
| | | } |
| | | page.setPages(pages); |
| | | return page; |
| | | } |
| | | |
| | | @Override |
| | | public HashMap<String, MasterAuthor> merageRoleAuthor(Set<String> roleIds) { |
| | |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenu(Character character) { |
| | | return getMenu(character, false); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenuUnParent(Character character) { |
| | | return getMenuUnParent(character, false); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenuUnParent(Character character, boolean isTableMenu) { |
| | | MasterAuthorType type = character.getType(); |
| | | List<MasterAuthor> masterAuthors = null; |
| | | switch (type){ |
| | |
| | | return null; |
| | | } |
| | | List<String> menuIds = masterAuthors.stream().map(masterAuthor -> masterAuthor.getMenuId()).collect(Collectors.toList()); |
| | | LinkedHashSet<String> strings = new LinkedHashSet<>(menuIds); |
| | | LinkedHashSet<String> byParentId = menuService.getByParentId(strings); |
| | | if (byParentId == null) { |
| | | return null; |
| | | |
| | | if (isTableMenu) { |
| | | List<String> tempList = new ArrayList<>(); |
| | | for (String menuId : menuIds) { |
| | | String tableNameByMenu = menuMappingService.getTableNameByMenu(menuId); |
| | | boolean exists = unBigDataDataSourceInfo.checkTableExists(tableNameByMenu); |
| | | if (exists) { |
| | | tempList.add(menuId); |
| | | } |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | } |
| | | menuIds = tempList; |
| | | } |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(menuIds); |
| | | return sysMenus; |
| | | } |
| | | |
| | | private List<MasterAuthor> getUserAuthor(String characterId, MaintainField maintainField) { |
| | | @Override |
| | | public List<SysMenu> getMenu(Character character, boolean isTableMenu) { |
| | | MasterAuthorType type = character.getType(); |
| | | List<MasterAuthor> masterAuthors = null; |
| | | switch (type){ |
| | | case role: |
| | | masterAuthors = getRoleAuthors(character.getId(), null); |
| | | break; |
| | | case groupInfo: |
| | | masterAuthors = getOneGroupAuthors(character.getId(), null); |
| | | break; |
| | | case user: |
| | | masterAuthors = getUserAuthor(character.getId(), null); |
| | | } |
| | | if (masterAuthors == null || masterAuthors.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<String> menuIds = masterAuthors.stream().map(masterAuthor -> masterAuthor.getMenuId()).collect(Collectors.toList()); |
| | | |
| | | if (isTableMenu) { |
| | | List<String> tempList = new ArrayList<>(); |
| | | for (String menuId : menuIds) { |
| | | String tableNameByMenu = menuMappingService.getTableNameByMenu(menuId); |
| | | boolean exists = unBigDataDataSourceInfo.checkTableExists(tableNameByMenu); |
| | | if (exists) { |
| | | tempList.add(menuId); |
| | | } |
| | | } |
| | | menuIds = tempList; |
| | | } |
| | | |
| | | LinkedHashSet<String> strings = new LinkedHashSet<>(menuIds); |
| | | List<SysMenu> sysMenus = menuService.getMenuByParentId(strings); |
| | | if (sysMenus == null) { |
| | | return null; |
| | | } |
| | | return sysMenus; |
| | | } |
| | | |
| | | @Override |
| | | public List<MasterAuthor> getUserAuthor(String characterId, MaintainField maintainField) { |
| | | Wrapper<MasterAuthor> userWrapper = new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.user).eq(MasterAuthorController.character_id, characterId); |
| | | |
| | | if (maintainField != null) { |
| | |
| | | builder.append(format); |
| | | } |
| | | String filter = builder.toString(); |
| | | if (StringUtils.isEmpty(filter)) { |
| | | return Constant.WHERE_DEFAULT; |
| | | } |
| | | return filter; |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public LinkedHashSet<Maintain> getMaintainSet(String tableName, TUser user) { |
| | | List<MasterAuthor> userAuthor = this.getUserAuthor(user.getUserId(), null); |
| | | LinkedHashSet<Maintain> maintainSet = new LinkedHashSet<>(); |
| | | Collections.reverse(userAuthor); |
| | | |
| | | for (MasterAuthor masterAuthor : userAuthor) { |
| | | String tabName = masterAuthor.getTableName(); |
| | | String maintainFieldId = masterAuthor.getMaintainFieldId(); |
| | | if (StringUtils.isEmpty(tabName) || !tableName.equalsIgnoreCase(tableName) || StringUtils.isEmpty(maintainFieldId)) { |
| | | continue; |
| | | } |
| | | List<Maintain> maintainByMaintainField = maintainFieldService.getMaintainByMaintainField(maintainFieldId, tableName); |
| | | maintainSet.addAll(maintainByMaintainField); |
| | | } |
| | | return maintainSet; |
| | | } |
| | | |
| | | public void dealFlow(String maintainId, ActivitiStatus status) { |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | MaintainField maintainFieldByMaintain = fieldService.getMaintainFieldByMaintain(maintainId); |
| | | SysMenu menuByTableName = menuMappingService.getMenuByTableName(maintain.getTableName()); |
| | | |
| | | List<MasterAuthor> masterAuthors = selectList(new EntityWrapper<MasterAuthor>() |
| | | .eq("maintain_field_id", maintainFieldByMaintain.getId()) |
| | | .eq("table_name", maintain.getTableName()) |
| | | .eq("menu_id", menuByTableName.getId()) |
| | | .eq("maintain_auto", true)); |
| | | for (MasterAuthor masterAuthor : masterAuthors) { |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | private MasterAuthor merage(MasterAuthor preMerageMasterAuthor, MasterAuthor masterAuthor) { |
| | | // table name masterField 一样 只有字段不同了 |
| | | List<MasterAuthorDetail> preFields = preMerageMasterAuthor.getFields(); |
New file |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.MasterAuthorSubscribeMapper; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import com.highdatas.mdm.util.pool.MqEntity; |
| | | import com.highdatas.mdm.util.pool.MqMessage; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-20 |
| | | */ |
| | | @Service |
| | | public class MasterAuthorSubscribeServiceImpl extends ServiceImpl<MasterAuthorSubscribeMapper, MasterAuthorSubscribe> implements IMasterAuthorSubscribeService { |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | DispenseService dispenseService; |
| | | |
| | | @Override |
| | | public void dealFlow(String maintainId, ActivitiStatus status) { |
| | | if (!ActivitiStatus.open.equals(status)) { |
| | | return; |
| | | } |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | |
| | | SysMenu menuByTableName = menuMappingService.getMenuByTableName(maintain.getTableName()); |
| | | |
| | | MaintainField maintainFieldByMaintain = fieldService.getMaintainFieldByMaintain(maintainId); |
| | | Set<String> userIdList = new HashSet<>(); |
| | | |
| | | Set<TUser> allUser = DbUtils.getAllUser(); |
| | | |
| | | for (TUser user : allUser) { |
| | | List<MasterAuthor> userAuthor = masterAuthorService.getUserAuthor(user.getUserId(), null); |
| | | |
| | | List<MasterAuthor> authorMaintainFieldList = userAuthor.stream() |
| | | .filter(masterAuthor -> menuByTableName.getId().equalsIgnoreCase(masterAuthor.getMenuId())) |
| | | .collect(Collectors.toList()); |
| | | int count = authorMaintainFieldList.size(); |
| | | if (count == 0) { |
| | | continue; |
| | | } |
| | | for (MasterAuthor masterAuthor : authorMaintainFieldList) { |
| | | String maintainFieldId = masterAuthor.getMaintainFieldId(); |
| | | |
| | | if (maintainFieldId.equalsIgnoreCase(Constant.All) || maintainFieldId.equalsIgnoreCase(maintainFieldByMaintain.getId())) { |
| | | userIdList.add(user.getUserId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (String userId : userIdList) { |
| | | MqEntity mqEntity = new MqEntity(); |
| | | mqEntity.setUserId(userId); |
| | | mqEntity.setIncrement(true); |
| | | mqEntity.setMsgTopicName(Constant.Master); |
| | | mqEntity.setType(Constant.Master); |
| | | mqEntity.setDataId(menuByTableName.getId()); |
| | | mqEntity.setMaintainId(maintainId); |
| | | mqEntity.setMsgTagName(menuByTableName.getId()); |
| | | MqEntity.MsgBodyBean msgBody = mqEntity.getMsgBody(); |
| | | msgBody.setVersion(maintainId); |
| | | mqEntity.setMsgKey(DbUtils.getUUID(16)); |
| | | MqMessage mqMessage = new MqMessage(mqEntity); |
| | | dispenseService.pushActiveMq(mqMessage); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.highdatas.mdm.entity.MasterAuthorUnactive; |
| | | import com.highdatas.mdm.mapper.MasterAuthorUnactiveMapper; |
| | | import com.highdatas.mdm.service.IMasterAuthorUnactiveService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-18 |
| | | */ |
| | | @Service |
| | | public class MasterAuthorUnactiveServiceImpl extends ServiceImpl<MasterAuthorUnactiveMapper, MasterAuthorUnactive> implements IMasterAuthorUnactiveService { |
| | | |
| | | } |
| | |
| | | |
| | | return result; |
| | | } |
| | | @Override |
| | | public Long getCountByVersion(Character character, String tableName, String whereSegment, String version, boolean findMax) { |
| | | Maintain maintainFromVersion = maintainService.getMaintainFromVersion(tableName, version); |
| | | Maintain nowVersionMaintain = maintainService.getNowVersion(tableName); |
| | | boolean isMax = maintainService.checkdMaxVersion(maintainFromVersion.getId()); |
| | | boolean isNow = maintainService.checkNowVersion(maintainFromVersion.getId()); |
| | | boolean isFirst = maintainService.checkFirstVersion(maintainFromVersion.getId()); |
| | | |
| | | Integer fromVersionOrderNo = maintainFromVersion.getOrderNo(); |
| | | Integer nowVersionOrderNo = 0; |
| | | if (nowVersionMaintain != null) { |
| | | nowVersionOrderNo = nowVersionMaintain.getOrderNo(); |
| | | } |
| | | |
| | | String tableTempName = tableName + Constant.RECORD; |
| | | |
| | | Long count; |
| | | |
| | | if (isNow && !findMax){ |
| | | count = getCount(tableName, whereSegment); |
| | | } |
| | | else if (isMax && findMax) { |
| | | if (isFirst && nowVersionMaintain == null) { |
| | | nowVersionOrderNo = nowVersionOrderNo - 1; |
| | | } |
| | | |
| | | count = getCountByMaxVersion(character, maintainFromVersion.getId(), tableName, tableTempName, fromVersionOrderNo, nowVersionOrderNo, whereSegment); |
| | | }else { |
| | | count = getCountByVersion(character, maintainFromVersion.getId(), tableName, tableTempName, nowVersionOrderNo, fromVersionOrderNo, whereSegment); |
| | | } |
| | | return count; |
| | | } |
| | | @Override |
| | | public Result selectListByPageByVersion(Character character, String tableName, List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, String version, boolean findMax) { |
| | | Maintain maintainFromVersion = maintainService.getMaintainFromVersion(tableName, version); |
| | |
| | | }else { |
| | | count = getCountByVersion(character, maintainFromVersion.getId(), tableName, tableTempName, nowVersionOrderNo, fromVersionOrderNo, whereSegment); |
| | | } |
| | | if (count == 0) { |
| | | if (count == null || count == 0) { |
| | | return Result.success(null); |
| | | } |
| | | //mapper.selectByPageByVersion(tableName, tableTempName, fieldList, whereSegment,); |
| | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", result); |
| | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", result); |
| | |
| | | @Async |
| | | public void dealFlow(String maintainId, ActivitiStatus status) { |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | if (maintain == null) { |
| | | return; |
| | | } |
| | | String tableName = maintain.getTableName(); |
| | | String recordTableName = tableName + Constant.RECORD; |
| | | List<Map<String,String>> modifiedList = masterModifiedMapper.selectByMaintainId(recordTableName, DbUtils.quotedStr(maintainId)); |
| | |
| | | @Override |
| | | public void dealAssemble(String maintainId, String userId, boolean audit) { |
| | | List<SysField> fieldByMaintain = fieldService.getFieldByMaintain(maintainId); |
| | | if(fieldByMaintain == null) { |
| | | return; |
| | | } |
| | | String fieldStr = fieldByMaintain.stream().map(SysField::getField).collect(Collectors.joining(Constant.SEMICOLON)); |
| | | List<TableSchemaResult> tableField = tableInfoMapper.getTableField(master_modified); |
| | | long count = tableField.stream().map(tableSchemaResult -> tableSchemaResult.getFieldName()).filter(s -> s.equalsIgnoreCase(userId)).count(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public MenuMapping getMenuMappingByTableName(String tableName) { |
| | | MenuMapping menuMapping = selectOne(new EntityWrapper<MenuMapping>().eq("table_name", tableName).orderBy("create_time desc")); |
| | | if (menuMapping == null) { |
| | | return null; |
| | | } |
| | | return menuMapping; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getTableNameByMenu(String menuId) { |
| | | MenuMapping menuMapping = selectOne(new EntityWrapper<MenuMapping>().eq("menu_id", menuId).orderBy("create_time desc")); |
| | | if (menuMapping == null) { |
New file |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.highdatas.mdm.entity.SysDispenseConfig; |
| | | import com.highdatas.mdm.mapper.SysDispenseConfigMapper; |
| | | import com.highdatas.mdm.service.ISysDispenseConfigService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-20 |
| | | */ |
| | | @Service |
| | | public class SysDispenseConfigServiceImpl extends ServiceImpl<SysDispenseConfigMapper, SysDispenseConfig> implements ISysDispenseConfigService { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.entity.SysDispenseLogs; |
| | | import com.highdatas.mdm.mapper.SysDispenseLogsMapper; |
| | | import com.highdatas.mdm.service.ISysDispenseLogsService; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import com.highdatas.mdm.util.pool.MqEntity; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-21 |
| | | */ |
| | | @Service |
| | | public class SysDispenseLogsServiceImpl extends ServiceImpl<SysDispenseLogsMapper, SysDispenseLogs> implements ISysDispenseLogsService { |
| | | |
| | | @Override |
| | | public SysDispenseLogs getLogByMqEntity(MqEntity mqEntity) { |
| | | Wrapper<SysDispenseLogs> sysDispenseLogsWrapper = new EntityWrapper<SysDispenseLogs>() |
| | | .eq("topic_id", mqEntity.getMsgTopicName()) |
| | | .eq("tag_id", mqEntity.getMsgTagName()) |
| | | .eq("key_id", mqEntity.getMsgKey()) |
| | | .orderBy("create_time desc"); |
| | | |
| | | |
| | | SysDispenseLogs sysDispenseLogs = selectOne(sysDispenseLogsWrapper); |
| | | return sysDispenseLogs; |
| | | } |
| | | |
| | | @Override |
| | | public SysDispenseLogs getPreUnSuccessByMqEntity(MqEntity mqEntity) { |
| | | Wrapper<SysDispenseLogs> sysDispenseLogsWrapper = new EntityWrapper<SysDispenseLogs>() |
| | | .eq("topic_id", mqEntity.getMsgTopicName()) |
| | | .eq("tag_id", mqEntity.getMsgTagName()) |
| | | .eq("status", "fail") |
| | | .orderBy("create_time desc"); |
| | | |
| | | |
| | | SysDispenseLogs sysDispenseLogs = selectOne(sysDispenseLogsWrapper); |
| | | return sysDispenseLogs; |
| | | } |
| | | |
| | | @Override |
| | | public SysDispenseLogs createLogByMqEntity(MqEntity mqEntity) { |
| | | SysDispenseLogs sysDispenseLogs = new SysDispenseLogs() |
| | | .setId(DbUtils.getUUID()) |
| | | .setCreateTime(new Date()) |
| | | .setDataType(mqEntity.getType()) |
| | | .setTopicId(mqEntity.getMsgTopicName()) |
| | | .setTagId(mqEntity.getMsgTagName()) |
| | | .setKeyId(mqEntity.getMsgKey()); |
| | | int totalSize = mqEntity.getTotalSize(); |
| | | if (totalSize > 0) { |
| | | sysDispenseLogs.setTotal(totalSize); |
| | | } |
| | | AtomicInteger pageNo = mqEntity.getPageNo(); |
| | | if (pageNo != null) { |
| | | sysDispenseLogs.setPageNo(pageNo.get()); |
| | | } |
| | | |
| | | AtomicInteger pages = mqEntity.getPages(); |
| | | if (pages != null) { |
| | | sysDispenseLogs.setPages(pages.get()); |
| | | } |
| | | sysDispenseLogs.insert(); |
| | | return sysDispenseLogs; |
| | | } |
| | | } |
| | |
| | | List subList = (List) list.stream().skip(page.getBeginRecordNo_1()).limit(page.getPageSize()).collect(Collectors.toList()); |
| | | result.fluentPut("pages", page.getPageCount()); |
| | | result.fluentPut("current", pageNo); |
| | | result.fluentPut("passiveQueueSize", pageSize); |
| | | result.fluentPut("size", pageSize); |
| | | result.fluentPut("total", page.getRecordCount()); |
| | | result.fluentPut("list", subList); |
| | | |
| | |
| | | List<Object> subList = list.stream().skip(page.getBeginRecordNo_1()).limit(page.getPageSize()).collect(Collectors.toList()); |
| | | result.fluentPut("pages", page.getPageCount()); |
| | | result.fluentPut("current", pageNo); |
| | | result.fluentPut("passiveQueueSize", pageSize); |
| | | result.fluentPut("size", pageSize); |
| | | result.fluentPut("total", page.getRecordCount()); |
| | | result.fluentPut("list", subList); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public SysField getOneFieldByMaintain(String maintainId, String field) { |
| | | List<SysField> fieldByMaintain = getFieldByMaintain(maintainId); |
| | | if (fieldByMaintain == null || fieldByMaintain.isEmpty()) { |
| | | return null; |
| | | } |
| | | for (SysField sysField : fieldByMaintain) { |
| | | if (sysField.getField().equalsIgnoreCase(field)) { |
| | | return sysField; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<SysField> getFieldByMaintainField(String maintainId) { |
| | | if (StringUtils.isEmpty(maintainId)) { |
| | | return null; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | return parentIdSet; |
| | | } |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenuByParentId(LinkedHashSet<String> parentIdSet) { |
| | | LinkedHashSet<String> byParentId = getByParentId(parentIdSet); |
| | | List<SysMenu> sysMenus = selectBatchIds(byParentId); |
| | | List<SysMenu> result = new ArrayList<SysMenu>(); |
| | | for (String s : byParentId) { |
| | | List<SysMenu> collect = sysMenus.stream().filter(sysMenu -> sysMenu.getId().equalsIgnoreCase(s)).collect(Collectors.toList()); |
| | | result.add(collect.get(0)); |
| | | } |
| | | Collections.reverse(result); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", datas); |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.highdatas.mdm.entity.SysView; |
| | | import com.highdatas.mdm.mapper.SysViewMapper; |
| | | import com.highdatas.mdm.service.ISysViewService; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.SysViewMapper; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.*; |
| | | import com.highdatas.mdm.pojo.kettle.UnBigDataDataSourceInfo; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.ContentBuilder; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import com.highdatas.mdm.util.ExcelUtil; |
| | | import com.highdatas.mdm.util.pool.MqEntity; |
| | | import com.highdatas.mdm.util.pool.MqMessage; |
| | | import lombok.SneakyThrows; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class SysViewServiceImpl extends ServiceImpl<SysViewMapper, SysView> implements ISysViewService { |
| | | @Autowired |
| | | ISysViewJoinService joinService; |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | UnBigDataDataSourceInfo unBigDataDataSourceInfo; |
| | | @Autowired |
| | | TableInfoMapper tableInfoMapper; |
| | | @Autowired |
| | | SysViewMapper viewMapper; |
| | | @Autowired |
| | | MasterDataService masterDataService; |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | @Autowired |
| | | ISysMenuService menuService; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | @Autowired |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | DispenseService dispenseService; |
| | | |
| | | @Override |
| | | public Page getInitPageInfo(String viewId) { |
| | | Page page = new Page(0); |
| | | SysView sysView = selectById(viewId); |
| | | String viewTableName = sysView.getViewTableName(); |
| | | List<TableSchemaResult> tableField = tableInfoMapper.getTableField(viewTableName); |
| | | int totalLength = 0; |
| | | for (TableSchemaResult tableSchemaResult : tableField) { |
| | | int length = tableSchemaResult.getLength(); |
| | | totalLength += length; |
| | | } |
| | | int pageSize = Constant.MaxDispenseSize / totalLength; |
| | | page.setPageSize(pageSize); |
| | | Long viewCount = getViewCount(sysView); |
| | | if (viewCount == 0) { |
| | | return null; |
| | | } |
| | | int pages; |
| | | if (viewCount % pageSize == 0) { |
| | | pages = Long.valueOf(viewCount/pageSize).intValue(); |
| | | }else { |
| | | pages = (Long.valueOf(viewCount/pageSize).intValue()) + 1; |
| | | } |
| | | page.setPages(pages); |
| | | return page; |
| | | } |
| | | @Override |
| | | public boolean createView(String viewId) { |
| | | SysView sysView = selectById(viewId); |
| | | if (sysView == null) { |
| | | return false; |
| | | } |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | return false; |
| | | } |
| | | |
| | | Maintain baseMaintain = getBaseMaintain(sysView); |
| | | if (baseMaintain == null) { |
| | | return false; |
| | | } |
| | | String baseTableName = baseMaintain.getTableName(); |
| | | sysView.setBaseTableName(baseTableName); |
| | | |
| | | List<String> totalFieldList = getTotalFieldList(sysView); |
| | | |
| | | // |
| | | String tableName = getViewTableName(sysView); |
| | | totalFieldList.add(Constant.ID); |
| | | boolean created = dropCreateViewTable(totalFieldList, tableName); |
| | | //TODO 主键 |
| | | if (!created) { |
| | | return false; |
| | | } |
| | | totalFieldList.remove(Constant.ID); |
| | | List<String> baseFieldList = getBaseFieldList(sysView); |
| | | //trans first |
| | | baseFieldList.add(Constant.ID); |
| | | String baseFields = baseFieldList.stream() |
| | | .map(s -> Constant.ID.equalsIgnoreCase(s) ? Constant.MYSQL_UUID : s) |
| | | .collect(Collectors.joining(Constant.COMMA)); |
| | | String fixBaseFields = baseFieldList.stream() |
| | | .map(s -> Constant.ID.equalsIgnoreCase(s) ? Constant.ID : changeFieldName(baseTableName, s)) |
| | | .collect(Collectors.joining(Constant.COMMA)); |
| | | |
| | | baseFieldList.remove(Constant.ID); |
| | | |
| | | String filter = masterAuthorService.getFilter(user, baseMaintain.getId()); |
| | | |
| | | String s = masterDataService.selectByVersionSql(null, baseTableName, baseFieldList, filter, baseMaintain.getVersion(), false); |
| | | |
| | | //base INSERT |
| | | tableInfoMapper.insertOneSelect(tableName, fixBaseFields, baseFields, s); |
| | | |
| | | // left insert |
| | | InsertJoin(sysView); |
| | | |
| | | // change val common |
| | | changeValCommon(sysView); |
| | | sysView.setStatus(ViewStatus.working).updateById(); |
| | | // |
| | | return true; |
| | | } |
| | | |
| | | private void InsertJoin(SysView sysView) { |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | String baseTableName = sysView.getBaseTableName(); |
| | | String tableName = sysView.getViewTableName(); |
| | | ContentBuilder joinBuilder = new ContentBuilder(Constant.EMPTY); |
| | | ContentBuilder updateFieldBuilder = new ContentBuilder(Constant.COMMA); |
| | | List<SysViewJoin> viewJoinList = sysView.getViewJoinList(); |
| | | |
| | | for (SysViewJoin sysViewJoin : viewJoinList) { |
| | | sysViewJoin.setBaseField(changeFieldName(baseTableName, sysViewJoin.getBaseField())); |
| | | Maintain joinMaintain = getJoinMaintain(sysViewJoin); |
| | | String joinTableName = joinMaintain.getTableName(); |
| | | |
| | | sysViewJoin.setBaseTableName(sysView.getViewTableName()); |
| | | String joinStr = sysViewJoin.createJoinStr(); |
| | | if (StringUtils.isEmpty(joinStr)) { |
| | | continue; |
| | | } |
| | | joinBuilder.append(joinStr); |
| | | List<String> subFieldList = getSubFieldList(sysViewJoin, user); |
| | | for (String subOneField : subFieldList) { |
| | | String changeFieldName = changeFieldName(sysViewJoin.getJoinTableName(), subOneField); |
| | | String base = MessageFormat.format(Constant.Alias, sysView.getViewTableName(), changeFieldName); |
| | | String join = MessageFormat.format(Constant.Alias, joinTableName, subOneField); |
| | | Segment segment = new Segment(base, join); |
| | | updateFieldBuilder.append(segment.toRawString()); |
| | | } |
| | | } |
| | | // JOIN |
| | | String joinSql = joinBuilder.toString(); |
| | | if (StringUtils.isEmpty(joinSql)) { |
| | | return; |
| | | } |
| | | tableInfoMapper.updateJoin(tableName, joinSql, updateFieldBuilder.toString(), Constant.WHERE_DEFAULT); |
| | | } |
| | | |
| | | private void changeValCommon(SysView sysView) { |
| | | String mappingField = sysView.getMappingField(); |
| | | String tableName = sysView.getViewTableName(); |
| | | String mappingTable = sysView.getMappingTable(); |
| | | |
| | | List<String> split = DbUtils.split(mappingField); |
| | | for (String oneMapField : split) { |
| | | String base = MessageFormat.format(Constant.Alias, tableName, oneMapField); |
| | | String join = MessageFormat.format(Constant.Alias, mappingTable, Constant.Pre); |
| | | String updateJoin = MessageFormat.format(Constant.Alias, mappingTable, Constant.fix); |
| | | Segment joinSegment = new Segment(base, join); |
| | | Segment updateSegment = new Segment(base, updateJoin); |
| | | Segment filterSegment = new Segment(MessageFormat.format(Constant.Alias, mappingTable, Constant.Code), oneMapField); |
| | | String changeJoinStr = MessageFormat.format(Constant.InnerJoinTemplate, ViewJoinType.inner, mappingTable, joinSegment.toRawString()); |
| | | if (StringUtils.isEmpty(changeJoinStr)){ |
| | | return; |
| | | } |
| | | tableInfoMapper.updateJoin(tableName, changeJoinStr, updateSegment.toRawString(), filterSegment.toString()); |
| | | } |
| | | } |
| | | |
| | | private boolean dropCreateViewTable(List<String> totalFieldList, String tableName) { |
| | | boolean created = unBigDataDataSourceInfo.dropData(tableName); |
| | | if (!created) { |
| | | return false; |
| | | } |
| | | |
| | | created = unBigDataDataSourceInfo.createTable(tableName, totalFieldList); |
| | | if (!created) { |
| | | //TODO |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public String getViewTableName(SysView view) { |
| | | String viewTableName = view.getViewTableName(); |
| | | if (StringUtils.isEmpty(viewTableName)) { |
| | | Maintain baseMaintain = getBaseMaintain(view); |
| | | viewTableName = Constant.VIEW + baseMaintain.getTableName() + baseMaintain.getOrderNo() + DbUtils.getUUID(5); |
| | | view.setViewTableName(viewTableName).updateById(); |
| | | } |
| | | return viewTableName; |
| | | } |
| | | |
| | | @Override |
| | | public String getMappingTableName(SysView view) { |
| | | String id = view.getId(); |
| | | String top = id.substring(0, 5); |
| | | String mappingTableName = Constant.VIEW + top + "mapping" + DbUtils.getUUID(4); |
| | | view.setMappingTable(mappingTableName).updateById(); |
| | | return mappingTableName; |
| | | } |
| | | @Override |
| | | public List<String> getSubFieldList(SysViewJoin join, TUser user) { |
| | | String fieldsStr = join.getFields(); |
| | | List<String> baseFieldList = new ArrayList<>(); |
| | | if (Constant.All.equalsIgnoreCase(fieldsStr)) { |
| | | Maintain joinMaintain = getJoinMaintain(join); |
| | | List<SysField> fieldList = masterAuthorService.getField(user, joinMaintain.getId()); |
| | | baseFieldList = fieldList.stream().map(sysField -> sysField.getField()).collect(Collectors.toList()); |
| | | }else { |
| | | baseFieldList = DbUtils.split(fieldsStr); |
| | | } |
| | | |
| | | return baseFieldList; |
| | | } |
| | | |
| | | private List<String> getBaseFieldList(SysView sysView) { |
| | | String fieldsStr = sysView.getFields(); |
| | | List<String> baseFieldList = new ArrayList<>(); |
| | | if (Constant.All.equalsIgnoreCase(fieldsStr)) { |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | Maintain baseMaintain = getBaseMaintain(sysView); |
| | | List<SysField> fieldList = masterAuthorService.getField(user, baseMaintain.getId()); |
| | | baseFieldList = fieldList.stream().map(sysField -> sysField.getField()).collect(Collectors.toList()); |
| | | }else { |
| | | baseFieldList = DbUtils.split(fieldsStr); |
| | | } |
| | | |
| | | return baseFieldList; |
| | | } |
| | | @Override |
| | | public List<ViewMapFieldItem> getMapField(SysView sysView) { |
| | | List<ViewMapFieldItem> result = new ArrayList<>(); |
| | | Maintain baseMaintain = getBaseMaintain(sysView); |
| | | SysMenu menuByTableName = menuMappingService.getMenuByTableName(baseMaintain.getTableName()); |
| | | if (menuByTableName == null) { |
| | | return null; |
| | | } |
| | | List<String> baseFieldList = getBaseFieldList(sysView); |
| | | |
| | | for (String field : baseFieldList) { |
| | | String changeFieldName = changeFieldName(baseMaintain.getTableName(), field); |
| | | SysField oneFieldByMaintainField = fieldService.getOneFieldByMaintain(baseMaintain.getId(), field); |
| | | if (oneFieldByMaintainField == null) { |
| | | continue; |
| | | } |
| | | ViewMapFieldItem viewMapFieldItem = new ViewMapFieldItem(); |
| | | viewMapFieldItem.setChangedField(changeFieldName); |
| | | viewMapFieldItem.setField(field); |
| | | viewMapFieldItem.setFieldName(oneFieldByMaintainField.getAlias()); |
| | | viewMapFieldItem.setMenuId(menuByTableName.getId()); |
| | | viewMapFieldItem.setMenuName(menuByTableName.getName()); |
| | | |
| | | result.add(viewMapFieldItem); |
| | | } |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | List<SysViewJoin> joinList = getJoinList(sysView); |
| | | for (SysViewJoin sysViewJoin : joinList) { |
| | | Maintain joinMaintain = getJoinMaintain(sysViewJoin); |
| | | SysMenu subMenu = menuMappingService.getMenuByTableName(joinMaintain.getTableName()); |
| | | List<String> subFieldList = getSubFieldList(sysViewJoin, user); |
| | | for (String subField : subFieldList) { |
| | | String changeFieldName = changeFieldName(joinMaintain.getTableName(), subField); |
| | | SysField oneFieldByMaintainField = fieldService.getOneFieldByMaintain(joinMaintain.getId(), subField); |
| | | if (oneFieldByMaintainField == null) { |
| | | continue; |
| | | } |
| | | ViewMapFieldItem viewMapFieldItem = new ViewMapFieldItem(); |
| | | viewMapFieldItem.setChangedField(changeFieldName); |
| | | viewMapFieldItem.setField(subField); |
| | | viewMapFieldItem.setFieldName(oneFieldByMaintainField.getAlias()); |
| | | viewMapFieldItem.setMenuId(subMenu.getId()); |
| | | viewMapFieldItem.setMenuName(subMenu.getName()); |
| | | |
| | | result.add(viewMapFieldItem); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private List<SysViewJoin> getJoinList(SysView sysView) { |
| | | String id = sysView.getId(); |
| | | Wrapper<SysViewJoin> eq = new EntityWrapper<SysViewJoin>().eq(Constant.PARENT_ID, id); |
| | | List<SysViewJoin> joinList = joinService.selectList(eq); |
| | | return joinList; |
| | | } |
| | | |
| | | public List<String> getTotalFieldList(SysView sysView) { |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | |
| | | List<String> totalFieldList = new ArrayList<>(); |
| | | Maintain baseMaintain = getBaseMaintain(sysView); |
| | | List<String> baseFieldList = getBaseFieldList(sysView); |
| | | totalFieldList.addAll(baseFieldList); |
| | | |
| | | totalFieldList = totalFieldList.stream().map(s -> changeFieldName(baseMaintain.getTableName(), s)).collect(Collectors.toList()); |
| | | List<SysViewJoin> sysViewJoins = joinService.selectList(new EntityWrapper<SysViewJoin>().eq(Constant.PARENT_ID, sysView.getId())); |
| | | for (SysViewJoin sysViewJoin : sysViewJoins) { |
| | | Maintain joinMaintain = getJoinMaintain(sysViewJoin); |
| | | List<String> subFieldList = getSubFieldList(sysViewJoin, user); |
| | | subFieldList = subFieldList.stream().map(s -> changeFieldName(joinMaintain.getTableName(), s)).collect(Collectors.toList()); |
| | | totalFieldList.addAll(subFieldList); |
| | | |
| | | sysViewJoin.setJoinTableName(joinMaintain.getTableName()); |
| | | sysViewJoin.setBaseTableName(baseMaintain.getTableName()); |
| | | } |
| | | sysView.setViewJoinList(sysViewJoins); |
| | | return totalFieldList; |
| | | } |
| | | |
| | | @Override |
| | | public Maintain getBaseMaintain(SysView sysView) { |
| | | |
| | | String baseMaintainStr = sysView.getBaseMaintain(); |
| | | if (StringUtils.isEmpty(baseMaintainStr)) { |
| | | return null; |
| | | } |
| | | Maintain baseMaintain; |
| | | if (sysView.getNeedUpdate()) { |
| | | baseMaintain = maintainService.getNowVersion(baseMaintainStr); |
| | | }else { |
| | | baseMaintain = maintainService.selectById(baseMaintainStr); |
| | | } |
| | | return baseMaintain; |
| | | } |
| | | |
| | | @Override |
| | | public Maintain getJoinMaintain(SysViewJoin viewJoin) { |
| | | |
| | | String baseMaintainStr = viewJoin.getJoinMaintain(); |
| | | if (StringUtils.isEmpty(baseMaintainStr)) { |
| | | return null; |
| | | } |
| | | Maintain baseMaintain; |
| | | if (viewJoin.getNeedUpdate()) { |
| | | baseMaintain = maintainService.getNowVersion(baseMaintainStr); |
| | | }else { |
| | | baseMaintain = maintainService.selectById(baseMaintainStr); |
| | | } |
| | | return baseMaintain; |
| | | } |
| | | |
| | | @Override |
| | | public String changeFieldName(String baseTableName, String field) { |
| | | return DbUtils.StrJoinLink(Constant.EMPTY_Str, baseTableName, Constant.UnderLine, field); |
| | | } |
| | | |
| | | @Override |
| | | public void dealFlow(String maintainId, ActivitiStatus status) { |
| | | if (!ActivitiStatus.open.equals(status)) { |
| | | return; |
| | | } |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | String maintainTableName = maintain.getTableName(); |
| | | |
| | | Wrapper<SysView> eq = new EntityWrapper<SysView>() |
| | | .eq("need_update", true) |
| | | .eq("base_maintain", maintainTableName); |
| | | List<SysView> sysViews = selectList(eq); |
| | | for (SysView sysView : sysViews) { |
| | | ViewStatus viewStatus = sysView.getStatus(); |
| | | if (!ViewStatus.working.equals(viewStatus)) { |
| | | continue; |
| | | } |
| | | createView(sysView.getId()); |
| | | |
| | | Boolean subscribe = sysView.getSubscribe(); |
| | | if (!subscribe) { |
| | | continue; |
| | | } |
| | | MqEntity mqEntity = new MqEntity(); |
| | | mqEntity.setUserId(sysView.getUserId()); |
| | | mqEntity.setMsgTopicName(Constant.View); |
| | | mqEntity.setType(Constant.View); |
| | | mqEntity.setDataId(sysView.getId()); |
| | | mqEntity.setMsgTagName(sysView.getId()); |
| | | mqEntity.setMsgKey(DbUtils.getUUID(16)); |
| | | MqMessage mqMessage = new MqMessage(mqEntity); |
| | | dispenseService.pushActiveMq(mqMessage); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result deleteView(String id) throws Exception { |
| | | SysView sysView = selectById(id); |
| | | if (sysView == null) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | | } |
| | | joinService.delete(new EntityWrapper<SysViewJoin>().eq(Constant.PARENT_ID, id)); |
| | | String viewTableName = sysView.getViewTableName(); |
| | | if (!StringUtils.isEmpty(viewTableName)) { |
| | | unBigDataDataSourceInfo.dropData(viewTableName); |
| | | } |
| | | String mappingTable = sysView.getMappingTable(); |
| | | if (!StringUtils.isEmpty(mappingTable)) { |
| | | unBigDataDataSourceInfo.dropData(mappingTable); |
| | | } |
| | | sysView.deleteById(); |
| | | return Result.success(CodeMsg.DELETE_SUCCESS); |
| | | } |
| | | |
| | | @Override |
| | | public List<ViewDictItem> getViewFieldMap(String viewId) { |
| | | SysView sysView = selectById(viewId); |
| | | if (sysView == null) { |
| | | return null; |
| | | } |
| | | Maintain baseMaintain = getBaseMaintain(sysView); |
| | | if (baseMaintain == null) { |
| | | return null; |
| | | } |
| | | String menuId = sysView.getMenuId(); |
| | | SysMenu sysMenu = menuService.selectById(menuId); |
| | | if (sysMenu == null) { |
| | | return null; |
| | | } |
| | | List<String> baseFieldList = getBaseFieldList(sysView); |
| | | ArrayList<ViewDictItem> dictList = new ArrayList<>(); |
| | | |
| | | for (String field : baseFieldList) { |
| | | ViewDictItem viewDictItem = new ViewDictItem(); |
| | | viewDictItem.setMenuId(sysMenu.getId()); |
| | | viewDictItem.setRawField(field); |
| | | String changeFieldName = changeFieldName(baseMaintain.getTableName(), field); |
| | | viewDictItem.setViewField(changeFieldName); |
| | | dictList.add(viewDictItem); |
| | | } |
| | | |
| | | List<SysViewJoin> sysViewJoins = joinService.selectList(new EntityWrapper<SysViewJoin>().eq(Constant.PARENT_ID, sysView.getId())); |
| | | for (SysViewJoin sysViewJoin : sysViewJoins) { |
| | | String subMenuId = sysViewJoin.getMenuId(); |
| | | SysMenu subMenu = menuService.selectById(subMenuId); |
| | | if (subMenu == null) { |
| | | continue; |
| | | } |
| | | Maintain joinMaintain = getJoinMaintain(sysViewJoin); |
| | | if (joinMaintain == null) { |
| | | continue; |
| | | } |
| | | String fields = sysViewJoin.getFields(); |
| | | |
| | | List<String> subFieldList = DbUtils.split(fields); |
| | | for (String field : subFieldList) { |
| | | ViewDictItem viewDictItem = new ViewDictItem(); |
| | | viewDictItem.setMenuId(subMenu.getId()); |
| | | viewDictItem.setRawField(field); |
| | | String changeFieldName = changeFieldName(joinMaintain.getTableName(), field); |
| | | viewDictItem.setViewField(changeFieldName); |
| | | dictList.add(viewDictItem); |
| | | } |
| | | } |
| | | return dictList; |
| | | } |
| | | |
| | | @Override |
| | | public Result getMapData(SysView sysView, String changedField, Integer pageNo, int pageSize) { |
| | | String mappingTable = sysView.getMappingTable(); |
| | | if (StringUtils.isEmpty(mappingTable)) { |
| | | return null; |
| | | } |
| | | boolean exists = unBigDataDataSourceInfo.checkTableExists(mappingTable); |
| | | if (!exists) { |
| | | return null; |
| | | } |
| | | Segment segment = new Segment(Constant.Code, changedField); |
| | | |
| | | Long count = tableInfoMapper.getCount(mappingTable, segment.toString()); |
| | | if (count == 0) { |
| | | return null; |
| | | } |
| | | Page page = new Page(count); |
| | | page.setPageSize(pageSize); |
| | | page.setPageNo(pageNo); |
| | | ArrayList<String> fields = new ArrayList<>(); |
| | | fields.add(Constant.Code); |
| | | fields.add(Constant.Pre); |
| | | fields.add(Constant.fix); |
| | | String fieldStr = fields.stream().collect(Collectors.joining(Constant.COMMA)); |
| | | List<Map<String, Object>> maps = tableInfoMapper.selectByPage(mappingTable, fieldStr, segment.toString(), page.getLimitSQL()); |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("records", maps); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", pageNo); |
| | | object.fluentPut("total", count); |
| | | |
| | | return Result.success(object); |
| | | } |
| | | @Override |
| | | public long getViewCount(SysView sysView) { |
| | | String viewTableName = sysView.getViewTableName(); |
| | | if (StringUtils.isEmpty(viewTableName)) { |
| | | return 0; |
| | | } |
| | | boolean exists = unBigDataDataSourceInfo.checkTableExists(viewTableName); |
| | | if (!exists) { |
| | | return 0; |
| | | } |
| | | |
| | | Long count = tableInfoMapper.getCount(viewTableName, Constant.WHERE_DEFAULT); |
| | | if (count == null) { |
| | | return 0L; |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | @Override |
| | | public Result getViewData(SysView sysView, Integer pageNo, int pageSize) { |
| | | String viewTableName = sysView.getViewTableName(); |
| | | long count = getViewCount(sysView); |
| | | if (count == 0) { |
| | | return null; |
| | | } |
| | | Page page = new Page(count); |
| | | page.setPageSize(pageSize); |
| | | page.setPageNo(pageNo); |
| | | List<TableSchemaResult> tableField = tableInfoMapper.getTableField(viewTableName); |
| | | String fields = tableField.stream().map(tableSchemaResult -> tableSchemaResult.getFieldName()).collect(Collectors.joining(Constant.COMMA)); |
| | | List<Map<String, Object>> maps = tableInfoMapper.selectByPage(viewTableName, fields, Constant.WHERE_DEFAULT, page.getLimitSQL()); |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("records", maps); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", pageNo); |
| | | object.fluentPut("total", count); |
| | | object.fluentPut("pageSize", page.getPageSize()); |
| | | |
| | | //fields |
| | | ArrayList<ViewField> sysFields = new ArrayList<>(); |
| | | Maintain baseMaintain = getBaseMaintain(sysView); |
| | | List<String> baseFieldList = getBaseFieldList(sysView); |
| | | |
| | | for (String field : baseFieldList) { |
| | | SysField oneFieldByMaintain = fieldService.getOneFieldByMaintain(baseMaintain.getId(), field); |
| | | if (oneFieldByMaintain == null) { |
| | | continue; |
| | | } |
| | | String changeFieldName = changeFieldName(baseMaintain.getTableName(), field); |
| | | ViewField viewField = new ViewField(); |
| | | viewField.setChangedField(changeFieldName); |
| | | viewField.setField(field); |
| | | viewField.setFieldName(oneFieldByMaintain.getAlias()); |
| | | viewField.setMenuId(sysView.getId()); |
| | | viewField.setMenuName(sysView.getName()); |
| | | sysFields.add(viewField); |
| | | } |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | |
| | | List<SysViewJoin> joinList = joinService.selectList(new EntityWrapper<SysViewJoin>().eq(Constant.PARENT_ID, sysView.getId())); |
| | | for (SysViewJoin sysViewJoin : joinList) { |
| | | Maintain joinMaintain = getJoinMaintain(sysViewJoin); |
| | | List<String> subFieldList = getSubFieldList(sysViewJoin, user); |
| | | for (String subField : subFieldList) { |
| | | SysField oneFieldByMaintain = fieldService.getOneFieldByMaintain(joinMaintain.getId(), subField); |
| | | if (oneFieldByMaintain == null) { |
| | | continue; |
| | | } |
| | | String changeFieldName = changeFieldName(joinMaintain.getTableName(), subField); |
| | | ViewField viewField = new ViewField(); |
| | | viewField.setChangedField(changeFieldName); |
| | | viewField.setField(subField); |
| | | viewField.setFieldName(oneFieldByMaintain.getAlias()); |
| | | viewField.setMenuId(sysView.getId()); |
| | | viewField.setMenuName(sysView.getName()); |
| | | sysFields.add(viewField); |
| | | } |
| | | } |
| | | object.fluentPut("fields", sysFields); |
| | | |
| | | return Result.success(object); |
| | | } |
| | | |
| | | @SneakyThrows |
| | | @Override |
| | | public void downlodMap(SysView sysView, TUser user, HttpServletResponse response,String field, String menuId) { |
| | | Maintain maintain = getMaintainByMenu(sysView, menuId); |
| | | if (maintain == null) { |
| | | return; |
| | | } |
| | | ArrayList<String> fields = new ArrayList<>(); |
| | | fields.add(field); |
| | | fields.add(Constant.ID); |
| | | String filter = masterAuthorService.getFilter(user, maintain.getId()); |
| | | String sql = masterDataService.selectByVersionSql(user, maintain.getTableName(), fields, filter, maintain.getVersion(), false); |
| | | String tableName = MessageFormat.format(Constant.asTempSql, sql, Constant.H); |
| | | String mappingTable = sysView.getMappingTable(); |
| | | boolean exists = unBigDataDataSourceInfo.checkTableExists(mappingTable); |
| | | List<Map<String, Object>> maps; |
| | | if (exists) { |
| | | String changeFieldName = changeFieldName(maintain.getTableName(), field); |
| | | maps = viewMapper.selectMapVal(tableName, MessageFormat.format(Constant.FieldAsAlias, field, Constant.Pre), Constant.WHERE_DEFAULT, mappingTable, DbUtils.quotedStr(changeFieldName)); |
| | | |
| | | } else { |
| | | maps = tableInfoMapper.selectDistinct(tableName, MessageFormat.format(Constant.FieldAsAlias, field, Constant.Pre), Constant.WHERE_DEFAULT); |
| | | |
| | | } |
| | | |
| | | |
| | | //todo 大数据量优化 |
| | | fields.remove(Constant.ID); |
| | | ArrayList<SysField> sysFields = new ArrayList<>(); |
| | | sysFields.add(new SysField().setField(Constant.Pre).setAlias(Constant.PreValue)); |
| | | sysFields.add(new SysField().setField(Constant.fix).setAlias(Constant.fixValue)); |
| | | ExcelUtil.export(response, maps, sysFields); |
| | | } |
| | | |
| | | @Override |
| | | public Maintain getMaintainByMenu(SysView sysView, String menuId) { |
| | | Maintain maintain = null; |
| | | String baseMenu = sysView.getMenuId(); |
| | | if (baseMenu != null && baseMenu.equalsIgnoreCase(menuId)) { |
| | | maintain = getBaseMaintain(sysView); |
| | | }else { |
| | | List<SysViewJoin> joinList = joinService.selectList(new EntityWrapper<SysViewJoin>().eq(Constant.PARENT_ID, sysView.getId())); |
| | | |
| | | for (SysViewJoin sysViewJoin : joinList) { |
| | | String subMenuId = sysViewJoin.getMenuId(); |
| | | if (subMenuId != null && subMenuId.equalsIgnoreCase(menuId)) { |
| | | maintain = getJoinMaintain(sysViewJoin); |
| | | } |
| | | |
| | | } |
| | | } |
| | | return maintain; |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteMapField(SysView sysView, String changedField) { |
| | | try { |
| | | Segment segment = new Segment(Constant.Code, changedField); |
| | | String mappingTable = sysView.getMappingTable(); |
| | | String mappingfield = sysView.getMappingField(); |
| | | if (StringUtils.isEmpty(mappingTable) || StringUtils.isEmpty(mappingfield)) { |
| | | return true; |
| | | } |
| | | tableInfoMapper.delete(mappingTable, segment.toString()); |
| | | String mappingField = sysView.getMappingField(); |
| | | List<String> split = DbUtils.split(mappingField); |
| | | String collect = split.stream().filter(s -> !s.equalsIgnoreCase(changedField)).collect(Collectors.joining(Constant.SEMICOLON)); |
| | | boolean b = sysView.setMappingField(collect).updateById(); |
| | | return b; |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.util;
|
| | |
|
| | | import org.apache.commons.codec.binary.Base64;
|
| | |
|
| | | import javax.crypto.Cipher;
|
| | | import javax.crypto.spec.SecretKeySpec;
|
| | | import java.security.Security;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-17 9:31
|
| | | */
|
| | |
|
| | |
|
| | | public class AESUtil {
|
| | |
|
| | | private static final String EncryptAlg ="AES";
|
| | |
|
| | | private static final String Cipher_Mode="AES/ECB/PKCS7Padding";
|
| | |
|
| | | private static final String Encode="UTF-8";
|
| | |
|
| | | private static final int Secret_Key_Size=32;
|
| | |
|
| | | private static final String Key_Encode="UTF-8";
|
| | |
|
| | | /**
|
| | | * AES/ECB/PKCS7Padding 加密
|
| | | * @param content
|
| | | * @param key 密钥
|
| | | * @return aes加密后 转base64
|
| | | * @throws Exception
|
| | | */
|
| | | public static String aesPKCS7PaddingEncrypt(String content, String key) throws Exception {
|
| | | try {
|
| | | Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
| | |
|
| | | Cipher cipher = Cipher.getInstance(Cipher_Mode);
|
| | | byte[] realKey=getSecretKey(key);
|
| | | cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(realKey,EncryptAlg));
|
| | | byte[] data=cipher.doFinal(content.getBytes(Encode));
|
| | | String result=new Base64().encodeToString(data);
|
| | | return result;
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | throw new Exception("AES加密失败:content=" +content +" key="+key);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * AES/ECB/PKCS7Padding 解密
|
| | | * @param content
|
| | | * @param key 密钥
|
| | | * @return 先转base64 再解密
|
| | | * @throws Exception
|
| | | */
|
| | | public static String aesPKCS7PaddingDecrypt(String content, String key) throws Exception {
|
| | | try {
|
| | | //Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
| | |
|
| | | byte[] decodeBytes= Base64.decodeBase64(content);
|
| | |
|
| | | Cipher cipher = Cipher.getInstance(Cipher_Mode);
|
| | | byte[] realKey=getSecretKey(key);
|
| | | cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(realKey,EncryptAlg));
|
| | | byte[] realBytes=cipher.doFinal(decodeBytes);
|
| | |
|
| | | return new String(realBytes, Encode);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | throw new Exception("AES解密失败:Aescontent = " +e.fillInStackTrace(),e);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 对密钥key进行处理:如密钥长度不够位数的则 以指定paddingChar 进行填充;
|
| | | * 此处用空格字符填充,也可以 0 填充
|
| | | * @param key
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public static byte[] getSecretKey(String key) throws Exception{
|
| | | final byte paddingChar=' ';
|
| | |
|
| | | byte[] realKey = new byte[Secret_Key_Size];
|
| | | byte[] byteKey = key.getBytes(Key_Encode);
|
| | | for (int i =0;i<realKey.length;i++){
|
| | | if (i<byteKey.length){
|
| | | realKey[i] = byteKey[i];
|
| | | }else {
|
| | | realKey[i] = paddingChar;
|
| | | }
|
| | | }
|
| | |
|
| | | return realKey;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.util;
|
| | |
|
| | | import java.lang.reflect.Field;
|
| | | import java.lang.reflect.Method;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-18 14:11
|
| | | */
|
| | |
|
| | |
|
| | | public class ClassUtil {
|
| | | public static Field[] getClassAttribute(Object targetObj){
|
| | |
|
| | | Class<?> objectClass = targetObj.getClass();
|
| | | return objectClass.getDeclaredFields();
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取对象的所有get或set方法
|
| | | * @param targetObj 要获取属性的类
|
| | | * @param methodKeyword get或者set关键字
|
| | | * @return 含有类get或set方法的集合
|
| | | */
|
| | | public static List<Method> getMethod(Object targetObj,String methodKeyword){
|
| | | List<Method> methodList = new ArrayList<>();
|
| | |
|
| | | Class<?> objectClass = targetObj.getClass();
|
| | |
|
| | | Field[] field = objectClass.getDeclaredFields();
|
| | | for (int i = 0;i<field.length;i++){
|
| | | //获取属性名并组装方法名
|
| | | String fieldName = field[i].getName();
|
| | | String getMethodName = methodKeyword
|
| | | + fieldName.substring(0, 1).toUpperCase()
|
| | | + fieldName.substring(1);
|
| | |
|
| | | try {
|
| | | Method method = objectClass.getMethod(getMethodName,new Class[]{});
|
| | | methodList.add(method);
|
| | | } catch (NoSuchMethodException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | return methodList;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取对象的所有get方法
|
| | | * @param targetObj 要获取属性的类
|
| | | * @return 含有类方法的集合
|
| | | */
|
| | | public static List<Method> getMethodGet(Object targetObj){
|
| | | return getMethod(targetObj,"get");
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取对象的所有set方法
|
| | | * @param targetObj 要获取属性的类
|
| | | * @return 含有类方法的集合
|
| | | */
|
| | | public static List<Method> getMethodSet(Object targetObj){
|
| | | return getMethod(targetObj,"set");
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | String AND = " and "; |
| | | String MD = "md_"; |
| | | |
| | | |
| | | String CNT = "cnt"; |
| | | String checkFieldSqlTemplate = "select count(1) as cnt from (select {0} from {1}) a1"; |
| | | String selectRecordFieldSqlTemplate = "select {0}, 0 as deal from {1}"; |
| | |
| | | String STEP_READ_FROM_TABLE = "Read data from table"; |
| | | String STEP_INSERT_UPDATE = "Insert or update"; |
| | | String STEP_DUMMY = "Dummy"; |
| | | String MYSQL_UUID = "replace(UUID(),'-', '')"; |
| | | String MYSQL_UUID = " UUID_SHORT() "; |
| | | String TYPE = "type"; |
| | | String Active = "active"; |
| | | String AssembleTempTable = "hj_table_"; |
| | |
| | | String FIELD = "field"; |
| | | String DISTINCT = "distinct {0}"; |
| | | String InSql = "{0} in ( {1} )"; |
| | | String asTempSql = "( {0} ) {1}"; |
| | | String z_AllVal = "z_AllVal"; |
| | | |
| | | |
| | | int queueSize = 20; |
| | | int cntCoefficient = 50; |
| | | String VIEW = "view_"; |
| | | String InnerJoinTemplate = " {0} {1} on {2}"; |
| | | String changedField = "change_field"; |
| | | String XLS = "xls"; |
| | | String xlsx = "xlsx"; |
| | | String LeftJoin = " left join "; |
| | | String InnerJoin = " inner join "; |
| | | String Pre = "pre"; |
| | | String PreValue = "原始值"; |
| | | String fix = "fix"; |
| | | String fixValue = "转换值"; |
| | | String userDO = "userDO"; |
| | | String MasterDispense = "Master-Dispense"; |
| | | String Master = "master"; |
| | | String View = "view"; |
| | | String Token = "token"; |
| | | |
| | | int MaxDispenseSize = Double.valueOf(1024 * 1024 * 1.5).intValue(); |
| | | String RECORDS = "records"; |
| | | String SUCCESSCODE = "200"; |
| | | } |
| | |
| | | this.content = new StringBuilder(); |
| | | } |
| | | |
| | | public ContentBuilder clear() { |
| | | content.delete(0, content.length()); |
| | | empty = true; |
| | | return this; |
| | | } |
| | | |
| | | public ContentBuilder append(Object data) { |
| | | if (data == null) { |
| | | return this; |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.google.common.collect.Maps; |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.MaintainDetailMapper; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | import com.highdatas.mdm.pojo.Segment; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.pool.MqClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.ibatis.mapping.BoundSql; |
| | |
| | | import org.apache.ibatis.session.Configuration; |
| | | import org.apache.ibatis.session.SqlSessionFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cglib.beans.BeanMap; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | import java.lang.reflect.Method; |
| | | import java.security.MessageDigest; |
| | | import java.text.MessageFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | |
| | | public class DbUtils { |
| | | |
| | | private static UserRoleClient userRoleClient; |
| | | public static MaintainDetailMapper maintainDetailMapper; |
| | | public static IMaintainService maintainService; |
| | | public static IMaintainDetailService maintainDetailService; |
| | | public static ISysFieldService fieldService; |
| | | public static IMaintainFieldService maintainFieldService; |
| | | public static TableInfoMapper tableInfoMapper; |
| | | public static ISysViewService viewService; |
| | | public static MasterDataService masterDataService; |
| | | public static IMasterAuthorService masterAuthorService; |
| | | public static ISysMenuService menuService; |
| | | public static MqClient mqClient; |
| | | |
| | | public static ISysDispenseLogsService dispenseLogsService; |
| | | |
| | | @Autowired |
| | | public void setISysDispenseLogsService(ISysDispenseLogsService dispenseLogsService){ |
| | | DbUtils.dispenseLogsService = dispenseLogsService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setMqClient(MqClient mqClient){ |
| | | DbUtils.mqClient = mqClient; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setISysMenuService(ISysMenuService menuService){ |
| | | DbUtils.menuService = menuService; |
| | | } |
| | | @Autowired |
| | | public void setIMasterAuthorService(IMasterAuthorService masterAuthorService){ |
| | | DbUtils.masterAuthorService = masterAuthorService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setMasterDataService(MasterDataService masterDataService){ |
| | | DbUtils.masterDataService = masterDataService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setISysViewService(ISysViewService viewService){ |
| | | DbUtils.viewService = viewService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setTableInfoMapper(TableInfoMapper tableInfoMapper){ |
| | | DbUtils.tableInfoMapper = tableInfoMapper; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setIMaintainFieldService(IMaintainFieldService maintainFieldService){ |
| | | DbUtils.maintainFieldService = maintainFieldService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setISysFieldService(ISysFieldService fieldService){ |
| | | DbUtils.fieldService = fieldService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setIMaintainDetailService(IMaintainDetailService maintainDetailService){ |
| | | DbUtils.maintainDetailService = maintainDetailService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setIMaintainService(IMaintainService maintainService){ |
| | | DbUtils.maintainService = maintainService; |
| | | } |
| | | @Autowired |
| | | public void setMaintainDetailMapper(MaintainDetailMapper maintainDetailMapper){ |
| | | DbUtils.maintainDetailMapper = maintainDetailMapper; |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | public void setUserRoleClient(UserRoleClient userRoleClient){ |
| | |
| | | bigVersion++; |
| | | return MessageFormat.format("V{0}.{1}",bigVersion, 0); |
| | | } |
| | | |
| | | public static <T> Map<String, Object> beanToMap(T bean) { |
| | | Map<String, Object> map = Maps.newHashMap(); |
| | | if (bean != null) { |
| | | BeanMap beanMap = BeanMap.create(bean); |
| | | for (Object key : beanMap.keySet()) { |
| | | map.put(key+"", beanMap.get(key)); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public static Integer getSubVersion(String baseVersion) { |
| | | if (StringUtils.isEmpty(baseVersion)) { |
| | |
| | | |
| | | public static String StrJoin(String... objects){ |
| | | ContentBuilder builder = new ContentBuilder(Constant.EMPTY); |
| | | for (String object : objects) { |
| | | builder.append(object); |
| | | } |
| | | return builder.toString(); |
| | | } |
| | | |
| | | public static String StrJoinLink(String link,String... objects){ |
| | | ContentBuilder builder = new ContentBuilder(link); |
| | | for (String object : objects) { |
| | | builder.append(object); |
| | | } |
| | |
| | | |
| | | public static List<String> split(String redisVal) { |
| | | if (StringUtils.isEmpty(redisVal)) { |
| | | return null; |
| | | return new ArrayList<>(); |
| | | } |
| | | String[] split = redisVal.split(Constant.SEMICOLON); |
| | | List<String> strings = Arrays.asList(split); |
| | |
| | | return collect; |
| | | } |
| | | |
| | | public static Set<TUser> getAllUser() { |
| | | List<TUser> tRoleListByUserId = userRoleClient.listUserRoleGroup(); |
| | | return new HashSet<TUser>(tRoleListByUserId); |
| | | } |
| | | |
| | | |
| | | public static Set<String> getUserByRole(String roleId) { |
| | | List<String> userListByRole = userRoleClient.getUserListByRole(roleId); |
| | | |
| | | HashSet<String> result = new HashSet<>(userListByRole); |
| | | return result; |
| | | } |
| | | |
| | | public static Set<String> getGroupByUser(String userId) { |
| | | List<TUserGroup> tRoleListByUserId = userRoleClient.getUserGroupByUserId(userId); |
| | | if (tRoleListByUserId == null || tRoleListByUserId.isEmpty()){ |
| | |
| | | return ibatisSql; |
| | | } |
| | | |
| | | public static String getNowDateStr() { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String time = format.format(new Date()); |
| | | return time; |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.util;
|
| | |
|
| | | import com.highdatas.mdm.entity.SysField;
|
| | | import com.highdatas.mdm.entity.ViewMappingItem;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
| | | import org.apache.poi.ss.usermodel.*;
|
| | | import org.apache.poi.xssf.streaming.SXSSFSheet;
|
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| | |
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.net.URLEncoder;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-17 12:16
|
| | | */
|
| | |
|
| | | @Slf4j
|
| | | public class ExcelUtil {
|
| | |
|
| | |
|
| | | /**
|
| | | * @param in
|
| | | * @param fileName
|
| | | * @return
|
| | | */
|
| | | public static List<ViewMappingItem> getViewMappingByExcel(InputStream in, String fileName) {
|
| | |
|
| | | List list = new ArrayList<>();
|
| | | Workbook work = null;
|
| | | try{
|
| | | // 创建excel工作簿
|
| | | work = getWorkbook(in, fileName);
|
| | | if (null == work) {
|
| | | throw new Exception("创建Excel工作薄为空!");
|
| | | }
|
| | |
|
| | | Sheet sheet = null;
|
| | | Row row = null;
|
| | | Cell cell = null;
|
| | |
|
| | | for (int i = 0; i < work.getNumberOfSheets(); i++) {
|
| | |
|
| | | sheet = work.getSheetAt(i);
|
| | | if(sheet == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | // 滤过第一行标题
|
| | | for (int j = sheet.getFirstRowNum(); j <= sheet.getLastRowNum(); j++) {
|
| | | row = sheet.getRow(j);
|
| | | if (row == null || row.getFirstCellNum() == j) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | ViewMappingItem item = new ViewMappingItem();
|
| | | Cell preCell = row.getCell(0);
|
| | | if (preCell != null) {
|
| | | item.setPre(preCell.getStringCellValue());
|
| | | }
|
| | |
|
| | | Cell fixCell = row.getCell(1);
|
| | | if (fixCell != null) {
|
| | | item.setFix(fixCell.getStringCellValue());
|
| | | }
|
| | |
|
| | | list.add(item);
|
| | | }
|
| | | }
|
| | | }catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | return null;
|
| | | }finally {
|
| | | try {
|
| | | work.close();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 判断文件格式
|
| | | * @param in
|
| | | * @param fileName
|
| | | * @return
|
| | | */
|
| | | private static Workbook getWorkbook(InputStream in, String fileName) throws Exception {
|
| | |
|
| | | Workbook book = null;
|
| | | String filetype = fileName.substring(fileName.lastIndexOf("."));
|
| | |
|
| | | if(".xls".equals(filetype)) {
|
| | | book = new HSSFWorkbook(in);
|
| | | } else if (".xlsx".equals(filetype)) {
|
| | | book = new XSSFWorkbook(in);
|
| | | } else {
|
| | | throw new Exception("请上传excel文件!");
|
| | | }
|
| | |
|
| | | return book;
|
| | | }
|
| | |
|
| | | public static void export(HttpServletResponse response, List<Map<String, Object>> importlist, ArrayList<SysField> fieldList) throws UnsupportedEncodingException {
|
| | | //获取数据集
|
| | | List<Map<String, Object>> datalist = importlist;
|
| | |
|
| | | //声明一个工作薄
|
| | | SXSSFWorkbook workbook = new SXSSFWorkbook();
|
| | | //生成一个表格
|
| | | SXSSFSheet sheet = workbook.createSheet();
|
| | | //设置表格默认列宽度为15个字节
|
| | | sheet.setDefaultColumnWidth((short) 15);
|
| | |
|
| | | //获取字段名数组
|
| | | // String[] tableAttributeName = attributeNames;
|
| | | // //获取对象属性
|
| | | // Field[] fields = ClassUtil.getClassAttribute(importlist.get(0));
|
| | | // //获取对象get方法
|
| | | // List<Method> methodList = ClassUtil.getMethodGet(importlist.get(0));
|
| | |
|
| | | //循环字段名数组,创建标题行
|
| | | Row row = sheet.createRow(0);
|
| | |
|
| | | for (int j = 0; j< fieldList.size(); j++){
|
| | | //创建列
|
| | | SysField sysField = fieldList.get(j);
|
| | | Cell cell = row.createCell(j);
|
| | | //设置单元类型为String
|
| | | cell.setCellType(CellType.STRING);
|
| | | cell.setCellValue(sysField.getAlias());
|
| | | }
|
| | | //创建普通行
|
| | | for (int i = 0;i<datalist.size();i++){
|
| | | //因为第一行已经用于创建标题行,故从第二行开始创建
|
| | | row = sheet.createRow(i+1);
|
| | | //如果是第一行就让其为标题行
|
| | |
|
| | | Map<String, Object> oneData = datalist.get(i);
|
| | | for (int j = 0;j<fieldList.size();j++){
|
| | | //创建列
|
| | | SysField sysField = fieldList.get(j);
|
| | |
|
| | | Cell cell = row.createCell(j);
|
| | | cell.setCellType(CellType.STRING);
|
| | | //
|
| | | Object value = oneData.get(sysField.getField());
|
| | | cell.setCellValue(transCellType(value));
|
| | | }
|
| | | }
|
| | | response.setContentType("application/octet-stream;charset=UTF-8");
|
| | | response.setCharacterEncoding("UTF-8");
|
| | | response.setHeader("content-type", "application/octet-stream;charset=UTF-8");
|
| | | //默认Excel名称
|
| | | response.setHeader("Content-Disposition", "attachment;fileName="+ URLEncoder.encode("mapping数据.xlsx","UTF-8"));
|
| | |
|
| | | try {
|
| | | response.flushBuffer();
|
| | | workbook.write(response.getOutputStream());
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private static String transCellType(Object value){
|
| | | String str = null;
|
| | | if (value instanceof Date){
|
| | | Date date = (Date) value;
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | str = sdf.format(date);
|
| | | }else{
|
| | | str = String.valueOf(value);
|
| | | if (str == "null"){
|
| | | str = "";
|
| | | }
|
| | | }
|
| | |
|
| | | return str;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | // strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意 |
| | | strategy.setTablePrefix(new String[]{""});// 此处可以修改为您的表前缀 |
| | | strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 |
| | | strategy.setInclude(new String[]{"sys_view","sys_view_join","sys_subscribe"}); // 需要生成的表 |
| | | strategy.setInclude(new String[]{"sys_dispense_logs"}); // 需要生成的表 |
| | | // strategy.setExclude(new String[]{"test"}); // 排除生成的表 |
| | | // 自定义实体父类 |
| | | // strategy.setSuperEntityClass("com.baomidou.demo.TestEntity"); |
| | |
| | | @Override |
| | | public void addInterceptors(InterceptorRegistry registry) { |
| | | InterceptorRegistration interceptorRegistration = registry.addInterceptor(commonInterceptor); |
| | | interceptorRegistration.excludePathPatterns("/designer/**","/upload/**", "/process/**", "/processes/**", "/swagger-ui.html", "/webjars/**", "/swagger-resources/**", "/v2/api-docs", "/"); |
| | | interceptorRegistration.excludePathPatterns("/sysView/download/**","/designer/**","/upload/**", "/process/**", "/processes/**", "/swagger-ui.html", "/webjars/**", "/swagger-resources/**", "/v2/api-docs", "/"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | }
|
| | |
|
| | | public String getRedisVal(String key) {
|
| | | try {
|
| | | String url = this.url + prefix + "get";
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("key",key);
|
| | |
| | | return null;
|
| | | }else {
|
| | | return result.getString(Constant.Data);
|
| | | }
|
| | | }catch (Exception e){
|
| | | e.printStackTrace();
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.highdatas.mdm.util;
|
| | |
|
| | | import com.highdatas.mdm.service.DispenseService;
|
| | | import com.highdatas.mdm.util.pool.MqMessage;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.context.annotation.Configuration;
|
| | | import org.springframework.scheduling.annotation.EnableScheduling;
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.Date;
|
| | | import java.util.concurrent.PriorityBlockingQueue;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | |
| | | @EnableScheduling
|
| | | @Slf4j
|
| | | public class TimeTasks {
|
| | | @Autowired
|
| | | DispenseService dispenseService;
|
| | | // @Autowired
|
| | | // DispenseService dispenseService;
|
| | |
|
| | | @Scheduled(fixedRate=1000 * 10)
|
| | | private void configureTasks() {
|
| | | PriorityBlockingQueue<Runnable> queue = dispenseService.getQueue();
|
| | | if (queue.isEmpty()) {
|
| | | return;
|
| | | }
|
| | | log.info("queue passiveQueueSize: {}", queue.size());
|
| | | for (Runnable runnable : queue) {
|
| | | if (!(runnable instanceof MqMessage)) {
|
| | | continue;
|
| | | }
|
| | | MqMessage mqMessage = (MqMessage) runnable;
|
| | | Date endTime = mqMessage.getEndTime();
|
| | | Date now = new Date();
|
| | | if (now.after(endTime)) {
|
| | | //timeout;
|
| | | try {
|
| | | mqMessage.printTimeOut();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | // @Scheduled(fixedRate=1000 * 10)
|
| | | // private void configureTasks() {
|
| | | // PriorityBlockingQueue<Runnable> queue = dispenseService.getQueue();
|
| | | // if (queue.isEmpty()) {
|
| | | // return;
|
| | | // }
|
| | | // log.info("queue passiveQueueSize: {}", queue.size());
|
| | | // for (Runnable runnable : queue) {
|
| | | // if (!(runnable instanceof MqMessage)) {
|
| | | // continue;
|
| | | // }
|
| | | // MqMessage mqMessage = (MqMessage) runnable;
|
| | | // Date endTime = mqMessage.getEndTime();
|
| | | // Date now = new Date();
|
| | | // if (now.after(endTime)) {
|
| | | // //timeout;
|
| | | // try {
|
| | | // mqMessage.printTimeOut();
|
| | | // } catch (IOException e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | }
|
| | |
| | | import com.highdatas.mdm.entity.TRole;
|
| | | import com.highdatas.mdm.entity.TUser;
|
| | | import com.highdatas.mdm.entity.TUserGroup;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.http.HttpMethod;
|
| | |
| | |
|
| | | @ConfigurationProperties(prefix = "user")
|
| | | @Component
|
| | | @Slf4j
|
| | | public class UserRoleClient {
|
| | |
|
| | | @Value("${user.url}")
|
| | |
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("userId",userId);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params, MediaType.APPLICATION_JSON);
|
| | | log.info(s);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | | if (StringUtils.isEmpty(sucess) || !Boolean.valueOf(sucess)) {
|
| | | return null;
|
| | | }else {
|
| | | JSONObject data = result.getJSONObject(Constant.Data);
|
| | | data = data.getJSONObject(Constant.userDO);
|
| | | TUser user = JSON.toJavaObject(data, TUser.class);
|
| | | if (user == null){
|
| | | return null;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public List<TUser> listUserRoleGroup() {
|
| | | try {
|
| | | String url = this.url + prefix + "user/listUserRoleGroup";
|
| | | String s = HttpUtils.HttpRestClientByObjectParams(url, HttpMethod.POST, null, null,null,MediaType.APPLICATION_JSON);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | | if (StringUtils.isEmpty(sucess) || !Boolean.valueOf(sucess)) {
|
| | | return null;
|
| | | }
|
| | | JSONArray jsonArray = result.getJSONArray(Constant.Data);
|
| | | List<TUser> tUsers = JSONObject.parseArray(jsonArray.toJSONString(), TUser.class);
|
| | | return tUsers;
|
| | | }catch (Exception e){
|
| | | e.printStackTrace();
|
| | | return null;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | public boolean deleteRoleByGroupId(List<String> roleIds, String groupId) {
|
| | | try {
|
| | |
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | public List<String> getUserListByRole(String roleId) {
|
| | | try {
|
| | | String url = this.url + prefix + "userRole/selectUserMap";
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | | params.put("roleId", roleId);
|
| | | String s = HttpUtils.HttpRestClientByObjectParams(url, HttpMethod.POST, params, null,null,MediaType.APPLICATION_JSON);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | | if (StringUtils.isEmpty(sucess) || !Boolean.valueOf(sucess)) {
|
| | | return null;
|
| | | }
|
| | | List<String> array = result.getObject(Constant.Data, List.class);
|
| | |
|
| | | return array;
|
| | | }catch (Exception e){
|
| | | e.printStackTrace();
|
| | | return null;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.util.pool;
|
| | |
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.highdatas.mdm.service.ISysDispenseConfigService;
|
| | | import com.highdatas.mdm.util.DbUtils;
|
| | | import com.highdatas.mdm.util.HttpUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.http.HttpMethod;
|
| | | import org.springframework.http.MediaType;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import java.util.Map;
|
| | |
|
| | | @ConfigurationProperties(prefix = "mq")
|
| | | @Component
|
| | | public class MqClient {
|
| | |
|
| | | @Value("${mq.url}")
|
| | | String url;
|
| | | @Autowired
|
| | | ISysDispenseConfigService sysDispenseConfigService;
|
| | |
|
| | | String prefix ;
|
| | |
|
| | | private MqClient() {
|
| | | this.prefix = "/api/datacvg/mqProducer/";
|
| | |
|
| | | }
|
| | |
|
| | | public MqResult syncProduce(MqEntity mqEntity) {
|
| | | String url = this.url + prefix + "syncProduce";
|
| | | MqResult mqResult = sendMqEntity(url, mqEntity);
|
| | | return mqResult;
|
| | | }
|
| | |
|
| | | public MqResult oneWayProduce(MqEntity mqEntity) {
|
| | | String url = this.url + prefix + "oneWayProduce";
|
| | | MqResult mqResult = sendMqEntity(url, mqEntity);
|
| | | return mqResult;
|
| | | }
|
| | |
|
| | | public MqResult asyncProduce(MqEntity mqEntity) {
|
| | | String url = this.url + prefix + "asyncProduce";
|
| | | MqResult mqResult = sendMqEntity(url, mqEntity);
|
| | | return mqResult;
|
| | | }
|
| | |
|
| | | private MqResult sendMqEntity(String url, MqEntity mqEntity) {
|
| | | Map<String, Object> dataMap = DbUtils.beanToMap(mqEntity);
|
| | | Object msgBody = dataMap.get("msgBody");
|
| | | String bodyStr = JSONObject.toJSONString(msgBody);
|
| | | dataMap.put("msgBody", bodyStr);
|
| | | dataMap.remove("increment");
|
| | | dataMap.remove("pageSize");
|
| | | dataMap.remove("type");
|
| | | dataMap.remove("userId");
|
| | | dataMap.remove("maintainId");
|
| | | dataMap.remove("pages");
|
| | | dataMap.remove("dataId");
|
| | | dataMap.remove("pageNo");
|
| | | dataMap.remove("msgCode");
|
| | | String s = HttpUtils.HttpRestClientByObjectParams(url, HttpMethod.POST, dataMap,null, null,MediaType.APPLICATION_JSON);
|
| | | MqResult mqResult = JSONObject.parseObject(s, MqResult.class);
|
| | | return mqResult;
|
| | | }
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.util.pool;
|
| | |
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.highdatas.mdm.entity.SysDispenseLogs;
|
| | | import com.highdatas.mdm.util.Constant;
|
| | | import com.highdatas.mdm.util.DbUtils;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | |
|
| | | import java.util.concurrent.atomic.AtomicInteger;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-20 9:58
|
| | | */
|
| | |
|
| | | @Slf4j
|
| | | public class MqEntity {
|
| | |
|
| | | /**
|
| | | * msgTopicName : 消息主题
|
| | | * msgTagName : 消息主题标签
|
| | | * msgKey : 消息key
|
| | | * msgBody : {"moduleName":"模块名称","form":"源系统","to":"目标系统","data":"weodfsdfwefsdfwefwef","total":"数据总量","version":"版本号","timestamp":"时间戳"}
|
| | | */
|
| | |
|
| | | private String msgTopicName;
|
| | | private String msgTagName;
|
| | | private String msgKey;
|
| | | private MsgBodyBean msgBody;
|
| | |
|
| | | private transient String userId;
|
| | | private transient volatile AtomicInteger pageNo;
|
| | | private transient volatile AtomicInteger pageSize;
|
| | | private transient volatile AtomicInteger pages;
|
| | | private transient volatile AtomicInteger totalSize;
|
| | | private transient String type;
|
| | | private transient String dataId;
|
| | | private transient String maintainId;
|
| | | private Boolean increment;
|
| | |
|
| | |
|
| | | public String getMsgCode() {
|
| | | return msgTopicName + msgTagName + msgBody.version;
|
| | | }
|
| | |
|
| | | public AtomicInteger getPageNo() {
|
| | | return pageNo;
|
| | | }
|
| | |
|
| | | public void setPageNo(AtomicInteger pageNo) {
|
| | | this.pageNo = pageNo;
|
| | | }
|
| | |
|
| | | public AtomicInteger getPageSize() {
|
| | | return pageSize;
|
| | | }
|
| | |
|
| | | public void setPageSize(AtomicInteger pageSize) {
|
| | | this.pageSize = pageSize;
|
| | | }
|
| | |
|
| | | public AtomicInteger getPages() {
|
| | | return pages;
|
| | | }
|
| | |
|
| | | public void setPages(AtomicInteger pages) {
|
| | | this.pages = pages;
|
| | | }
|
| | |
|
| | | public String getUserId() {
|
| | | return userId;
|
| | | }
|
| | |
|
| | | public void setUserId(String userId) {
|
| | | this.userId = userId;
|
| | | }
|
| | |
|
| | | public String getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(String type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public String getDataId() {
|
| | | return dataId;
|
| | | }
|
| | |
|
| | | public void setDataId(String dataId) {
|
| | | this.dataId = dataId;
|
| | | }
|
| | |
|
| | | public String getMaintainId() {
|
| | | return maintainId;
|
| | | }
|
| | |
|
| | | public void setMaintainId(String maintainId) {
|
| | | this.maintainId = maintainId;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return DbUtils.StrJoin("消息主题:", msgTopicName, "消息主题标签:" ,msgTagName, "消息key:", msgKey , "time:" + msgBody.timestamp);
|
| | | }
|
| | |
|
| | | public MqEntity() {
|
| | | this.msgBody = new MsgBodyBean();
|
| | | }
|
| | |
|
| | | public String getMsgTopicName() {
|
| | | return msgTopicName;
|
| | | }
|
| | |
|
| | | public void setMsgTopicName(String msgTopicName) {
|
| | | this.msgTopicName = msgTopicName;
|
| | | }
|
| | |
|
| | | public String getMsgTagName() {
|
| | | return msgTagName;
|
| | | }
|
| | |
|
| | | public void setMsgTagName(String msgTagName) {
|
| | | this.msgTagName = msgTagName;
|
| | | }
|
| | |
|
| | | public String getMsgKey() {
|
| | | return msgKey;
|
| | | }
|
| | |
|
| | | public void setMsgKey(String msgKey) {
|
| | | this.msgKey = msgKey;
|
| | | }
|
| | |
|
| | | public MsgBodyBean getMsgBody() {
|
| | | return msgBody;
|
| | | }
|
| | |
|
| | | public void setMsgBody(MsgBodyBean msgBody) {
|
| | | this.msgBody = msgBody;
|
| | | }
|
| | |
|
| | | public void send2Mq() {
|
| | | String s = JSONObject.toJSONString(this);
|
| | | log.info(s);
|
| | | MqResult mqResult = DbUtils.mqClient.asyncProduce(this);
|
| | | SysDispenseLogs logByMqEntity = DbUtils.dispenseLogsService.getLogByMqEntity(this);
|
| | | if (logByMqEntity == null) {
|
| | | return;
|
| | | }
|
| | | String code = mqResult.getCode();
|
| | | logByMqEntity.setPageNo(pageNo.get()).setMsgCode(code);
|
| | | if (!code.equalsIgnoreCase(Constant.SUCCESSCODE)) {
|
| | | logByMqEntity.setStatus("false");
|
| | | }
|
| | | if (code.equalsIgnoreCase(Constant.SUCCESSCODE) && pageNo.get() == pages.get()) {
|
| | | logByMqEntity.setStatus("true");
|
| | | }
|
| | | MqResult.DataBean data = mqResult.getData();
|
| | | if (data != null) {
|
| | | String msgId = data.getMsgId();
|
| | | logByMqEntity.setMsgId(msgId);
|
| | | }
|
| | | logByMqEntity.updateById();
|
| | | }
|
| | |
|
| | | public void setIncrement(Boolean increment) {
|
| | | this.increment = increment;
|
| | | }
|
| | |
|
| | | public Boolean getIncrement() {
|
| | | return increment;
|
| | | }
|
| | |
|
| | | public void setTotalSize(AtomicInteger totalSize) {
|
| | | this.totalSize = totalSize;
|
| | | }
|
| | |
|
| | | public int getTotalSize() {
|
| | | if (totalSize == null) {
|
| | | return 0;
|
| | | } else {
|
| | | return totalSize.get();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | public static class MsgBodyBean {
|
| | | /**
|
| | | * moduleName : 模块名称
|
| | | * form : 源系统
|
| | | * to : 目标系统
|
| | | * data : weodfsdfwefsdfwefwef
|
| | | * total : 数据总量
|
| | | * version : 版本号
|
| | | * timestamp : 时间戳
|
| | | */
|
| | |
|
| | | private String moduleName;
|
| | | private String form;
|
| | | private String to;
|
| | | private String data;
|
| | | private int total;
|
| | | private String version;
|
| | | private String timestamp;
|
| | |
|
| | | public MsgBodyBean() {
|
| | | this.moduleName = Constant.MasterDispense;
|
| | | this.form = Constant.Master;
|
| | | this.timestamp = DbUtils.getNowDateStr();
|
| | | }
|
| | |
|
| | | public String getModuleName() {
|
| | | return moduleName;
|
| | | }
|
| | |
|
| | | public void setModuleName(String moduleName) {
|
| | | this.moduleName = moduleName;
|
| | | }
|
| | |
|
| | | public String getForm() {
|
| | | return form;
|
| | | }
|
| | |
|
| | | public void setForm(String form) {
|
| | | this.form = form;
|
| | | }
|
| | |
|
| | | public String getTo() {
|
| | | return to;
|
| | | }
|
| | |
|
| | | public void setTo(String to) {
|
| | | this.to = to;
|
| | | }
|
| | |
|
| | | public String getData() {
|
| | | return data;
|
| | | }
|
| | |
|
| | | public void setData(String data) {
|
| | | this.data = data;
|
| | | }
|
| | |
|
| | | public int getTotal() {
|
| | | return total;
|
| | | }
|
| | |
|
| | | public void setTotal(int total) {
|
| | | this.total = total;
|
| | | }
|
| | |
|
| | | public String getVersion() {
|
| | | return version;
|
| | | }
|
| | |
|
| | | public void setVersion(String version) {
|
| | | this.version = version;
|
| | | }
|
| | |
|
| | | public String getTimestamp() {
|
| | | return timestamp;
|
| | | }
|
| | |
|
| | | public void setTimestamp(String timestamp) {
|
| | | this.timestamp = timestamp;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | package com.highdatas.mdm.util.pool;
|
| | |
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.highdatas.mdm.pojo.CodeMsg;
|
| | | import com.highdatas.mdm.entity.*;
|
| | | import com.highdatas.mdm.pojo.Page;
|
| | | import com.highdatas.mdm.pojo.Result;
|
| | | import com.highdatas.mdm.util.Constant;
|
| | | import com.highdatas.mdm.util.DbUtils;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.http.MediaType;
|
| | |
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.concurrent.atomic.AtomicInteger;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | |
| | |
|
| | | @Slf4j
|
| | | public class MqMessage extends PriorityTask{
|
| | | public MqMessage(String code, HttpServletResponse response) {
|
| | | super(code,response);
|
| | |
|
| | |
|
| | | public MqMessage(MqEntity mqEntity) {
|
| | | super(mqEntity);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | log.info("mq: {} ---------- run", mqEntity.toString());
|
| | | String type = mqEntity.getType();
|
| | | try {
|
| | | log.info("code {} ---------- run", code);
|
| | | Thread.sleep(1000 * 30 * 1);
|
| | | response.setCharacterEncoding("UTF-8");
|
| | | response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
| | | PrintWriter writer = response.getWriter();
|
| | | writer.write(JSONObject.toJSONString(Result.success(CodeMsg.SUCCESS)));
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | if (type.equalsIgnoreCase(Constant.Master)) {
|
| | | sendMasterData();
|
| | | } else if (type.equalsIgnoreCase(Constant.View)){
|
| | | sendViewData();
|
| | | }
|
| | | }
|
| | | catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | //log
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private void sendMasterData() throws Exception {
|
| | | AtomicInteger pageNo = mqEntity.getPageNo();
|
| | | AtomicInteger pageSize = mqEntity.getPageSize();
|
| | | AtomicInteger pages = mqEntity.getPages();
|
| | | String maintainId = mqEntity.getMaintainId();
|
| | | String userId = mqEntity.getUserId();
|
| | | TUser user = new TUser().setUserId(userId);
|
| | | Maintain maintain = DbUtils.maintainService.selectById(maintainId);
|
| | | long totalCnt = 0;
|
| | |
|
| | | if (pageSize == null) {
|
| | | MasterAuthor masterAuthor = new MasterAuthor().setTableName(maintain.getTableName());
|
| | | Page initPageInfo = DbUtils.masterAuthorService.getInitPageInfo(masterAuthor, maintain, user, mqEntity.getIncrement());
|
| | | pages = new AtomicInteger(initPageInfo.getPages());
|
| | | pageSize = new AtomicInteger(initPageInfo.getPageSize());
|
| | | mqEntity.setTotalSize(new AtomicInteger(Long.valueOf(initPageInfo.getRecordCount()).intValue()));
|
| | | mqEntity.setPages(pages);
|
| | | mqEntity.setPageSize(pageSize);
|
| | | }
|
| | |
|
| | | if (pageNo == null) {
|
| | | pageNo = new AtomicInteger(1);
|
| | | mqEntity.setPageNo(pageNo);
|
| | | for (pageNo.get(); pageNo.get() <= pages.get(); pageNo.addAndGet(1)){
|
| | | sendOneMasterPackage(pageNo, pageSize,totalCnt, maintain, user);
|
| | | }
|
| | | } else {
|
| | | sendOneMasterPackage(pageNo, pageSize, totalCnt, maintain, user);
|
| | | }
|
| | | }
|
| | |
|
| | | private void sendOneMasterPackage(AtomicInteger pageNo, AtomicInteger pageSize, long totalCnt, Maintain maintain, TUser user) throws Exception {
|
| | | Boolean increment = mqEntity.getIncrement();
|
| | | 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());
|
| | | String content;
|
| | | if (increment) {
|
| | | String maintainTableName = maintain.getTableName();
|
| | | String tempTableName = maintainTableName + Constant.RECORD;
|
| | | Page page = new Page(totalCnt);
|
| | | page.setPageSize(mqEntity.getPageSize().get());
|
| | | page.setPageNo(mqEntity.getPageNo().get());
|
| | | List<Map<String, Object>> maps = DbUtils.maintainDetailMapper.selectMaintainDetail(fields, tempTableName, maintain.getId(), filter, page.getLimitSQL());
|
| | | JSONObject object = new JSONObject();
|
| | | object.fluentPut("total", page.getRecordCount());
|
| | | object.fluentPut("size", page.getPageSize());
|
| | | object.fluentPut("pages", page.getPageCount());
|
| | | object.fluentPut("current", page.getPageNo());
|
| | | object.fluentPut("records", maps);
|
| | | content = JSONObject.toJSONString(object);
|
| | | } else {
|
| | | Result result = DbUtils.masterDataService.selectListByPageByVersion(user, maintain.getTableName(), fieldList, filter, pageNo.get(), pageSize.get(), maintain.getVersion(), false);
|
| | | JSONObject data = (JSONObject) result.getData();
|
| | | JSONObject grid = data.getJSONObject("grid");
|
| | | JSONObject object = new JSONObject();
|
| | | object.fluentPut("total", grid.get("total"));
|
| | | object.fluentPut("size", grid.get("size"));
|
| | | object.fluentPut("pages", grid.get("pages"));
|
| | | object.fluentPut("current", grid.get("current"));
|
| | | object.fluentPut("records", grid.get("record"));
|
| | |
|
| | | content = JSONObject.toJSONString(object);
|
| | |
|
| | | }
|
| | | sendMqBody(pageSize.get(), content);
|
| | | }
|
| | |
|
| | | private void sendViewData() throws Exception {
|
| | | //logs
|
| | | String dataId = mqEntity.getDataId();
|
| | | AtomicInteger pageNo = mqEntity.getPageNo();
|
| | | AtomicInteger pageSize = mqEntity.getPageSize();
|
| | | AtomicInteger pages = mqEntity.getPages();
|
| | | SysView sysView = DbUtils.viewService.selectById(dataId);
|
| | | ViewStatus status = sysView.getStatus();
|
| | | if (!ViewStatus.working.equals(status)) {
|
| | | return;
|
| | | }
|
| | | if (pageSize == null) {
|
| | | Page initPageInfo = DbUtils.viewService.getInitPageInfo(sysView.getId());
|
| | | pages = new AtomicInteger(initPageInfo.getPages());
|
| | | pageSize = new AtomicInteger(initPageInfo.getPageSize());
|
| | | mqEntity.setPages(pages);
|
| | | mqEntity.setPageSize(pageSize);
|
| | | mqEntity.setTotalSize(new AtomicInteger(Long.valueOf(initPageInfo.getRecordCount()).intValue()));
|
| | | }
|
| | | if (pageNo == null) {
|
| | | //主动
|
| | | pageNo =new AtomicInteger(1);
|
| | | mqEntity.setPageNo(pageNo);
|
| | | for (pageNo.get(); pageNo.get() <= pages.get(); pageNo.addAndGet(1)) {
|
| | | sendOneViewPackage(pageNo, pageSize, sysView);
|
| | | }
|
| | |
|
| | | } else {
|
| | | //被动
|
| | | sendOneViewPackage(pageNo, pageSize, sysView);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private void sendOneViewPackage(AtomicInteger pageNo, AtomicInteger pageSize, SysView sysView) throws Exception {
|
| | | Result viewData = DbUtils.viewService.getViewData(sysView, pageNo.get(), pageSize.get());
|
| | | JSONObject object = (JSONObject) viewData.getData();
|
| | | String content = JSONObject.toJSONString(object);
|
| | | sendMqBody(pageSize.get(), content);
|
| | | }
|
| | |
|
| | | private void sendMqBody(Integer pageSize, String content) throws Exception {
|
| | | byte[] bytes = content.getBytes("UTF-8");
|
| | | String size = (bytes.length / 1024) + "k";
|
| | | log.info(size);
|
| | | Date now = new Date();
|
| | |
|
| | | // String mqBody = com.datacvg.common.AESUtil.getInstance().encoder(content, mqEntity.getUserId(),"http://180.169.94.250:9107");
|
| | | String mqBody = content;
|
| | | bytes = mqBody.getBytes("UTF-8");
|
| | | size = (bytes.length / 1024) + "k";
|
| | | log.info(size);
|
| | | Date after = new Date();
|
| | | long l = after.getTime() - now.getTime();
|
| | | log.info("time:"+l);
|
| | | // String mqBody = content;
|
| | | MqEntity.MsgBodyBean msgBody = mqEntity.getMsgBody();
|
| | | msgBody.setData(mqBody);
|
| | | msgBody.setTotal(pageSize);
|
| | | mqEntity.setMsgBody(msgBody);
|
| | | Thread.sleep(1000 * 60 * 3);
|
| | | mqEntity.send2Mq();
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.util.pool;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-21 9:49
|
| | | */
|
| | |
|
| | |
|
| | | public class MqResult {
|
| | |
|
| | | /**
|
| | | * code : 200
|
| | | * msg : 消息发送成功
|
| | | * data : {"sendStatus":"SEND_OK","msgId":"C0A804C303E118B4AAC25FB7E22F0002","messageQueue":{"topic":"DATA","brokerName":"BryantdeMacBook-Pro.local","queueId":2},"queueOffset":2,"transactionId":null,"offsetMsgId":"C0A804C300002A9F000000000002CB0E","regionId":"DefaultRegion","traceOn":true}
|
| | | */
|
| | |
|
| | | private String code;
|
| | | private String msg;
|
| | | private DataBean data;
|
| | |
|
| | | public String getCode() {
|
| | | return code;
|
| | | }
|
| | |
|
| | | public void setCode(String code) {
|
| | | this.code = code;
|
| | | }
|
| | |
|
| | | public String getMsg() {
|
| | | return msg;
|
| | | }
|
| | |
|
| | | public void setMsg(String msg) {
|
| | | this.msg = msg;
|
| | | }
|
| | |
|
| | | public DataBean getData() {
|
| | | return data;
|
| | | }
|
| | |
|
| | | public void setData(DataBean data) {
|
| | | this.data = data;
|
| | | }
|
| | |
|
| | | public static class DataBean {
|
| | | /**
|
| | | * sendStatus : SEND_OK
|
| | | * msgId : C0A804C303E118B4AAC25FB7E22F0002
|
| | | * messageQueue : {"topic":"DATA","brokerName":"BryantdeMacBook-Pro.local","queueId":2}
|
| | | * queueOffset : 2
|
| | | * transactionId : null
|
| | | * offsetMsgId : C0A804C300002A9F000000000002CB0E
|
| | | * regionId : DefaultRegion
|
| | | * traceOn : true
|
| | | */
|
| | |
|
| | | private String sendStatus;
|
| | | private String msgId;
|
| | | private MessageQueueBean messageQueue;
|
| | | private int queueOffset;
|
| | | private Object transactionId;
|
| | | private String offsetMsgId;
|
| | | private String regionId;
|
| | | private boolean traceOn;
|
| | |
|
| | | public String getSendStatus() {
|
| | | return sendStatus;
|
| | | }
|
| | |
|
| | | public void setSendStatus(String sendStatus) {
|
| | | this.sendStatus = sendStatus;
|
| | | }
|
| | |
|
| | | public String getMsgId() {
|
| | | return msgId;
|
| | | }
|
| | |
|
| | | public void setMsgId(String msgId) {
|
| | | this.msgId = msgId;
|
| | | }
|
| | |
|
| | | public MessageQueueBean getMessageQueue() {
|
| | | return messageQueue;
|
| | | }
|
| | |
|
| | | public void setMessageQueue(MessageQueueBean messageQueue) {
|
| | | this.messageQueue = messageQueue;
|
| | | }
|
| | |
|
| | | public int getQueueOffset() {
|
| | | return queueOffset;
|
| | | }
|
| | |
|
| | | public void setQueueOffset(int queueOffset) {
|
| | | this.queueOffset = queueOffset;
|
| | | }
|
| | |
|
| | | public Object getTransactionId() {
|
| | | return transactionId;
|
| | | }
|
| | |
|
| | | public void setTransactionId(Object transactionId) {
|
| | | this.transactionId = transactionId;
|
| | | }
|
| | |
|
| | | public String getOffsetMsgId() {
|
| | | return offsetMsgId;
|
| | | }
|
| | |
|
| | | public void setOffsetMsgId(String offsetMsgId) {
|
| | | this.offsetMsgId = offsetMsgId;
|
| | | }
|
| | |
|
| | | public String getRegionId() {
|
| | | return regionId;
|
| | | }
|
| | |
|
| | | public void setRegionId(String regionId) {
|
| | | this.regionId = regionId;
|
| | | }
|
| | |
|
| | | public boolean isTraceOn() {
|
| | | return traceOn;
|
| | | }
|
| | |
|
| | | public void setTraceOn(boolean traceOn) {
|
| | | this.traceOn = traceOn;
|
| | | }
|
| | |
|
| | | public static class MessageQueueBean {
|
| | | /**
|
| | | * topic : DATA
|
| | | * brokerName : BryantdeMacBook-Pro.local
|
| | | * queueId : 2
|
| | | */
|
| | |
|
| | | private String topic;
|
| | | private String brokerName;
|
| | | private int queueId;
|
| | |
|
| | | public String getTopic() {
|
| | | return topic;
|
| | | }
|
| | |
|
| | | public void setTopic(String topic) {
|
| | | this.topic = topic;
|
| | | }
|
| | |
|
| | | public String getBrokerName() {
|
| | | return brokerName;
|
| | | }
|
| | |
|
| | | public void setBrokerName(String brokerName) {
|
| | | this.brokerName = brokerName;
|
| | | }
|
| | |
|
| | | public int getQueueId() {
|
| | | return queueId;
|
| | | }
|
| | |
|
| | | public void setQueueId(int queueId) {
|
| | | this.queueId = queueId;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | package com.highdatas.mdm.util.pool;
|
| | |
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.highdatas.mdm.pojo.CodeMsg;
|
| | | import com.highdatas.mdm.pojo.Result;
|
| | | import com.highdatas.mdm.util.Constant;
|
| | | import com.highdatas.mdm.util.DbUtils;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.http.MediaType;
|
| | |
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.util.Date;
|
| | |
|
| | | /**
|
| | |
| | | @Value("${pool.timeout}")
|
| | | Integer timeout;
|
| | | protected Long prority;
|
| | | protected String code;
|
| | | protected volatile MqEntity mqEntity;
|
| | | protected int cnt;
|
| | | protected Date time;
|
| | | protected Date endTime;
|
| | | protected HttpServletResponse response;
|
| | |
|
| | | public PriorityTask(String code, HttpServletResponse response, int cnt, Date time) {
|
| | | this.code = code;
|
| | | this.response = response;
|
| | | public MqEntity getMqEntity() {
|
| | | return mqEntity;
|
| | | }
|
| | |
|
| | | public PriorityTask(MqEntity mqEntity, int cnt, Date time) {
|
| | | this.mqEntity = mqEntity;
|
| | | calPrority();
|
| | | calEndTime();
|
| | | }
|
| | |
|
| | | public PriorityTask(String code, HttpServletResponse response) {
|
| | | this.code = code;
|
| | | this.response = response;
|
| | | public PriorityTask(MqEntity mqEntity) {
|
| | | this.mqEntity = mqEntity;
|
| | | }
|
| | |
|
| | | public void calEndTime() {
|
| | |
| | | this.prority = basePrority;
|
| | | }
|
| | |
|
| | | public String getCode() {
|
| | | return code;
|
| | | }
|
| | |
|
| | | public int getCnt() {
|
| | | return cnt;
|
| | |
| | | return time;
|
| | | }
|
| | |
|
| | | public HttpServletResponse getResponse() {
|
| | | return response;
|
| | | }
|
| | |
|
| | | public PriorityTask(String code, long prority, HttpServletResponse response) {
|
| | | public PriorityTask(MqEntity mqEntity, long prority) {
|
| | | this.prority = prority;
|
| | | this.code = code;
|
| | | this.response = response;
|
| | | this.mqEntity = mqEntity;
|
| | | }
|
| | |
|
| | | public void setCnt(int cnt) {
|
| | |
| | | this.time = time;
|
| | | calPrority();
|
| | | calEndTime();
|
| | | }
|
| | |
|
| | | public void setResponse(HttpServletResponse response) {
|
| | | this.response = response;
|
| | | }
|
| | |
|
| | | public long getPrority() {
|
| | |
| | | return prority.compareTo(o.getPrority());
|
| | | }
|
| | |
|
| | | public void printTimeOut() throws IOException {
|
| | | PrintWriter writer = response.getWriter();
|
| | | response.setCharacterEncoding("UTF-8");
|
| | | response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
| | | writer.write(JSONObject.toJSONString(Result.error(CodeMsg.TIMOUT_ERROR)));
|
| | | }
|
| | |
|
| | | public void printRepeat() throws IOException {
|
| | | PrintWriter writer = response.getWriter();
|
| | | response.setCharacterEncoding("UTF-8");
|
| | | response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
| | | writer.write(JSONObject.toJSONString(Result.error(CodeMsg.REPEAT_ERROR)));
|
| | | }
|
| | | }
|
| | |
| | | |
| | | user: |
| | | url: http://180.169.94.250:9107 |
| | | mq: |
| | | url: http://180.169.94.250:9107 |
| | | |
| | | rule: |
| | | url: http://180.169.94.250:9107 |
| | |
| | | |
| | | user: |
| | | url: http://127.0.0.1:9107 |
| | | mq: |
| | | url: http://127.0.0.1:9107 |
| | | |
| | | rule: |
| | | url: http://127.0.0.1:9107 |
| | |
| | | pool: |
| | | coresize: 5 |
| | | coefficient: 20 |
| | | timeout: 3000000 |
| | |
| | | redis: |
| | | url: http://180.169.94.250:9107 |
| | | |
| | | mq: |
| | | url: http://180.169.94.250:9107 |
| | | |
| | | rule: |
| | | url: http://180.169.94.250:9107 |
| | | |
| | |
| | | bigdata: |
| | | db:hbase? |
| | | |
| | | |
| | | pool: |
| | | coresize: 5 |
| | | coefficient: 20 |
| | | timeout: 3000000 |
| | |
| | | spring: |
| | | profiles: |
| | | active: |
| | | dev |
| | | pro |
| | | |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | |
| | | update maintain_detail set deal = 0 |
| | | where parent_id = #{maintainFieldId} |
| | | </update> |
| | | |
| | | <select id="selectMaintainDetail" resultType="java.util.Map"> |
| | | select * from ( |
| | | select ${fields}, maintain_detail.operate from maintain_detail |
| | | LEFT JOIN ${tempTableName} a on a.id = maintain_detail.pre_merge_id |
| | | where maintain_detail.parent_id = #{maintainId} |
| | | ) b where ${where} ${limit} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.highdatas.mdm.mapper.MasterAuthorMapper">
|
| | |
|
| | | <!-- 通用查询映射结果 -->
|
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.MasterAuthor">
|
| | | <id column="id" property="id" />
|
| | | <result column="type" property="type" />
|
| | | <result column="table_name" property="tableName" />
|
| | | <result column="active" property="active" />
|
| | | <result column="create_time" property="createTime" />
|
| | | <result column="update_time" property="updateTime" />
|
| | | </resultMap>
|
| | |
|
| | | <select id="selectAuthorUserCnt" resultType="java.util.Map" statementType="STATEMENT">
|
| | | SELECT count(character_id) as cnt, character_id as user_id from master_author WHERE type = 'user' and user_group = 0 and active = 1 GROUP BY character_id
|
| | | </select>
|
| | |
|
| | | <select id="selectViewCnt" resultType="java.util.Map" statementType="STATEMENT">
|
| | | SELECT count(user_id) as cnt, user_id as user_id from sys_view WHERE active = 1 GROUP BY user_id
|
| | | </select>
|
| | | </mapper>
|
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.highdatas.mdm.mapper.SysViewMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.SysView"> |
| | | <id column="id" property="id" /> |
| | | <result column="code" property="code" /> |
| | | <result column="name" property="name" /> |
| | | <result column="base_maintain" property="baseMaintain" /> |
| | | <result column="fields" property="fields" /> |
| | | <result column="mapping_table" property="mappingTable" /> |
| | | <result column="user_id" property="userId" /> |
| | | </resultMap> |
| | | |
| | | <insert id="insertViewMapping"> |
| | | insert into ${tableName} (code, pre, fix) |
| | | VALUES (${values}) |
| | | </insert> |
| | | |
| | | <select id="selectMapVal" resultType="java.util.Map" statementType="STATEMENT" > |
| | | select a.pre,b.fix from (select DISTINCT ${field} from ${tableName} where ${where}) a |
| | | LEFT JOIN ${mapTableName} b on b.pre = a.pre where b.code = ${changeField} |
| | | </select> |
| | | </mapper> |
| | |
| | | </select> |
| | | |
| | | <select id="getTableField" parameterType="String" resultType="com.highdatas.mdm.entity.TableSchemaResult"> |
| | | select COLUMN_NAME as fieldName,DATA_TYPE as dbType from information_schema.COLUMNS where table_name = #{tableName} and table_schema = (select database()) |
| | | select COLUMN_NAME as fieldName,DATA_TYPE as dbType, character_maximum_length as length from information_schema.COLUMNS where table_name = #{tableName} and table_schema = (select database()) |
| | | </select> |
| | | |
| | | <select id="getTableFieldFromDb" parameterType="com.highdatas.mdm.entity.TableSchema" resultType="com.highdatas.mdm.entity.TableSchemaResult"> |
| | | select COLUMN_NAME as fieldName,DATA_TYPE as dbType from information_schema.COLUMNS where table_name = #{tableName} and table_schema = #{dbName} |
| | | select COLUMN_NAME as fieldName,DATA_TYPE as dbType,character_maximum_length as length from information_schema.COLUMNS where table_name = #{tableName} and table_schema = #{dbName} |
| | | </select> |
| | | |
| | | <select id="selectByPage" resultType="java.util.Map" statementType="STATEMENT" > |
| | | select ${fields} from ${tableName} where ${where} ${limit} |
| | | </select> |
| | | |
| | | <select id="selectDistinct" resultType="java.util.Map" statementType="STATEMENT" > |
| | | select DISTINCT ${fields} from ${tableName} where ${where} |
| | | </select> |
| | | |
| | | <select id="selectByPageByVersion" resultType="java.util.Map" statementType="STATEMENT" > |
| | |
| | | INSERT INTO ${tableName} (${fields}) VALUES ${values} |
| | | </insert> |
| | | |
| | | <insert id="insertOneSelect" statementType="STATEMENT" > |
| | | INSERT INTO ${tableName} (${fields}) |
| | | select ${selectFields} from (${selectSql}) a |
| | | </insert> |
| | | |
| | | <update id="update"> |
| | | update ${tableName} set ${updateSegment} |
| | | where ${where} |
| | | </update> |
| | | |
| | | <update id="updateJoin"> |
| | | update ${tableName} |
| | | ${joinTableSegment} |
| | | set ${updateSegment} |
| | | where ${where} |
| | | </update> |
| | | |
| | | <delete id="delete"> |
| | | DELETE FROM ${tableName} where ${where} |
| | | </delete> |
| | |
| | | <select id="findById" parameterType="String" resultType="com.highdatas.mdm.entity.User"> |
| | | select * from user where user_id = #{value} |
| | | </select> |
| | | |
| | | <select id="test" parameterType="String" resultType="java.util.Map"> |
| | | select * from md_khxxcssj_copy1 |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | package com.highdatas.mdm.service.impl;
|
| | |
|
| | | class MasterAuthorServiceImplTest {
|
| | |
|
| | | } |