kimi42345
2020-03-28 f7af6b99c11bf876c0faef82d42caacf5475de93
no message
31个文件已修改
13个文件已添加
1803 ■■■■■ 已修改文件
src/main/java/com/highdatas/mdm/controller/ActivitiController.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/AssembleController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/MaintainController.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/MaintainFieldController.java 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/MasterAuthorController.java 206 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/MasterAuthorDetailController.java 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/MasterDataController.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/MenuMappingController.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/SysMenuController.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/entity/MasterAuthor.java 166 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/entity/MasterAuthorDetail.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/mapper/MasterAuthorDetailMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/mapper/MasterAuthorMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/mapper/TableInfoMapper.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/mapper/xml/MasterAuthorDetailMapper.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/mapper/xml/MasterAuthorMapper.xml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/pojo/MasterAuthorType.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/process/canvas/ProcessDiagramGenerator.java 86 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/IFlowsService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/IMaintainFieldService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/IMasterAuthorDetailService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/IMasterAuthorService.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/IMenuMappingService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/ISysFieldService.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/ISysMenuService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/MasterDataService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/act/RepositoryService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/act/impl/IdentityServiceImpl.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/act/impl/RepositoryServiceImpl.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/MaintainFieldServiceImpl.java 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/MasterAuthorDetailServiceImpl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/MasterAuthorServiceImpl.java 246 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/MasterDataServiceImpl.java 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/MenuMappingServiceImpl.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/SysFieldServiceImpl.java 110 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/SysMenuServiceImpl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/util/Constant.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/util/DbUtils.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/util/MpGenerator.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-dev.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-pro.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-prod.yml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapping/TableInfoMapper.xml 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/ActivitiController.java
@@ -90,16 +90,14 @@
    }
    @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);
            }
        }
@@ -107,9 +105,9 @@
            e.printStackTrace();
        }
        finally {
            if (fileInputStream != null) {
            if (is != null) {
                try {
                    fileInputStream.close();
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
@@ -314,6 +312,7 @@
            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
        }
        HttpSession session = request.getSession();
        //todo 判断当前task是否是当前人能审批的
        taskService.setSession(session);
        ActivitiStatus status = flows.getStatus();
src/main/java/com/highdatas/mdm/controller/AssembleController.java
@@ -397,8 +397,6 @@
                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);
src/main/java/com/highdatas/mdm/controller/MaintainController.java
@@ -47,6 +47,8 @@
    IFlowsService  flowsService;
    @Autowired
    IMaintainFieldService maintainFieldService;
    @Autowired
    IMasterAuthorService masterAuthorService;
    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    public Result get(@PathVariable String id) {
@@ -106,7 +108,10 @@
            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;
src/main/java/com/highdatas/mdm/controller/MaintainFieldController.java
@@ -1,10 +1,32 @@
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>
@@ -17,5 +39,80 @@
@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);
    }
}
src/main/java/com/highdatas/mdm/controller/MasterAuthorController.java
New file
@@ -0,0 +1,206 @@
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());
    }
}
src/main/java/com/highdatas/mdm/controller/MasterAuthorDetailController.java
New file
@@ -0,0 +1,111 @@
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);
    }
}
src/main/java/com/highdatas/mdm/controller/MasterDataController.java
@@ -13,7 +13,6 @@
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.*;
@@ -40,7 +39,8 @@
    IMaintainService maintainService;
    @Autowired
    IMaintainDetailService maintainDetailService;
    @Autowired
    IMaintainFieldService maintainFieldService;
    @Autowired
    IMenuMappingService menuMappingService;
@@ -49,6 +49,8 @@
    @Autowired
    IMasterModifiedService masterModifiedService;
    @Autowired
    IMasterAuthorService masterAuthorService;
    @RequestMapping(value = "{tableName}/uploaded",  method = RequestMethod.GET)
    public Result get(@PathVariable String tableName, HttpServletRequest request) {
@@ -99,9 +101,13 @@
            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);
@@ -125,9 +131,9 @@
            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)
@@ -328,4 +334,22 @@
            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);
    }
}
src/main/java/com/highdatas/mdm/controller/MenuMappingController.java
@@ -56,7 +56,7 @@
    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);
        }
@@ -72,4 +72,6 @@
        }
    }
}
src/main/java/com/highdatas/mdm/controller/SysMenuController.java
@@ -46,12 +46,21 @@
    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)
@@ -174,7 +183,7 @@
        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);
        }
@@ -227,7 +236,7 @@
//            }
//        }
        return Result.success(CodeMsg.SUCCESS);
        return Result.success(menu);
    }
    @RequestMapping(value = "/update", method = RequestMethod.GET)
