| | |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | <version>5.1.46</version> |
| | | <version>6.0.6</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| | |
| | | <artifactId>druid</artifactId> |
| | | <version>1.1.10</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>druid-spring-boot-starter</artifactId> |
| | | <version>1.1.9</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | |
| | | <artifactId>sqlite-jdbc</artifactId> |
| | | <version>3.7.2</version> |
| | | </dependency> |
| | | <!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik-gvt --> |
| | | <dependency> |
| | | <groupId>org.apache.xmlgraphics</groupId> |
| | | <artifactId>batik-gvt</artifactId> |
| | | <version>1.7</version> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | ITUserService userService; |
| | | |
| | | @Autowired |
| | | IMasterModifiedService masterModifiedService; |
| | | |
| | |
| | | maintain.updateById(); |
| | | return Result.success(flows.getId()); |
| | | }else if (type.equals(ActivitiBusinessType.exists)) { |
| | | HashMap<String, String> body=new HashMap(); |
| | | HashMap<String, Object> body=new HashMap(); |
| | | NextTaskUserInfo nestTaskAssignee = taskService.getNestTaskAssignee(flows.getWorkflowId()); |
| | | |
| | | body.put("activitiId", flows.getId()); |
| | | if (nestTaskAssignee == null) { |
| | | body.put("roleId", null); |
| | | body.put("userId", null); |
| | | body.put("roleIdList", null); |
| | | body.put("userIdList", null); |
| | | } else { |
| | | body.put("roleId", nestTaskAssignee.getRoleId()); |
| | | body.put("userId", nestTaskAssignee.getUserId()); |
| | | body.put("roleIdList", nestTaskAssignee.getRoleIdList()); |
| | | body.put("userIdList", nestTaskAssignee.getUserIdList()); |
| | | } |
| | | return Result.success(body); |
| | | } |
| | |
| | | HashMap<String, Object> one = new HashMap<>(); |
| | | String workflowId = historicProcessInstance.getId(); |
| | | String startUserId = historicProcessInstance.getStartUserId(); |
| | | TUser user = userService.selectById(startUserId); |
| | | 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()); |
| | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", result); |
| | |
| | | } |
| | | 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) { |
| | |
| | | nextTaskDefinition = taskService.getNestTaskAssignee(workflowId); |
| | | |
| | | } |
| | | HashMap<String, String> body=new HashMap(); |
| | | HashMap<String, Object> body=new HashMap(); |
| | | if (flows.getBusinessType().equals(ActivitiBusinessType.exists)){ |
| | | body.put("status", flows.getStatus().name()); |
| | | if (nextTaskDefinition == null) { |
| | | body.put("roleId", null); |
| | | body.put("userId", null); |
| | | body.put("roleIdList", null); |
| | | body.put("userIdList", null); |
| | | } else { |
| | | body.put("roleId", nextTaskDefinition.getRoleId()); |
| | | body.put("userId", nextTaskDefinition.getUserId()); |
| | | body.put("roleIdList", nextTaskDefinition.getRoleIdList()); |
| | | body.put("userIdList", nextTaskDefinition.getUserIdList()); |
| | | } |
| | | } |
| | | |
| | |
| | | @RequestMapping(value = "new", method = RequestMethod.GET)
|
| | | public Result delete(HttpServletRequest request) {
|
| | | SysAssemble assemble = new SysAssemble();
|
| | | TUser user = (TUser) request.getSession().getAttribute(Constant.USER);
|
| | | TUser user = DbUtils.getUser(request);
|
| | | assemble.setStatus(SysAssembleStatus.edit).setCreateTime(new Date()).setUserId(user.getUserId()).setUpdateType(SysAssembleUpdateType.All);
|
| | | boolean insert = assemble.setId(DbUtils.getUUID()).setEmptyData(true).insert();
|
| | | if (insert) {
|
| | |
| | | assemble.setUpdateType(updateType).setUpdateFields(updateFields);
|
| | | assemble.setEmptyData(false);
|
| | | assemble.setBigdata(Boolean.valueOf(bigData));
|
| | | TUser user = (TUser) request.getSession().getAttribute(Constant.USER);
|
| | | TUser user = DbUtils.getUser(request);
|
| | | boolean insert = assemble.setUserId(user.getUserId()).setMenuId(menuId).setUpdateTime(new Date()).updateById();
|
| | |
|
| | | if (insert) {
|
New file |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.DispenseService; |
| | | import com.highdatas.mdm.service.MasterDataService; |
| | | 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.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 javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2019-12-31 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/dispense") |
| | | public class DispenseController { |
| | | @Autowired |
| | | DispenseService dispenseService; |
| | | @Autowired |
| | | RedisClient redisClient; |
| | | @Autowired |
| | | MasterDataService masterDataService; |
| | | |
| | | @RequestMapping(value = "/add", method = RequestMethod.GET) |
| | | public void getAll(@RequestParam String code, HttpServletResponse response) { |
| | | dispenseService.pushPassiveMq(new MqMessage( code, response)); |
| | | } |
| | | @RequestMapping(value = "/test", method = RequestMethod.GET) |
| | | public String test(@RequestParam String tableName, HttpServletRequest request) { |
| | | TUser user = DbUtils.getUser(request); |
| | | List<String> size = new ArrayList<>(); |
| | | String s = masterDataService.selectByVersionSql(user, tableName, size, Constant.WHERE_DEFAULT, "V1.0", false); |
| | | return s; |
| | | } |
| | | |
| | | @RequestMapping(value = "/login", method = RequestMethod.GET) |
| | | public Result login(HttpServletRequest request) { |
| | | TUser user = DbUtils.getUser(request); |
| | | String token = DbUtils.getUUID(32); |
| | | boolean b = redisClient.putRedisVal(user.getId(), token); |
| | | if (b) { |
| | | return Result.success(token); |
| | | }else { |
| | | return Result.success(CodeMsg.ERROR_SAVE_TOKEN); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.highdatas.mdm.entity.Flows; |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.IFlowsService; |
| | | import com.highdatas.mdm.service.ITUserService; |
| | | import com.sun.tools.javac.jvm.Code; |
| | | import org.activiti.engine.HistoryService; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.activiti.engine.RuntimeService; |
| | | import org.activiti.engine.runtime.ProcessInstance; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class FlowsController { |
| | | @Autowired |
| | | IFlowsService flowsService; |
| | | @Autowired |
| | | ITUserService userService; |
| | | |
| | | @Autowired |
| | | RuntimeService runtimeService; |
| | | @RequestMapping(value = "/{pageno}", method = RequestMethod.GET) |
| | |
| | | Page page = new Page(pageno, size); |
| | | Page<Flows> menuPage = flowsService.selectPage(page, flowsEntityWrapper); |
| | | List<Flows> records = menuPage.getRecords(); |
| | | List<Flows> recordsStr = records.stream().map(flows -> flows.setBusinessTypeStr(flows.getBusinessType().toString()).setUserName(userService.selectById(flows.getUserId()).getUserName())).collect(Collectors.toList()); |
| | | List<Flows> recordsStr = new ArrayList<>(); |
| | | for (Flows flows : records) { |
| | | flows.setBusinessTypeStr(flows.getBusinessType().toString()); |
| | | TUser userById = DbUtils.getUserById(flows.getUserId()); |
| | | flows.setUserName(userById.getUserName()); |
| | | recordsStr.add(flows); |
| | | } |
| | | menuPage.setRecords(recordsStr); |
| | | return Result.success(menuPage); |
| | | } |
| | |
| | | public class MaintainController { |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | ITUserService userService; |
| | | |
| | | @Autowired |
| | | IMaintainDetailService maintainDetailService; |
| | | @Autowired |
| | |
| | | |
| | | @RequestMapping(value = "/version/{tableName}", method = RequestMethod.GET) |
| | | public Result getHistory(@PathVariable String tableName, HttpServletRequest request) { |
| | | TUser user = (TUser) request.getSession().getAttribute("user"); |
| | | TUser user = DbUtils.getUser(request); |
| | | String userId = user.getUserId(); |
| | | |
| | | Maintain maxVersion = maintainService.getMaxVersion(tableName); |
| | |
| | | if (StringUtils.isEmpty(flowId)) { |
| | | continue; |
| | | } |
| | | boolean author = masterAuthorService.checkMaintainAuthor(userId, maintain.getId()); |
| | | boolean author = masterAuthorService.checkMaintainAuthor(user, maintain.getId()); |
| | | if (!author) { |
| | | continue; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | String chargeId = record.getChargeId(); |
| | | TUser user = userService.selectOne(new EntityWrapper<TUser>().eq("user_id", chargeId)); |
| | | TUser user = DbUtils.getUserById(chargeId); |
| | | if (user == null) { |
| | | record.setChargeId("用户已删除"); |
| | | }else { |
| | | record.setChargeId(user.getUserName()); |
| | | } |
| | | |
| | | resultObj.add(record); |
| | | } |
| | | result.setRecords(resultObj); |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/get/{characterId}", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String characterId, @RequestParam MasterAuthorType type, HttpServletRequest request){ |
| | | List<MasterAuthor> masterAuthorList = authorService.selectList(new EntityWrapper<MasterAuthor>().eq("type", type.name()).eq("character_id", characterId)); |
| | | 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); |
| | | }else if (type.equals(MasterAuthorType.user) && masterAuthorList.isEmpty()){ |
| | | //user 获取角色 多脚色混合 |
| | | String userId = characterId; |
| | | List<TUserRole> tUserRoles = userRoleService.selectList(new EntityWrapper<TUserRole>().eq(Constant.USERID, userId)); |
| | | List<String> roleIdList = tUserRoles.stream().map(tUserRole -> tUserRole.getRoleId()).collect(Collectors.toList()); |
| | | HashMap<String, MasterAuthor> tableMasterAuthor = authorService.merageRoleAuthor(roleIdList); |
| | | Set<String> roleIdSet; |
| | | if (isGroup) { |
| | | roleIdSet = DbUtils.getRoleByGroup(userId); |
| | | } else { |
| | | roleIdSet = DbUtils.getRoleByUser(userId); |
| | | } |
| | | if (roleIdSet.isEmpty()) { |
| | | return Result.success(null); |
| | | } |
| | | HashMap<String, MasterAuthor> tableMasterAuthor = authorService.merageRoleAuthor(roleIdSet); |
| | | if (tableMasterAuthor == null) { |
| | | Result.success(null); |
| | | } |
| | |
| | | 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) { |
| | | return Result.success(object); |
| | | } |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | object.fluentPut("audit",sysMenus); |
| | | return Result.success(object); |
| | |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("type", type); |
| | | object.fluentPut("author",masterAuthorList); |
| | | |
| | | 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) { |
| | | return Result.success(object); |
| | | } |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | |
| | | object.fluentPut("type", MasterAuthorType.user); |
| | | object.fluentPut("author",masterAuthorList); |
| | | object.fluentPut("audit",sysMenus); |
| | | return Result.success(object); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/addRole/{roleId}", method = RequestMethod.GET) |
| | | public Result addRole(@PathVariable String roleId, HttpServletRequest request){ |
| | | @RequestMapping(value = "/groupAddRole/{roleId}", method = RequestMethod.GET) |
| | | public Result addGroupRole(@PathVariable String roleId, @RequestParam String groupId, HttpServletRequest request){ |
| | | TUser user = DbUtils.getUser(request); |
| | | String userId = user.getUserId(); |
| | | List<TUserRole> tUserRoles = userRoleService.selectList(new EntityWrapper<TUserRole>().eq(Constant.USERID, userId)); |
| | | List<String> roleIdList = tUserRoles.stream().map(tUserRole -> tUserRole.getRoleId()).collect(Collectors.toList()); |
| | | roleIdList.add(roleId); |
| | | if (user == null){ |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | ArrayList<String> addRoleList = new ArrayList<>(); |
| | | Set<String> roleIdSet = DbUtils.getRoleByGroup(groupId); |
| | | addRoleList.addAll(roleIdSet); |
| | | addRoleList.add(roleId); |
| | | boolean b = DbUtils.groupAddOneRole(user.getUserId(),groupId, addRoleList); |
| | | if (!b) { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } |
| | | |
| | | HashMap<String, MasterAuthor> tableMasterAuthor = authorService.merageRoleAuthor(roleIdList); |
| | | roleIdSet.add(roleId); |
| | | |
| | | HashMap<String, MasterAuthor> tableMasterAuthor = authorService.merageRoleAuthor(roleIdSet); |
| | | if (tableMasterAuthor == null) { |
| | | Result.success(null); |
| | | } |
| | | return Result.success(tableMasterAuthor.values()); |
| | | } |
| | | |
| | | @RequestMapping(value = "/userAddRole/{roleId}", method = RequestMethod.GET) |
| | | public Result addRole(@PathVariable String roleId, @RequestParam String userId, HttpServletRequest request){ |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null){ |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | ArrayList<String> addRoleList = new ArrayList<>(); |
| | | Set<String> roleIdSet = DbUtils.getRoleByUser(userId); |
| | | addRoleList.addAll(roleIdSet); |
| | | addRoleList.add(roleId); |
| | | boolean b = DbUtils.addOneRole(user, addRoleList); |
| | | if (!b) { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } |
| | | |
| | | roleIdSet.add(roleId); |
| | | |
| | | HashMap<String, MasterAuthor> tableMasterAuthor = authorService.merageRoleAuthor(roleIdSet); |
| | | if (tableMasterAuthor == null) { |
| | | Result.success(null); |
| | | } |
| | | return Result.success(tableMasterAuthor.values()); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/userDelRole/{roleId}", method = RequestMethod.GET) |
| | | public Result delRole(@PathVariable String roleId, @RequestParam String userId, HttpServletRequest request){ |
| | | ArrayList<String> delRoleList = new ArrayList<>(); |
| | | |
| | | delRoleList.add(roleId); |
| | | boolean b = DbUtils.delOneRole(userId, delRoleList); |
| | | if (!b) { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } |
| | | |
| | | Set<String> roleIdSet = DbUtils.getRoleByUser(userId); |
| | | HashMap<String, MasterAuthor> tableMasterAuthor = authorService.merageRoleAuthor(roleIdSet); |
| | | if (tableMasterAuthor == null) { |
| | | Result.success(null); |
| | | } |
| | | return Result.success(tableMasterAuthor.values()); |
| | | } |
| | | |
| | | @RequestMapping(value = "/groupDelRole/{roleId}", method = RequestMethod.GET) |
| | | public Result delGroupRole(@PathVariable String roleId, @RequestParam String groupId, HttpServletRequest request){ |
| | | ArrayList<String> delRoleList = new ArrayList<>(); |
| | | |
| | | delRoleList.add(roleId); |
| | | boolean b = DbUtils.groupDelOneRole(groupId, delRoleList); |
| | | if (!b) { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } |
| | | |
| | | Set<String> roleIdSet = DbUtils.getRoleByGroup(groupId); |
| | | HashMap<String, MasterAuthor> tableMasterAuthor = authorService.merageRoleAuthor(roleIdSet); |
| | | if (tableMasterAuthor == null) { |
| | | Result.success(null); |
| | | } |
| | | return Result.success(tableMasterAuthor.values()); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.highdatas.mdm.entity.MasterAuthor; |
| | | import com.highdatas.mdm.entity.MasterAuthorDetail; |
| | | import com.highdatas.mdm.entity.SysField; |
| | | import com.highdatas.mdm.entity.TUserRole; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | import com.highdatas.mdm.pojo.Result; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | @RequestMapping(value = "/getFieldByMaintainFieldId/{id}", method = RequestMethod.GET) |
| | | public Result getFieldByMaintainFieldId(@PathVariable String id, @RequestParam MasterAuthorType type, @RequestParam String characterId, HttpServletRequest request) { |
| | | public Result getFieldByMaintainFieldId(@PathVariable String id, @RequestParam boolean isGroup, @RequestParam MasterAuthorType type, @RequestParam String characterId, HttpServletRequest request) { |
| | | List<SysField> result; |
| | | |
| | | String menuId = request.getParameter("menuId"); |
| | |
| | | JSONObject resultObj = new JSONObject(); |
| | | MasterAuthor masterAuthor = masterAuthorService.selectOne(new EntityWrapper<MasterAuthor>() |
| | | .eq(Constant.TYPE, type) |
| | | .eq("user_group", isGroup) |
| | | .eq("table_name", tableName) |
| | | .eq("character_id", characterId) |
| | | .eq("maintain_field_id", id)); |
| | | |
| | | if (masterAuthor == null && type.equals(MasterAuthorType.user)) { |
| | | List<TUserRole> tUserRoles = userRoleService.selectList(new EntityWrapper<TUserRole>().eq(Constant.USERID, characterId)); |
| | | List<String> roleIdList = tUserRoles.stream().map(tUserRole -> tUserRole.getRoleId()).collect(Collectors.toList()); |
| | | HashMap<String, MasterAuthor> tableMasterAuthor = masterAuthorService.merageRoleAuthor(roleIdList); |
| | | Set<String> roleIdSet; |
| | | if (isGroup) { |
| | | roleIdSet = DbUtils.getRoleByGroup(characterId); |
| | | } else { |
| | | roleIdSet = DbUtils.getRoleByUser(characterId); |
| | | } |
| | | if (roleIdSet == null || roleIdSet.isEmpty()) { |
| | | masterAuthor = null; |
| | | } else { |
| | | HashMap<String, MasterAuthor> tableMasterAuthor = masterAuthorService.merageRoleAuthor(roleIdSet); |
| | | String key = DbUtils.getFieldRedisKey(tableName, id); |
| | | masterAuthor = tableMasterAuthor.get(key); |
| | | } |
| | | } |
| | | |
| | | if (masterAuthor == null) { |
| | | |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Operate; |
| | |
| | | uploadType = SysAssembleUpdateType.Increment; |
| | | } |
| | | uploadType = SysAssembleUpdateType.valueOf(uploadTypeStr); |
| | | TUser user = (TUser) request.getSession().getAttribute(Constant.USER); |
| | | TUser user = DbUtils.getUser(request); |
| | | Maintain maintain = masterDataService.uploadedData(tableName, uploadType, user.getUserId()); |
| | | // 处理关联人 |
| | | masterModifiedService.dealAssemble(maintain.getId(), user.getUserId(), true); |
| | |
| | | |
| | | @RequestMapping(value = "{tableName}/all/{pageNo}", method = RequestMethod.GET) |
| | | public Result getByPage(@PathVariable String tableName, @PathVariable Integer pageNo, HttpServletRequest request) throws UnsupportedEncodingException { |
| | | TUser user = DbUtils.getUser(request); |
| | | Character character = DbUtils.getCharacter(request); |
| | | |
| | | String pageSizeStr = request.getParameter("pageSize"); |
| | | String whereSegment = request.getParameter(Constant.WHERE_SEGMENT); |
| | | String fields = request.getParameter(Constant.FIELDS); |
| | |
| | | return null; |
| | | } |
| | | //ADD Filter |
| | | String filter = masterAuthorService.getFilter(user.getUserId(), maintainFromVersion.getId()); |
| | | String filter = masterAuthorService.getFilter(character, maintainFromVersion.getId()); |
| | | if (!StringUtils.isEmpty(filter)) { |
| | | whereSegment = DbUtils.StrJoin(whereSegment, Constant.AND, filter); |
| | | } |
| | |
| | | |
| | | if (StringUtils.isEmpty(fields)) { |
| | | if (StringUtils.isEmpty(pageSizeStr)) { |
| | | return masterDataService.selectListByPageByVersion(user, tableName, whereSegment,pageNo,version, findMax); |
| | | return masterDataService.selectListByPageByVersion(character, tableName, whereSegment,pageNo,version, findMax); |
| | | } |
| | | return masterDataService.selectListByPageByVersion(user, tableName, null, whereSegment,pageNo, Integer.valueOf(pageSizeStr),version,findMax); |
| | | return masterDataService.selectListByPageByVersion(character, tableName, null, whereSegment,pageNo, Integer.valueOf(pageSizeStr),version,findMax); |
| | | }else { |
| | | String[] split = fields.split(Constant.COMMA_TRIM); |
| | | List<String> fieldList = Arrays.stream(split).collect(Collectors.toList()); |
| | | if (StringUtils.isEmpty(pageSizeStr)) { |
| | | return masterDataService.selectListByPageByVersion(user, tableName, fieldList, whereSegment,pageNo, null,version, findMax); |
| | | return masterDataService.selectListByPageByVersion(character, tableName, fieldList, whereSegment,pageNo, null,version, findMax); |
| | | } |
| | | return masterDataService.selectListByPageByVersion(user, tableName, fieldList, whereSegment,pageNo, Integer.valueOf(pageSizeStr), findMax); |
| | | return masterDataService.selectListByPageByVersion(character, tableName, fieldList, whereSegment,pageNo, Integer.valueOf(pageSizeStr), findMax); |
| | | |
| | | } |
| | | } |
| | |
| | | String[] split = modify.split(Constant.SEMICOLON); |
| | | modifyFields = Arrays.stream(split).collect(Collectors.toList()); |
| | | } |
| | | TUser user = (TUser) request.getSession().getAttribute("user"); |
| | | TUser user = DbUtils.getUser(request); |
| | | |
| | | switch (operate) { |
| | | case delete: |
| | |
| | | public Result insert(@PathVariable String tableName,@PathVariable String operateStr, @RequestParam String datas, @RequestParam String modify, HttpServletRequest request) { |
| | | String fields = request.getParameter("fields"); |
| | | Operate operate = Operate.parse(operateStr); |
| | | TUser user = (TUser) request.getSession().getAttribute("user"); |
| | | TUser user = DbUtils.getUser(request); |
| | | String userId = user.getUserId(); |
| | | Maintain maintain = maintainService.getMaxVersion(tableName); |
| | | Maintain nowMaintain = maintainService.getNextMaintain(tableName, userId); |
| | |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.ISysBusinessOperateService; |
| | | import com.highdatas.mdm.service.ITUserService; |
| | | import com.highdatas.mdm.service.act.RepositoryService; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | |
| | | @Autowired |
| | | RepositoryService repositoryService; |
| | | |
| | | @Autowired |
| | | ITUserService userService; |
| | | |
| | | @RequestMapping(value = "delete/{id}", method = RequestMethod.GET) |
| | | public Result delete(@PathVariable String id, HttpServletRequest request) { |
| | | boolean delete = businessOperateService.deleteById(id); |
| | |
| | | |
| | | @RequestMapping(value = "/add", method = RequestMethod.GET) |
| | | public Result add(HttpServletRequest request) { |
| | | TUser user = (TUser) request.getSession().getAttribute(Constant.USER); |
| | | TUser user = DbUtils.getUser(request); |
| | | |
| | | String modelId = request.getParameter("modelId"); |
| | | String businessType = request.getParameter("businessType"); |
| | |
| | | if (StringUtils.isEmpty(id)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | TUser user = (TUser) request.getSession().getAttribute(Constant.USER); |
| | | TUser user = DbUtils.getUser(request); |
| | | |
| | | String modelId = request.getParameter("modelId"); |
| | | |
| | |
| | | if (StringUtils.isEmpty(chageId)) { |
| | | continue; |
| | | } |
| | | TUser user = userService.selectById(chageId); |
| | | TUser user = DbUtils.getUserById(chageId); |
| | | if (user == null) { |
| | | continue; |
| | | } |
| | |
| | | import com.fasterxml.jackson.databind.DeserializationFeature; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.mapper.SysFieldMapper; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | |
| | | |
| | | @RequestMapping(value = "/{tableName}", method = RequestMethod.GET) |
| | | public Result getFields(@PathVariable String tableName, HttpServletRequest request){ |
| | | TUser user = DbUtils.getUser(request); |
| | | Character character = DbUtils.getCharacter(request); |
| | | String maintainId = request.getParameter("maintainId"); |
| | | if (StringUtils.isEmpty(maintainId)) { |
| | | List<SysField> fieldList = fieldService.getFieldByTable(tableName); |
| | | return Result.success(fieldList); |
| | | }else { |
| | | List<SysField> field = masterAuthorService.getField(user.getUserId(), maintainId); |
| | | List<SysField> field = masterAuthorService.getField(character, maintainId); |
| | | //List<SysField> fieldList = fieldService.getFieldByMaintain(maintainId); |
| | | |
| | | return Result.success(field); |
| | |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | TUser user = DbUtils.getUser(request); |
| | | List<SysField> field = masterAuthorService.getField(user.getUserId(), maintainId); |
| | | List<SysField> field = masterAuthorService.getField(user, maintainId); |
| | | Integer size; |
| | | if(StringUtils.isEmpty(pageSize)){ |
| | | size = 15; |
| | |
| | | @RequestMapping(value = "/author/all", method = RequestMethod.GET) |
| | | public Result<List<SysMenu>> getAllBak(HttpServletRequest request) { |
| | | TUser user = DbUtils.getUser(request); |
| | | List<SysMenu> menu = masterAuthorService.getMenu(user.getUserId()); |
| | | List<SysMenu> menu = masterAuthorService.getMenu(user); |
| | | return Result.success(menu) ; |
| | | } |
| | | |
| | |
| | | } |
| | | tableNameSet.add(tableName); |
| | | } |
| | | maintainIds = maintainIds.stream().filter(s -> masterAuthorService.checkMaintainAuthor(userId,s)).collect(Collectors.toList()); |
| | | maintainIds = maintainIds.stream().filter(s -> masterAuthorService.checkMaintainAuthor(user,s)).collect(Collectors.toList()); |
| | | if (!maintainIds.isEmpty()) { |
| | | List<Maintain> maintains = maintainService.selectBatchIds(maintainIds); |
| | | |
New file |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/sysSubscribe") |
| | | public class SysSubscribeController { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/sysView") |
| | | public class SysViewController { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/sysViewJoin") |
| | | public class SysViewJoinController { |
| | | |
| | | } |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.ITUserService; |
New file |
| | |
| | | package com.highdatas.mdm.entity;
|
| | |
|
| | | import com.highdatas.mdm.pojo.MasterAuthorType;
|
| | |
|
| | | public interface Character {
|
| | | String getId();
|
| | | MasterAuthorType getType();
|
| | | }
|
| | |
| | | @TableField("field_auto") |
| | | private Boolean fieldAuto; |
| | | |
| | | @TableField("is_group") |
| | | private Boolean isGroup; |
| | | @TableField("user_group") |
| | | private Boolean userGroup; |
| | | |
| | | @TableField("maintain_auto") |
| | | private Boolean maintainAuto; |
| | |
| | | |
| | | private transient List<MasterAuthorDetail> fields; |
| | | |
| | | public Boolean getGroup() { |
| | | return isGroup; |
| | | public Boolean getUserGroup() { |
| | | return userGroup; |
| | | } |
| | | |
| | | public MasterAuthor setGroup(Boolean group) { |
| | | isGroup = group; |
| | | public MasterAuthor setUserGroup(Boolean userGroup) { |
| | | this.userGroup = userGroup; |
| | | return this; |
| | | } |
| | | |
| | |
| | | ", url=" + url + |
| | | ", headers=" + headers + |
| | | ", pagination=" + pagination + |
| | | ", size=" + size + |
| | | ", passiveQueueSize=" + 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-15 |
| | | */ |
| | | @TableName("sys_subscribe") |
| | | public class SysSubscribe extends Model<SysSubscribe> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | private String type; |
| | | |
| | | @TableField("maintain_id") |
| | | private String maintainId; |
| | | |
| | | @TableField("table_name") |
| | | private String tableName; |
| | | |
| | | @TableField("user_id") |
| | | private String userId; |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public SysSubscribe setId(String id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public SysSubscribe setType(String type) { |
| | | this.type = type; |
| | | return this; |
| | | } |
| | | public String getMaintainId() { |
| | | return maintainId; |
| | | } |
| | | |
| | | public SysSubscribe setMaintainId(String maintainId) { |
| | | this.maintainId = maintainId; |
| | | return this; |
| | | } |
| | | public String getTableName() { |
| | | return tableName; |
| | | } |
| | | |
| | | public SysSubscribe setTableName(String tableName) { |
| | | this.tableName = tableName; |
| | | return this; |
| | | } |
| | | public String getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public SysSubscribe setUserId(String userId) { |
| | | this.userId = userId; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SysSubscribe{" + |
| | | "id=" + id + |
| | | ", type=" + type + |
| | | ", maintainId=" + maintainId + |
| | | ", tableName=" + tableName + |
| | | ", 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-15 |
| | | */ |
| | | @TableName("sys_view") |
| | | public class SysView extends Model<SysView> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | private String code; |
| | | |
| | | private String name; |
| | | |
| | | @TableField("base_maintain") |
| | | private String baseMaintain; |
| | | |
| | | private String fields; |
| | | |
| | | @TableField("mapping_table") |
| | | private String mappingTable; |
| | | |
| | | @TableField("user_id") |
| | | private String userId; |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public SysView setId(String id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public SysView setCode(String code) { |
| | | this.code = code; |
| | | return this; |
| | | } |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public SysView setName(String name) { |
| | | this.name = name; |
| | | return this; |
| | | } |
| | | public String getBaseMaintain() { |
| | | return baseMaintain; |
| | | } |
| | | |
| | | public SysView setBaseMaintain(String baseMaintain) { |
| | | this.baseMaintain = baseMaintain; |
| | | return this; |
| | | } |
| | | public String getFields() { |
| | | return fields; |
| | | } |
| | | |
| | | public SysView setFields(String fields) { |
| | | this.fields = fields; |
| | | return this; |
| | | } |
| | | public String getMappingTable() { |
| | | return mappingTable; |
| | | } |
| | | |
| | | public SysView setMappingTable(String mappingTable) { |
| | | this.mappingTable = mappingTable; |
| | | return this; |
| | | } |
| | | public String getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public SysView setUserId(String userId) { |
| | | this.userId = userId; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SysView{" + |
| | | "id=" + id + |
| | | ", code=" + code + |
| | | ", name=" + name + |
| | | ", baseMaintain=" + baseMaintain + |
| | | ", fields=" + fields + |
| | | ", mappingTable=" + mappingTable + |
| | | ", 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-15 |
| | | */ |
| | | @TableName("sys_view_join") |
| | | public class SysViewJoin extends Model<SysViewJoin> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | @TableField("view_id") |
| | | private String viewId; |
| | | |
| | | @TableField("join_maintain") |
| | | private String joinMaintain; |
| | | |
| | | @TableField("join_segment") |
| | | private String joinSegment; |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public SysViewJoin setId(String id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | public String getViewId() { |
| | | return viewId; |
| | | } |
| | | |
| | | public SysViewJoin setViewId(String viewId) { |
| | | this.viewId = viewId; |
| | | return this; |
| | | } |
| | | public String getJoinMaintain() { |
| | | return joinMaintain; |
| | | } |
| | | |
| | | public SysViewJoin setJoinMaintain(String joinMaintain) { |
| | | this.joinMaintain = joinMaintain; |
| | | return this; |
| | | } |
| | | public String getJoinSegment() { |
| | | return joinSegment; |
| | | } |
| | | |
| | | public SysViewJoin setJoinSegment(String joinSegment) { |
| | | this.joinSegment = joinSegment; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SysViewJoin{" + |
| | | "id=" + id + |
| | | ", viewId=" + viewId + |
| | | ", joinMaintain=" + joinMaintain + |
| | | ", joinSegment=" + joinSegment + |
| | | "}"; |
| | | } |
| | | } |
| | |
| | | package com.highdatas.mdm.entity; |
| | | |
| | | import java.util.Date; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2019-12-31 |
| | | */ |
| | | @TableName("t_role") |
| | | public class TRole extends Model<TRole> { |
| | | public class TRole extends Model<TRole> implements Character{ |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | |
| | | ", updateTime=" + updateTime + |
| | | "}"; |
| | | } |
| | | |
| | | @Override |
| | | public String getId() { |
| | | return getRoleId(); |
| | | } |
| | | |
| | | @Override |
| | | public MasterAuthorType getType() { |
| | | return MasterAuthorType.role; |
| | | } |
| | | } |
| | |
| | | package com.highdatas.mdm.entity; |
| | | |
| | | import java.util.Date; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2019-12-31 |
| | | */ |
| | | @TableName("t_user") |
| | | public class TUser extends Model<TUser> { |
| | | public class TUser extends Model<TUser> implements Character{ |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | |
| | | ", updateTime=" + updateTime + |
| | | "}"; |
| | | } |
| | | |
| | | @Override |
| | | public String getId() { |
| | | return getUserId(); |
| | | } |
| | | |
| | | @Override |
| | | public MasterAuthorType getType() { |
| | | return MasterAuthorType.user; |
| | | } |
| | | } |
| | |
| | | package com.highdatas.mdm.entity;
|
| | |
|
| | | import com.highdatas.mdm.pojo.MasterAuthorType;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | |
| | | */
|
| | |
|
| | |
|
| | | public class TUserGroup {
|
| | | public class TUserGroup implements Character{
|
| | |
|
| | | private String groupId;
|
| | | private String groupName;
|
| | |
| | | this.groupDesc = groupDesc;
|
| | | return this;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String getId() {
|
| | | return groupId;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public MasterAuthorType getType() {
|
| | | return MasterAuthorType.groupInfo;
|
| | | }
|
| | | }
|
| | |
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.http.*;
|
| | | import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
| | | import org.springframework.http.converter.StringHttpMessageConverter;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.util.LinkedMultiValueMap;
|
| | | import org.springframework.util.MultiValueMap;
|
| | | import org.springframework.util.StringUtils;
|
| | | import org.springframework.web.client.RestTemplate;
|
| | |
|
| | | import java.nio.charset.StandardCharsets;
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | @Slf4j
|
| | |
| | | }
|
| | | public boolean login() {
|
| | | String url = this.url + prefix + "login";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("userName","mdmadmin");
|
| | | params.set("password","datacvg123");
|
| | | params.set("ifRemember","false");
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("userName","mdmadmin");
|
| | | params.put("password","datacvg123");
|
| | | params.put("ifRemember","false");
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
|
| | |
| | | public boolean saveJobGroup() {
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/saveJobGroup";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("appName","MDMApp");
|
| | | params.set("order", "1");
|
| | | params.set("title","数据汇集定时任务执行器");
|
| | | params.set("modelId","MDM");
|
| | | params.set("addressType","1");
|
| | | params.set("addressList",local);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("appName","MDMApp");
|
| | | params.put("order", "1");
|
| | | params.put("title","数据汇集定时任务执行器");
|
| | | params.put("modelId","MDM");
|
| | | params.put("addressType","1");
|
| | | params.put("addressList",local);
|
| | | String s = null;
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | |
| | | public boolean removeJobGroup() {
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/saveJobGroup";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelid","MDM");
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelid","MDM");
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
|
| | |
| | | try {
|
| | | String jobId = createJobId(assemble.getId());
|
| | | String url = this.url + prefix + "xxlcustapi/addJob";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelId","MDM");
|
| | | params.set("modelJobId", jobId);
|
| | | params.set("jobCron",assemble.getCron());
|
| | | params.set("author",assemble.getUserId());
|
| | | params.set("executorHandler","assembleJob");
|
| | | params.set("executorParam",assemble.getId());
|
| | | params.set("cronGen_display",assemble.getCron());
|
| | | params.set("executorBlockStrategy","DISCARD_LATER");
|
| | | params.set("executorTimeout","0");
|
| | | params.set("executorFailRetryCount","3");
|
| | | params.set("triggerStatus","1");
|
| | | params.set("glueType","BEAN");
|
| | | params.set("executorRouteStrategy","FIRST");
|
| | | params.set("jobDesc","创建汇集job");
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelId","MDM");
|
| | | params.put("modelJobId", jobId);
|
| | | params.put("jobCron",assemble.getCron());
|
| | | params.put("author",assemble.getUserId());
|
| | | params.put("executorHandler","assembleJob");
|
| | | params.put("executorParam",assemble.getId());
|
| | | params.put("cronGen_display",assemble.getCron());
|
| | | params.put("executorBlockStrategy","DISCARD_LATER");
|
| | | params.put("executorTimeout","0");
|
| | | params.put("executorFailRetryCount","3");
|
| | | params.put("triggerStatus","1");
|
| | | params.put("glueType","BEAN");
|
| | | params.put("executorRouteStrategy","FIRST");
|
| | | params.put("jobDesc","创建汇集job");
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
|
| | |
| | | public boolean updateJob(SysAssemble assemble) {
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/updateJob";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelId","MDM");
|
| | | params.set("modelJobId",assemble.getJobId());
|
| | | params.set("jobCron",assemble.getCron());
|
| | | params.set("author",assemble.getUserId());
|
| | | params.set("executorHandler","assembleJob");
|
| | | params.set("executorParam",assemble.getId());
|
| | | params.set("cronGen_display",assemble.getCron());
|
| | | params.set("executorBlockStrategy","DISCARD_LATER");
|
| | | params.set("executorTimeout","0");
|
| | | params.set("executorFailRetryCount","3");
|
| | | params.set("triggerStatus","1");
|
| | | params.set("glueType","BEAN");
|
| | | params.set("executorRouteStrategy","FIRST");
|
| | | params.set("jobDesc","更新汇集job");
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelId","MDM");
|
| | | params.put("modelJobId",assemble.getJobId());
|
| | | params.put("jobCron",assemble.getCron());
|
| | | params.put("author",assemble.getUserId());
|
| | | params.put("executorHandler","assembleJob");
|
| | | params.put("executorParam",assemble.getId());
|
| | | params.put("cronGen_display",assemble.getCron());
|
| | | params.put("executorBlockStrategy","DISCARD_LATER");
|
| | | params.put("executorTimeout","0");
|
| | | params.put("executorFailRetryCount","3");
|
| | | params.put("triggerStatus","1");
|
| | | params.put("glueType","BEAN");
|
| | | params.put("executorRouteStrategy","FIRST");
|
| | | params.put("jobDesc","更新汇集job");
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
|
| | |
| | |
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/removeJob";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelId","MDM");
|
| | | params.set("modelJobId", jobId);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelId","MDM");
|
| | | params.put("modelJobId", jobId);
|
| | |
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | |
| | | }
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/queryJobLogById";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelId","MDM");
|
| | | params.set("modelJobId", assemble.getJobId());
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelId","MDM");
|
| | | params.put("modelJobId", assemble.getJobId());
|
| | |
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | |
| | | }
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/trigger";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelId","MDM");
|
| | | params.set("modelJobId", assemble.getJobId());
|
| | | params.set("executorParam", assemble.getId());
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelId","MDM");
|
| | | params.put("modelJobId", assemble.getJobId());
|
| | | params.put("executorParam", assemble.getId());
|
| | |
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | |
| | | }
|
| | |
|
| | |
|
| | | private String HttpRestClient(String url, HttpMethod method, MultiValueMap<String, String> formParams, String getParams, MediaType mediaType) {
|
| | | private String HttpRestClient(String url, HttpMethod method, Map<String, String> formParams, String getParams, MediaType mediaType) {
|
| | | if (!StringUtils.isEmpty(getParams)) {
|
| | | url = url + Constant.QUESTION + getParams;
|
| | | }
|
| | |
| | | headers.setContentType(mediaType);
|
| | | }
|
| | |
|
| | | HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(formParams, headers);
|
| | | HttpEntity<Map<String, String>> requestEntity = new HttpEntity<Map<String, String>>(formParams, headers);
|
| | | // 执行HTTP请求
|
| | | ResponseEntity<String> response = client.exchange(url, method, requestEntity, String.class);
|
| | |
|
New file |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.SysSubscribe; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | public interface SysSubscribeMapper extends BaseMapper<SysSubscribe> { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.SysViewJoin; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | public interface SysViewJoinMapper extends BaseMapper<SysViewJoin> { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.SysView; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | public interface SysViewMapper extends BaseMapper<SysView> { |
| | | |
| | | } |
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.SysSubscribeMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.SysSubscribe"> |
| | | <id column="id" property="id" /> |
| | | <result column="type" property="type" /> |
| | | <result column="maintain_id" property="maintainId" /> |
| | | <result column="table_name" property="tableName" /> |
| | | <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.SysViewJoinMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.SysViewJoin"> |
| | | <id column="id" property="id" /> |
| | | <result column="view_id" property="viewId" /> |
| | | <result column="join_maintain" property="joinMaintain" /> |
| | | <result column="join_segment" property="joinSegment" /> |
| | | </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.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> |
| | | |
| | | </mapper> |
| | |
| | | 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 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 CodeMsg(int code, String msg) { |
| | | this.code = code; |
| | |
| | |
|
| | |
|
| | | public enum MasterAuthorType {
|
| | | role,user
|
| | | role,user,groupInfo
|
| | | }
|
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author kimi |
| | | * @description |
| | |
| | | |
| | | @Data |
| | | public class NextTaskUserInfo { |
| | | String userId; |
| | | String roleId; |
| | | List<String> userIdList; |
| | | List<String> roleIdList; |
| | | public void addUserList(Collection userList) { |
| | | if (userIdList == null) { |
| | | userIdList = new ArrayList<>(); |
| | | } |
| | | userIdList.addAll(userList); |
| | | } |
| | | |
| | | public void addRoleList(Collection roleList) { |
| | | if (this.roleIdList == null) { |
| | | this.roleIdList = new ArrayList<>(); |
| | | } |
| | | this.roleIdList.addAll(roleList); |
| | | } |
| | | |
| | | public void addOneUser(String userId) { |
| | | if (userIdList == null) { |
| | | userIdList = new ArrayList<>(); |
| | | } |
| | | userIdList.add(userId); |
| | | } |
| | | |
| | | public void addOneRole(String roleId) { |
| | | if (roleIdList== null) { |
| | | roleIdList= new ArrayList<>(); |
| | | } |
| | | roleIdList.add(roleId); |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service;
|
| | |
|
| | | import com.highdatas.mdm.util.pool.MqMessage;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import java.util.concurrent.PriorityBlockingQueue;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-14 12:53
|
| | | */
|
| | |
|
| | | @Service
|
| | | public interface DispenseService {
|
| | |
|
| | | boolean pushActiveMq(MqMessage message);
|
| | |
|
| | | boolean pushPassiveMq(MqMessage message);
|
| | |
|
| | | PriorityBlockingQueue<Runnable> getQueue();
|
| | |
|
| | | Integer passiveQueueSize();
|
| | |
|
| | | Integer avtiveQueueSize();
|
| | | }
|
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.MasterAuthor; |
| | | import com.highdatas.mdm.entity.SysField; |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.entity.Character; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface IMasterAuthorService extends IService<MasterAuthor> { |
| | | |
| | | HashMap<String, MasterAuthor> merageRoleAuthor(List<String> roleIds); |
| | | HashMap<String, MasterAuthor> merageRoleAuthor(Set<String> roleIds); |
| | | |
| | | List<SysMenu> getMenu(String userId); |
| | | List<SysMenu> getMenu(Character character); |
| | | |
| | | List<MasterAuthor> getOneGroupAuthors(String groupId, MaintainField maintainField); |
| | | |
| | | List<SysField> getField(String userId, String maintainId); |
| | | List<SysField> getField(Character character, String maintainId); |
| | | |
| | | boolean checkMaintainAuthor(String userId, String maintainId); |
| | | boolean checkMaintainAuthor(Character character, String maintainId); |
| | | |
| | | String getFilter(String userId, String maintainId); |
| | | String getFilter(Character character, String maintainId); |
| | | |
| | | Maintain getMaxVersionMaintain(String userId, String tableName); |
| | | Maintain getMaxVersionMaintain(Character character, String tableName); |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.SysSubscribe; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | public interface ISysSubscribeService extends IService<SysSubscribe> { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.SysViewJoin; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | public interface ISysViewJoinService extends IService<SysViewJoin> { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.SysView; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | public interface ISysViewService extends IService<SysView> { |
| | | |
| | | } |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.pojo.SysAssembleUpdateType; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author kimi |
| | | * @description |
| | |
| | | |
| | | Result selectById(String tableName, String id); |
| | | |
| | | Result selectList(TUser user, String tableName); |
| | | Result selectList(Character character, String tableName); |
| | | |
| | | Result selectList(TUser user, String tableName, String whereSegment); |
| | | Result selectList(TUser user, String tableName, String whereSegment, String version); |
| | | Result selectList(Character character, String tableName, String whereSegment); |
| | | Result selectList(Character character, String tableName, String whereSegment, String version); |
| | | |
| | | Result selectList(TUser user, String tableName, List<String> fieldList, String whereSegment); |
| | | Result selectList(TUser user, String tableName, List<String> fieldList, String whereSegment,String version); |
| | | Result selectList(Character character, String tableName, List<String> fieldList, String whereSegment); |
| | | Result selectList(Character character, String tableName, List<String> fieldList, String whereSegment,String version); |
| | | |
| | | Result selectList(TUser user, String tableName, List<String> fields); |
| | | Result selectList(Character character, String tableName, List<String> fields); |
| | | |
| | | Long getCountByVersion(TUser user, String maintainId, String tableName, String tableTempName, Integer fromOrderNo, Integer toOrderNo, String whereSegment); |
| | | Long getCountByVersion(Character character, String maintainId, String tableName, String tableTempName, Integer fromOrderNo, Integer toOrderNo, String whereSegment); |
| | | |
| | | String getFields(String tableName); |
| | | String getFields(TUser user, String tableName, Maintain maintain); |
| | | String getFields(Character character, String tableName, Maintain maintain); |
| | | |
| | | String getFields(String tableName, String alias); |
| | | String getFields(TUser user, String tableName, String alias, Maintain maintain); |
| | | String getFields(Character character, String tableName, String alias, Maintain maintain); |
| | | |
| | | String getTempFields(TUser user, String tableName, Maintain maintain); |
| | | String getTempFields(TUser user, String tableName); |
| | | String getTempFields(Character character, String tableName, Maintain maintain); |
| | | String getTempFields(Character character, String tableName); |
| | | |
| | | String getTempFields(TUser user, String tableName, String alias); |
| | | String getTempFields(TUser user, String tableName, String alias, Maintain maintain); |
| | | String getTempFields(Character character, String tableName, String alias); |
| | | String getTempFields(Character character, String tableName, String alias, Maintain maintain); |
| | | |
| | | Result selectListByPageByVersion(TUser user, String tableName, Integer pageNo, Integer pageSize, boolean findMax); |
| | | Result selectListByPageByVersion(Character character, String tableName, Integer pageNo, Integer pageSize, boolean findMax); |
| | | |
| | | Result selectListByPageByVersion(TUser user, String tableName, String whereSegment, Integer pageNo, boolean findMax); |
| | | Result selectListByPageByVersion(Character character, String tableName, String whereSegment, Integer pageNo, boolean findMax); |
| | | |
| | | Result selectListByPageByVersion(TUser user, String tableName, Integer pageNo, String version, boolean findMax); |
| | | Result selectListByPageByVersion(Character character, String tableName, Integer pageNo, String version, boolean findMax); |
| | | |
| | | Result selectListByPageByVersion(TUser user, String tableName, Integer pageNo, boolean findMax); |
| | | Result selectListByPageByVersion(Character character, String tableName, Integer pageNo, boolean findMax); |
| | | |
| | | Result selectListByPageByVersion(TUser user, String tableName, String whereSegment, Integer pageno, Integer pageSize, boolean findMax); |
| | | Result selectListByPageByVersion(Character character, String tableName, String whereSegment, Integer pageno, Integer pageSize, boolean findMax); |
| | | |
| | | Result selectListByPageByVersion(TUser user, String tableName, List<String> fieldList, String whereSegment, Integer pageNo, boolean findMax); |
| | | Result selectListByPageByVersion(Character character, String tableName, List<String> fieldList, String whereSegment, Integer pageNo, boolean findMax); |
| | | |
| | | Result selectListByPageByVersion(TUser user, String tableName, List<String> fieldList, Integer pageNo, boolean findMax); |
| | | Result selectListByPageByVersion(Character character, String tableName, List<String> fieldList, Integer pageNo, boolean findMax); |
| | | |
| | | Result selectListByPageByVersion(TUser user, String tableName, List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, boolean findMax); |
| | | Result selectListByPageByVersion(Character character, String tableName, List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, boolean findMax); |
| | | |
| | | Result insert(String tableName, String fields, String jsonValues); |
| | | Result insert(String tableName, String json); |
| | |
| | | |
| | | Result delete(String tableName, String whereSegment); |
| | | |
| | | Result selectListByPageByVersion(TUser user, String tableName, String whereSegment, Integer pageNo, String version, boolean findMax); |
| | | Result selectListByPageByVersion(Character character, String tableName, String whereSegment, Integer pageNo, String version, boolean findMax); |
| | | |
| | | List<Map<String, Object>> selectListByVersion(TUser user, String tableName, List<String> fieldList, String whereSegment, String version, boolean findMax); |
| | | List<Map<String, Object>> selectListByVersion(Character character, String tableName, List<String> fieldList, String whereSegment, String version, boolean findMax); |
| | | |
| | | Result selectListByPageByVersion(TUser user, String tableName, List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, String version, boolean findMax); |
| | | String selectByVersionSql(Character character, String tableName, List<String> fieldList, 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); |
| | | Maintain uploadedData(String tableName, SysAssembleUpdateType uploadType, String userId, boolean bigVersion); |
| | |
| | | import com.fasterxml.jackson.databind.node.ObjectNode; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.MultiValueMap; |
| | | |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public interface ModelEditorService { |
| | | public ObjectNode getEditorJson(String modelId); |
| | | |
| | | public Result saveModel(String modelId, MultiValueMap<String, String> values); |
| | | public Result saveModel(String modelId, Map<String, String> values); |
| | | |
| | | public String getStencilset(); |
| | | |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author kimi |
| | |
| | | |
| | | Result deleteRole(String id); |
| | | Result deleteUserRole(String roleId, String userId); |
| | | |
| | | List<String> getRoleByUser(String userId); |
| | | } |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class IdentityServiceImpl extends BaseServiceImpl implements com.highdatas.mdm.service.act.IdentityService{ |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getRoleByUser(String userId) { |
| | | List<Group> list = identityService.createGroupQuery().groupMember(userId).list(); |
| | | if (list == null || list.isEmpty()) { |
| | | return null; |
| | | } |
| | | return list.stream().map(group -> group.getId()).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | } |
| | | public String claimTask(String workflowId) { |
| | | Task task = getTask(workflowId); |
| | | |
| | | if (task == null) { |
| | | return null; |
| | | } |
| | | TUser onlineUser = getOnlineUser(); |
| | | //resultPool = serviceCaller.getResultPool(); |
| | | |
| | | if (onlineUser == null) { |
| | | return null; |
| | | } |
| | | try { |
| | | taskService.claim(task.getId(), onlineUser.getUserId()); |
| | | //resultPool.setMessage("Task is claimed"); |
| | |
| | | |
| | | @Override |
| | | public NextTaskUserInfo getNestTaskAssignee(String workflowId) { |
| | | //TODO 需修改 |
| | | NextTaskUserInfo nextTaskUserInfo = new NextTaskUserInfo(); |
| | | Task nextTask = geTask(workflowId); |
| | | if (nextTask == null) { |
| | |
| | | } |
| | | String nextTaskAssignee = nextTask.getAssignee(); |
| | | if (!StringUtils.isEmpty(nextTaskAssignee)) { |
| | | nextTaskUserInfo.setUserId(nextTaskAssignee); |
| | | nextTaskUserInfo.setRoleId("R001"); |
| | | nextTaskUserInfo.addOneUser(nextTaskAssignee); |
| | | return nextTaskUserInfo; |
| | | } |
| | | |
| | | String processDefinitionId=nextTask.getProcessDefinitionId(); // 获取流程定义id |
| | | |
| | | ProcessDefinitionEntity processDefinitionEntity= (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinitionId); |
| | |
| | | TaskDefinition taskDef = (TaskDefinition)activityImpl.getProperties().get("taskDefinition"); |
| | | Set<Expression> userCodes = taskDef.getCandidateUserIdExpressions();//候选人 |
| | | Set<Expression> roleCodes = taskDef.getCandidateGroupIdExpressions();//候选组 |
| | | if (roleCodes.size() != 0) { |
| | | String roleId = roleCodes.stream().map(expression -> expression.getExpressionText()).findFirst().get(); |
| | | nextTaskUserInfo.setRoleId(roleId); |
| | | 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); |
| | | } |
| | | return nextTaskUserInfo; |
| | | } |
| | |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.service.act.*; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | IFlowsService flowsService; |
| | | |
| | | @Autowired |
| | | ITUserService userService; |
| | | |
| | | @Autowired |
| | | HistoryService historyService; |
| | |
| | | |
| | | for (Flows flow : records) { |
| | | String userId = flow.getUserId(); |
| | | TUser user = userService.selectOne(new EntityWrapper<TUser>().eq("user_id", userId)); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | continue; |
| | | } |
| | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", maps); |
New file |
| | |
| | | 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.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.stereotype.Service;
|
| | |
|
| | | import javax.annotation.PostConstruct;
|
| | | import java.util.Date;
|
| | | import java.util.concurrent.*;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-14 12:58
|
| | | */
|
| | |
|
| | | @Service
|
| | | @Slf4j
|
| | | public class DispenseServiceImpl implements DispenseService {
|
| | | @Autowired
|
| | | MasterDataService masterDataService;
|
| | | @Value("${pool.coresize}")
|
| | | private Integer coreSize;
|
| | | private ExecutorService executorService;
|
| | | private PriorityBlockingQueue<Runnable> queue;
|
| | | private LinkedBlockingQueue activeQueue;
|
| | | private ThreadPoolExecutor activeExecutorService;
|
| | |
|
| | | @PostConstruct
|
| | | public void init() {
|
| | | if (coreSize == null && coreSize == 0) {
|
| | | //IO密集型 设置默认 cpu数量 预留 主动和被动两组线程池
|
| | | coreSize = Double.valueOf(Runtime.getRuntime().availableProcessors()).intValue();
|
| | | }
|
| | | 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());
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean pushActiveMq(MqMessage message) {
|
| | | try{
|
| | | activeExecutorService.execute(message);
|
| | | return true;
|
| | | }catch (Exception e) {
|
| | | log.error(e.getMessage());
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean pushPassiveMq(MqMessage message) {
|
| | | try{
|
| | | MqMessage preMsg = null;
|
| | | for (Runnable runnable : queue) {
|
| | | if (!(runnable instanceof MqMessage)) {
|
| | | continue;
|
| | | }
|
| | | MqMessage mqMessage = (MqMessage) runnable;
|
| | | String code = mqMessage.getCode();
|
| | | if (StringUtils.isEmpty(code)){
|
| | | continue;
|
| | | }
|
| | | if (code.equalsIgnoreCase(message.getCode())) {
|
| | | preMsg = (MqMessage) runnable;
|
| | | }
|
| | | }
|
| | | if (preMsg != null) {
|
| | | int cnt = preMsg.getCnt();
|
| | | preMsg.setCnt(cnt + 1);
|
| | | message.printRepeat();
|
| | | }else {
|
| | | message.setTime(new Date());
|
| | | message.setCnt(0);
|
| | | }
|
| | | executorService.execute(message);
|
| | | return true;
|
| | | }catch (Exception e) {
|
| | | log.error(e.getMessage());
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public PriorityBlockingQueue<Runnable> getQueue() {
|
| | | return queue;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Integer passiveQueueSize() {
|
| | | return queue.size();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Integer avtiveQueueSize() {
|
| | | return activeQueue.size();
|
| | | }
|
| | |
|
| | | private void createView(Maintain baseMaintain) {
|
| | | String maintainTableName = baseMaintain.getTableName();
|
| | | String version = baseMaintain.getVersion();
|
| | |
|
| | | }
|
| | | }
|
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.entity.Flows; |
| | | import com.highdatas.mdm.entity.MaintainField; |
| | | import com.highdatas.mdm.entity.TUserRole; |
| | | import com.highdatas.mdm.mapper.FlowsMapper; |
| | | import com.highdatas.mdm.mapper.SysFieldMapper; |
| | | import com.highdatas.mdm.pojo.ActivitiBusinessType; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | import com.highdatas.mdm.pojo.NextTaskUserInfo; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.service.act.IdentityService; |
| | | import com.highdatas.mdm.service.act.TaskService; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | IMasterModifiedService masterModifiedService; |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | IdentityService identityService; |
| | | |
| | | @Override |
| | | public MaintainField createNowVerion(String tableName, String maintainId, String userId) { |
| | |
| | | if (nestTaskAssignee == null){ |
| | | return false; |
| | | } |
| | | String taskAssigneeUserId = nestTaskAssignee.getUserId(); |
| | | if (!StringUtils.isEmpty(taskAssigneeUserId)){ |
| | | return taskAssigneeUserId.equalsIgnoreCase(userId); |
| | | List<String> userIdList = nestTaskAssignee.getUserIdList(); |
| | | if (userIdList.contains(userId)) { |
| | | return true; |
| | | } |
| | | String roleId = nestTaskAssignee.getRoleId(); |
| | | if (StringUtils.isEmpty(roleId)) { |
| | | |
| | | List<String> roleIdList = nestTaskAssignee.getRoleIdList(); |
| | | if (roleIdList == null || roleIdList.isEmpty()) { |
| | | return false; |
| | | } |
| | | List<TUserRole> userRoles = userRoleService.selectList(new EntityWrapper<TUserRole>().eq("role_id", roleId)); |
| | | long count = userRoles.stream().map(tUserRole -> tUserRole.getUserId()).filter(s -> s.equalsIgnoreCase(userId)).count(); |
| | | |
| | | List<String> roleByUser = identityService.getRoleByUser(userId); |
| | | if (roleByUser == null || roleByUser.isEmpty()) { |
| | | return false; |
| | | } |
| | | long count = roleByUser.stream().filter(roleId -> roleIdList.contains(roleId)).count(); |
| | | if (count == 0) { |
| | | return false; |
| | | }else { |
| | |
| | | if (resultMap == null) { |
| | | return null; |
| | | } |
| | | if (maintainFieldId.equalsIgnoreCase(Constant.All)) { |
| | | Collection<List<Maintain>> values = resultMap.values(); |
| | | HashSet<Maintain> maintains = new HashSet<>(); |
| | | for (List<Maintain> value : values) { |
| | | maintains.addAll(value); |
| | | } |
| | | |
| | | return new ArrayList<>(maintains); |
| | | } |
| | | return resultMap.get(maintainFieldId); |
| | | } |
| | | |
| | |
| | | public List<Maintain> getMaintainListByMaintainField(String id, String tableName) { |
| | | MaintainField maintainField = selectById(id); |
| | | if (maintainField == null) { |
| | | if (!id.equalsIgnoreCase(Constant.Default)){ |
| | | if (!id.equalsIgnoreCase(Constant.Default) && !id.equalsIgnoreCase(Constant.All)){ |
| | | return null; |
| | | }else { |
| | | maintainField = new MaintainField().setId(Constant.Default).setTableName(tableName); |
| | | maintainField = new MaintainField().setId(id).setTableName(tableName); |
| | | } |
| | | |
| | | } |
| | |
| | | object.fluentPut("records", maps); |
| | | object.fluentPut("maintainId", maintainId); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("passiveQueueSize", 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("size", page.getPageSize()); |
| | | object.fluentPut("passiveQueueSize", 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("size", page.getPageSize()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", maps); |
| | |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.controller.MasterAuthorController; |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.MasterAuthorMapper; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | |
| | | IFlowsService flowsService; |
| | | |
| | | @Override |
| | | public HashMap<String, MasterAuthor> merageRoleAuthor(List<String> roleIds) { |
| | | public HashMap<String, MasterAuthor> merageRoleAuthor(Set<String> roleIds) { |
| | | List<MasterAuthor> masterAuthors = selectList(new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.role).in(MasterAuthorController.character_id, roleIds)); |
| | | HashMap<String, MasterAuthor> resultMap = new HashMap<>(); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenu(String userId) { |
| | | List<MasterAuthor> masterAuthors = selectList(new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.user).eq(MasterAuthorController.character_id, userId)); |
| | | if (masterAuthors.isEmpty()) { |
| | | //user 获取role |
| | | List<TUserRole> roles = userRoleService.selectList(new EntityWrapper<TUserRole>().eq("user_id", userId)); |
| | | List<String> roleIds = roles.stream().map(tUserRole -> tUserRole.getRoleId()).collect(Collectors.toList()); |
| | | masterAuthors = selectList(new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.role).in(MasterAuthorController.character_id, roleIds)); |
| | | public List<SysMenu> getMenu(Character character) { |
| | | 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); |
| | | } |
| | | List<MasterAuthor> groupAuthors = getUserGroupAuthor(userId); |
| | | masterAuthors.addAll(groupAuthors); |
| | | if (masterAuthors == null || masterAuthors.isEmpty()) { |
| | | 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; |
| | | } |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | return sysMenus; |
| | | } |
| | | |
| | | private List<MasterAuthor> getUserGroupAuthor(String userId) { |
| | | //TODO |
| | | List<MasterAuthor> result = new ArrayList<>(); |
| | | List<String> groupIds = new ArrayList<>(); |
| | | for (String groupId : groupIds) { |
| | | List<MasterAuthor> masterAuthors = selectList( |
| | | new EntityWrapper<MasterAuthor>() |
| | | .eq(Constant.TYPE, MasterAuthorType.user) |
| | | .eq("is_group", true) |
| | | .eq(MasterAuthorController.character_id, groupId)); |
| | | if (masterAuthors.isEmpty()) { |
| | | //TODO getRoleList; |
| | | List<String> roleIds = new ArrayList<>(); |
| | | masterAuthors = selectList(new EntityWrapper<MasterAuthor>().eq("is_group", true).eq(Constant.TYPE, MasterAuthorType.role).in(MasterAuthorController.character_id, roleIds)); |
| | | private 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) { |
| | | if (maintainField.getId() != null) { |
| | | userWrapper.eq("maintain_field_id", maintainField.getId()); |
| | | } |
| | | result.addAll(masterAuthors); |
| | | if (maintainField.getTableName() != null) { |
| | | userWrapper.eq("table_name",maintainField.getTableName()); |
| | | } |
| | | } |
| | | List<MasterAuthor> masterAuthors = selectList(userWrapper); |
| | | if (masterAuthors.isEmpty()) { |
| | | //user 获取role |
| | | Set<String> roleIdSet = DbUtils.getRoleByUser(characterId); |
| | | if (roleIdSet.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | }else { |
| | | Wrapper<MasterAuthor> roleWrapper = new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.role).in(MasterAuthorController.character_id, roleIdSet); |
| | | if (maintainField != null) { |
| | | roleWrapper.eq("maintain_field_id", maintainField.getId()).eq("table_name",maintainField.getTableName()); |
| | | } |
| | | masterAuthors = selectList(roleWrapper); |
| | | } |
| | | } |
| | | List<MasterAuthor> groupAuthors = getUserGroupAuthor(characterId, null); |
| | | masterAuthors.addAll(groupAuthors); |
| | | return masterAuthors; |
| | | } |
| | | |
| | | private List<MasterAuthor> getRoleAuthors(String characterId, MaintainField maintainField) { |
| | | Wrapper<MasterAuthor> roleWrapper = new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.role).eq(MasterAuthorController.character_id, characterId); |
| | | if (maintainField != null) { |
| | | if (maintainField.getId() != null) { |
| | | roleWrapper.eq("maintain_field_id", maintainField.getId()); |
| | | } |
| | | if (maintainField.getTableName() != null) { |
| | | roleWrapper.eq("table_name",maintainField.getTableName()); |
| | | } |
| | | |
| | | } |
| | | |
| | | return selectList(roleWrapper); |
| | | } |
| | | |
| | | private List<MasterAuthor> getUserGroupAuthor(String userId, MaintainField maintainField) { |
| | | Set<String> groupIdList = DbUtils.getGroupByUser(userId); |
| | | List<MasterAuthor> result = new ArrayList<>(); |
| | | if (groupIdList == null) { |
| | | return result; |
| | | } |
| | | |
| | | for (String groupId : groupIdList) { |
| | | List<MasterAuthor> oneGroupAuthors = getOneGroupAuthors(groupId, maintainField); |
| | | if (oneGroupAuthors == null || oneGroupAuthors.isEmpty()) { |
| | | continue; |
| | | } |
| | | result.addAll(oneGroupAuthors); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | @Override |
| | | public List<MasterAuthor> getOneGroupAuthors(String groupId, MaintainField maintainField) { |
| | | Wrapper<MasterAuthor> userWrapper = new EntityWrapper<MasterAuthor>().eq("user_group", true).eq(Constant.TYPE, MasterAuthorType.user).eq(MasterAuthorController.character_id, groupId); |
| | | Wrapper<MasterAuthor> roleWrapper = new EntityWrapper<MasterAuthor>().eq("user_group", true).eq(Constant.TYPE, MasterAuthorType.role).eq(MasterAuthorController.character_id, groupId); |
| | | |
| | | if (maintainField != null) { |
| | | if (maintainField.getId() != null) { |
| | | userWrapper.eq("maintain_field_id", maintainField.getId()); |
| | | roleWrapper.eq("maintain_field_id", maintainField.getId()); |
| | | } |
| | | if (maintainField.getTableName() != null) { |
| | | userWrapper.eq("table_name",maintainField.getTableName()); |
| | | roleWrapper.eq("table_name",maintainField.getTableName()); |
| | | } |
| | | |
| | | } |
| | | List<MasterAuthor> groupAuthors = selectList(userWrapper); |
| | | if (groupAuthors.isEmpty()) { |
| | | Set<String> roleByGroup = DbUtils.getRoleByGroup(groupId); |
| | | if(roleByGroup.isEmpty()) { |
| | | groupAuthors = new ArrayList<>(); |
| | | }else { |
| | | groupAuthors = selectList(roleWrapper); |
| | | } |
| | | } |
| | | return groupAuthors; |
| | | } |
| | | |
| | | @Override |
| | | public List<SysField> getField(String userId, String maintainId) { |
| | | public List<SysField> getField(Character character, String maintainId) { |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | if (maintain == null){ |
| | | return new ArrayList<>(); |
| | | } |
| | | boolean isAll = checkUnFilterAuthor(userId, maintain.getTableName()); |
| | | |
| | | boolean isAll = checkUnFilterAuthor(character, maintain.getTableName()); |
| | | if (isAll) { |
| | | List<SysField> total = fieldService.getFieldByMaintain(maintainId); |
| | | return total; |
| | |
| | | } |
| | | String maintainFieldId = maintainField.getId(); |
| | | |
| | | List<MasterAuthor> masterAuthors = selectList(new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.user).eq(MasterAuthorController.character_id, userId).eq("maintain_field_id", maintainFieldId)); |
| | | if (masterAuthors.size() == 0) { |
| | | //user 获取role |
| | | List<TUserRole> roles = userRoleService.selectList(new EntityWrapper<TUserRole>().eq("user_id", userId)); |
| | | List<String> roleIds = roles.stream().map(tUserRole -> tUserRole.getRoleId()).collect(Collectors.toList()); |
| | | masterAuthors = selectList(new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.role).in(MasterAuthorController.character_id, roleIds).eq("maintain_field_id", maintainFieldId)); |
| | | MasterAuthorType type = character.getType(); |
| | | List<MasterAuthor> masterAuthors = null; |
| | | switch (type){ |
| | | case role: |
| | | masterAuthors = getRoleAuthors(character.getId(), maintainField); |
| | | break; |
| | | case groupInfo: |
| | | masterAuthors = getOneGroupAuthors(character.getId(), maintainField); |
| | | break; |
| | | case user: |
| | | masterAuthors = getUserAuthor(character.getId(), maintainField); |
| | | } |
| | | |
| | | List<MasterAuthor> groupAuthors = getUserGroupAuthor(userId); |
| | | masterAuthors.addAll(groupAuthors); |
| | | |
| | | if (masterAuthors.isEmpty()) { |
| | | if (masterAuthors == null || masterAuthors.isEmpty()) { |
| | | return null; |
| | | } |
| | | |
| | | List<String> authorIds = masterAuthors.stream().map(masterAuthor -> masterAuthor.getId()).collect(Collectors.toList()); |
| | | List<MasterAuthorDetail> masterAuthorDetails = authorDetailService.selectList(new EntityWrapper<MasterAuthorDetail>().in(Constant.PARENT_ID, authorIds)); |
| | | Set<String> codes = masterAuthorDetails.stream().map(masterAuthorDetail -> masterAuthorDetail.getField()).collect(Collectors.toSet()); |
| | |
| | | return fieldList; |
| | | } |
| | | |
| | | private boolean checkUnFilterAuthor(String userId, String tableName) { |
| | | List<MasterAuthor> masterAuthors = selectList(new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.user).eq("is_group", false).eq(MasterAuthorController.character_id, userId).eq("table_name", tableName)); |
| | | private boolean checkUnFilterAuthor(Character character, String tableName) { |
| | | MasterAuthorType type = character.getType(); |
| | | List<MasterAuthor> masterAuthors = null; |
| | | MaintainField maintainField = new MaintainField().setTableName(tableName); |
| | | switch (type){ |
| | | case role: |
| | | masterAuthors = getRoleAuthors(character.getId(), maintainField); |
| | | break; |
| | | case groupInfo: |
| | | masterAuthors = getOneGroupAuthors(character.getId(), maintainField); |
| | | break; |
| | | case user: |
| | | masterAuthors = getUserAuthor(character.getId(), maintainField); |
| | | } |
| | | if (masterAuthors.isEmpty()) { |
| | | return false; |
| | | } |
| | | long isAll = masterAuthors.stream().filter(masterAuthor -> masterAuthor.getMaintainFieldId().equalsIgnoreCase(Constant.All)).count(); |
| | | if (isAll > 0) { |
| | | return true; |
| | | } |
| | | if (!masterAuthors.isEmpty()) { |
| | | }else { |
| | | return false; |
| | | } |
| | | Set<String> roleByUser = DbUtils.getRoleByUser(userId); |
| | | isAll = selectCount(new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.role).in(MasterAuthorController.character_id, roleByUser).eq("table_name", tableName).eq("maintain_field_id", Constant.All_UPCASE)); |
| | | if (isAll > 0) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean checkMaintainAuthor(String userId, String maintainId) { |
| | | public boolean checkMaintainAuthor(Character character, String maintainId) { |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | if (maintain == null) { |
| | | return false; |
| | | } |
| | | int checked = 0; |
| | | boolean isAll = checkUnFilterAuthor(userId, maintain.getTableName()); |
| | | boolean isAll = checkUnFilterAuthor(character, maintain.getTableName()); |
| | | if (isAll){ |
| | | return true; |
| | | |
| | | } |
| | | MaintainField maintainField = fieldService.getMaintainFieldByMaintain(maintainId); |
| | | if (maintainField == null) { |
| | | return false; |
| | | } |
| | | //get user author |
| | | checked = selectCount(new EntityWrapper<MasterAuthor>() |
| | | .eq(Constant.TYPE, MasterAuthorType.user) |
| | | .eq(MasterAuthorController.character_id, userId) |
| | | .eq("table_name", maintain.getTableName()) |
| | | .eq("maintain_field_id", maintainField.getId())); |
| | | if (checked > 0) { |
| | | return true; |
| | | MasterAuthorType type = character.getType(); |
| | | List<MasterAuthor> masterAuthors = null; |
| | | switch (type){ |
| | | case role: |
| | | masterAuthors = getRoleAuthors(character.getId(), maintainField); |
| | | break; |
| | | case groupInfo: |
| | | masterAuthors = getOneGroupAuthors(character.getId(), maintainField); |
| | | break; |
| | | case user: |
| | | masterAuthors = getUserAuthor(character.getId(), maintainField); |
| | | } |
| | | List<TUserRole> roles = userRoleService.selectList(new EntityWrapper<TUserRole>().eq("user_id", userId)); |
| | | Set<String> collect = roles.stream().map(tUserRole -> tUserRole.getRoleId()).collect(Collectors.toSet()); |
| | | checked = selectCount(new EntityWrapper<MasterAuthor>() |
| | | .eq(Constant.TYPE, MasterAuthorType.role) |
| | | .in(MasterAuthorController.character_id, collect) |
| | | .eq("table_name", maintain.getTableName()) |
| | | .eq("maintain_field_id", maintainField.getId())); |
| | | if (checked > 0) { |
| | | return true; |
| | | } |
| | | if (masterAuthors.isEmpty()) { |
| | | return false; |
| | | }else { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String getFilter(String userId, String maintainId) { |
| | | public String getFilter(Character character, String maintainId) { |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | if (maintain == null){ |
| | | return Constant.WHERE_DEFAULTUN; |
| | | } |
| | | boolean isAll = checkUnFilterAuthor(userId, maintain.getTableName()); |
| | | boolean isAll = checkUnFilterAuthor(character, maintain.getTableName()); |
| | | if (isAll) { |
| | | return Constant.WHERE_DEFAULT; |
| | | } |
| | | MaintainField maintainField = fieldService.getMaintainFieldByMaintain(maintainId); |
| | | String maintainFieldId = maintainField.getId(); |
| | | |
| | | List<MasterAuthor> masterAuthors = selectList(new EntityWrapper<MasterAuthor>() |
| | | .eq("table_name", maintain.getTableName()) |
| | | .eq(Constant.TYPE, MasterAuthorType.user).eq(MasterAuthorController.character_id, userId).eq("maintain_field_id", maintainFieldId)); |
| | | if (masterAuthors.size() == 0) { |
| | | //user 获取role |
| | | List<TUserRole> roles = userRoleService.selectList(new EntityWrapper<TUserRole>().eq("user_id", userId)); |
| | | List<String> roleIds = roles.stream().map(tUserRole -> tUserRole.getRoleId()).collect(Collectors.toList()); |
| | | masterAuthors = selectList(new EntityWrapper<MasterAuthor>().eq("table_name", maintain.getTableName()).eq(Constant.TYPE, MasterAuthorType.role).in(MasterAuthorController.character_id, roleIds).eq("maintain_field_id", maintainFieldId)); |
| | | MasterAuthorType type = character.getType(); |
| | | List<MasterAuthor> masterAuthors = null; |
| | | switch (type){ |
| | | case role: |
| | | masterAuthors = getRoleAuthors(character.getId(), maintainField); |
| | | break; |
| | | case groupInfo: |
| | | masterAuthors = getOneGroupAuthors(character.getId(), maintainField); |
| | | break; |
| | | case user: |
| | | masterAuthors = getUserAuthor(character.getId(), maintainField); |
| | | } |
| | | |
| | | List<MasterAuthor> groupAuthors = getUserGroupAuthor(userId); |
| | | masterAuthors.addAll(groupAuthors); |
| | | |
| | | if (masterAuthors.isEmpty()){ |
| | | return Constant.WHERE_DEFAULTUN; |
| | | } |
| | | |
| | | List<String> authorIds = masterAuthors.stream().map(masterAuthor -> masterAuthor.getId()).collect(Collectors.toList()); |
| | | List<MasterAuthorDetail> masterAuthorDetails = authorDetailService.selectList(new EntityWrapper<MasterAuthorDetail>().in(Constant.PARENT_ID, authorIds)); |
| | | if (masterAuthorDetails.isEmpty()) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Maintain getMaxVersionMaintain(String userId, String tableName) { |
| | | public Maintain getMaxVersionMaintain(Character character, String tableName) { |
| | | List<Maintain> maintainList = maintainService.selectList(new EntityWrapper<Maintain>().eq("table_name", tableName).orderBy("order_no desc")); |
| | | for (Maintain maintain : maintainList) { |
| | | ActivitiStatus status = flowsService.getStatusByBusinessId(maintain.getId()); |
| | | if (!status.equals(ActivitiStatus.open)) { |
| | | if (!ActivitiStatus.open.equals(status)) { |
| | | continue; |
| | | } |
| | | boolean b = checkMaintainAuthor(userId, maintain.getId()); |
| | | boolean b = checkMaintainAuthor(character, maintain.getId()); |
| | | if (b) { |
| | | return maintain; |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.*; |
| | | 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.RedisClient; |
| | | import com.highdatas.mdm.util.*; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.ibatis.session.SqlSessionFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.sql.DataSource; |
| | | import java.sql.Connection; |
| | | import java.sql.SQLException; |
| | | import java.text.MessageFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author kimi |
| | | * @description |
| | |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | |
| | | @Autowired |
| | | SqlSessionFactory sqlSessionFactory; |
| | | @Resource |
| | | protected DataSource dataSource; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result selectList(TUser user, String tableName) { |
| | | return selectList(user, tableName, null,null, (maintainService.getNowVersion(tableName).getVersion())); |
| | | public Result selectList(Character character, String tableName) { |
| | | return selectList(character, tableName, null,null, (maintainService.getNowVersion(tableName).getVersion())); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result selectList(TUser user, String tableName, String whereSegment) { |
| | | return selectList(user,tableName, whereSegment, (maintainService.getNowVersion(tableName).getVersion())); |
| | | public Result selectList(Character character, String tableName, String whereSegment) { |
| | | return selectList(character,tableName, whereSegment, (maintainService.getNowVersion(tableName).getVersion())); |
| | | } |
| | | |
| | | @Override |
| | | public Result selectList(TUser user,String tableName, String whereSegment, String version) { |
| | | return selectList(user, tableName, null, whereSegment, version); |
| | | public Result selectList(Character character,String tableName, String whereSegment, String version) { |
| | | return selectList(character, tableName, null, whereSegment, version); |
| | | } |
| | | |
| | | @Override |
| | | public Result selectList(TUser user, String tableName, List<String> fieldList, String whereSegment) { |
| | | return selectList(user, tableName, fieldList, whereSegment, maintainService.getNowVersion(tableName).getVersion()); |
| | | public Result selectList(Character character, String tableName, List<String> fieldList, String whereSegment) { |
| | | return selectList(character, tableName, fieldList, whereSegment, maintainService.getNowVersion(tableName).getVersion()); |
| | | } |
| | | |
| | | @Override |
| | | public Result selectList(TUser user, String tableName,List<String> fieldList, String whereSegment, String version) { |
| | | public Result selectList(Character character, String tableName,List<String> fieldList, String whereSegment, String version) { |
| | | try{ |
| | | JSONObject object = new JSONObject(); |
| | | //TODO only add version |
| | | Maintain maintainFromVersion = maintainService.getMaintainFromVersion(tableName, version); |
| | | String fields; |
| | | if (fieldList == null || fieldList.size() == 0) { |
| | | fields = getFields(user, tableName, maintainFromVersion); |
| | | fields = getFields(character, tableName, maintainFromVersion); |
| | | } else { |
| | | fields = fieldList.stream().collect(Collectors.joining(Constant.COMMA)); |
| | | } |
| | |
| | | |
| | | |
| | | @Override |
| | | public Result selectList(TUser user, String tableName, List<String> fields) { |
| | | return selectList(user, tableName,fields,Constant.WHERE_DEFAULT,(maintainService.getNowVersion(tableName).getVersion())); |
| | | public Result selectList(Character character, String tableName, List<String> fields) { |
| | | return selectList(character, tableName,fields,Constant.WHERE_DEFAULT,(maintainService.getNowVersion(tableName).getVersion())); |
| | | } |
| | | |
| | | public Long getCount(String tableName, String whereSegment) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Long getCountByVersion (TUser user, String maintainId, String tableName,String tableTempName,Integer fromOrderNo, Integer toOrderNo, String whereSegment) { |
| | | public Long getCountByVersion (Character character, String maintainId, String tableName,String tableTempName,Integer fromOrderNo, Integer toOrderNo, String whereSegment) { |
| | | try{ |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | |
| | | String fields = getFields(user,tableName, maintain); |
| | | String Hfields = getFields(user, tableName, Constant.H, maintain); |
| | | String tempFields = getTempFields(user, tableName, maintain); |
| | | String A1fields = getFields(user, tableName, Constant.A1, maintain); |
| | | String A2fields = getFields(user, tableName, Constant.A2, maintain); |
| | | String tempHFields = getTempFields(user, tableName, Constant.H, maintain); |
| | | String fields = getFields(character,tableName, maintain); |
| | | String Hfields = getFields(character, tableName, Constant.H, maintain); |
| | | String tempFields = getTempFields(character, tableName, maintain); |
| | | String A1fields = getFields(character, tableName, Constant.A1, maintain); |
| | | String A2fields = getFields(character, tableName, Constant.A2, maintain); |
| | | String tempHFields = getTempFields(character, tableName, Constant.H, maintain); |
| | | if (StringUtils.isEmpty(whereSegment)) { |
| | | whereSegment = Constant.WHERE_DEFAULT; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public Long getCountByMaxVersion (TUser user, String maintainId, String tableName,String tableTempName,Integer fromOrderNo, Integer toOrderNo, String whereSegment) { |
| | | public Long getCountByMaxVersion (Character character, String maintainId, String tableName,String tableTempName,Integer fromOrderNo, Integer toOrderNo, String whereSegment) { |
| | | try{ |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | |
| | | String fields = getFields(user, tableName, maintain); |
| | | String Hfields = getFields(user, tableName, Constant.H, maintain); |
| | | String tempFields = getTempFields(user, tableName, maintain); |
| | | String A1fields = getFields(user, tableName, Constant.A1, maintain); |
| | | String A2fields = getFields(user, tableName, Constant.A2, maintain); |
| | | String tempHFields = getTempFields(user, tableName, Constant.H, maintain); |
| | | String fields = getFields(character, tableName, maintain); |
| | | String Hfields = getFields(character, tableName, Constant.H, maintain); |
| | | String tempFields = getTempFields(character, tableName, maintain); |
| | | String A1fields = getFields(character, tableName, Constant.A1, maintain); |
| | | String A2fields = getFields(character, tableName, Constant.A2, maintain); |
| | | String tempHFields = getTempFields(character, tableName, Constant.H, maintain); |
| | | if (StringUtils.isEmpty(whereSegment)) { |
| | | whereSegment = Constant.WHERE_DEFAULT; |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getFields(TUser user, String tableName, Maintain maintain) { |
| | | public String getFields(Character character, String tableName, Maintain maintain) { |
| | | |
| | | return getFields(user, tableName, null, maintain); |
| | | return getFields(character, tableName, null, maintain); |
| | | } |
| | | |
| | | private String getCaseWhenFields(String tableName) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getFields(TUser user, String tableName, String alias, Maintain maintain) { |
| | | public String getFields(Character character, String tableName, String alias, Maintain maintain) { |
| | | List<SysField> fields; |
| | | if (user == null) { |
| | | if (character == null) { |
| | | fields = fieldService.getFieldByMaintain(maintain.getId()); |
| | | }else { |
| | | fields = masterAuthorService.getField(user.getUserId(), maintain.getId()); |
| | | fields = masterAuthorService.getField(character, maintain.getId()); |
| | | } |
| | | ContentBuilder contentBuilder = new ContentBuilder(Constant.COMMA); |
| | | if (fields == null) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getTempFields(TUser user, String tableName, Maintain maintain) { |
| | | return getTempFields(user, tableName, null, maintain); |
| | | public String getTempFields(Character character, String tableName, Maintain maintain) { |
| | | return getTempFields(character, tableName, null, maintain); |
| | | } |
| | | |
| | | @Override |
| | | public String getTempFields(TUser user, String tableName) { |
| | | return getTempFields(user, tableName, Constant.EMPTY_Str); |
| | | public String getTempFields(Character character, String tableName) { |
| | | return getTempFields(character, tableName, Constant.EMPTY_Str); |
| | | } |
| | | @Override |
| | | public String getTempFields(TUser user, String tableName, String alias) { |
| | | public String getTempFields(Character character, String tableName, String alias) { |
| | | List<TableSchemaResult> tableField = mapper.getTableField(tableName); |
| | | |
| | | ContentBuilder contentBuilder = new ContentBuilder(Constant.COMMA); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getTempFields(TUser user, String tableName, String alias, Maintain maintain) { |
| | | public String getTempFields(Character character, String tableName, String alias, Maintain maintain) { |
| | | List<SysField> fields; |
| | | if (user == null) { |
| | | if (character == null) { |
| | | fields = fieldService.getFieldByMaintain(maintain.getId()); |
| | | }else { |
| | | fields = masterAuthorService.getField(user.getUserId(), maintain.getId()); |
| | | fields = masterAuthorService.getField(character, maintain.getId()); |
| | | } |
| | | if (fields == null) { |
| | | return Constant.EMPTY_Str; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result selectListByPageByVersion(TUser user, String tableName, Integer pageNo, Integer pageSize, boolean findMax) { |
| | | return selectListByPageByVersion(user, tableName,Constant.WHERE_DEFAULT,pageNo,pageSize, findMax); |
| | | public Result selectListByPageByVersion(Character character, String tableName, Integer pageNo, Integer pageSize, boolean findMax) { |
| | | return selectListByPageByVersion(character, tableName,Constant.WHERE_DEFAULT,pageNo,pageSize, findMax); |
| | | } |
| | | |
| | | @Override |
| | | public Result selectListByPageByVersion(TUser user, String tableName, String whereSegment, Integer pageNo, boolean findMax) { |
| | | return selectListByPageByVersion(user, tableName,null, whereSegment,pageNo, null, String.valueOf(maintainService.getNowVersion(tableName).getVersion()), findMax); |
| | | public Result selectListByPageByVersion(Character character, String tableName, String whereSegment, Integer pageNo, boolean findMax) { |
| | | return selectListByPageByVersion(character, tableName,null, whereSegment,pageNo, null, String.valueOf(maintainService.getNowVersion(tableName).getVersion()), findMax); |
| | | } |
| | | |
| | | @Override |
| | | public Result selectListByPageByVersion(TUser user, String tableName, Integer pageNo, String version, boolean findMax) { |
| | | return selectListByPageByVersion(user, tableName,null,Constant.WHERE_DEFAULT,pageNo, null, version, findMax); |
| | | public Result selectListByPageByVersion(Character character, String tableName, Integer pageNo, String version, boolean findMax) { |
| | | return selectListByPageByVersion(character, tableName,null,Constant.WHERE_DEFAULT,pageNo, null, version, findMax); |
| | | } |
| | | @Override |
| | | public Result selectListByPageByVersion(TUser user, String tableName, Integer pageNo, boolean findMax) { |
| | | return selectListByPageByVersion(user, tableName,null,Constant.WHERE_DEFAULT,pageNo, null, String.valueOf(maintainService.getNowVersion(tableName).getVersion()), findMax); |
| | | public Result selectListByPageByVersion(Character character, String tableName, Integer pageNo, boolean findMax) { |
| | | return selectListByPageByVersion(character, tableName,null,Constant.WHERE_DEFAULT,pageNo, null, String.valueOf(maintainService.getNowVersion(tableName).getVersion()), findMax); |
| | | } |
| | | |
| | | @Override |
| | | public Result selectListByPageByVersion(TUser user, String tableName, String whereSegment, Integer pageNo, Integer pageSize, boolean findMax) { |
| | | return selectListByPageByVersion(user, tableName,null,whereSegment,pageNo,pageSize, findMax); |
| | | public Result selectListByPageByVersion(Character character, String tableName, String whereSegment, Integer pageNo, Integer pageSize, boolean findMax) { |
| | | return selectListByPageByVersion(character, tableName,null,whereSegment,pageNo,pageSize, findMax); |
| | | } |
| | | |
| | | @Override |
| | | public Result selectListByPageByVersion(TUser user, String tableName, List<String> fieldList, String whereSegment, Integer pageNo, boolean findMax) { |
| | | return selectListByPageByVersion(user, tableName,null,whereSegment,pageNo, null, findMax); |
| | | public Result selectListByPageByVersion(Character character, String tableName, List<String> fieldList, String whereSegment, Integer pageNo, boolean findMax) { |
| | | return selectListByPageByVersion(character, tableName,null,whereSegment,pageNo, null, findMax); |
| | | } |
| | | |
| | | @Override |
| | | public Result selectListByPageByVersion(TUser user, String tableName, List<String> fieldList, Integer pageNo, boolean findMax) { |
| | | return selectListByPageByVersion(user, tableName,null,Constant.WHERE_DEFAULT,pageNo, findMax); |
| | | public Result selectListByPageByVersion(Character character, String tableName, List<String> fieldList, Integer pageNo, boolean findMax) { |
| | | return selectListByPageByVersion(character, tableName,null,Constant.WHERE_DEFAULT,pageNo, findMax); |
| | | } |
| | | @Override |
| | | public Result selectListByPageByVersion(TUser user, String tableName, String whereSegment, Integer pageNo, String version, boolean findMax) { |
| | | return selectListByPageByVersion(user, tableName, null,whereSegment, pageNo, null,version, findMax); |
| | | public Result selectListByPageByVersion(Character character, String tableName, String whereSegment, Integer pageNo, String version, boolean findMax) { |
| | | return selectListByPageByVersion(character, tableName, null,whereSegment, pageNo, null,version, findMax); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectListByVersion(TUser user, String tableName, List<String> fieldList, String whereSegment, String version, boolean findMax) { |
| | | public List<Map<String, Object>> selectListByVersion(Character character, String tableName, List<String> fieldList, String whereSegment, String version, boolean findMax) { |
| | | Maintain maintainFromVersion = maintainService.getMaintainFromVersion(tableName, version); |
| | | Maintain nowVersionMaintain = maintainService.getNowVersion(tableName); |
| | | boolean isMax = maintainService.checkdMaxVersion(maintainFromVersion.getId()); |
| | |
| | | |
| | | String tempHfields; |
| | | if (fieldList == null || fieldList.size() == 0) { |
| | | fields = getFields(user, tableName, maintainFromVersion); |
| | | Hfields = getFields(user, tableName,Constant.H, maintainFromVersion); |
| | | A1fields = getFields(user, tableName,Constant.A1, maintainFromVersion); |
| | | A2fields = getFields(user, tableName,Constant.A2, maintainFromVersion); |
| | | tempFields = getTempFields(user, tableName, maintainFromVersion); |
| | | tempHfields = getTempFields(user, tableName, Constant.H, maintainFromVersion); |
| | | fields = getFields(character, tableName, maintainFromVersion); |
| | | Hfields = getFields(character, tableName,Constant.H, maintainFromVersion); |
| | | A1fields = getFields(character, tableName,Constant.A1, maintainFromVersion); |
| | | A2fields = getFields(character, tableName,Constant.A2, maintainFromVersion); |
| | | tempFields = getTempFields(character, tableName, maintainFromVersion); |
| | | tempHfields = getTempFields(character, tableName, Constant.H, maintainFromVersion); |
| | | } else { |
| | | fields = fieldList.stream().collect(Collectors.joining(Constant.COMMA)); |
| | | Hfields = fieldList.stream().map(s -> MessageFormat.format(Constant.Alias,Constant.H, s)).collect(Collectors.joining(Constant.COMMA)); |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Result selectListByPageByVersion(TUser user, String tableName, List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, String version, boolean findMax) { |
| | | public String selectByVersionSql(Character character, String tableName, List<String> fieldList, 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; |
| | | String result = null; |
| | | |
| | | String fields; |
| | | String tempFields; |
| | | String Hfields; |
| | | String A1fields; |
| | | String A2fields; |
| | | |
| | | String tempHfields; |
| | | if (fieldList == null || fieldList.size() == 0) { |
| | | fields = getFields(null, tableName, maintainFromVersion); |
| | | Hfields = getFields(null, tableName,Constant.H, maintainFromVersion); |
| | | A1fields = getFields(null, tableName,Constant.A1, maintainFromVersion); |
| | | A2fields = getFields(null, tableName,Constant.A2, maintainFromVersion); |
| | | tempFields = getTempFields(null, tableName, maintainFromVersion); |
| | | tempHfields = getTempFields(null, tableName, Constant.H, maintainFromVersion); |
| | | } else { |
| | | fields = fieldList.stream().collect(Collectors.joining(Constant.COMMA)); |
| | | Hfields = fieldList.stream().map(s -> MessageFormat.format(Constant.Alias,Constant.H, s)).collect(Collectors.joining(Constant.COMMA)); |
| | | A1fields = fieldList.stream().map(s -> MessageFormat.format(Constant.Alias,Constant.A1, s)).collect(Collectors.joining(Constant.COMMA)); |
| | | A2fields = fieldList.stream().map(s -> MessageFormat.format(Constant.Alias,Constant.A2, s)).collect(Collectors.joining(Constant.COMMA)); |
| | | tempFields = fieldList.stream() |
| | | .map(s -> |
| | | s.equalsIgnoreCase(Constant.ID) ? MessageFormat.format("{0} as id",Constant.STD_ID): s) |
| | | .collect(Collectors.joining(Constant.COMMA)); |
| | | |
| | | tempHfields = fieldList.stream() |
| | | .map(s -> |
| | | s.equalsIgnoreCase(Constant.ID) ? MessageFormat.format("{0} as id",Constant.STD_ID): s) |
| | | .map(s -> MessageFormat.format(Constant.Alias,Constant.H,s)) |
| | | .collect(Collectors.joining(Constant.COMMA)); |
| | | |
| | | } |
| | | MyBatisSql ibatisSql = new MyBatisSql(); |
| | | Map<String, Object> parameterMap = new HashMap<>(); |
| | | if (isNow && !findMax){ |
| | | parameterMap.put("tableName", tableName); |
| | | parameterMap.put("fields", fields); |
| | | parameterMap.put("where", whereSegment); |
| | | parameterMap.put("limit", null); |
| | | result = DbUtils.getMyBatisSql("selectByPage", parameterMap, sqlSessionFactory).getSql(); |
| | | } |
| | | else if (isMax && findMax) { |
| | | ContentBuilder builder = new ContentBuilder(Constant.COMMA); |
| | | if (nowVersionMaintain == null) { |
| | | builder.append(DbUtils.quotedStr(maintainFromVersion.getId())); |
| | | }else { |
| | | List<String> maintainIds = maintainService.getCompareVersionMaintains(nowVersionMaintain, maintainFromVersion); |
| | | long con = maintainIds.stream().map(s -> builder.append(DbUtils.quotedStr(s))).count(); |
| | | } |
| | | parameterMap.put("tableName", tableName); |
| | | parameterMap.put("tableTempName", tableTempName); |
| | | parameterMap.put("fields", fields); |
| | | parameterMap.put("tempFields", tempFields); |
| | | parameterMap.put("Hfields", Hfields); |
| | | parameterMap.put("A1fields", A1fields); |
| | | parameterMap.put("A2fields", A2fields); |
| | | parameterMap.put("tempHFields", tempHfields); |
| | | parameterMap.put("fromOrderNo", fromVersionOrderNo); |
| | | parameterMap.put("toOrderNo", nowVersionOrderNo); |
| | | parameterMap.put("maintainId", DbUtils.quotedStr(maintainFromVersion.getId())); |
| | | parameterMap.put("where", whereSegment); |
| | | parameterMap.put("limit", null); |
| | | result = DbUtils.getMyBatisSql("selectByPageByMaxVersion", parameterMap, sqlSessionFactory).getSql(); |
| | | |
| | | }else { |
| | | parameterMap.put("tableName", tableName); |
| | | parameterMap.put("tableTempName", tableTempName); |
| | | parameterMap.put("fields", fields); |
| | | parameterMap.put("tempFields", tempFields); |
| | | parameterMap.put("Hfields", Hfields); |
| | | parameterMap.put("A1fields", A1fields); |
| | | parameterMap.put("A2fields", A2fields); |
| | | parameterMap.put("tempHFields", tempHfields); |
| | | parameterMap.put("fromOrderNo", fromVersionOrderNo); |
| | | parameterMap.put("toOrderNo", nowVersionOrderNo); |
| | | parameterMap.put("maintainId", DbUtils.quotedStr(maintainFromVersion.getId())); |
| | | parameterMap.put("where", whereSegment); |
| | | parameterMap.put("limit", null); |
| | | result = DbUtils.getMyBatisSql("selectByPageByVersion", parameterMap, sqlSessionFactory).getSql(); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @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); |
| | | Maintain nowVersionMaintain = maintainService.getNowVersion(tableName); |
| | | boolean isMax = maintainService.checkdMaxVersion(maintainFromVersion.getId()); |
| | |
| | | if (isFirst && nowVersionMaintain == null) { |
| | | nowVersionOrderNo = nowVersionOrderNo - 1; |
| | | } |
| | | count = getCountByMaxVersion(user, maintainFromVersion.getId(), tableName, tableTempName, fromVersionOrderNo, nowVersionOrderNo, whereSegment); |
| | | |
| | | count = getCountByMaxVersion(character, maintainFromVersion.getId(), tableName, tableTempName, fromVersionOrderNo, nowVersionOrderNo, whereSegment); |
| | | }else { |
| | | count = getCountByVersion(user, maintainFromVersion.getId(), tableName, tableTempName, nowVersionOrderNo, fromVersionOrderNo, whereSegment); |
| | | count = getCountByVersion(character, maintainFromVersion.getId(), tableName, tableTempName, nowVersionOrderNo, fromVersionOrderNo, whereSegment); |
| | | } |
| | | if (count == 0) { |
| | | return Result.success(null); |
| | |
| | | |
| | | String tempHfields; |
| | | if (fieldList == null || fieldList.size() == 0) { |
| | | fields = getFields(user, tableName, maintainFromVersion); |
| | | Hfields = getFields(user, tableName,Constant.H, maintainFromVersion); |
| | | A1fields = getFields(user, tableName,Constant.A1, maintainFromVersion); |
| | | A2fields = getFields(user, tableName,Constant.A2, maintainFromVersion); |
| | | tempFields = getTempFields(user, tableName, maintainFromVersion); |
| | | tempHfields = getTempFields(user, tableName, Constant.H, maintainFromVersion); |
| | | fields = getFields(character, tableName, maintainFromVersion); |
| | | Hfields = getFields(character, tableName,Constant.H, maintainFromVersion); |
| | | A1fields = getFields(character, tableName,Constant.A1, maintainFromVersion); |
| | | A2fields = getFields(character, tableName,Constant.A2, maintainFromVersion); |
| | | tempFields = getTempFields(character, tableName, maintainFromVersion); |
| | | tempHfields = getTempFields(character, tableName, Constant.H, maintainFromVersion); |
| | | } else { |
| | | fields = fieldList.stream().collect(Collectors.joining(Constant.COMMA)); |
| | | Hfields = fieldList.stream().map(s -> MessageFormat.format(Constant.Alias,Constant.H, s)).collect(Collectors.joining(Constant.COMMA)); |
| | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", result); |
| | |
| | | maintain.setTableName(tableName); |
| | | maintain.setCreateTime(new Date()); |
| | | |
| | | Connection connection; |
| | | Connection connection = null; |
| | | try { |
| | | connection = dataSource.getConnection(); |
| | | connection.setAutoCommit(false); |
| | |
| | | .setDesp("批量上传数据"); |
| | | |
| | | maintain.insert(); |
| | | connection.commit(); |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | |
| | | }finally { |
| | | if (connection != null) { |
| | | try { |
| | | connection.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return maintain; |
| | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", result); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result selectListByPageByVersion(TUser user, String tableName,List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, boolean findMax) { |
| | | return selectListByPageByVersion(user, tableName, fieldList, whereSegment,pageNo,pageSize,String.valueOf(maintainService.getNowVersion(tableName).getVersion()), findMax); |
| | | public Result selectListByPageByVersion(Character character, String tableName,List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, boolean findMax) { |
| | | return selectListByPageByVersion(character, tableName, fieldList, whereSegment,pageNo,pageSize,String.valueOf(maintainService.getNowVersion(tableName).getVersion()), findMax); |
| | | } |
| | | |
| | | @Override |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.gson.JsonObject; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.SysField; |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.entity.TableSchemaResult; |
| | | import com.highdatas.mdm.mapper.MaintainFieldMapper; |
| | | import com.highdatas.mdm.mapper.MasterModifiedMapper; |
| | |
| | | TableInfoMapper tableInfoMapper; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | ITUserService userService; |
| | | @Autowired |
| | | MaintainFieldMapper maintainFieldMapper; |
| | | @Autowired |
| | |
| | | String tableName = menuMapping.getTableName(); |
| | | TUser user = (TUser) session.getAttribute(Constant.USER); |
| | | |
| | | Maintain resultMaintain = masterAuthorService.getMaxVersionMaintain(user.getUserId(), tableName); |
| | | Maintain resultMaintain = masterAuthorService.getMaxVersionMaintain(user, tableName); |
| | | Maintain nowVersion = maintainService.getNowVersion(tableName); |
| | | |
| | | if (resultMaintain != null) { |
| | |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.MultiValueMap; |
| | | |
| | | import java.io.InputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author kimi |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result saveModel(String modelId, MultiValueMap<String, String> values) { |
| | | public Result saveModel(String modelId, Map<String, String> values) { |
| | | return null; |
| | | } |
| | | |
| | |
| | | BigDataDataSourceInfo bigDataDataSourceInfo; |
| | | @Autowired |
| | | MasterDataService masterDataService; |
| | | @Autowired |
| | | ITUserService userService; |
| | | |
| | | @Autowired |
| | | RuleClient ruleClient; |
| | | @Autowired |
| | |
| | | |
| | | if (audit) { |
| | | String chargeId = menuMapping.getChargeId(); |
| | | TUser user = userService.selectById(chargeId); |
| | | TUser user = DbUtils.getUserById(chargeId); |
| | | if (user == null) { |
| | | return Result.error(new CodeMsg(6009, "找不到对应的负责人:" + chargeId)); |
| | | } |
| | |
| | | conn = dataSourceInfo.conn(); |
| | | PreparedStatement statement = conn.prepareStatement(sql); |
| | | int result = 0; |
| | | if (statement.isWrapperFor(com.mysql.jdbc.Statement.class)) { |
| | | com.mysql.jdbc.PreparedStatement mysqlStatement = statement.unwrap(com.mysql.jdbc.PreparedStatement.class); |
| | | if (statement.isWrapperFor(java.sql.Statement.class)) { |
| | | com.mysql.cj.jdbc.PreparedStatement mysqlStatement = statement.unwrap( com.mysql.cj.jdbc.PreparedStatement.class); |
| | | mysqlStatement.setLocalInfileInputStream(dataStream); |
| | | result = mysqlStatement.executeUpdate(); |
| | | } |
| | |
| | | Map<String, String> maintainFieldMap = maintainFieldMapper.getMappedMatintainId(DbUtils.quotedStr(maintain.getTableName()), maintain.getOrderNo()); |
| | | |
| | | if (maintainFieldMap == null) { |
| | | return new MaintainField().setId(Constant.Default); |
| | | return new MaintainField().setId(Constant.Default).setTableName(maintain.getTableName()); |
| | | } |
| | | String maintainFieldId = maintainFieldMap.get(Constant.ID); |
| | | maintainField = maintainFieldService.selectById(maintainFieldId); |
| | | if (maintainField == null){ |
| | | return new MaintainField().setId(Constant.Default); |
| | | return new MaintainField().setId(Constant.Default).setTableName(maintain.getTableName()); |
| | | } |
| | | } |
| | | |
| | |
| | | // 当前版本正在审批 找前一版本 |
| | | Integer maintainFieldOrderNo = maintainField.getOrderNo(); |
| | | if (maintainFieldOrderNo < 1) { |
| | | return new MaintainField().setId(Constant.Default); |
| | | return new MaintainField().setId(Constant.Default).setTableName(maintain.getTableName()); |
| | | }else { |
| | | Integer preNo = maintainFieldOrderNo - 1; |
| | | maintainField = maintainFieldService.selectOne(new EntityWrapper<MaintainField>().eq("table_name", maintain.getTableName()).eq("order_no", preNo)); |
| | |
| | | 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("size", pageSize); |
| | | result.fluentPut("passiveQueueSize", 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("size", pageSize); |
| | | result.fluentPut("passiveQueueSize", pageSize); |
| | | result.fluentPut("total", page.getRecordCount()); |
| | | result.fluentPut("list", subList); |
| | | |
| | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", datas); |
New file |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.highdatas.mdm.entity.SysSubscribe; |
| | | import com.highdatas.mdm.mapper.SysSubscribeMapper; |
| | | import com.highdatas.mdm.service.ISysSubscribeService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | @Service |
| | | public class SysSubscribeServiceImpl extends ServiceImpl<SysSubscribeMapper, SysSubscribe> implements ISysSubscribeService { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.highdatas.mdm.entity.SysViewJoin; |
| | | import com.highdatas.mdm.mapper.SysViewJoinMapper; |
| | | import com.highdatas.mdm.service.ISysViewJoinService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | @Service |
| | | public class SysViewJoinServiceImpl extends ServiceImpl<SysViewJoinMapper, SysViewJoin> implements ISysViewJoinService { |
| | | |
| | | } |
New file |
| | |
| | | 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.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-04-15 |
| | | */ |
| | | @Service |
| | | public class SysViewServiceImpl extends ServiceImpl<SysViewMapper, SysView> implements ISysViewService { |
| | | |
| | | } |
| | |
| | | package com.highdatas.mdm.util; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.ITUserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | |
| | | @Service(value = "testInterceptor") |
| | | public class CommonInterceptor implements HandlerInterceptor{ |
| | | @Autowired |
| | | ITUserService userService; |
| | | UserRoleClient userRoleClient; |
| | | |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { |
| | |
| | | if (StringUtils.isEmpty(token)) { |
| | | log.error("token is null"); |
| | | token= "U001"; |
| | | /* response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); |
| | | // String url = "/industryiot/Login.html"; |
| | | // response.sendRedirect(url); |
| | | |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setContentType("application/json; charset=utf-8"); |
| | | Result<Object> error = Result.error(CodeMsg.ERROR_TOKEN); |
| | | PrintWriter out = null ; |
| | | out = response.getWriter(); |
| | | out.write(JSON.toJSONString(error)); |
| | | out.flush(); |
| | | out.close(); |
| | | return false;*/ |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | |
| | | String baseUrl = ""; |
| | | LinkedMultiValueMap<String, String> body=new LinkedMultiValueMap(); |
| | | |
| | | body.add("token", token); |
| | | //String userId = token; |
| | | // ObjectMapper objectMapper = new ObjectMapper(); |
| | | // objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
| | | // TUser user = objectMapper.readValue(login, TUser.class); |
| | | // String userId = HttpUtils.HttpRestClient(baseUrl, HttpMethod.GET, body); |
| | | |
| | | TUser user = userService.selectOne(new EntityWrapper<TUser>().eq("user_id", userId)); |
| | | TUser user = userRoleClient.getTUserById(userId); |
| | | if (user == null) { |
| | | log.error("user not found by : " + userId); |
| | | response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); |
| | | // String url = "/industryiot/Login.html"; |
| | | // response.sendRedirect(url); |
| | | |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setContentType("application/json; charset=utf-8"); |
| | | Result<Object> error = Result.error(CodeMsg.ERROR_TOKEN); |
| | | PrintWriter out = null ; |
| | | out = response.getWriter(); |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(JSON.toJSONString(error)); |
| | | out.flush(); |
| | | out.close(); |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | String DISTINCT = "distinct {0}"; |
| | | String InSql = "{0} in ( {1} )"; |
| | | String z_AllVal = "z_AllVal"; |
| | | |
| | | |
| | | int queueSize = 20; |
| | | int cntCoefficient = 50; |
| | | } |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.MaintainField; |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.entity.TableSchemaResult; |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | import com.highdatas.mdm.pojo.Segment; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.ibatis.mapping.BoundSql; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.ParameterMapping; |
| | | import org.apache.ibatis.mapping.ParameterMode; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.apache.ibatis.reflection.property.PropertyTokenizer; |
| | | import org.apache.ibatis.scripting.xmltags.ForEachSqlNode; |
| | | import org.apache.ibatis.session.Configuration; |
| | | import org.apache.ibatis.session.SqlSessionFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.lang.reflect.Field; |
| | |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author kimi |
| | |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class DbUtils { |
| | | |
| | | private static UserRoleClient userRoleClient; |
| | | |
| | | @Autowired |
| | | public void setUserRoleClient(UserRoleClient userRoleClient){ |
| | | DbUtils.userRoleClient = userRoleClient; |
| | | } |
| | | |
| | | private static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; |
| | | |
| | | public static String versionAddSub (String baseVersion) { |
| | |
| | | return orderNo + 1; |
| | | } |
| | | |
| | | public static Date getDateByStart() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | Date zero = calendar.getTime(); |
| | | return zero; |
| | | } |
| | | public static Date getDateByEnd() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 23); |
| | | calendar.set(Calendar.MINUTE, 59); |
| | | calendar.set(Calendar.SECOND, 59); |
| | | Date zero = calendar.getTime(); |
| | | return zero; |
| | | } |
| | | |
| | | public static long getDistanceTime2Long(Date startTime, Date endTime) { |
| | | long time1 = startTime.getTime(); |
| | | long time2 = endTime.getTime(); |
| | | |
| | | long diff; |
| | | if (time1 < time2) { |
| | | diff = time2 - time1; |
| | | } else { |
| | | diff = time1 - time2; |
| | | } |
| | | return diff; |
| | | } |
| | | |
| | | public static final String getChineseOrEnglishOrNumber(String str) { |
| | | StringBuffer sbf = new StringBuffer(); |
| | | char[] charArray = str.toCharArray(); |
| | |
| | | } |
| | | |
| | | public static TUser getUser(HttpServletRequest request) { |
| | | String userId = request.getParameter("userId"); |
| | | if (StringUtils.isEmpty(userId)) { |
| | | return (TUser) request.getSession().getAttribute(Constant.USER); |
| | | } else { |
| | | return getUserById(userId); |
| | | } |
| | | } |
| | | |
| | | public static Character getCharacter(HttpServletRequest request) { |
| | | String characterType = request.getParameter("characterType"); |
| | | if (StringUtils.isEmpty(characterType)) { |
| | | return (TUser) request.getSession().getAttribute(Constant.USER); |
| | | }else { |
| | | String characterId = request.getParameter("characterId"); |
| | | MasterAuthorType type = MasterAuthorType.valueOf(characterType); |
| | | switch (type){ |
| | | case role: |
| | | return DbUtils.getRoleById(characterId); |
| | | case user: |
| | | return DbUtils.getUserById(characterId); |
| | | case groupInfo: |
| | | return DbUtils.getGroupById(characterId); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private static Character getGroupById(String characterId) { |
| | | return new TUserGroup().setGroupId(characterId); |
| | | } |
| | | |
| | | private static Character getRoleById(String roleId) { |
| | | return userRoleClient.getRoleByRoleId(roleId); |
| | | } |
| | | |
| | | public static boolean addOneRole(TUser user, List<String> roleIds) { |
| | | if (user == null) { |
| | | return false; |
| | | } |
| | | return userRoleClient.addRoleByUser(user.getUserId(), roleIds, user.getUserName()); |
| | | } |
| | | |
| | | public static boolean groupAddOneRole(String userId, String groupId, List<String> roleIds) { |
| | | |
| | | return userRoleClient.addRoleByGroupId(userId, roleIds, groupId); |
| | | } |
| | | |
| | | public static boolean delOneRole(String userId, List<String> roleIds) { |
| | | return userRoleClient.deleteRoleByUser(userId, roleIds); |
| | | } |
| | | public static boolean groupDelOneRole(String groupId, List<String> roleIds) { |
| | | return userRoleClient.deleteRoleByGroupId(roleIds, groupId); |
| | | } |
| | | public static TUser getUserById(String userId) { |
| | | TUser tUserById = userRoleClient.getTUserById(userId); |
| | | return tUserById; |
| | | } |
| | | |
| | | public static Set<String> getRoleByGroup(String groupId) { |
| | | List<TRole> tRoleListByUserId = userRoleClient.getRoleListByGroupId(groupId); |
| | | if (tRoleListByUserId == null || tRoleListByUserId.isEmpty()){ |
| | | return new HashSet<>(); |
| | | } |
| | | Set<String> collect = tRoleListByUserId.stream().map(tRole -> tRole.getRoleId()).collect(Collectors.toSet()); |
| | | return collect; |
| | | } |
| | | |
| | | public static Set<String> getRoleByUser(String userId) { |
| | | Set<String> roleIds = new HashSet<>(); |
| | | roleIds.add("R001"); |
| | | roleIds.add("R002"); |
| | | return roleIds; |
| | | List<TRole> tRoleListByUserId = userRoleClient.getTRoleListByUserId(userId); |
| | | if (tRoleListByUserId == null || tRoleListByUserId.isEmpty()){ |
| | | return new HashSet<>(); |
| | | } |
| | | Set<String> collect = tRoleListByUserId.stream().map(tRole -> tRole.getRoleId()).collect(Collectors.toSet()); |
| | | return collect; |
| | | } |
| | | |
| | | public static Set<String> getGroupByUser(String userId) { |
| | | List<TUserGroup> tRoleListByUserId = userRoleClient.getUserGroupByUserId(userId); |
| | | if (tRoleListByUserId == null || tRoleListByUserId.isEmpty()){ |
| | | return new HashSet<>(); |
| | | } |
| | | Set<String> collect = tRoleListByUserId.stream().map(tRole -> tRole.getGroupId()).collect(Collectors.toSet()); |
| | | return collect; |
| | | } |
| | | |
| | | |
| | | public static MyBatisSql getMyBatisSql(String id, Map<String, Object> parameterMap, SqlSessionFactory sqlSessionFactory) { |
| | | MyBatisSql ibatisSql = new MyBatisSql(); |
| | | MappedStatement ms = sqlSessionFactory.getConfiguration().getMappedStatement(id); |
| | | BoundSql boundSql = ms.getBoundSql(parameterMap); |
| | | ibatisSql.setSql(boundSql.getSql()); |
| | | List<ParameterMapping> parameterMappings = boundSql.getParameterMappings(); |
| | | Configuration configuration = sqlSessionFactory.getConfiguration(); |
| | | if (parameterMappings != null) { |
| | | Object[] parameterArray = new Object[parameterMappings.size()]; |
| | | ParameterMapping parameterMapping = null; |
| | | Object value = null; |
| | | Object parameterObject = null; |
| | | MetaObject metaObject = null; |
| | | PropertyTokenizer prop = null; |
| | | String propertyName = null; |
| | | String[] names = null; |
| | | for (int i = 0; i < parameterMappings.size(); i++) { |
| | | parameterMapping = parameterMappings.get(i); |
| | | if (parameterMapping.getMode() != ParameterMode.OUT) { |
| | | propertyName = parameterMapping.getProperty(); |
| | | names = propertyName.split("\\."); |
| | | if (propertyName.indexOf(".") != -1 && names.length == 2) { |
| | | parameterObject = parameterMap.get(names[0]); |
| | | propertyName = names[1]; |
| | | } else if (propertyName.indexOf(".") != -1 && names.length == 3) { |
| | | parameterObject = parameterMap.get(names[0]); // map |
| | | if (parameterObject instanceof Map) { |
| | | parameterObject = ((Map) parameterObject).get(names[1]); |
| | | } |
| | | propertyName = names[2]; |
| | | } else { |
| | | parameterObject = parameterMap.get(propertyName); |
| | | } |
| | | metaObject = parameterMap == null ? null : MetaObject.forObject(parameterObject,configuration.getObjectFactory(),configuration.getObjectWrapperFactory(), configuration.getReflectorFactory()); |
| | | prop = new PropertyTokenizer(propertyName); |
| | | if (parameterObject == null) { |
| | | value = null; |
| | | } else if (ms.getConfiguration().getTypeHandlerRegistry().hasTypeHandler(parameterObject.getClass())) { |
| | | value = parameterObject; |
| | | } else if (boundSql.hasAdditionalParameter(propertyName)) { |
| | | value = boundSql.getAdditionalParameter(propertyName); |
| | | } else if (propertyName.startsWith(ForEachSqlNode.ITEM_PREFIX) && boundSql.hasAdditionalParameter(prop.getName())) { |
| | | value = boundSql.getAdditionalParameter(prop.getName()); |
| | | if (value != null) { |
| | | value = MetaObject.forObject(value,configuration.getObjectFactory(),configuration.getObjectWrapperFactory(), configuration.getReflectorFactory()).getValue(propertyName.substring(prop.getName().length())); |
| | | } |
| | | } else { |
| | | value = metaObject == null ? null : metaObject.getValue(propertyName); |
| | | } |
| | | parameterArray[i] = value; |
| | | } |
| | | } |
| | | ibatisSql.setParameters(parameterArray); |
| | | } |
| | | return ibatisSql; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.highdatas.mdm.util; |
| | | |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.*; |
| | | import org.springframework.http.client.SimpleClientHttpRequestFactory; |
| | | import org.springframework.http.converter.StringHttpMessageConverter; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | */ |
| | | |
| | | @Component |
| | | @Slf4j |
| | | public class HttpUtils { |
| | | public static String HttpRestClient(String url, HttpMethod method, MultiValueMap<String, String> formParams) { |
| | | public static String HttpRestClient(String url, HttpMethod method, Map<String, String> formParams) { |
| | | return HttpRestClient(url,method,formParams, null, null); |
| | | } |
| | | |
| | | public static String HttpRestClient(String url, HttpMethod method, MultiValueMap<String, String> formParams, String getParams) { |
| | | public static String HttpRestClient(String url, HttpMethod method, Map<String, String> formParams, String getParams) { |
| | | return HttpRestClient(url,method,formParams, getParams, null); |
| | | } |
| | | public static String HttpRestClient(String url, HttpMethod method, MultiValueMap<String, String> formParams, MediaType mediaType) { |
| | | public static String HttpRestClient(String url, HttpMethod method, Map<String, String> formParams, MediaType mediaType) { |
| | | return HttpRestClient(url,method,formParams, null, mediaType); |
| | | } |
| | | |
| | | public static String HttpRestClient(String url, HttpMethod method, MultiValueMap<String, String> formParams, String getParams, MediaType mediaType) { |
| | | public static String HttpRestClient(String url, HttpMethod method, Map<String, String> formParams, String getParams, MediaType mediaType) { |
| | | if (!StringUtils.isEmpty(getParams)) { |
| | | url = url + Constant.QUESTION + getParams; |
| | | } |
| | | SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); |
| | | requestFactory.setConnectTimeout(15*1000); |
| | | requestFactory.setReadTimeout(15*1000); |
| | | requestFactory.setConnectTimeout(10*1000); |
| | | requestFactory.setReadTimeout(10*1000); |
| | | RestTemplate client = new RestTemplate(requestFactory); |
| | | client.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8)); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpEntity requestEntity; |
| | | if (mediaType == null){ |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | }else { |
| | | headers.setContentType(mediaType); |
| | | MultiValueMap<String, String> vals = new LinkedMultiValueMap(); |
| | | |
| | | Set<String> keySet = formParams.keySet(); |
| | | for (String key : keySet) { |
| | | String s = formParams.get(key); |
| | | List<String> strings = new ArrayList<>(); |
| | | strings.add(s); |
| | | vals.put(key,strings); |
| | | } |
| | | |
| | | HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(formParams, headers); |
| | | requestEntity = new HttpEntity<MultiValueMap<String, String>>(vals, headers); |
| | | }else { |
| | | headers.setContentType(mediaType); |
| | | requestEntity = new HttpEntity<Map<String, String>>(formParams, headers); |
| | | } |
| | | |
| | | // 执行HTTP请求 |
| | | ResponseEntity<String> response = client.exchange(url, method, requestEntity, String.class); |
| | | |
| | | return response.getBody(); |
| | | String body = response.getBody(); |
| | | log.info(MessageFormat.format("请求外部接口:url:{0}, 返回结果:{1}", url, body)); |
| | | return body; |
| | | } |
| | | |
| | | public static String HttpRestClientByObjectParams(String url, HttpMethod method, MultiValueMap<String, Object> formParams, String getParams,Map<String,String> headerValMap, MediaType mediaType) { |
| | | public static String HttpRestClientByObjectParams(String url, HttpMethod method, Map<String, Object> formParams, String getParams,Map<String,String> headerValMap, MediaType mediaType) { |
| | | if (!StringUtils.isEmpty(getParams)) { |
| | | url = url + Constant.QUESTION + getParams; |
| | | } |
| | | SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); |
| | | requestFactory.setConnectTimeout(15*1000); |
| | | requestFactory.setReadTimeout(15*1000); |
| | | requestFactory.setConnectTimeout(10*1000); |
| | | requestFactory.setReadTimeout(10*1000); |
| | | RestTemplate client = new RestTemplate(requestFactory); |
| | | client.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8)); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | |
| | | if (headerValMap != null) { |
| | | headers.setAll(headerValMap); |
| | | } |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(formParams, headers); |
| | | HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<Map<String, Object>>(formParams, headers); |
| | | // 执行HTTP请求 |
| | | ResponseEntity<String> response = client.exchange(url, method, requestEntity, String.class); |
| | | |
| | | return response.getBody(); |
| | | String body = response.getBody(); |
| | | log.info(MessageFormat.format("请求外部接口:url:{0}, 返回结果:{1}", url, body)); |
| | | return body; |
| | | } |
| | | |
| | | public static String getUrlParamsByMap(Map<String, Object> map) { |
| | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.http.HttpMethod;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.util.LinkedMultiValueMap;
|
| | | import org.springframework.util.MultiValueMap;
|
| | | import org.springframework.util.StringUtils;
|
| | |
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | @ConfigurationProperties(prefix = "mask")
|
| | | @Component
|
| | |
| | | }
|
| | | public boolean putRedisVal(String key, String value) {
|
| | | String url = maskUrl + prefix + "put";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("key",key);
|
| | | params.set("value",value);
|
| | | params.set("type",Constant.MainData);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("key",key);
|
| | | params.put("value",value);
|
| | | params.put("type",Constant.MainData);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | | public String getRedisVal(String key) {
|
| | | try {
|
| | | String url = maskUrl + prefix + "get";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("key",key);
|
| | | params.set("type",Constant.MainData);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("key",key);
|
| | | params.put("type",Constant.MainData);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | |
|
| | | public boolean deleteRedisVal(String key) {
|
| | | String url = maskUrl + prefix + "delete";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("key",key);
|
| | | params.set("type",Constant.MainData);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("key",key);
|
| | | params.put("type",Constant.MainData);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | | // strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意 |
| | | strategy.setTablePrefix(new String[]{""});// 此处可以修改为您的表前缀 |
| | | strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 |
| | | strategy.setInclude(new String[]{"master_author","master_author_detail"}); // 需要生成的表 |
| | | strategy.setInclude(new String[]{"sys_view","sys_view_join","sys_subscribe"}); // 需要生成的表 |
| | | // strategy.setExclude(new String[]{"test"}); // 排除生成的表 |
| | | // 自定义实体父类 |
| | | // strategy.setSuperEntityClass("com.baomidou.demo.TestEntity"); |
New file |
| | |
| | | package com.highdatas.mdm.util;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-15 15:39
|
| | | */
|
| | |
|
| | |
|
| | | public class MyBatisSql {
|
| | |
|
| | | private String sql;
|
| | |
|
| | | private Object[] parameters;
|
| | |
|
| | | public void setSql(String sql) {
|
| | | this.sql = sql;
|
| | | }
|
| | |
|
| | | public String getSql() {
|
| | | return sql;
|
| | | }
|
| | |
|
| | | public void setParameters(Object[] parameters) {
|
| | | this.parameters = parameters;
|
| | | }
|
| | |
|
| | | public Object[] getParameters() {
|
| | | return parameters;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | if (parameters == null || sql == null) {
|
| | | return "";
|
| | | }
|
| | | List<Object> parametersArray = Arrays.asList(parameters);
|
| | | List<Object> list = new ArrayList<Object>(parametersArray);
|
| | | while (sql.indexOf("?") != -1 && list.size() > 0 && parameters.length > 0) {
|
| | | sql = sql.replaceFirst("\\?", list.get(0).toString());
|
| | | list.remove(0);
|
| | | }
|
| | | return sql.replaceAll("(\r?\n(\\s*\r?\n)+)", "\r\n");
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.http.HttpMethod;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.util.LinkedMultiValueMap;
|
| | | import org.springframework.util.MultiValueMap;
|
| | | import org.springframework.util.StringUtils;
|
| | |
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | @ConfigurationProperties(prefix = "redis")
|
| | | @Component
|
| | |
| | | }
|
| | | public boolean putRedisVal(String key, String value) {
|
| | | String url = this.url + prefix + "put";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("key",key);
|
| | | params.set("value",value);
|
| | | params.set("type",Constant.MainData);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("key",key);
|
| | | params.put("value",value);
|
| | | params.put("type",Constant.MainData);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | | public String getRedisVal(String key) {
|
| | | try {
|
| | | String url = this.url + prefix + "get";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("key",key);
|
| | | params.set("type",Constant.MainData);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("key",key);
|
| | | params.put("type",Constant.MainData);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | |
|
| | | public boolean deleteRedisVal(String key) {
|
| | | String url = this.url + prefix + "delete";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("key",key);
|
| | | params.set("type",Constant.MainData);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("key",key);
|
| | | params.put("type",Constant.MainData);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | | import com.highdatas.mdm.pojo.CodeMsg;
|
| | | import com.highdatas.mdm.pojo.Result;
|
| | | import com.highdatas.mdm.service.ISysFieldService;
|
| | | import org.jcodings.util.Hash;
|
| | | 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.client.SimpleClientHttpRequestFactory;
|
| | | import org.springframework.http.converter.StringHttpMessageConverter;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.util.LinkedMultiValueMap;
|
| | | import org.springframework.util.MultiValueMap;
|
| | | import org.springframework.util.StringUtils;
|
| | | import org.springframework.web.client.RestTemplate;
|
| | |
|
| | | import java.nio.charset.StandardCharsets;
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | url = url + Constant.QUESTION + getParams;
|
| | | }
|
| | | SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
| | | requestFactory.setConnectTimeout(15*1000);
|
| | | requestFactory.setReadTimeout(15*1000);
|
| | | requestFactory.setConnectTimeout(10*1000);
|
| | | requestFactory.setReadTimeout(10*1000);
|
| | | RestTemplate client = new RestTemplate(requestFactory);
|
| | | client.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
| | | HttpHeaders headers = new HttpHeaders();
|
New file |
| | |
| | | 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
|
| | | * @description
|
| | | * @date 2020-04-15 13:25
|
| | | */
|
| | |
|
| | |
|
| | | @Configuration
|
| | | @EnableScheduling
|
| | | @Slf4j
|
| | | public class TimeTasks {
|
| | | @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();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | import org.springframework.http.HttpMethod;
|
| | | import org.springframework.http.MediaType;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.util.LinkedMultiValueMap;
|
| | | import org.springframework.util.MultiValueMap;
|
| | | import org.springframework.util.StringUtils;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | @ConfigurationProperties(prefix = "user")
|
| | | @Component
|
| | |
| | |
|
| | | String prefix ;
|
| | |
|
| | | private UserRoleClient() {
|
| | | public UserRoleClient() {
|
| | | this.prefix = "/api/datacvg/";
|
| | | }
|
| | |
|
| | | public TUser getTUserById(String userId) {
|
| | | String url = this.url + prefix + "user/selectUser";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("userId",userId);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("userId",userId);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params, MediaType.APPLICATION_JSON);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | | public TRole getRoleByRoleId(String roleId) {
|
| | | try {
|
| | | String url = this.url + prefix + "role/selectRole";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("roleId", roleId);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("roleId", roleId);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params, MediaType.APPLICATION_JSON);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | |
|
| | | public List<TUserGroup> getUserGroupByUserId(String userId) {
|
| | | String url = this.url + prefix + "group/userGroupInfo";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("userId",userId);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params, MediaType.APPLICATION_JSON);
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | | params.put("userId",userId);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(params);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, null,urlParamsByMap, MediaType.APPLICATION_JSON);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | | if (StringUtils.isEmpty(sucess) || !Boolean.valueOf(sucess)) {
|
| | |
| | | }
|
| | |
|
| | | public List<TRole> getTRoleListByUserId(String userId) {
|
| | | String url = this.url + prefix + "userRole/selectUserRole";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("userId",userId);
|
| | | String url = this.url + prefix + "userRole/selectUserRoleList";
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("userId",userId);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params, MediaType.APPLICATION_JSON);
|
| | | 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);
|
| | | JSONArray groupArray = data.getJSONArray("Unauthorized");
|
| | | JSONArray groupArray = result.getJSONArray(Constant.Data);
|
| | | List<TRole> tRoles = JSONArray.parseArray(groupArray.toJSONString(), TRole.class);
|
| | | if (tRoles == null || tRoles.isEmpty()) {
|
| | | return null;
|
| | |
| | | public List<TRole> getRoleListByGroupId(String groupId) {
|
| | | try {
|
| | | String url = this.url + prefix + "group/groupRoleInfo";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("groupId", groupId);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params, MediaType.APPLICATION_JSON);
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | | params.put("groupId", groupId);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(params);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, null,urlParamsByMap, MediaType.APPLICATION_JSON);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | | if (StringUtils.isEmpty(sucess) || !Boolean.valueOf(sucess)) {
|
| | |
| | | public boolean addRoleByUser(String userId, List<String> roleIds, String userName) {
|
| | | try {
|
| | | String url = this.url + prefix + "userRole/addRoleUser";
|
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
| | | params.set("userId", userId);
|
| | | params.set("listRoleId", roleIds);
|
| | | params.set("createUser", userId);
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | | params.put("userId", userId);
|
| | | params.put("listRoleId", roleIds);
|
| | | params.put("createUser", userId);
|
| | | 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);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public boolean deleteRoleByUser(String userId, List<String> roleIds, String userName) {
|
| | | public boolean deleteRoleByUser(String userId, List<String> roleIds) {
|
| | | try {
|
| | | String url = this.url + prefix + "userRole/deleteRoleUsers";
|
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
| | | params.set("userId", userId);
|
| | | params.set("listRoleId", roleIds);
|
| | | params.set("createUser", userId);
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | | params.put("userId", userId);
|
| | | params.put("listRoleId", roleIds);
|
| | | 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);
|
| | |
| | | HashMap<String, String> headerMap = new HashMap<>();
|
| | | headerMap.put("userId", userId);
|
| | |
|
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
| | | params.set("groupId", groupId);
|
| | | params.set("roleIdList", roleIds);
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | | params.put("groupId", groupId);
|
| | | params.put("roleIdList", roleIds);
|
| | | String s = HttpUtils.HttpRestClientByObjectParams(url, HttpMethod.POST, params, null,headerMap,MediaType.APPLICATION_JSON);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | | public boolean deleteRoleByGroupId(List<String> roleIds, String groupId) {
|
| | | try {
|
| | | String url = this.url + prefix + "group/delGroupRole";
|
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
| | | params.set("groupId", groupId);
|
| | | params.set("roleIdList", roleIds);
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | | params.put("groupId", groupId);
|
| | | params.put("roleIdList", roleIds);
|
| | | 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);
|
| | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.http.HttpMethod;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.util.LinkedMultiValueMap;
|
| | | import org.springframework.util.MultiValueMap;
|
| | | import org.springframework.util.StringUtils;
|
| | |
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | @ConfigurationProperties(prefix = "visit")
|
| | | @Component
|
| | |
| | |
|
| | | public boolean putRedisVal(HttpTraceLogFilter.HttpTraceLog traceLog) {
|
| | | String url = maskUrl + prefix + "recordVisitLog";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("userId",traceLog.getUserId());
|
| | | params.set("userIp",traceLog.getUserIp());
|
| | | params.set("urlId",traceLog.getUrlId());
|
| | | params.set("requestParam",traceLog.getRequestBody());
|
| | | params.set("requestResult",traceLog.getResponseStatus());
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("userId",traceLog.getUserId());
|
| | | params.put("userIp",traceLog.getUserIp());
|
| | | params.put("urlId",traceLog.getUrlId());
|
| | | params.put("requestParam",traceLog.getRequestBody());
|
| | | params.put("requestResult",traceLog.getResponseStatus());
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | | public String getRedisVal(String key) {
|
| | | try {
|
| | | String url = maskUrl + prefix + "get";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("key",key);
|
| | | params.set("type",Constant.MainData);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("key",key);
|
| | | params.put("type",Constant.MainData);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | |
| | |
|
| | | public boolean deleteRedisVal(String key) {
|
| | | String url = maskUrl + prefix + "delete";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("key",key);
|
| | | params.set("type",Constant.MainData);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("key",key);
|
| | | params.put("type",Constant.MainData);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
New file |
| | |
| | | package com.highdatas.mdm.util.pool;
|
| | |
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.highdatas.mdm.pojo.CodeMsg;
|
| | | import com.highdatas.mdm.pojo.Result;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.http.MediaType;
|
| | |
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-14 12:49
|
| | | */
|
| | |
|
| | | @Slf4j
|
| | | public class MqMessage extends PriorityTask{
|
| | | public MqMessage(String code, HttpServletResponse response) {
|
| | | super(code,response);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | 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();
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.highdatas.mdm.util.pool;
|
| | |
|
| | | import java.util.concurrent.*;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-14 11:45
|
| | | */
|
| | |
|
| | |
|
| | | public class PassiveMqThreadPoolExecutor extends ThreadPoolExecutor {
|
| | |
|
| | | public PassiveMqThreadPoolExecutor(int corePoolSize, int maximumPoolSize,
|
| | | long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
|
| | | super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
|
| | | }
|
| | |
|
| | | public PassiveMqThreadPoolExecutor(int corePoolSize, int maximumPoolSize,
|
| | | long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue,
|
| | | RejectedExecutionHandler handler) {
|
| | | super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
|
| | | }
|
| | |
|
| | | public PassiveMqThreadPoolExecutor(int corePoolSize, int maximumPoolSize,
|
| | | long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue,
|
| | | ThreadFactory threadFactory) {
|
| | | super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
|
| | | }
|
| | |
|
| | | public PassiveMqThreadPoolExecutor(int corePoolSize, int maximumPoolSize,
|
| | | long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue,
|
| | | ThreadFactory threadFactory, RejectedExecutionHandler handler) {
|
| | | super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {
|
| | | return new ComparableFutureTask<T>(runnable, value);
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
|
| | | return new ComparableFutureTask<T>(callable);
|
| | | }
|
| | |
|
| | | protected class ComparableFutureTask<V>
|
| | | extends FutureTask<V> implements Comparable<ComparableFutureTask<V>> {
|
| | | private Object object;
|
| | |
|
| | | public ComparableFutureTask(Callable<V> callable) {
|
| | | super(callable);
|
| | | object = callable;
|
| | | }
|
| | |
|
| | | public ComparableFutureTask(Runnable runnable, V result) {
|
| | | super(runnable, result);
|
| | | object = runnable;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @SuppressWarnings("unchecked")
|
| | | public int compareTo(ComparableFutureTask<V> o) {
|
| | | if (this == o) {
|
| | | return 0;
|
| | | }
|
| | | if (o == null) {
|
| | | return -1; // high priority
|
| | | }
|
| | | if (object != null && o.object != null) {
|
| | | if (object.getClass().equals(o.object.getClass())) {
|
| | | if (object instanceof Comparable) {
|
| | | return ((Comparable) object).compareTo(o.object);
|
| | | }
|
| | | }
|
| | | }
|
| | | return 0;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-14 11:42
|
| | | */
|
| | |
|
| | |
|
| | | public abstract class PriorityTask implements Runnable, Comparable<PriorityTask>{
|
| | | @Value("${pool.coefficient}")
|
| | | Integer cntCoefficient;
|
| | | @Value("${pool.timeout}")
|
| | | Integer timeout;
|
| | | protected Long prority;
|
| | | protected String code;
|
| | | 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;
|
| | | calPrority();
|
| | | calEndTime();
|
| | | }
|
| | |
|
| | | public PriorityTask(String code, HttpServletResponse response) {
|
| | | this.code = code;
|
| | | this.response = response;
|
| | | }
|
| | |
|
| | | public void calEndTime() {
|
| | | long time = this.time.getTime();
|
| | | if (timeout == null) {
|
| | | timeout = 3000000;
|
| | | }
|
| | | long l = time + timeout;
|
| | | this.endTime = new Date(l);
|
| | | }
|
| | |
|
| | | public void calPrority() {
|
| | | long basePrority = DbUtils.getDistanceTime2Long(DbUtils.getDateByEnd(), this.time) / 1000;
|
| | | if (cntCoefficient == null) {
|
| | | //默认系数50
|
| | | cntCoefficient = Constant.cntCoefficient;
|
| | | }
|
| | | int val = cnt * cntCoefficient;
|
| | | basePrority += val;
|
| | | this.prority = basePrority;
|
| | | }
|
| | |
|
| | | public String getCode() {
|
| | | return code;
|
| | | }
|
| | |
|
| | | public int getCnt() {
|
| | | return cnt;
|
| | | }
|
| | |
|
| | | public Date getEndTime() {
|
| | | return endTime;
|
| | | }
|
| | |
|
| | | public Date getTime() {
|
| | | return time;
|
| | | }
|
| | |
|
| | | public HttpServletResponse getResponse() {
|
| | | return response;
|
| | | }
|
| | |
|
| | | public PriorityTask(String code, long prority, HttpServletResponse response) {
|
| | | this.prority = prority;
|
| | | this.code = code;
|
| | | this.response = response;
|
| | | }
|
| | |
|
| | | public void setCnt(int cnt) {
|
| | | this.cnt = cnt;
|
| | | calPrority();
|
| | | }
|
| | |
|
| | | public void setTime(Date time) {
|
| | | this.time = time;
|
| | | calPrority();
|
| | | calEndTime();
|
| | | }
|
| | |
|
| | | public void setResponse(HttpServletResponse response) {
|
| | | this.response = response;
|
| | | }
|
| | |
|
| | | public long getPrority() {
|
| | | return prority;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public abstract void run();
|
| | |
|
| | |
|
| | | @Override
|
| | | public int compareTo(PriorityTask o) {
|
| | | 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)));
|
| | | }
|
| | | }
|
| | |
| | | username: root |
| | | password: 123456 |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | |
| | | druid: |
| | | maxActive: 3 |
| | | maxWait: 30000 |
| | | validationQuery: select 1 |
| | | testWhileIdle: true |
| | | testOnBorrow: false |
| | | testOnReturn: false |
| | | timeBetweenEvictionRunsMillis: 60000 |
| | | minEvictableIdleTimeMillis: 300000 |
| | | removeAbandoned: true |
| | | removeAbandonedTimeout: 1800 |
| | | logAbandoned: false |
| | | |
| | | activiti: |
| | | database-schema-update: true |
| | |
| | | #activiti: |
| | | # check-process-definitions: false |
| | | redis: |
| | | url: http://180.169.94.250:9107 |
| | | |
| | | user: |
| | | url: http://180.169.94.250:9107 |
| | | |
| | | rule: |
| | |
| | | zookeeper: |
| | | znode: |
| | | parent: /hbase |
| | | |
| | | pool: |
| | | coresize: 5 |
| | | coefficient: 20 |
| | | timeout: 3000000 |
| | |
| | | server: |
| | | port: 18090 |
| | | |
| | | |
| | | |
| | | spring: |
| | | datasource: |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | | url: jdbc:mysql://139.224.69.76:3306/data_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | username: dsmp |
| | | password: Datacvg123! |
| | | hikari: |
| | | minimum-idle: 3 |
| | | max-lifetime: 30000 |
| | | connection-test-query: select 1 |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | druid: |
| | | maxActive: 20 |
| | | maxWait: 30000 |
| | | validationQuery: select 1 |
| | | testWhileIdle: true |
| | | testOnBorrow: false |
| | | testOnReturn: false |
| | | timeBetweenEvictionRunsMillis: 60000 |
| | | minEvictableIdleTimeMillis: 300000 |
| | | removeAbandoned: true |
| | | removeAbandonedTimeout: 1800 |
| | | logAbandoned: false |
| | | |
| | | activiti: |
| | | database-schema-update: flase |
| | | |
| | |
| | | redis: |
| | | url: http://127.0.0.1:9107 |
| | | |
| | | user: |
| | | url: http://127.0.0.1:9107 |
| | | |
| | | rule: |
| | | url: http://127.0.0.1:9107 |
| | | |
| | | |
| | | xxljob: |
| | | local: http://127.0.0.1:9010 |
| | |
| | | password: Datacvg123! |
| | | bigdata: |
| | | db:hbase? |
| | | |
| | | pool: |
| | | coresize: 5 |
| | | coefficient: 20 |
| | |
| | | port: 9010 |
| | | bak: |
| | | url: 220.158.10.151 |
| | | img: |
| | | url: d:/datagovernance/file/activiti/ |
| | | |
| | | baks: |
| | | url: jdbc:mysql://127.0.0.1:3306/data_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | username: root |
| | |
| | | url: jdbc:mysql://180.169.94.250:8306/data_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | username: masterdata |
| | | password: md123! |
| | | hikari: |
| | | minimum-idle: 3 |
| | | max-lifetime: 30000 |
| | | connection-test-query: select 1 |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | druid: |
| | | maxActive: 20 |
| | | maxWait: 30000 |
| | | validationQuery: select 1 |
| | | testWhileIdle: true |
| | | testOnBorrow: false |
| | | testOnReturn: false |
| | | timeBetweenEvictionRunsMillis: 60000 |
| | | minEvictableIdleTimeMillis: 300000 |
| | | removeAbandoned: true |
| | | removeAbandonedTimeout: 1800 |
| | | logAbandoned: false |
| | | |
| | | activiti: |
| | | database-schema-update: flase |
| | |
| | | column-underline: true |
| | | |
| | | redis: |
| | | host: http://180.169.94.250 |
| | | port: 9107 |
| | | url: http://180.169.94.250:9107 |
| | | |
| | | rule: |
| | | url: http://180.169.94.250:9107 |
| | | |
| | | user: |
| | | url: http://180.169.94.250:9107 |
| | | |
| | | xxljob: |
| | | local: http://180.169.94.250:9010 |
| | |
| | | password: md123! |
| | | bigdata: |
| | | db:hbase? |
| | | |
| | | pool: |
| | | coresize: 5 |
| | | coefficient: 20 |
New file |
| | |
| | | server:
|
| | | port: 18090
|
| | |
|
| | | spring:
|
| | | datasource:
|
| | | driver-class-name: com.mysql.jdbc.Driver
|
| | | url: jdbc:mysql://127.0.0.1:3306/data_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true
|
| | | username: root
|
| | | password: datacvg123!
|
| | | type: com.alibaba.druid.pool.DruidDataSource
|
| | | druid:
|
| | | maxActive: 20
|
| | | maxWait: 30000
|
| | | validationQuery: select 1
|
| | | testWhileIdle: true
|
| | | testOnBorrow: false
|
| | | testOnReturn: false
|
| | | timeBetweenEvictionRunsMillis: 60000
|
| | | minEvictableIdleTimeMillis: 300000
|
| | | removeAbandoned: true
|
| | | removeAbandonedTimeout: 1800
|
| | | logAbandoned: false
|
| | |
|
| | | activiti:
|
| | | database-schema-update: flase
|
| | |
|
| | | thymeleaf:
|
| | | cache: false
|
| | | prefix: classpath:/templates/
|
| | | suffix: .html
|
| | | servlet:
|
| | | content-type: text/html
|
| | | encoding: utf-8
|
| | |
|
| | | logging:
|
| | | level:
|
| | | com:
|
| | | highdatas:
|
| | | mdm:
|
| | | mapper: DEBUG
|
| | |
|
| | | mybatis-plus:
|
| | | mapper-locations: classpath:mapping/*.xml
|
| | | type-aliases-package: com.highdatas.mdm.mapper
|
| | | global-config:
|
| | | db-config:
|
| | | column-underline: true
|
| | |
|
| | | redis:
|
| | | url: http://127.0.0.1:9107
|
| | |
|
| | | user:
|
| | | url: http://127.0.0.1:9107
|
| | |
|
| | | rule:
|
| | | url: http://127.0.0.1:9107
|
| | |
|
| | | xxljob:
|
| | | local: http://127.0.0.1:9010
|
| | | url: http://127.0.0.1:6890
|
| | | xxl:
|
| | | job:
|
| | | accessToken:
|
| | | executor:
|
| | | ip:
|
| | | port: 9909
|
| | | logpath: /data/applogs/xxl-job/jobhandler
|
| | | logretentiondays: 1
|
| | | appname: assemble
|
| | | admin:
|
| | | addresses: http://127.0.0.1:8090/xxl-job-admin
|
| | |
|
| | |
|
| | | master:
|
| | | unbigdata:
|
| | | db:
|
| | | host: http://127.0.0.1
|
| | | type: MYSQL
|
| | | port: 3306
|
| | | schema: data_admin
|
| | | url: jdbc:mysql://127.0.0.1:3306/data_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true
|
| | | username: root
|
| | | password: datacvg123!
|
| | | bigdata:
|
| | | db:hbase?
|
| | |
|
| | | pool:
|
| | | coresize: 5
|
| | | coefficient: 20 |