| | |
| | | } |
| | | @RequestMapping(value = "/img/{modelId}", method = RequestMethod.GET) |
| | | public void image(@PathVariable String modelId, HttpServletResponse response) { |
| | | String filePath = basePath + modelId +"/"+ modelId + ".png"; |
| | | File file = new File(filePath); |
| | | FileInputStream fileInputStream = null; |
| | | InputStream is = repositoryService.getModelImg(modelId); |
| | | |
| | | response.setHeader("Content-Type", "image/png"); |
| | | try{ |
| | | fileInputStream = new FileInputStream(file); |
| | | OutputStream outputStream = response.getOutputStream(); |
| | | byte[] b = new byte[1024]; |
| | | int len; |
| | | while ((len = fileInputStream.read(b, 0, 1024)) != -1) { |
| | | while ((len = is.read(b, 0, 1024)) != -1) { |
| | | outputStream.write(b, 0, len); |
| | | } |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | finally { |
| | | if (fileInputStream != null) { |
| | | if (is != null) { |
| | | try { |
| | | fileInputStream.close(); |
| | | is.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | //todo 判断当前task是否是当前人能审批的 |
| | | |
| | | taskService.setSession(session); |
| | | ActivitiStatus status = flows.getStatus(); |
| | |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId);
|
| | | o.fluentPut("menuList", sysMenus);
|
| | | }
|
| | |
|
| | |
|
| | | List<SysAssembleDb> dbList = dbService.selectList(new EntityWrapper<SysAssembleDb>().eq(Constant.PARENT_ID, record.getId()));
|
| | | o.fluentPut("dbList", dbList);
|
| | |
|
| | |
| | | IFlowsService flowsService; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String id) { |
| | |
| | | if (StringUtils.isEmpty(flowId)) { |
| | | continue; |
| | | } |
| | | |
| | | boolean author = masterAuthorService.checkMaintainAuthor(userId, maintain.getId()); |
| | | if (!author) { |
| | | continue; |
| | | } |
| | | Flows flows = flowsService.selectById(maintain.getFlowId()); |
| | | if (flows.getStatus().equals(ActivitiStatus.close)) { |
| | | continue; |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.MaintainField; |
| | | import com.highdatas.mdm.entity.MenuMapping; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.IMaintainFieldService; |
| | | import com.highdatas.mdm.service.IMaintainService; |
| | | import com.highdatas.mdm.service.IMenuMappingService; |
| | | import com.highdatas.mdm.service.ISysFieldService; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RestController |
| | | @RequestMapping("/maintainField") |
| | | public class MaintainFieldController { |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | TableInfoMapper tableInfoMapper; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | |
| | | @RequestMapping(value = "/getMaintainListByMenu/{menuId}", method = RequestMethod.GET) |
| | | public Result getMaintainListByTable(@PathVariable String menuId) { |
| | | MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("menu_id", menuId).orderBy("create_time")); |
| | | if (menuMapping == null){ |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | String tableName = menuMapping.getTableName(); |
| | | |
| | | JSONArray array = maintainFieldService.getMaintainListByTable(tableName); |
| | | return Result.success(array); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getMaintainListByTable/{tableName}", method = RequestMethod.GET) |
| | | public Result deleteModel(@PathVariable String tableName) { |
| | | List<MaintainField> maintainFieldList = maintainFieldService.selectList(new EntityWrapper<MaintainField>().eq("table_name", tableName).orderBy("order_no")); |
| | | int preOrderNo = -1; |
| | | HashMap<String, List<Maintain>> resultMap = new HashMap<>(); |
| | | if (maintainFieldList.size() == 0) { |
| | | List<Maintain> maintainList = maintainService.selectList(new EntityWrapper<Maintain>().orderBy("order_no")); |
| | | resultMap.put(Constant.Default, maintainList); |
| | | return Result.success(resultMap); |
| | | } |
| | | for (MaintainField maintainField : maintainFieldList) { |
| | | String maintainId = maintainField.getMaintainId(); |
| | | if (StringUtils.isEmpty(maintainId)) { |
| | | continue; |
| | | } |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | if (maintain == null) { |
| | | continue; |
| | | } |
| | | Integer orderNo = maintain.getOrderNo(); |
| | | List<Maintain> maintainList = maintainService.selectList(new EntityWrapper<Maintain>().ge("order_no", preOrderNo).le("order_no", orderNo)); |
| | | resultMap.put(maintainField.getId(), maintainList); |
| | | preOrderNo = orderNo; |
| | | } |
| | | Set<String> keySet = resultMap.keySet(); |
| | | JSONArray array = new JSONArray(); |
| | | for (String s : keySet) { |
| | | List<Maintain> maintainList = resultMap.get(s); |
| | | Maintain max = maintainList.stream().max(new Comparator<Maintain>() { |
| | | @Override |
| | | public int compare(Maintain o1, Maintain o2) { |
| | | return o1.getOrderNo() - o2.getOrderNo(); |
| | | } |
| | | }).get(); |
| | | Maintain min = maintainList.stream().min(new Comparator<Maintain>() { |
| | | @Override |
| | | public int compare(Maintain o1, Maintain o2) { |
| | | return o1.getOrderNo() - o2.getOrderNo(); |
| | | } |
| | | }).get(); |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("maintainFieldId", s); |
| | | object.fluentPut("version", MessageFormat.format(Constant.extent, min.getVersion(), max.getVersion())); |
| | | |
| | | array.add(object); |
| | | } |
| | | return Result.success(array); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-03-23 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/masterAuthor") |
| | | public class MasterAuthorController { |
| | | |
| | | @Autowired |
| | | IMasterAuthorService authorService; |
| | | @Autowired |
| | | IMasterAuthorDetailService authorDetailService; |
| | | @Autowired |
| | | ITUserRoleService userRoleService; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | @Autowired |
| | | ISysMenuService menuService; |
| | | |
| | | public static final String masterAuthorType = "masterAuthorType"; |
| | | public static final String masterId = "masterId"; |
| | | public static final String tableName = "table_name"; |
| | | public static final String characterId = "characterId"; |
| | | public static final String character_id = "character_id"; |
| | | public static final String fields = "fields"; |
| | | private String maintainFieldId = "maintainFieldId"; |
| | | private String maintain_field_id = "maintain_field_id"; |
| | | |
| | | @RequestMapping(value = "/addOrUpdate", method = RequestMethod.POST) |
| | | public Result deleteModel(@RequestBody MasterAuthor masterAuthor) { |
| | | if (!StringUtils.isEmpty(masterAuthor.getId())) { |
| | | masterAuthor.setUpdateTime(new Date()); |
| | | }else { |
| | | masterAuthor.setId(DbUtils.getUUID()).setCreateTime(new Date()); |
| | | } |
| | | String menuId = masterAuthor.getMenuId(); |
| | | String tableName = menuMappingService.getTableNameByMenu(menuId); |
| | | masterAuthor.setTableName(tableName); |
| | | //delete pre |
| | | boolean delete = authorDetailService.delete(new EntityWrapper<MasterAuthorDetail>().eq(Constant.PARENT_ID, masterAuthor.getId())); |
| | | if (!delete){ |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | | } |
| | | |
| | | for (MasterAuthorDetail detail : masterAuthor.getFields()) { |
| | | detail.setId(DbUtils.getUUID()).setParentId(masterAuthor.getId()).insert(); |
| | | } |
| | | |
| | | boolean b = masterAuthor.insertOrUpdate(); |
| | | if (b) { |
| | | return Result.success(masterAuthor); |
| | | }else { |
| | | return Result.error(CodeMsg.UPDATE_ERROR); |
| | | } |
| | | } |
| | | |
| | | @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)); |
| | | 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); |
| | | if (tableMasterAuthor == null) { |
| | | Result.success(null); |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | ArrayList<MasterAuthor> list = new ArrayList(tableMasterAuthor.values()); |
| | | |
| | | object.fluentPut("type", MasterAuthorType.role); |
| | | object.fluentPut("author",list); |
| | | |
| | | Set<String> collect = list.stream().map(masterAuthor -> masterAuthor.getMenuId()).collect(Collectors.toSet()); |
| | | LinkedHashSet<String> menuIds= new LinkedHashSet<>(collect); |
| | | LinkedHashSet<String> byParentId = menuService.getByParentId(menuIds); |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | object.fluentPut("audit",sysMenus); |
| | | return Result.success(object); |
| | | } |
| | | |
| | | for (MasterAuthor masterAuthor : masterAuthorList) { |
| | | List<MasterAuthorDetail> masterAuthorDetails = authorDetailService |
| | | .selectList(new EntityWrapper<MasterAuthorDetail>() |
| | | .eq(Constant.PARENT_ID, masterAuthor.getId())); |
| | | masterAuthor.setFields(masterAuthorDetails); |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | Set<String> collect = masterAuthorList.stream().map(masterAuthor -> masterAuthor.getMenuId()).collect(Collectors.toSet()); |
| | | LinkedHashSet<String> menuIds= new LinkedHashSet<>(collect); |
| | | LinkedHashSet<String> byParentId = menuService.getByParentId(menuIds); |
| | | 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 = "/delete/{characterId}", method = RequestMethod.GET) |
| | | public Result delete(@PathVariable String characterId, @RequestParam MasterAuthorType type){ |
| | | List<MasterAuthor> masterAuthorList = authorService.selectList(new EntityWrapper<MasterAuthor>() |
| | | .eq(Constant.TYPE, type).eq(this.characterId, characterId)); |
| | | if (masterAuthorList.isEmpty()) { |
| | | return Result.success(null); |
| | | } |
| | | boolean delete = false; |
| | | for (MasterAuthor masterAuthor : masterAuthorList) { |
| | | delete = authorDetailService.delete(new EntityWrapper<MasterAuthorDetail>().eq(Constant.PARENT_ID, masterAuthor.getId())); |
| | | if (delete) { |
| | | delete = masterAuthor.deleteById(); |
| | | } |
| | | } |
| | | |
| | | if (delete) { |
| | | return Result.success(CodeMsg.DELETE_SUCCESS); |
| | | }else { |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/delete/menu/{menuId}", method = RequestMethod.GET) |
| | | public Result deleteTable(@PathVariable String menuId, @RequestParam String characterId, @RequestParam MasterAuthorType type, HttpServletRequest request){ |
| | | String maintainFieldId = request.getParameter(this.maintainFieldId); |
| | | Wrapper<MasterAuthor> masterAuthorWrapper = new EntityWrapper<MasterAuthor>() |
| | | .eq(Constant.TYPE, type) |
| | | .eq(character_id, characterId) |
| | | .eq("menu_id", menuId); |
| | | if (!StringUtils.isEmpty(maintainFieldId)) { |
| | | masterAuthorWrapper.eq(this.maintain_field_id, maintainFieldId); |
| | | } |
| | | |
| | | List<MasterAuthor> masterAuthorList = authorService.selectList(masterAuthorWrapper); |
| | | if (masterAuthorList.isEmpty()) { |
| | | return Result.success(null); |
| | | } |
| | | boolean partDel = false; |
| | | if (masterAuthorList.size() == 1 && !StringUtils.isEmpty(maintainFieldId)) { |
| | | // 只有一个且删除 字段版本 保留本条 |
| | | partDel = true; |
| | | } |
| | | boolean delete = false; |
| | | for (MasterAuthor masterAuthor : masterAuthorList) { |
| | | delete = authorDetailService.delete(new EntityWrapper<MasterAuthorDetail>().eq(Constant.PARENT_ID, masterAuthor.getId())); |
| | | if (delete) { |
| | | if (partDel) { |
| | | delete = masterAuthor.setMaintainFieldId(null).updateById(); |
| | | }else { |
| | | delete = masterAuthor.deleteById(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | if (delete) { |
| | | return Result.success(CodeMsg.DELETE_SUCCESS); |
| | | }else { |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/addRole/{roleId}", method = RequestMethod.GET) |
| | | public Result addRole(@PathVariable String roleId, 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); |
| | | |
| | | HashMap<String, MasterAuthor> tableMasterAuthor = authorService.merageRoleAuthor(roleIdList); |
| | | if (tableMasterAuthor == null) { |
| | | Result.success(null); |
| | | } |
| | | return Result.success(tableMasterAuthor.values()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | 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 com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-03-23 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/masterAuthor/detail") |
| | | public class MasterAuthorDetailController { |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | @Autowired |
| | | IMasterAuthorDetailService masterAuthorDetailService; |
| | | @Autowired |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | @Autowired |
| | | ITUserRoleService userRoleService; |
| | | |
| | | @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) |
| | | public Result addRole(@PathVariable String id,@RequestParam String field){ |
| | | MasterAuthor masterAuthor = masterAuthorService.selectById(id); |
| | | if (masterAuthor == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean delete = masterAuthorDetailService.delete(new EntityWrapper<MasterAuthorDetail>() |
| | | .eq(Constant.PARENT_ID, masterAuthor.getId()).eq(Constant.FIELD, field)); |
| | | if (delete) { |
| | | return Result.success(CodeMsg.DELETE_SUCCESS); |
| | | }else { |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/getFieldByMaintainFieldId/{id}", method = RequestMethod.GET) |
| | | public Result getFieldByMaintainFieldId(@PathVariable String id, @RequestParam MasterAuthorType type, @RequestParam String characterId, HttpServletRequest request) { |
| | | List<SysField> result; |
| | | |
| | | String menuId = request.getParameter("menuId"); |
| | | String tableName = menuMappingService.getTableNameByMenu(menuId); |
| | | if (Constant.Default.equalsIgnoreCase(id)) { |
| | | if (StringUtils.isEmpty(tableName)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | result = fieldService.getDefaultTableField(tableName); |
| | | }else if (Constant.All.equalsIgnoreCase(id)) { |
| | | if (StringUtils.isEmpty(tableName)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | result = fieldService.getTotalTableField(tableName); |
| | | }else { |
| | | result = fieldService.getFieldByMaintainField(id); |
| | | } |
| | | JSONObject resultObj = new JSONObject(); |
| | | MasterAuthor masterAuthor = masterAuthorService.selectOne(new EntityWrapper<MasterAuthor>() |
| | | .eq(Constant.TYPE, type) |
| | | .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); |
| | | String key = DbUtils.getFieldRedisKey(tableName, id); |
| | | masterAuthor = tableMasterAuthor.get(key); |
| | | } |
| | | |
| | | if (masterAuthor == null) { |
| | | |
| | | resultObj.fluentPut("unchecked", result); |
| | | return Result.success(resultObj); |
| | | } |
| | | List<MasterAuthorDetail> fields = masterAuthorDetailService.selectList(new EntityWrapper<MasterAuthorDetail>().eq(Constant.PARENT_ID, masterAuthor.getId())); |
| | | if (fields != null) { |
| | | List<String> checkedFieldStrList = fields.stream().map(masterAuthorDetail -> masterAuthorDetail.getField()).collect(Collectors.toList()); |
| | | result = result.stream().filter(sysField -> !checkedFieldStrList.contains(sysField.getField())).collect(Collectors.toList()); |
| | | } |
| | | resultObj.fluentPut("unchecked", result); |
| | | resultObj.fluentPut("checked", fields); |
| | | return Result.success(resultObj); |
| | | } |
| | | } |
| | |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.pentaho.reporting.libraries.formula.function.text.StringCountFunction; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | IMaintainDetailService maintainDetailService; |
| | | |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | IMasterModifiedService masterModifiedService; |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | |
| | | @RequestMapping(value = "{tableName}/uploaded", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String tableName, HttpServletRequest request) { |
| | |
| | | version = String.valueOf(nowVersion.getVersion()); |
| | | }else if(version.equalsIgnoreCase(Constant.MAX)){ |
| | | findMax = true; |
| | | version = String.valueOf(maintainService.getMaxVersion(tableName).getVersion()); |
| | | Maintain maxVersion = maintainService.getMaxVersion(tableName); |
| | | if (maxVersion == null) { |
| | | return Result.success(null); |
| | | } |
| | | version = String.valueOf(maxVersion.getVersion()); |
| | | } |
| | | |
| | | masterAuthorService.getFilter() |
| | | if (StringUtils.isEmpty(fields)) { |
| | | if (StringUtils.isEmpty(pageSizeStr)) { |
| | | return masterDataService.selectListByPageByVersion(tableName, whereSegment,pageNo,version, findMax); |
| | |
| | | version = String.valueOf(maintainService.getNowVersion(tableName).getVersion()); |
| | | } |
| | | if (StringUtils.isEmpty(whereSegment)) { |
| | | return masterDataService.selectList(tableName); |
| | | return masterDataService.selectList(tableName,Constant.WHERE_DEFAULT, version); |
| | | } |
| | | return masterDataService.selectList(tableName,whereSegment); |
| | | return masterDataService.selectList(tableName,whereSegment, version); |
| | | } |
| | | |
| | | @RequestMapping(value = "{maintainId}/modify/{operateStr}", method = RequestMethod.POST) |
| | |
| | | return masterDataService.delete(tableName, whereSegment); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/getValByMaintainFieldId/{maintainFieldId}", method = RequestMethod.GET) |
| | | public Result getValByMaintainFieldId(@PathVariable String maintainFieldId,@RequestParam String menuId, @RequestParam String field, HttpServletRequest request) { |
| | | String tableName = menuMappingService.getTableNameByMenu(menuId); |
| | | if (StringUtils.isEmpty(tableName)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | if (maintainFieldId.equalsIgnoreCase(Constant.All)) { |
| | | Set<String> fieldValList = masterDataService.getFieldValByTable(tableName, field); |
| | | return Result.success(fieldValList); |
| | | } |
| | | |
| | | Set<String> fieldValByMaintainField = masterDataService.getFieldValByMaintainField(maintainFieldId, field, tableName); |
| | | |
| | | return Result.success(fieldValByMaintainField); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | public Result<Object> update(@RequestParam String data) throws Exception { |
| | | boolean updated =menuMappingService.update(data); |
| | | if (updated) { |
| | | return Result.success("更新成功", null); |
| | | return Result.success(data); |
| | | } else { |
| | | return Result.error(CodeMsg.UPDATE_ERROR); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | |
| | | @RequestMapping(value = "/all", method = RequestMethod.GET) |
| | | public Result<List<SysMenu>> getAll() { |
| | | EntityWrapper<SysMenu> sysMenuEntityWrapper = new EntityWrapper<>(); |
| | | sysMenuEntityWrapper.orderBy("parent_id, order_no"); |
| | | return Result.success(menuService.selectList(sysMenuEntityWrapper)) ; |
| | | } |
| | | |
| | | @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()); |
| | | return Result.success(menu) ; |
| | | } |
| | | |
| | | @RequestMapping(value = "/audit", method = RequestMethod.GET) |
| | |
| | | menu.setMenuType(menuType); |
| | | boolean inserted = menuService.insert(menu); |
| | | if (inserted) { |
| | | return Result.success("插入成功", null); |
| | | return Result.success(menu); |
| | | } else { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } |
| | |
| | | // } |
| | | // } |
| | | |
| | | return Result.success(CodeMsg.SUCCESS); |
| | | return Result.success(menu); |
| | | } |
| | | |
| | | @RequestMapping(value = "/update", method = RequestMethod.GET) |
| | |
| | | List<SysMenu> sysMenus = menuService.selectList(menuEntityWrapper); |
| | | return Result.success(sysMenus); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.entity; |
| | | |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.FieldStrategy; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-03-23 |
| | | */ |
| | | @TableName("master_author") |
| | | public class MasterAuthor extends Model<MasterAuthor> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | private MasterAuthorType type; |
| | | |
| | | @TableField("table_name") |
| | | private String tableName; |
| | | |
| | | @TableField("field_auto") |
| | | private Boolean fieldAuto; |
| | | |
| | | @TableField("character_id") |
| | | private String characterId; |
| | | |
| | | @TableField("menu_id") |
| | | private String menuId; |
| | | |
| | | @TableField(value = "maintain_field_id", strategy = FieldStrategy.IGNORED) |
| | | private String maintainFieldId; |
| | | |
| | | |
| | | private Boolean active; |
| | | |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | | |
| | | @TableField("update_time") |
| | | private Date updateTime; |
| | | |
| | | private transient List<MasterAuthorDetail> fields; |
| | | |
| | | public String getMenuId() { |
| | | return menuId; |
| | | } |
| | | |
| | | public MasterAuthor setMenuId(String menuId) { |
| | | this.menuId = menuId; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getFieldAuto() { |
| | | return fieldAuto; |
| | | } |
| | | |
| | | public MasterAuthor setFieldAuto(Boolean fieldAuto) { |
| | | this.fieldAuto = fieldAuto; |
| | | return this; |
| | | } |
| | | |
| | | public List<MasterAuthorDetail> getFields() { |
| | | return fields; |
| | | } |
| | | |
| | | public MasterAuthor setFields(List<MasterAuthorDetail> fields) { |
| | | this.fields = fields; |
| | | return this; |
| | | } |
| | | |
| | | public String getMaintainFieldId() { |
| | | return maintainFieldId; |
| | | } |
| | | |
| | | public MasterAuthor setMaintainFieldId(String maintainFieldId) { |
| | | this.maintainFieldId = maintainFieldId; |
| | | return this; |
| | | } |
| | | |
| | | public String getCharacterId() { |
| | | return characterId; |
| | | } |
| | | |
| | | public MasterAuthor setCharacterId(String characterId) { |
| | | this.characterId = characterId; |
| | | return this; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public MasterAuthor setId(String id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | public MasterAuthorType getType() { |
| | | return type; |
| | | } |
| | | |
| | | public MasterAuthor setType(MasterAuthorType type) { |
| | | this.type = type; |
| | | return this; |
| | | } |
| | | public String getTableName() { |
| | | return tableName; |
| | | } |
| | | |
| | | public MasterAuthor setTableName(String tableName) { |
| | | this.tableName = tableName; |
| | | return this; |
| | | } |
| | | public Boolean getActive() { |
| | | return active; |
| | | } |
| | | |
| | | public MasterAuthor setActive(Boolean active) { |
| | | this.active = active; |
| | | return this; |
| | | } |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public MasterAuthor setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | return this; |
| | | } |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public MasterAuthor setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "MasterAuthor{" + |
| | | "id=" + id + |
| | | ", type=" + type + |
| | | ", tableName=" + tableName + |
| | | ", active=" + active + |
| | | ", createTime=" + createTime + |
| | | ", updateTime=" + updateTime + |
| | | "}"; |
| | | } |
| | | } |
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-03-23 |
| | | */ |
| | | @TableName("master_author_detail") |
| | | public class MasterAuthorDetail extends Model<MasterAuthorDetail> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | @TableField("parent_id") |
| | | private String parentId; |
| | | |
| | | @TableField("field") |
| | | private String field; |
| | | |
| | | private String val; |
| | | private Boolean all; |
| | | |
| | | public Boolean getAll() { |
| | | return all; |
| | | } |
| | | |
| | | public MasterAuthorDetail setAll(Boolean all) { |
| | | this.all = all; |
| | | return this; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public MasterAuthorDetail setId(String id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | public String getParentId() { |
| | | return parentId; |
| | | } |
| | | |
| | | public MasterAuthorDetail setParentId(String parentId) { |
| | | this.parentId = parentId; |
| | | return this; |
| | | } |
| | | public String getField() { |
| | | return field; |
| | | } |
| | | |
| | | public MasterAuthorDetail setField(String field) { |
| | | this.field = field; |
| | | return this; |
| | | } |
| | | |
| | | public String getVal() { |
| | | return val; |
| | | } |
| | | |
| | | public MasterAuthorDetail setVal(String val) { |
| | | this.val = val; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "MasterAuthorDetail{" + |
| | | "id=" + id + |
| | | ", parentId=" + parentId + |
| | | ", field=" + field + |
| | | ", val=" + val + |
| | | "}"; |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.MasterAuthorDetail; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-03-23 |
| | | */ |
| | | public interface MasterAuthorDetailMapper extends BaseMapper<MasterAuthorDetail> { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.MasterAuthor; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-03-23 |
| | | */ |
| | | public interface MasterAuthorMapper extends BaseMapper<MasterAuthor> { |
| | | |
| | | } |
| | |
| | | package com.highdatas.mdm.mapper; |
| | | |
| | | import com.highdatas.mdm.entity.TableSchemaResult; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | Integer deleteRecordByMaintainId(@Param("tableTempName")String tableTempName, @Param("stdId") String stdId, @Param("maintainId")String maintainId); |
| | | |
| | | Integer insertRecordFromStandrad(@Param("tableName")String tableName, @Param("recordTableName")String recordTableName, @Param("tempFieldList")String tempFieldList); |
| | | |
| | | Map<String,String> selectActMemberShip(@Param("userId")String userId, @Param("roleId")String roleId); |
| | | |
| | | List<Map<String, Object>> getOneTempFieldDataByMaintainExtent(@Param("tableName")String tableName, @Param("tempTableName")String tempTableName,@Param("field")String field, @Param("fromOrderNo")Integer fromOrderNo, @Param("toOrderNo")Integer toOrderNo); |
| | | List<Map<String, Object>> getTempDataByMaintainExtent(@Param("tableName")String tableName, @Param("tempTableName")String tempTableName,@Param("fromOrderNo")Integer fromOrderNo, @Param("toOrderNo")Integer toOrderNo); |
| | | } |
| | | |
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.MasterAuthorDetailMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.MasterAuthorDetail"> |
| | | <id column="id" property="id" /> |
| | | <result column="parent_id" property="parentId" /> |
| | | <result column="field_id" property="field" /> |
| | | <result column="val" property="val" /> |
| | | </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.MasterAuthorMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.MasterAuthor"> |
| | | <id column="id" property="id" /> |
| | | <result column="type" property="type" /> |
| | | <result column="table_name" property="tableName" /> |
| | | <result column="active" property="active" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | package com.highdatas.mdm.pojo;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-02-15 22:57
|
| | | */
|
| | |
|
| | |
|
| | | public enum MasterAuthorType {
|
| | | role,user
|
| | | }
|
| | |
| | | processDiagramCanvas.drawActivityMarkers((int)graphicInfo.getX(), (int)graphicInfo.getY(), (int)graphicInfo.getWidth(), (int)graphicInfo.getHeight(), multiInstanceSequential, multiInstanceParallel, collapsed); |
| | | } |
| | | |
| | | if (highLightedActivities.contains(flowNode.getId())) { |
| | | if (highLightedActivities != null && highLightedActivities.contains(flowNode.getId())) { |
| | | processDiagramCanvas.drawHighLight((int)graphicInfo.getX(), (int)graphicInfo.getY(), (int)graphicInfo.getWidth(), (int)graphicInfo.getHeight()); |
| | | } |
| | | |
| | | } |
| | | |
| | | for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) { |
| | | boolean highLighted = highLightedFlows.contains(sequenceFlow.getId()); |
| | | String defaultFlow = null; |
| | | if (flowNode instanceof Activity) |
| | | defaultFlow = ((Activity)flowNode).getDefaultFlow(); |
| | | else if (flowNode instanceof Gateway) { |
| | | defaultFlow = ((Gateway)flowNode).getDefaultFlow(); |
| | | } |
| | | boolean highLighted = false; |
| | | if (highLightedFlows != null) { |
| | | highLighted = highLightedFlows.contains(sequenceFlow.getId()); |
| | | } |
| | | |
| | | boolean isDefault = false; |
| | | if ((defaultFlow != null) && (defaultFlow.equalsIgnoreCase(sequenceFlow.getId()))) { |
| | | isDefault = true; |
| | | } |
| | | boolean drawConditionalIndicator = (sequenceFlow.getConditionExpression() != null) && (!(flowNode instanceof Gateway)); |
| | | String defaultFlow = null; |
| | | if (flowNode instanceof Activity) |
| | | defaultFlow = ((Activity)flowNode).getDefaultFlow(); |
| | | else if (flowNode instanceof Gateway) { |
| | | defaultFlow = ((Gateway)flowNode).getDefaultFlow(); |
| | | } |
| | | |
| | | String sourceRef = sequenceFlow.getSourceRef(); |
| | | String targetRef = sequenceFlow.getTargetRef(); |
| | | FlowElement sourceElement = bpmnModel.getFlowElement(sourceRef); |
| | | FlowElement targetElement = bpmnModel.getFlowElement(targetRef); |
| | | List graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(sequenceFlow.getId()); |
| | | if ((graphicInfoList != null) && (graphicInfoList.size() > 0)) { |
| | | graphicInfoList = connectionPerfectionizer(processDiagramCanvas, bpmnModel, sourceElement, targetElement, graphicInfoList); |
| | | int[] xPoints = new int[graphicInfoList.size()]; |
| | | int[] yPoints = new int[graphicInfoList.size()]; |
| | | boolean isDefault = false; |
| | | if ((defaultFlow != null) && (defaultFlow.equalsIgnoreCase(sequenceFlow.getId()))) { |
| | | isDefault = true; |
| | | } |
| | | boolean drawConditionalIndicator = (sequenceFlow.getConditionExpression() != null) && (!(flowNode instanceof Gateway)); |
| | | |
| | | for (int i = 1; i < graphicInfoList.size(); ++i) { |
| | | GraphicInfo graphicInfo = (GraphicInfo)graphicInfoList.get(i); |
| | | GraphicInfo previousGraphicInfo = (GraphicInfo)graphicInfoList.get(i - 1); |
| | | String sourceRef = sequenceFlow.getSourceRef(); |
| | | String targetRef = sequenceFlow.getTargetRef(); |
| | | FlowElement sourceElement = bpmnModel.getFlowElement(sourceRef); |
| | | FlowElement targetElement = bpmnModel.getFlowElement(targetRef); |
| | | List graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(sequenceFlow.getId()); |
| | | if ((graphicInfoList != null) && (graphicInfoList.size() > 0)) { |
| | | graphicInfoList = connectionPerfectionizer(processDiagramCanvas, bpmnModel, sourceElement, targetElement, graphicInfoList); |
| | | int[] xPoints = new int[graphicInfoList.size()]; |
| | | int[] yPoints = new int[graphicInfoList.size()]; |
| | | |
| | | if (i == 1) { |
| | | xPoints[0] = (int)previousGraphicInfo.getX(); |
| | | yPoints[0] = (int)previousGraphicInfo.getY(); |
| | | } |
| | | xPoints[i] = (int)graphicInfo.getX(); |
| | | yPoints[i] = (int)graphicInfo.getY(); |
| | | } |
| | | for (int i = 1; i < graphicInfoList.size(); ++i) { |
| | | GraphicInfo graphicInfo = (GraphicInfo)graphicInfoList.get(i); |
| | | GraphicInfo previousGraphicInfo = (GraphicInfo)graphicInfoList.get(i - 1); |
| | | |
| | | processDiagramCanvas.drawSequenceflow(xPoints, yPoints, drawConditionalIndicator, isDefault, highLighted, scaleFactor); |
| | | if (i == 1) { |
| | | xPoints[0] = (int)previousGraphicInfo.getX(); |
| | | yPoints[0] = (int)previousGraphicInfo.getY(); |
| | | } |
| | | xPoints[i] = (int)graphicInfo.getX(); |
| | | yPoints[i] = (int)graphicInfo.getY(); |
| | | } |
| | | |
| | | GraphicInfo labelGraphicInfo = bpmnModel.getLabelGraphicInfo(sequenceFlow.getId()); |
| | | if (labelGraphicInfo != null) { |
| | | processDiagramCanvas.drawLabel(sequenceFlow.getName(), labelGraphicInfo, false); |
| | | } |
| | | else { |
| | | GraphicInfo lineCenter = getLineCenter(graphicInfoList); |
| | | processDiagramCanvas.drawLabel(sequenceFlow.getName(), lineCenter, false); |
| | | } |
| | | processDiagramCanvas.drawSequenceflow(xPoints, yPoints, drawConditionalIndicator, isDefault, highLighted, scaleFactor); |
| | | |
| | | GraphicInfo labelGraphicInfo = bpmnModel.getLabelGraphicInfo(sequenceFlow.getId()); |
| | | if (labelGraphicInfo != null) { |
| | | processDiagramCanvas.drawLabel(sequenceFlow.getName(), labelGraphicInfo, false); |
| | | } |
| | | else { |
| | | GraphicInfo lineCenter = getLineCenter(graphicInfoList); |
| | | processDiagramCanvas.drawLabel(sequenceFlow.getName(), lineCenter, false); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | MaintainField createNowVerion(String tableName, String maintainId, String userId); |
| | | |
| | | ActivitiStatus getStatusByBusinessId(String maintainFieldId); |
| | | ActivitiStatus getStatusByBusinessId(String businssId); |
| | | |
| | | boolean isNextAudit(Flows flows, String userId); |
| | | |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.MaintainField; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.SysField; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | MaintainField getNextMaintain(String tableName, String userId); |
| | | |
| | | |
| | | List<Maintain> getMaintainByMaintainField(String maintainFieldId, String tableName); |
| | | |
| | | boolean checkNowVersion(String id); |
| | | boolean checkFirstVersion(String id); |
| | |
| | | void dealFlow(String maintainId, ActivitiStatus status); |
| | | |
| | | int getUnFlowCount(String tableName, String userId); |
| | | |
| | | JSONArray getMaintainListByTable(String tableName); |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.MasterAuthorDetail; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-03-23 |
| | | */ |
| | | public interface IMasterAuthorDetailService extends IService<MasterAuthorDetail> { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.MasterAuthor; |
| | | import com.highdatas.mdm.entity.SysField; |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-03-23 |
| | | */ |
| | | public interface IMasterAuthorService extends IService<MasterAuthor> { |
| | | |
| | | HashMap<String, MasterAuthor> merageRoleAuthor(List<String> roleIds); |
| | | |
| | | List<SysMenu> getMenu(String userId); |
| | | |
| | | |
| | | List<SysField> getField(String userId, String maintainFieldId, String maintainId); |
| | | |
| | | boolean checkMaintainAuthor(String userId, String maintainId); |
| | | |
| | | String getFilter(String userId, String maintainId); |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.MenuMapping; |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | |
| | | import javax.servlet.http.HttpSession; |
| | |
| | | boolean update(String json); |
| | | |
| | | Result getMapping(HttpSession session, String id); |
| | | |
| | | SysMenu getMenuByTableName(String tableName); |
| | | |
| | | String getTableNameByMenu(String menuId); |
| | | } |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.highdatas.mdm.entity.SysField; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.MaintainField; |
| | | import com.highdatas.mdm.entity.SysField; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | List<SysField> getFieldByMaintain(String maintainId); |
| | | |
| | | MaintainField getMaintainFieldByMaintain(String maintainId); |
| | | |
| | | List<SysField> getFieldByTable(String tableName); |
| | | |
| | | |
| | |
| | | |
| | | List<SysField> getFieldByMaintainField(String maintainId); |
| | | |
| | | List<SysField> getDefaultTableField(String tableName); |
| | | |
| | | List<SysField> getTotalTableField(String tableName); |
| | | |
| | | Result getTotalFields(String tableName, Integer pageNo, Integer pageSize); |
| | | } |
| | |
| | | package com.highdatas.mdm.service; |
| | | |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | |
| | | LinkedHashSet<String> getByParentId(LinkedHashSet<String> parentIdSet); |
| | | |
| | | } |
| | |
| | | import com.highdatas.mdm.pojo.SysAssembleUpdateType; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author kimi |
| | |
| | | |
| | | Result selectListByPageByVersion(String tableName, String whereSegment, Integer pageNo, String version, boolean findMax); |
| | | |
| | | List<Map<String, Object>> selectListByVersion(String tableName, List<String> fieldList, String whereSegment, String version, boolean findMax); |
| | | |
| | | Result selectListByPageByVersion(String tableName, List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, String version, boolean findMax); |
| | | |
| | | Maintain uploadedData(String tableName, SysAssembleUpdateType uploadType, String userId); |
| | | |
| | | Set<String> getFieldValByTable(String tableName, String field); |
| | | Set<String> getFieldValByMaintainField(String maintainFieldId, String field, String tableName); |
| | | } |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | |
| | | /** |
| | |
| | | public boolean updateProcessDefStatus(String type, String modelId); |
| | | public void getModelXml(HttpServletResponse response,String modelId) throws IOException; |
| | | |
| | | InputStream getModelImg(String modelId); |
| | | } |
| | |
| | | package com.highdatas.mdm.service.act.impl; |
| | | |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import org.activiti.engine.IdentityService; |
| | |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class IdentityServiceImpl extends BaseServiceImpl implements com.highdatas.mdm.service.act.IdentityService{ |
| | |
| | | RuntimeService runtimeService; |
| | | @Autowired |
| | | RepositoryService repositoryService; |
| | | |
| | | @Autowired |
| | | TableInfoMapper tableInfoMapper; |
| | | |
| | | @Override |
| | | public String startProcess(String businessId, String key) { |
| | |
| | | |
| | | @Override |
| | | public Result addUser(String id) { |
| | | User preUser = identityService.createUserQuery().userId(id).singleResult(); |
| | | if (preUser != null) { |
| | | return Result.error(new CodeMsg(6002, "已有相同id的用户存在")); |
| | | } |
| | | try { |
| | | User user = identityService.newUser(id); |
| | | identityService.saveUser(user); |
| | |
| | | |
| | | @Override |
| | | public Result addRole(String id) { |
| | | Group preGroup = identityService.createGroupQuery().groupId(id).singleResult(); |
| | | if (preGroup != null) { |
| | | return Result.error(new CodeMsg(6002, "已有相同id的角色存在")); |
| | | } |
| | | try { |
| | | Group group = identityService.newGroup(id); |
| | | identityService.saveGroup(group); |
| | |
| | | if (user == null) { |
| | | return Result.error(new CodeMsg(3001, "当前用户不存在,请先创建用户")); |
| | | } |
| | | Group group = identityService.createGroupQuery().groupId(roleId).singleResult(); |
| | | if (user == null) { |
| | | return Result.error(new CodeMsg(3001, "当前角色不存在,请先角色用户")); |
| | | } |
| | | identityService.createMembership(userId,roleId); |
| | | |
| | | Map<String, String> memberShip = tableInfoMapper.selectActMemberShip(userId, roleId); |
| | | if (memberShip != null) { |
| | | return Result.success(null); |
| | | } |
| | | identityService.createMembership(userId,roleId); |
| | | return Result.success(null); |
| | | } |
| | | catch (Exception e) { |
| | |
| | | if (user == null) { |
| | | return Result.error(new CodeMsg(3001, "当前角色不存在,请先角色用户")); |
| | | } |
| | | |
| | | Map<String, String> memberShip = tableInfoMapper.selectActMemberShip(userId, roleId); |
| | | if (memberShip == null) { |
| | | return Result.success(null); |
| | | } |
| | | identityService.deleteMembership(userId,roleId); |
| | | return Result.success(null); |
| | | } |
| | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.fasterxml.jackson.databind.node.ObjectNode; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.process.canvas.ProcessDiagramGenerator; |
| | | import com.highdatas.mdm.util.WorkflowUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.activiti.bpmn.converter.BpmnXMLConverter; |
| | |
| | | import org.activiti.editor.constants.ModelDataJsonConstants; |
| | | import org.activiti.editor.language.json.converter.BpmnJsonConverter; |
| | | import org.activiti.engine.ActivitiException; |
| | | import org.activiti.engine.HistoryService; |
| | | import org.activiti.engine.RepositoryService; |
| | | import org.activiti.engine.repository.Deployment; |
| | | import org.activiti.engine.repository.Model; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ClassUtils; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | private static final String MODEL_DESCRIPTION = "description"; |
| | | @Autowired |
| | | RepositoryService service; |
| | | @Autowired |
| | | HistoryService historyService; |
| | | |
| | | @Autowired |
| | | ObjectMapper objectMapper; |
| | | @Value("${img.url}") |
| | |
| | | response.flushBuffer(); |
| | | } |
| | | |
| | | public boolean updateProcessDefStatus(String type, String modelId) { |
| | | @Override |
| | | public InputStream getModelImg(String modelId) { |
| | | InputStream resource = null; |
| | | try{ |
| | | Model model = service.createModelQuery().modelId(modelId).singleResult(); |
| | | JsonNode editorNode = new ObjectMapper().readTree(service.getModelEditorSource(model.getId())); |
| | | BpmnJsonConverter jsonConverter = new BpmnJsonConverter(); |
| | | BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode); |
| | | ProcessDiagramGenerator diagramGenerator = new ProcessDiagramGenerator(); |
| | | resource = diagramGenerator.generateDiagram(bpmnModel, "png",null,null, "宋体","宋体" ,null, null,0); |
| | | return resource; |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | finally { |
| | | if (resource != null) { |
| | | try { |
| | | resource.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public boolean updateProcessDefStatus(String type, String modelId) { |
| | | Model model = service.createModelQuery().modelId(modelId).singleResult(); |
| | | ProcessDefinition processDefinition = service.createProcessDefinitionQuery().deploymentId(model.getDeploymentId()).singleResult(); |
| | | String processDefinitionId = processDefinition.getId(); |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.entity.Flows; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.MaintainField; |
| | |
| | | import com.highdatas.mdm.pojo.Operate; |
| | | import com.highdatas.mdm.service.IFlowsService; |
| | | import com.highdatas.mdm.service.IMaintainFieldService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.service.IMaintainService; |
| | | import com.highdatas.mdm.service.ISysFieldService; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.mybatis.spring.SqlSessionTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Connection; |
| | | import java.sql.PreparedStatement; |
| | | import java.sql.SQLException; |
| | | import java.text.MessageFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | nowMaintain.setId(DbUtils.getUUID()); |
| | | } |
| | | return nowMaintain; |
| | | } |
| | | |
| | | @Override |
| | | public List<Maintain> getMaintainByMaintainField(String maintainFieldId, String tableName) { |
| | | HashMap<String, List<Maintain>> resultMap = getMaintainFieldMapByTable(tableName); |
| | | if (resultMap == null) { |
| | | return null; |
| | | } |
| | | return resultMap.get(maintainFieldId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | return cnt; |
| | | } |
| | | |
| | | @Override |
| | | public JSONArray getMaintainListByTable(String tableName) { |
| | | HashMap<String, List<Maintain>> resultMap = getMaintainFieldMapByTable(tableName); |
| | | |
| | | Set<String> keySet = resultMap.keySet(); |
| | | JSONArray array = new JSONArray(); |
| | | for (String s : keySet) { |
| | | List<Maintain> list = resultMap.get(s); |
| | | Maintain max = list.stream().max(new Comparator<Maintain>() { |
| | | @Override |
| | | public int compare(Maintain o1, Maintain o2) { |
| | | return o1.getOrderNo() - o2.getOrderNo(); |
| | | } |
| | | }).get(); |
| | | Maintain min = list.stream().min(new Comparator<Maintain>() { |
| | | @Override |
| | | public int compare(Maintain o1, Maintain o2) { |
| | | return o1.getOrderNo() - o2.getOrderNo(); |
| | | } |
| | | }).get(); |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("maintainFieldId", s); |
| | | object.fluentPut("version", MessageFormat.format(Constant.extent, min.getVersion(), max.getVersion())); |
| | | |
| | | array.add(object); |
| | | } |
| | | return array; |
| | | } |
| | | |
| | | private HashMap<String, List<Maintain>> getMaintainFieldMapByTable(String tableName) { |
| | | List<Maintain> maintainList = maintainService.selectList(new EntityWrapper<Maintain>().eq("table_name", tableName).isNotNull("flow_id").orderBy("order_no")); |
| | | HashMap<String, List<Maintain>> resultMap = new HashMap<>(); |
| | | for (Maintain maintain : maintainList) { |
| | | ActivitiStatus status = flowsService.getStatusByBusinessId(maintain.getId()); |
| | | if (!status.equals(ActivitiStatus.open)) { |
| | | continue; |
| | | } |
| | | MaintainField maintainFieldByMaintain = fieldService.getMaintainFieldByMaintain(maintain.getId()); |
| | | List<Maintain> list = resultMap.get(maintainFieldByMaintain.getId()); |
| | | if (list == null) { |
| | | list = new ArrayList<>(); |
| | | } |
| | | list.add(maintain); |
| | | resultMap.put(maintainFieldByMaintain.getId(), list); |
| | | } |
| | | return resultMap; |
| | | } |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.highdatas.mdm.entity.MasterAuthorDetail; |
| | | import com.highdatas.mdm.mapper.MasterAuthorDetailMapper; |
| | | import com.highdatas.mdm.service.IMasterAuthorDetailService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-03-23 |
| | | */ |
| | | @Service |
| | | public class MasterAuthorDetailServiceImpl extends ServiceImpl<MasterAuthorDetailMapper, MasterAuthorDetail> implements IMasterAuthorDetailService { |
| | | |
| | | } |
New file |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.controller.MasterAuthorController; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.MasterAuthorMapper; |
| | | import com.highdatas.mdm.pojo.MasterAuthorType; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.ContentBuilder; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | | * @since 2020-03-23 |
| | | */ |
| | | @Service |
| | | public class MasterAuthorServiceImpl extends ServiceImpl<MasterAuthorMapper, MasterAuthor> implements IMasterAuthorService { |
| | | public static final String characterId = "characterId"; |
| | | @Autowired |
| | | IMasterAuthorDetailService authorDetailService; |
| | | @Autowired |
| | | ITUserRoleService userRoleService; |
| | | @Autowired |
| | | ISysMenuService menuService; |
| | | @Autowired |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | |
| | | @Override |
| | | public HashMap<String, MasterAuthor> merageRoleAuthor(List<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<>(); |
| | | |
| | | for (MasterAuthor masterAuthor : masterAuthors) { |
| | | List<MasterAuthorDetail> masterAuthorDetails = authorDetailService.selectList(new EntityWrapper<MasterAuthorDetail>().eq(Constant.PARENT_ID, masterAuthor.getId())); |
| | | masterAuthor.setFields(masterAuthorDetails); |
| | | |
| | | String key = DbUtils.getFieldRedisKey(masterAuthor.getTableName(), masterAuthor.getMaintainFieldId()); |
| | | MasterAuthor preMerageMasterAuthor = resultMap.get(key); |
| | | if (preMerageMasterAuthor == null) { |
| | | resultMap.put(key, masterAuthor); |
| | | } |
| | | else { |
| | | preMerageMasterAuthor = merage(preMerageMasterAuthor, masterAuthor); |
| | | resultMap.put(key, preMerageMasterAuthor); |
| | | } |
| | | } |
| | | return resultMap; |
| | | } |
| | | |
| | | @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.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)); |
| | | } |
| | | List<String> menuIds = masterAuthors.stream().map(masterAuthor -> masterAuthor.getMenuId()).collect(Collectors.toList()); |
| | | LinkedHashSet<String> strings = new LinkedHashSet<>(menuIds); |
| | | LinkedHashSet<String> byParentId = menuService.getByParentId(strings); |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | return sysMenus; |
| | | } |
| | | |
| | | @Override |
| | | public List<SysField> getField(String userId, String maintainFieldId, String maintainId) { |
| | | if (maintainFieldId.equalsIgnoreCase(Constant.All)) { |
| | | List<SysField> total = fieldService.getFieldByMaintain(maintainId); |
| | | return total; |
| | | } |
| | | List<MasterAuthor> masterAuthors = selectList(new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.user).eq(this.characterId, 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(this.characterId, roleIds).eq("maintain_field_id", maintainFieldId)); |
| | | } |
| | | if (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()); |
| | | if (codes.isEmpty()) { |
| | | return null; |
| | | } |
| | | Wrapper<SysField> wrapper = new EntityWrapper<SysField>().in(Constant.FIELD, codes); |
| | | |
| | | if (maintainFieldId.equalsIgnoreCase(Constant.Default)) { |
| | | wrapper.eq("maintain_field_id", maintainFieldId); |
| | | }else { |
| | | wrapper.isNull("maintain_field_id"); |
| | | } |
| | | List<SysField> fieldList = fieldService.selectList(wrapper); |
| | | |
| | | |
| | | |
| | | return fieldList; |
| | | } |
| | | |
| | | @Override |
| | | public boolean checkMaintainAuthor(String userId, String maintainId) { |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | if (maintain == null) { |
| | | return false; |
| | | } |
| | | int checked = selectCount(new EntityWrapper<MasterAuthor>() |
| | | .eq(Constant.TYPE, MasterAuthorType.user) |
| | | .eq(MasterAuthorController.character_id, userId) |
| | | .eq("table_name", maintain.getTableName()) |
| | | .eq("maintain_field_id", Constant.All)); |
| | | if(checked > 0) { |
| | | 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; |
| | | } |
| | | 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; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public String getFilter(String userId, String maintainId) { |
| | | MaintainField maintainField = fieldService.getMaintainFieldByMaintain(maintainId); |
| | | if (maintainField) |
| | | if (maintainFieldId.equalsIgnoreCase(Constant.All)) { |
| | | return Constant.WHERE_DEFAULT; |
| | | } |
| | | List<MasterAuthor> masterAuthors = selectList(new EntityWrapper<MasterAuthor>().eq(Constant.TYPE, MasterAuthorType.user).eq(this.characterId, 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(this.characterId, roleIds).eq("maintain_field_id", maintainFieldId)); |
| | | } |
| | | 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()) { |
| | | return Constant.WHERE_DEFAULTUN; |
| | | } |
| | | HashMap<String, List<String>> segmentMap = new HashMap<>(); |
| | | HashMap<String, Boolean> segmentAllMap = new HashMap<>(); |
| | | |
| | | for (MasterAuthorDetail detail : masterAuthorDetails) { |
| | | String field = detail.getField(); |
| | | Boolean all = detail.getAll(); |
| | | if (!(segmentAllMap.containsKey(field) && segmentAllMap.get(field))) { |
| | | segmentAllMap.put(field, all); |
| | | } |
| | | |
| | | Boolean preAll = segmentAllMap.get(field); |
| | | if (preAll && segmentMap.containsKey(field)) { |
| | | segmentMap.remove(field); |
| | | } |
| | | |
| | | String val = detail.getVal(); |
| | | List<String> split = DbUtils.split(val); |
| | | segmentMap.put(field,split); |
| | | } |
| | | ContentBuilder builder = new ContentBuilder(Constant.AND); |
| | | Set<String> keySet = segmentMap.keySet(); |
| | | for (String code : keySet) { |
| | | List<String> vals = segmentMap.get(code); |
| | | String val = vals.stream() |
| | | .filter(s -> !StringUtils.isEmpty(s)) |
| | | .map(s -> DbUtils.quotedStr(s)).collect(Collectors.joining(Constant.COMMA)); |
| | | String format = MessageFormat.format(Constant.MYSQL_UUID, code, val); |
| | | builder.append(format); |
| | | } |
| | | String filter = builder.toString(); |
| | | return filter; |
| | | } |
| | | |
| | | private MasterAuthor merage(MasterAuthor preMerageMasterAuthor, MasterAuthor masterAuthor) { |
| | | // table name masterField 一样 只有字段不同了 |
| | | List<MasterAuthorDetail> preFields = preMerageMasterAuthor.getFields(); |
| | | Map<String, MasterAuthorDetail> fieldMap = masterAuthor.getFields().stream().collect(Collectors.toMap(MasterAuthorDetail::getField, masterAuthorDetail -> masterAuthorDetail)); |
| | | |
| | | HashSet<String> valSet = new HashSet<>(); |
| | | for (MasterAuthorDetail preField : preFields) { |
| | | valSet.clear(); |
| | | String fieldId = preField.getField(); |
| | | String val = preField.getVal(); |
| | | if (val.equalsIgnoreCase(Constant.All)) { |
| | | continue; |
| | | } |
| | | MasterAuthorDetail detail = fieldMap.get(fieldId); |
| | | if (detail == null) { |
| | | continue; |
| | | } |
| | | String preAddVal = detail.getVal(); |
| | | if (preAddVal.equalsIgnoreCase(Constant.All)) { |
| | | preField.setVal(preAddVal); |
| | | continue; |
| | | } |
| | | |
| | | valSet.addAll(DbUtils.split(val)); |
| | | valSet.addAll(DbUtils.split(preAddVal)); |
| | | |
| | | String resultVal = valSet.stream().collect(Collectors.joining(Constant.SEMICOLON)); |
| | | preField.setVal(resultVal); |
| | | } |
| | | return preMerageMasterAuthor; |
| | | } |
| | | } |
| | |
| | | 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 org.apache.commons.lang3.StringUtils; |
| | | import org.mybatis.spring.SqlSessionTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | 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; |
| | |
| | | IMaintainDetailService maintainDetailService; |
| | | @Autowired |
| | | IFlowsService flowsService; |
| | | |
| | | @Autowired |
| | | RedisClient redisClient; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Resource |
| | | protected DataSource dataSource; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectListByVersion(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; |
| | | List<Map<String, Object>> result = null; |
| | | |
| | | String fields; |
| | | String tempFields; |
| | | String Hfields; |
| | | String A1fields; |
| | | String A2fields; |
| | | |
| | | String tempHfields; |
| | | if (fieldList == null || fieldList.size() == 0) { |
| | | fields = getFields(tableName, maintainFromVersion); |
| | | Hfields = getFields(tableName,Constant.H, maintainFromVersion); |
| | | A1fields = getFields(tableName,Constant.A1, maintainFromVersion); |
| | | A2fields = getFields(tableName,Constant.A2, maintainFromVersion); |
| | | tempFields = getTempFields(tableName, maintainFromVersion); |
| | | tempHfields = getTempFields(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)); |
| | | |
| | | } |
| | | if (isNow && !findMax){ |
| | | result = mapper.selectByPage(tableName, fields, whereSegment, null); |
| | | } |
| | | 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(); |
| | | } |
| | | |
| | | result = mapper.selectByPageByMaxVersion(tableName,tableTempName,fields,tempFields, Hfields, A1fields, A2fields, tempHfields, fromVersionOrderNo, nowVersionOrderNo, DbUtils.quotedStr(maintainFromVersion.getId()), whereSegment, null); |
| | | |
| | | }else { |
| | | result = mapper.selectByPageByVersion(tableName,tableTempName,fields,tempFields, Hfields, A1fields, A2fields, tempHfields, nowVersionOrderNo, fromVersionOrderNo, DbUtils.quotedStr(maintainFromVersion.getId()), whereSegment, null); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | @Override |
| | | public Result selectListByPageByVersion(String tableName, List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, String version, boolean findMax) { |
| | | |
| | | Maintain maintainFromVersion = maintainService.getMaintainFromVersion(tableName, version); |
| | |
| | | |
| | | return maintain; |
| | | } |
| | | |
| | | |
| | | |
| | | //bak |
| | | public Result selectListByPage(String tableName, List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, String version) { |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Set<String> getFieldValByTable(String tableName, String field) { |
| | | //查缓存 |
| | | String key = DbUtils.getFieldRedisKey(tableName,field); |
| | | String redisVal = redisClient.getRedisVal(key); |
| | | if (!StringUtils.isEmpty(redisVal)) { |
| | | List<String> valList = DbUtils.split(redisVal); |
| | | if (valList != null) { |
| | | return new HashSet<String>(valList); |
| | | } |
| | | } |
| | | // 读数据库 |
| | | String tempTableName = tableName + Constant.RECORD; |
| | | List<Map<String, Object>> maps = mapper.selectByPage(tableName, MessageFormat.format(Constant.DISTINCT, field), Constant.WHERE_DEFAULT, null); |
| | | |
| | | List<Map<String, Object>> tempMaps = mapper.selectByPage(tempTableName, MessageFormat.format(Constant.DISTINCT, field), Constant.WHERE_DEFAULT, null); |
| | | maps.addAll(tempMaps); |
| | | if (maps.size() == 0) { |
| | | return null; |
| | | } |
| | | Set<String> result = maps.stream() |
| | | .filter(one -> one != null) |
| | | .map(one -> one.get(field)) |
| | | .filter(o -> o != null) |
| | | .map(o -> o.toString()).collect(Collectors.toSet()); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Set<String> getFieldValByMaintainField(String maintainFieldId, String field, String tableName) { |
| | | //查缓存 |
| | | MaintainField maintainField = maintainFieldService.selectById(maintainFieldId); |
| | | |
| | | String key = DbUtils.getFieldRedisKey(tableName, field); |
| | | String redisVal = redisClient.getRedisVal(key); |
| | | if (!StringUtils.isEmpty(redisVal)) { |
| | | List<String> valList = DbUtils.split(redisVal); |
| | | if (valList != null) { |
| | | HashSet<String> strings = new HashSet<>(valList); |
| | | return strings; |
| | | } |
| | | } |
| | | // 读数据库 |
| | | List<Maintain> list = maintainFieldService.getMaintainByMaintainField(maintainFieldId, tableName); |
| | | Maintain max = list.stream().max(new Comparator<Maintain>() { |
| | | @Override |
| | | public int compare(Maintain o1, Maintain o2) { |
| | | return o1.getOrderNo() - o2.getOrderNo(); |
| | | } |
| | | }).get(); |
| | | Maintain min = list.stream().min(new Comparator<Maintain>() { |
| | | @Override |
| | | public int compare(Maintain o1, Maintain o2) { |
| | | return o1.getOrderNo() - o2.getOrderNo(); |
| | | } |
| | | }).get(); |
| | | ArrayList<String> fieldList = new ArrayList<>(); |
| | | fieldList.add(field); |
| | | fieldList.add(Constant.ID); |
| | | List<Map<String, Object>> maps = selectListByVersion(tableName, fieldList, Constant.WHERE_DEFAULT, max.getVersion(), false); |
| | | String tempTableName = tableName + Constant.RECORD; |
| | | List<Map<String, Object>> tempVals = mapper.getOneTempFieldDataByMaintainExtent(DbUtils.quotedStr(tableName), tempTableName, field, min.getOrderNo(), max.getOrderNo()); |
| | | maps.addAll(tempVals); |
| | | if (maps.size() == 0) { |
| | | return null; |
| | | } |
| | | Set<String> result = maps.stream() |
| | | .filter(one -> one != null) |
| | | .map(one -> one.get(field)) |
| | | .filter(o -> o != null) |
| | | .map(o -> o.toString()).collect(Collectors.toSet()); |
| | | String val = result.stream().collect(Collectors.joining(Constant.SEMICOLON)); |
| | | redisClient.putRedisVal(key, val); |
| | | return result; |
| | | } |
| | | } |
| | |
| | | } else { |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | //only update no join |
| | | |
| | | //update menu name |
| | | String menuId = menuMapping.getMenuId(); |
| | | SysMenu sysMenu = menuService.selectById(menuId); |
| | | if (sysMenu == null) { |
| | | return false; |
| | | } |
| | | sysMenu.setName(menuMapping.getName()); |
| | | sysMenu.updateById(); |
| | | |
| | | return this.updateById(menuMapping); |
| | | } |
| | | |
| | |
| | | mapping.put("version", resultMaintain.getVersion()); |
| | | mapping.put("maintainId", resultMaintain.getId()); |
| | | } |
| | | |
| | | return Result.success(mapping); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public SysMenu getMenuByTableName(String tableName) { |
| | | MenuMapping menuMapping = selectOne(new EntityWrapper<MenuMapping>().eq("table_name", tableName).orderBy("create_time desc")); |
| | | if (menuMapping == null) { |
| | | return null; |
| | | } |
| | | String menuId = menuMapping.getMenuId(); |
| | | SysMenu sysMenu = menuService.selectById(menuId); |
| | | return sysMenu; |
| | | } |
| | | |
| | | @Override |
| | | public String getTableNameByMenu(String menuId) { |
| | | MenuMapping menuMapping = selectOne(new EntityWrapper<MenuMapping>().eq("menu_id", menuId).orderBy("create_time desc")); |
| | | if (menuMapping == null) { |
| | | return null; |
| | | } |
| | | return menuMapping.getTableName(); |
| | | |
| | | } |
| | | } |
| | |
| | | import com.highdatas.mdm.service.IMaintainFieldService; |
| | | import com.highdatas.mdm.service.IMaintainService; |
| | | import com.highdatas.mdm.service.ISysFieldService; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | TableInfoMapper tableInfoMapper; |
| | | |
| | | |
| | | @Override |
| | | public List<SysField> getFieldByMaintain(String maintainId) { |
| | | public MaintainField getMaintainFieldByMaintainId(String maintainId) { |
| | | MaintainField maintainField; |
| | | List<SysField> fieldList = null; |
| | | |
| | | if (StringUtils.isEmpty(maintainId)) { |
| | | return null; |
| | | return null; |
| | | } |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | if (maintain == null) { |
| | |
| | | //对应版本找不到 往前找 |
| | | String maintainFieldId = maintainFieldMapper.getMappedMatintainId(DbUtils.quotedStr(maintain.getTableName()), maintain.getOrderNo()); |
| | | if (StringUtils.isEmpty(maintainFieldId)) { |
| | | fieldList = this.selectList(new EntityWrapper<SysField>().eq("table_name", maintain.getTableName()).isNull("maintain_field_id").orderBy("order_no")); |
| | | return fieldList; |
| | | return null; |
| | | } |
| | | maintainField = maintainFieldService.selectById(maintainFieldId); |
| | | if (maintainField == null){ |
| | | //无对应版本 |
| | | fieldList = this.selectList(new EntityWrapper<SysField>().eq("table_name", maintain.getTableName()).isNull("maintain_field_id").orderBy("order_no")); |
| | | return fieldList; |
| | | } |
| | | } |
| | | return maintainField; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<SysField> getFieldByMaintain(String maintainId) { |
| | | List<SysField> fieldList; |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | if (maintain == null) { |
| | | return null; |
| | | } |
| | | |
| | | MaintainField maintainField = getMaintainFieldByMaintain(maintainId); |
| | | if (maintainField == null && Constant.Default.equalsIgnoreCase(maintainField.getId())) { |
| | | |
| | | fieldList = this.selectList(new EntityWrapper<SysField>().eq("table_name", maintain.getTableName()).isNull("maintain_field_id").orderBy("order_no")); |
| | | return fieldList; |
| | | } |
| | | String maintainFieldId = maintainField.getId(); |
| | | String tableName = maintainField.getTableName(); |
| | | //TODO 判断版本 |
| | |
| | | maintainField = maintainFieldService.selectOne(new EntityWrapper<MaintainField>().eq("table_name", maintain.getTableName()).eq("order_no", preNo)); |
| | | fieldList = this.selectList(new EntityWrapper<SysField>().eq("maintain_field_id", maintainField.getId()).eq("table_name", tableName).orderBy("order_no")); |
| | | return fieldList; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public MaintainField getMaintainFieldByMaintain(String maintainId) { |
| | | MaintainField maintainField; |
| | | List<SysField> fieldList = null; |
| | | |
| | | if (StringUtils.isEmpty(maintainId)) { |
| | | return null; |
| | | } |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | if (maintain == null) { |
| | | return null; |
| | | } |
| | | |
| | | maintainField = maintainFieldService.selectOne(new EntityWrapper<MaintainField>().eq("maintain_id", maintainId).orderBy("order_no desc, create_time desc")); |
| | | if (maintainField == null) { |
| | | //对应版本找不到 往前找 |
| | | String maintainFieldId = maintainFieldMapper.getMappedMatintainId(DbUtils.quotedStr(maintain.getTableName()), maintain.getOrderNo()); |
| | | if (StringUtils.isEmpty(maintainFieldId)) { |
| | | return new MaintainField().setId(Constant.Default); |
| | | } |
| | | maintainField = maintainFieldService.selectById(maintainFieldId); |
| | | if (maintainField == null){ |
| | | return new MaintainField().setId(Constant.Default); |
| | | } |
| | | } |
| | | |
| | | String maintainFieldId = maintainField.getId(); |
| | | String tableName = maintainField.getTableName(); |
| | | |
| | | ActivitiStatus status = flowsService.getStatusByBusinessId(maintainFieldId); |
| | | if (status != null && status.equals(ActivitiStatus.open)) { |
| | | return maintainFieldService.selectById(maintainField); |
| | | } |
| | | |
| | | // 当前版本正在审批 找前一版本 |
| | | Integer maintainFieldOrderNo = maintainField.getOrderNo(); |
| | | if (maintainFieldOrderNo < 1) { |
| | | return new MaintainField().setId(Constant.Default); |
| | | }else { |
| | | Integer preNo = maintainFieldOrderNo - 1; |
| | | maintainField = maintainFieldService.selectOne(new EntityWrapper<MaintainField>().eq("table_name", maintain.getTableName()).eq("order_no", preNo)); |
| | | return maintainField; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | return collect.get(0); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysField> getFieldByMaintainField(String maintainId) { |
| | | if (StringUtils.isEmpty(maintainId)) { |
| | | return selectList(new EntityWrapper<SysField>().isNull("maintain_field_id").orderBy("order_no")); |
| | | return null; |
| | | } |
| | | return selectList(new EntityWrapper<SysField>().eq("maintain_field_id", maintainId).orderBy("order_no")); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysField> getDefaultTableField(String tableName) { |
| | | return selectList(new EntityWrapper<SysField>().eq("table_name", tableName).isNull("maintain_field_id").orderBy("order_no")); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysField> getTotalTableField(String tableName) { |
| | | List<TableSchemaResult> tableField = tableInfoMapper.getTableField(tableName); |
| | | List<SysField> result = new ArrayList<>(); |
| | | for (TableSchemaResult tableSchemaResult : tableField) { |
| | | String fieldName = tableSchemaResult.getFieldName(); |
| | | List<SysField> fieldList = selectList(new EntityWrapper<SysField>().eq("table_name", tableName).eq(Constant.FIELD, fieldName).orderBy("create_time")); |
| | | if (fieldList.isEmpty()) { |
| | | //没有中文名称的 应该属于系统自留字段 如id |
| | | continue; |
| | | } |
| | | HashSet<SysField> strings = new HashSet<SysField>(fieldList); |
| | | String alias = strings.stream().map(SysField::getAlias).collect(Collectors.joining(Constant.SEMICOLON)); |
| | | SysField sysField = new SysField().setField(fieldName).setAlias(alias); |
| | | result.add(sysField); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.highdatas.mdm.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | import com.highdatas.mdm.mapper.SysMenuMapper; |
| | | import com.highdatas.mdm.service.ISysMenuService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | return parentIdSet; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | public static final String COMMA = " , "; |
| | | public static final String COMMA_TRIM = ","; |
| | | public static final String WHERE_DEFAULT = " 1 = 1 "; |
| | | public static final String WHERE_DEFAULTUN = " 1 <> 1 "; |
| | | public static final String SEGMENT_COMMON = "value = {0}"; |
| | | public static final String SEGMENT_STRING = "value = '{0}'"; |
| | | public static final String EQUAL = " = "; |
| | |
| | | String StructureMenu = "StructureMenu"; |
| | | String tableName = "tableName"; |
| | | String Alias = "{0}.{1}"; |
| | | String extent = "{0}~{1}"; |
| | | String FieldAsAlias = "{0} AS {1}"; |
| | | String caseWhen = " case when a2.{0} != null then a2.{0} else a1.{0} end as {0}"; |
| | | String H = "h"; |
| | |
| | | String varchar = "varchar"; |
| | | String varcharSize = " (255) "; |
| | | String Text = " text "; |
| | | String Default = "default"; |
| | | String USERID = "user_id"; |
| | | String FIELD = "field"; |
| | | String DISTINCT = "distinct {0}"; |
| | | String InSql = "{0} in ( {1} )"; |
| | | } |
| | |
| | | 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.pojo.Segment; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.security.MessageDigest; |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public static String getFieldRedisKey(String tableName, String field) { |
| | | if (StringUtils.isEmpty(tableName) && StringUtils.isEmpty(field)) { |
| | | return null; |
| | | }else if (StringUtils.isEmpty(field)){ |
| | | return tableName; |
| | | }else if (StringUtils.isEmpty(tableName)){ |
| | | return field; |
| | | }else { |
| | | return tableName + Constant.UnderLine + field; |
| | | } |
| | | } |
| | | |
| | | public static List<String> split(String redisVal) { |
| | | if (StringUtils.isEmpty(redisVal)) { |
| | | return null; |
| | | } |
| | | String[] split = redisVal.split(Constant.SEMICOLON); |
| | | List<String> strings = Arrays.asList(split); |
| | | return strings; |
| | | } |
| | | |
| | | public static TUser getUser(HttpServletRequest request) { |
| | | return (TUser) request.getSession().getAttribute(Constant.USER); |
| | | } |
| | | |
| | | public static ArrayList<String> getRoleByUser(String userId) { |
| | | ArrayList<String> roleIds = new ArrayList<>(); |
| | | roleIds.add("ROO1"); |
| | | return roleIds; |
| | | } |
| | | } |
| | |
| | | // 全局配置 |
| | | GlobalConfig gc = new GlobalConfig(); |
| | | gc.setAuthor("kimi"); |
| | | gc.setOutputDir("H://workspace/workspace_idea/mdm/src/main/java"); |
| | | gc.setOutputDir("D://workspace/workspace_idea/mdm_new/src/main/java"); |
| | | gc.setFileOverride(true);// 是否覆盖同名文件,默认是false |
| | | gc.setActiveRecord(true);// 不需要ActiveRecord特性的请改为false |
| | | gc.setEnableCache(false);// XML 二级缓存 |
| | |
| | | // strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意 |
| | | strategy.setTablePrefix(new String[]{""});// 此处可以修改为您的表前缀 |
| | | strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 |
| | | strategy.setInclude(new String[]{"master_modified",}); // 需要生成的表 |
| | | strategy.setInclude(new String[]{"master_author","master_author_detail"}); // 需要生成的表 |
| | | // strategy.setExclude(new String[]{"test"}); // 排除生成的表 |
| | | // 自定义实体父类 |
| | | // strategy.setSuperEntityClass("com.baomidou.demo.TestEntity"); |
| | |
| | | spring: |
| | | datasource: |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | | url: jdbc:mysql://localhost:3306/data_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | url: jdbc:mysql://localhost:3306/mdm?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | username: root |
| | | password: 123456 |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | |
| | | unbigdata: |
| | | db: |
| | | host: localhost |
| | | url: jdbc:mysql://localhost:3306/data_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | url: jdbc:mysql://localhost:3306/mdm?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | type: MYSQL |
| | | port: 3306 |
| | | schema: mdm |
| | |
| | | max-lifetime: 30000 |
| | | connection-test-query: select 1 |
| | | activiti: |
| | | database-schema-update: false |
| | | database-schema-update: flase |
| | | |
| | | thymeleaf: |
| | | cache: false |
| | |
| | | spring: |
| | | datasource: |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | | url: jdbc:mysql://180.169.94.250:8306/data_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | 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 |
| | | |
| | | activiti: |
| | | database-schema-update: true |
| | | database-schema-update: flase |
| | | |
| | | thymeleaf: |
| | | cache: false |
| | |
| | | spring: |
| | | profiles: |
| | | active: |
| | | pro |
| | | prod |
| | | |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | |
| | | ) |
| | | </select> |
| | | |
| | | |
| | | <update id="updateRecordByMaintainId" statementType="STATEMENT" > |
| | | update ${tableTempName} |
| | | INNER JOIN maintain_detail on ${tableTempName}.id = maintain_detail.pre_merge_id |
| | |
| | | </update> |
| | | |
| | | <delete id="deleteRecordByMaintainId" statementType="STATEMENT" > |
| | | |
| | | DELETE ${tableTempName} from ${tableTempName} |
| | | INNER JOIN maintain_detail on maintain_detail.pre_merge_id = ${tableTempName}.id |
| | | WHERE maintain_detail.parent_id = ${maintainId} and ${tableTempName}.std_id = ${stdId} |
| | | |
| | | |
| | | </delete> |
| | | |
| | | <select id="selectActMemberShip" parameterType="java.util.Map" resultType="java.util.Map"> |
| | | select * from act_id_membership where USER_ID_ = #{userId} and GROUP_ID_ = #{roleId} |
| | | </select> |
| | | |
| | | <select id="getOneTempFieldDataByMaintainExtent" statementType="STATEMENT" resultType="java.util.Map"> |
| | | <![CDATA[ |
| | | SELECT DISTINCT ${field} FROM ${tempTableName} t WHERE EXISTS ( |
| | | SELECT pre_merge_id FROM ( SELECT pre_merge_id FROM maintain_detail WHERE EXISTS ( |
| | | SELECT id FROM ( SELECT id FROM `maintain` WHERE |
| | | table_name = ${tableName} |
| | | AND order_no >= ${fromOrderNo} |
| | | AND order_no < ${toOrderNo} |
| | | ) a |
| | | WHERE |
| | | a.id = maintain_detail.parent_id ) |
| | | ) a |
| | | WHERE t.id = a.pre_merge_id) |
| | | |
| | | ]]> |
| | | </select> |
| | | |
| | | <select id="getTempDataByMaintainExtent" statementType="STATEMENT" resultType="java.util.Map"> |
| | | <![CDATA[ |
| | | SELECT * FROM ${tempTableName} t WHERE EXISTS ( |
| | | SELECT pre_merge_id FROM ( SELECT pre_merge_id FROM maintain_detail WHERE EXISTS ( |
| | | SELECT id FROM ( SELECT id FROM `maintain` WHERE |
| | | table_name = ${tableName} |
| | | AND order_no >= ${fromOrderNo} |
| | | AND order_no < ${toOrderNo} |
| | | ) a |
| | | WHERE |
| | | a.id = maintain_detail.parent_id ) |
| | | ) a |
| | | WHERE t.id = a.pre_merge_id) |
| | | |
| | | ]]> |
| | | </select> |
| | | </mapper> |