@@ -324,6 +333,5 @@
        List<SysMenu> sysMenus = menuService.selectList(menuEntityWrapper);
        return Result.success(sysMenus);
    }
}
src/main/java/com/highdatas/mdm/entity/MasterAuthor.java
New file
@@ -0,0 +1,166 @@
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 +
        "}";
    }
}
src/main/java/com/highdatas/mdm/entity/MasterAuthorDetail.java
New file
@@ -0,0 +1,89 @@
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 +
        "}";
    }
}
src/main/java/com/highdatas/mdm/mapper/MasterAuthorDetailMapper.java
New file
@@ -0,0 +1,16 @@
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> {
}
src/main/java/com/highdatas/mdm/mapper/MasterAuthorMapper.java
New file
@@ -0,0 +1,16 @@
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> {
}
src/main/java/com/highdatas/mdm/mapper/TableInfoMapper.java
@@ -1,7 +1,6 @@
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;
@@ -64,5 +63,10 @@
    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);
}
src/main/java/com/highdatas/mdm/mapper/xml/MasterAuthorDetailMapper.xml
New file
@@ -0,0 +1,13 @@
<?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>
src/main/java/com/highdatas/mdm/mapper/xml/MasterAuthorMapper.xml
New file
@@ -0,0 +1,15 @@
<?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>
src/main/java/com/highdatas/mdm/pojo/MasterAuthorType.java
New file
@@ -0,0 +1,12 @@
package com.highdatas.mdm.pojo;
/**
 * @author kimi
 * @description
 * @date 2020-02-15 22:57
 */
public enum MasterAuthorType {
    role,user
}
src/main/java/com/highdatas/mdm/process/canvas/ProcessDiagramGenerator.java
@@ -212,59 +212,63 @@
            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);
                }
           }
     }
src/main/java/com/highdatas/mdm/service/IFlowsService.java
@@ -17,7 +17,7 @@
    MaintainField createNowVerion(String tableName, String maintainId, String userId);
    ActivitiStatus getStatusByBusinessId(String maintainFieldId);
    ActivitiStatus getStatusByBusinessId(String businssId);
    boolean isNextAudit(Flows flows, String userId);
src/main/java/com/highdatas/mdm/service/IMaintainFieldService.java
@@ -1,9 +1,9 @@
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;
@@ -20,7 +20,7 @@
    MaintainField getNextMaintain(String tableName, String userId);
    List<Maintain> getMaintainByMaintainField(String maintainFieldId, String tableName);
    boolean checkNowVersion(String id);
    boolean checkFirstVersion(String id);
@@ -38,4 +38,7 @@
    void dealFlow(String maintainId, ActivitiStatus status);
    int getUnFlowCount(String tableName, String userId);
    JSONArray getMaintainListByTable(String tableName);
}
src/main/java/com/highdatas/mdm/service/IMasterAuthorDetailService.java
New file
@@ -0,0 +1,16 @@
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> {
}
src/main/java/com/highdatas/mdm/service/IMasterAuthorService.java
New file
@@ -0,0 +1,32 @@
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);
}
src/main/java/com/highdatas/mdm/service/IMenuMappingService.java
@@ -2,6 +2,7 @@
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;
@@ -23,4 +24,8 @@
    boolean update(String json);
    Result getMapping(HttpSession session, String id);
    SysMenu getMenuByTableName(String tableName);
    String getTableNameByMenu(String menuId);
}
src/main/java/com/highdatas/mdm/service/ISysFieldService.java
@@ -1,8 +1,8 @@
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;
@@ -20,6 +20,8 @@
    List<SysField> getFieldByMaintain(String maintainId);
    MaintainField getMaintainFieldByMaintain(String maintainId);
    List<SysField> getFieldByTable(String tableName);
@@ -31,5 +33,9 @@
    List<SysField> getFieldByMaintainField(String maintainId);
    List<SysField> getDefaultTableField(String tableName);
    List<SysField> getTotalTableField(String tableName);
    Result getTotalFields(String tableName, Integer pageNo, Integer pageSize);
}
src/main/java/com/highdatas/mdm/service/ISysMenuService.java
@@ -1,10 +1,9 @@
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>
@@ -18,4 +17,5 @@
    LinkedHashSet<String> getByParentId(LinkedHashSet<String> parentIdSet);
}
src/main/java/com/highdatas/mdm/service/MasterDataService.java
@@ -5,6 +5,8 @@
import com.highdatas.mdm.pojo.SysAssembleUpdateType;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
 * @author kimi
@@ -83,7 +85,12 @@
    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);
}
src/main/java/com/highdatas/mdm/service/act/RepositoryService.java
@@ -8,6 +8,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
/**
@@ -31,4 +32,5 @@
    public boolean updateProcessDefStatus(String type, String modelId);
    public void getModelXml(HttpServletResponse response,String modelId) throws IOException;
    InputStream getModelImg(String modelId);
}
src/main/java/com/highdatas/mdm/service/act/impl/IdentityServiceImpl.java
@@ -1,6 +1,7 @@
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;
@@ -17,6 +18,7 @@
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{
@@ -26,7 +28,8 @@
    RuntimeService runtimeService;
    @Autowired
    RepositoryService repositoryService;
    @Autowired
    TableInfoMapper tableInfoMapper;
    @Override
    public String startProcess(String businessId, String key) {
@@ -88,6 +91,10 @@
    @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);
@@ -101,6 +108,10 @@
    @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);
@@ -118,11 +129,12 @@
            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) {
@@ -174,6 +186,11 @@
            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);
        }
src/main/java/com/highdatas/mdm/service/act/impl/RepositoryServiceImpl.java
@@ -6,6 +6,7 @@
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;
@@ -14,6 +15,7 @@
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;
@@ -32,7 +34,6 @@
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;
@@ -51,6 +52,9 @@
    private static final String MODEL_DESCRIPTION = "description";
    @Autowired
    RepositoryService service;
    @Autowired
    HistoryService historyService;
    @Autowired
    ObjectMapper objectMapper;
    @Value("${img.url}")
@@ -71,7 +75,34 @@
        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();
src/main/java/com/highdatas/mdm/service/impl/MaintainFieldServiceImpl.java
@@ -1,7 +1,10 @@
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;
@@ -11,23 +14,16 @@
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;
/**
@@ -104,6 +100,15 @@
            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
@@ -247,4 +252,52 @@
        }
        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;
    }
}
src/main/java/com/highdatas/mdm/service/impl/MasterAuthorDetailServiceImpl.java
New file
@@ -0,0 +1,20 @@
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 {
}
src/main/java/com/highdatas/mdm/service/impl/MasterAuthorServiceImpl.java
New file
@@ -0,0 +1,246 @@
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;
    }
}
src/main/java/com/highdatas/mdm/service/impl/MasterDataServiceImpl.java
@@ -11,17 +11,14 @@
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;
@@ -46,7 +43,10 @@
    IMaintainDetailService maintainDetailService;
    @Autowired
    IFlowsService flowsService;
    @Autowired
    RedisClient redisClient;
    @Autowired
    IMaintainFieldService maintainFieldService;
    @Resource
    protected DataSource dataSource;
@@ -355,6 +355,74 @@
    }
    @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);
@@ -558,6 +626,8 @@
        return maintain;
    }
    //bak
    public Result selectListByPage(String tableName, List<String> fieldList, String whereSegment, Integer pageNo, Integer pageSize, String version) {
@@ -909,5 +979,79 @@
        }
    }
    @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;
    }
}
src/main/java/com/highdatas/mdm/service/impl/MenuMappingServiceImpl.java
@@ -135,7 +135,6 @@
        } else {
            return null;
        }
    }
    @Override
@@ -149,7 +148,16 @@
            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);
    }
@@ -183,9 +191,28 @@
            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();
    }
}
src/main/java/com/highdatas/mdm/service/impl/SysFieldServiceImpl.java
@@ -16,14 +16,13 @@
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;
/**
@@ -50,13 +49,12 @@
    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) {
@@ -68,17 +66,28 @@
            //对应版本找不到 往前找
            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  判断版本
@@ -100,6 +109,53 @@
            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;
        }
@@ -283,12 +339,38 @@
        }
        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;
    }
}
src/main/java/com/highdatas/mdm/service/impl/SysMenuServiceImpl.java
@@ -1,16 +1,14 @@
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>
@@ -49,4 +47,6 @@
        return parentIdSet;
    }
}
src/main/java/com/highdatas/mdm/util/Constant.java
@@ -9,6 +9,7 @@
    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 = " = ";
@@ -45,6 +46,7 @@
    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";
@@ -101,4 +103,9 @@
    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} )";
}
src/main/java/com/highdatas/mdm/util/DbUtils.java
@@ -4,11 +4,13 @@
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;
@@ -315,4 +317,35 @@
        }
        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;
    }
}
src/main/java/com/highdatas/mdm/util/MpGenerator.java
@@ -28,7 +28,7 @@
        // 全局配置
        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 二级缓存
@@ -65,7 +65,7 @@
        // 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");
src/main/resources/application-dev.yml
@@ -5,7 +5,7 @@
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
@@ -69,7 +69,7 @@
  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
src/main/resources/application-pro.yml
@@ -16,7 +16,7 @@
      max-lifetime: 30000
      connection-test-query: select 1
  activiti:
    database-schema-update: false
    database-schema-update: flase
  thymeleaf:
    cache: false
src/main/resources/application-prod.yml
@@ -12,15 +12,16 @@
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
src/main/resources/application.yml
@@ -1,7 +1,7 @@
spring:
  profiles:
    active:
      pro
      prod
  main:
    allow-bean-definition-overriding: true
src/main/resources/mapping/TableInfoMapper.xml
@@ -477,7 +477,6 @@
        )
    </select>
    <update id="updateRecordByMaintainId" statementType="STATEMENT" >
         update ${tableTempName}
        INNER JOIN maintain_detail on ${tableTempName}.id = maintain_detail.pre_merge_id
@@ -487,11 +486,46 @@
    </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>