kimi42345
2020-03-17 6c6fdb4db59a2a2343e43ffd73a07f17b057c4fa
3/17 添加 请求log
34个文件已修改
3个文件已添加
1115 ■■■■ 已修改文件
pom.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/MdmApplication.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/ActivitiController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/FlowsController.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/MaintainController.java 59 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/MasterDataController.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/SysAssembleDbController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/SysFieldController.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/controller/SysMenuController.java 59 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/entity/Flows.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/entity/Maintain.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/mapper/MasterModifiedMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/pojo/ActivitiBusinessType.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/IFlowsService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/IMaintainFieldService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/IMasterModifiedService.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/ISysAssembleDbService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/MasterDataService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/act/impl/TaskServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/FlowsServiceImpl.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/MaintainFieldServiceImpl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/MasterDataServiceImpl.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/MasterModifiedServiceImpl.java 184 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/SysAssembleDbServiceImpl.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/SysAssembleServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/service/impl/SysFieldServiceImpl.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/util/CommonInterceptor.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/util/Constant.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/util/DbUtils.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/util/FilterConfig.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/util/HttpTraceLogFilter.java 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/highdatas/mdm/util/OriginConfig.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-prod.yml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/lib/common-1.0.jar 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapping/MasterModifiedMapper.xml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapping/TableInfoMapper.xml 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -20,6 +20,10 @@
            <id>pentaho</id>
            <url>http://nexus.pentaho.org/content/groups/omni/</url>
        </repository>
        <!--<repository>-->
            <!--<id>mylibid</id>-->
            <!--<url>file://${pom.basedir}/lib</url>-->
        <!--</repository>-->
    </repositories>
    <properties>
@@ -408,7 +412,15 @@
            <artifactId>xxl-job-core</artifactId>
            <version>2.2.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/xxl-job-core-2.2.0-SNAPSHOT.jar</systemPath>
            <systemPath>${pom.basedir}/src/main/resources/lib/xxl-job-core-2.2.0-SNAPSHOT.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>com.datacvg</groupId>
            <artifactId>common</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${pom.basedir}/src/main/resources/lib/common-1.0.jar</systemPath>
        </dependency>
    </dependencies>
src/main/java/com/highdatas/mdm/MdmApplication.java
@@ -3,6 +3,7 @@
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication(exclude={
@@ -11,6 +12,7 @@
})
@MapperScan(value = "com.highdatas.mdm.mapper")
@EnableSwagger2
@EnableAsync
public class MdmApplication {
    public static void main(String[] args) {
src/main/java/com/highdatas/mdm/controller/ActivitiController.java
@@ -66,6 +66,8 @@
    IMaintainService maintainService;
    @Autowired
    ITUserService userService;
    @Autowired
    IMasterModifiedService masterModifiedService;
    @Autowired
    IMaintainFieldService maintainFieldService;
@@ -349,14 +351,8 @@
                        flows.setStatus(ActivitiStatus.close);
                    }
                    if (flows.getBusinessType().equals(ActivitiBusinessType.maintain)){
                        String maintainId = flows.getBusinessId();
                        maintainService.dealFlow(maintainId, flows.getStatus());
                    }
                    if (flows.getBusinessType().equals(ActivitiBusinessType.field)){
                        String maintainId = flows.getBusinessId();
                        maintainFieldService.dealFlow(maintainId, flows.getStatus());
                    }
                    flowsService.aduitFinish(flows);
                } else {
                    if (pass && flows.getStatus().equals(ActivitiStatus.refuse)) {
@@ -386,4 +382,6 @@
            return Result.success(CodeMsg.INSERT_ERROR);
        }
    }
}
src/main/java/com/highdatas/mdm/controller/FlowsController.java
@@ -1,8 +1,26 @@
package com.highdatas.mdm.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.highdatas.mdm.entity.Flows;
import com.highdatas.mdm.entity.SysMenu;
import com.highdatas.mdm.pojo.ActivitiStatus;
import com.highdatas.mdm.pojo.CodeMsg;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.service.IFlowsService;
import com.highdatas.mdm.service.ITUserService;
import com.sun.tools.javac.jvm.Code;
import org.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.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.stream.Collectors;
/**
 * <p>
@@ -15,5 +33,51 @@
@RestController
@RequestMapping("/flows")
public class FlowsController {
    @Autowired
    IFlowsService flowsService;
    @Autowired
    ITUserService userService;
    @RequestMapping(value = "/{pageno}", method = RequestMethod.GET)
    public Result<Page<Flows>> getAll(@PathVariable int pageno, HttpServletRequest request) {
        String pageSize = request.getParameter("pageSize");
        if (StringUtils.isEmpty(pageSize)) {
            pageSize = "15";
        }
        EntityWrapper<Flows> flowsEntityWrapper = new EntityWrapper<>();
        String userId = request.getParameter("userId");
        if (!StringUtils.isEmpty(userId)) {
            flowsEntityWrapper.eq("user_id", userId);
        }
        String status = request.getParameter("status");
        if (!StringUtils.isEmpty(status)) {
            flowsEntityWrapper.eq("status", status);
        }
        Integer size = Integer.valueOf(pageSize);
        Page page = new Page(pageno, size);
        Page<Flows> menuPage = flowsService.selectPage(page, flowsEntityWrapper);
        List<Flows> records = menuPage.getRecords();
        List<Flows> recordsStr = records.stream().map(flows -> flows.setBusinessTypeStr(flows.getBusinessType().toString()).setUserName(userService.selectById(flows.getUserId()).getUserName())).collect(Collectors.toList());
        menuPage.setRecords(recordsStr);
        return Result.success(menuPage);
    }
    @RequestMapping(value = "close/{id}", method = RequestMethod.GET)
    public Result close(@PathVariable String id, HttpServletRequest request) {
        Flows flows = flowsService.selectById(id);
        if (flows == null) {
            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
        }
        flows.setStatus(ActivitiStatus.close);
        flowsService.aduitFinish(flows);
        boolean update = flows.updateById();
        if (update) {
            return Result.success(flows);
        }else {
            return Result.error(CodeMsg.UPDATE_ERROR);
        }
    }
}
src/main/java/com/highdatas/mdm/controller/MaintainController.java
@@ -13,10 +13,7 @@
import com.highdatas.mdm.pojo.CodeMsg;
import com.highdatas.mdm.pojo.Operate;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.service.IFlowsService;
import com.highdatas.mdm.service.IMaintainDetailService;
import com.highdatas.mdm.service.IMaintainService;
import com.highdatas.mdm.service.ITUserService;
import com.highdatas.mdm.service.*;
import com.highdatas.mdm.util.Constant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,9 +22,7 @@
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.*;
/**
 * <p>
@@ -50,6 +45,8 @@
    TableInfoMapper tableInfoMapper;
    @Autowired
    IFlowsService  flowsService;
    @Autowired
    IMaintainFieldService maintainFieldService;
    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    public Result get(@PathVariable String id) {
@@ -91,14 +88,19 @@
    }
    @RequestMapping(value = "/version/{tableName}", method = RequestMethod.GET)
    public Result getHistory(@PathVariable String tableName) {
    public Result getHistory(@PathVariable String tableName, HttpServletRequest request) {
        TUser user = (TUser) request.getSession().getAttribute("user");
        String userId = user.getUserId();
        Maintain nowVersion = maintainService.getNowVersion(tableName);
        if (nowVersion == null) {
        Maintain maxVersion = maintainService.getMaxVersion(tableName);
        if (maxVersion == null) {
            return Result.error(new CodeMsg(100001,"无当前版本"));
        }
        Maintain nowVersion = maintainService.getNowVersion(tableName);
        List<Maintain> maintainList = maintainService.selectList(new EntityWrapper<Maintain>().eq("table_name", tableName).orderBy("order_no",false));
        List<Maintain> result = new ArrayList<>();
        int count = 0;
        for (Maintain maintain : maintainList) {
            String flowId = maintain.getFlowId();
            if (StringUtils.isEmpty(flowId)) {
@@ -110,18 +112,39 @@
                continue;
            }
            if (flows.getStatus().equals(ActivitiStatus.working) || flows.getStatus().equals(ActivitiStatus.refuse)) {
                maintain.setMaintainType(-1);
                boolean nextAudit = flowsService.isNextAudit(flows, userId);
                if (nextAudit) {
                    count++;
                }
                continue;
            }else if(flows.getStatus().equals(ActivitiStatus.open)){
                maintain.setMaintainType(1);
            }
            if (maintain.getId().equalsIgnoreCase(nowVersion.getId())) {
            if (nowVersion != null  && maintain.getId().equalsIgnoreCase(nowVersion.getId())) {
                maintain.setMaintainType(0);
            }
            result.add(maintain);
        }
        //
        int cnt = maintainFieldService.getUnFlowCount(tableName, userId);
        count += cnt;
        if (count > 0) {
            Maintain maintain = new Maintain();
            maintain.setMaintainType(-1);
            maintain.setVersion("待审核");
            maintain.setTableName(tableName);
            maintain.setRecordCount(count);
            result.add(maintain);
        }
        Collections.sort(result, new Comparator<Maintain>() {
            @Override
            public int compare(Maintain o1, Maintain o2) {
                return o1.getMaintainType().compareTo(o2.getMaintainType());
            }
        });
        return Result.success(result);
    }
}
    @RequestMapping(value = "/detail/{id}/{pageNo}", method = RequestMethod.GET)
    public Result detail(@PathVariable String id, @PathVariable int pageNo) {
@@ -182,6 +205,16 @@
        return Result.success(compare);
    }
    @RequestMapping(value = "/canUpload/{tableName}", method = RequestMethod.GET)
    public Result canUpload(@PathVariable String tableName) {
        Maintain nowVersion = maintainService.getNowVersion(tableName);
        if (nowVersion == null) {
            return Result.success(true);
        }else {
            return Result.success(false);
        }
    }
    @RequestMapping(value = "/detail/{pageNo}", method = RequestMethod.GET)
    public Result setFlowId(@RequestParam String flowId,@PathVariable Integer pageNo, HttpServletRequest request) {
        String whereSegment = request.getParameter("whereSegment");
src/main/java/com/highdatas/mdm/controller/MasterDataController.java
@@ -9,13 +9,11 @@
import com.highdatas.mdm.pojo.Operate;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.pojo.SysAssembleUpdateType;
import com.highdatas.mdm.service.IMaintainDetailService;
import com.highdatas.mdm.service.IMaintainService;
import com.highdatas.mdm.service.IMenuMappingService;
import com.highdatas.mdm.service.MasterDataService;
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.pentaho.reporting.libraries.formula.function.text.StringCountFunction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -23,9 +21,7 @@
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -51,6 +47,9 @@
    @Autowired
    TableInfoMapper tableInfoMapper;
    @Autowired
    IMasterModifiedService masterModifiedService;
    @RequestMapping(value = "{tableName}/uploaded",  method = RequestMethod.GET)
    public Result get(@PathVariable String tableName, HttpServletRequest request) {
        String uploadTypeStr = request.getParameter("uploadType");
@@ -61,6 +60,8 @@
        uploadType = SysAssembleUpdateType.valueOf(uploadTypeStr);
        TUser user = (TUser) request.getSession().getAttribute(Constant.USER);
        Maintain maintain = masterDataService.uploadedData(tableName, uploadType, user.getUserId());
        // 处理关联人
        masterModifiedService.dealAssemble(maintain.getId(), user.getUserId(), true);
        JSONObject object = new JSONObject();
        object.fluentPut("maintainId",maintain.getId());
        object.fluentPut("version",maintain.getVersion());
@@ -130,21 +131,28 @@
    }
    @RequestMapping(value = "{maintainId}/modify/{operateStr}", method = RequestMethod.POST)
    public Result modify(@RequestParam String datas, @PathVariable String maintainId, @PathVariable String operateStr, HttpServletRequest request) throws UnsupportedEncodingException {
    public Result modify(@RequestParam String datas, @PathVariable String maintainId, @PathVariable String operateStr,  @RequestParam String modify, HttpServletRequest request) throws UnsupportedEncodingException {
        Result result = null;
        Operate operate = Operate.parse(operateStr);
        Maintain maintain = maintainService.selectById(maintainId);
        List<String> modifyFields = null;
        if (!StringUtils.isEmpty(modify)) {
            String[] split = modify.split(Constant.SEMICOLON);
            modifyFields = Arrays.stream(split).collect(Collectors.toList());
        }
        TUser user = (TUser) request.getSession().getAttribute("user");
        switch (operate) {
            case delete:
                //datas is id;
                Integer deleteCount = tableInfoMapper.deleteRecordByMaintainId(maintain.getTableName() + Constant.RECORD, DbUtils.quotedStr(datas), DbUtils.quotedStr(maintainId));
                result = Result.success(deleteCount);
                break;
            case update:
                JSONObject jsonObject = JSONObject.parseObject(datas);
                String id = (String) jsonObject.get("id");
                masterModifiedService.updateModifiedUserById(maintainId, id, user.getUserId(), modifyFields);
                jsonObject.remove(Constant.ID);
                datas = jsonObject.toJSONString();
                String updateSegment = masterDataService.getUpdateSegment(maintain.getTableName(), maintain.getTableName() + Constant.RECORD, datas);
@@ -155,6 +163,9 @@
            case create:
                JSONObject createObject = JSONObject.parseObject(datas);
                String recordId = DbUtils.getUUID();
                masterModifiedService.updateModifiedUserById(maintainId, recordId, user.getUserId(), modifyFields);
                createObject.fluentPut(Constant.ID, recordId);
                createObject.fluentPut(Constant.STD_ID, DbUtils.getUUID());
                datas = createObject.toJSONString();
@@ -189,6 +200,11 @@
        Maintain maintain = maintainService.getMaxVersion(tableName);
        Maintain nowMaintain = maintainService.getNextMaintain(tableName, userId);
        List<String> modifyFields = null;
        if (!StringUtils.isEmpty(modify)) {
            String[] split = modify.split(Constant.SEMICOLON);
            modifyFields = Arrays.stream(split).collect(Collectors.toList());
        }
        Result result;
        if (operate.equals(Operate.delete)) {
@@ -209,16 +225,19 @@
        } else if (operate.equals(Operate.update)) {
            JSONObject jsonObject = JSONObject.parseObject(datas);
            Object id = jsonObject.get("id");
            String nowMaintainId = nowMaintain.getId();
            String tempId = tableInfoMapper.getTempIdByStdId(tableName + Constant.RECORD,DbUtils.quotedStr(id.toString()), DbUtils.quotedStr(nowMaintainId));
            if (StringUtils.isEmpty(tempId)) {
                result = masterDataService.selectById(tableName, id.toString());
            } else {
                masterModifiedService.updateModifiedUserById(nowMaintain.getId(), id.toString(), user.getUserId(), modifyFields);
                jsonObject.put(Constant.STD_ID, id);
                jsonObject.put(Constant.ID, tempId);
                return masterDataService.updateById(tableName + Constant.RECORD, JSON.toJSONString(jsonObject), tempId,false);
            }
        }
        //merge 2 temp
        String tableTempName = tableName + Constant.RECORD;
@@ -228,6 +247,7 @@
        if (dataId == null) {
            dataId = DbUtils.getUUID();
        }
        masterModifiedService.updateModifiedUserById(nowMaintain.getId(), dataId.toString(), user.getUserId(), modifyFields);
        object.put(Constant.STD_ID, dataId);
        object.put(Constant.ID, DbUtils.getUUID());
        datas = JSON.toJSONString(object);
src/main/java/com/highdatas/mdm/controller/SysAssembleDbController.java
@@ -82,6 +82,16 @@
        return Result.success(b);
    }
    @ResponseBody
    @RequestMapping(value = "/testConnection", method = RequestMethod.POST)
    public Result testConnection(@RequestBody SysAssembleDb sysAssembleDb) {
        if (sysAssembleDb == null) {
            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
        }
        boolean b =  dbService.testConnection(sysAssembleDb);
        return Result.success(b);
    }
    @RequestMapping(value = "/getSet", method = RequestMethod.GET)
    public Result getSet(HttpServletRequest request) {
        List<SysAssembleDb> dbList = dbService.selectList(null);
src/main/java/com/highdatas/mdm/controller/SysFieldController.java
@@ -15,6 +15,7 @@
import com.highdatas.mdm.util.Constant;
import com.highdatas.mdm.util.DbUtils;
import com.highdatas.mdm.util.WorkflowUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -32,6 +33,7 @@
 * @author kimi
 * @since 2019-12-16
 */
@Slf4j
@RestController
@RequestMapping("/field")
public class SysFieldController {
@@ -161,6 +163,7 @@
    @RequestMapping(value = "/loadFields", method = RequestMethod.POST)
    public Result loadFields(@RequestBody String fieldListStr, HttpServletRequest request)  {
        log.info(fieldListStr);
        List<SysField> fieldList = JSONObject.parseArray(fieldListStr,SysField.class);
        if (fieldList.size() == 0) {
            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
@@ -179,11 +182,13 @@
        HttpSession session = request.getSession();
        TUser user = (TUser) session.getAttribute("user");
        String userId = user.getUserId();
        Maintain dataMaintainMax = maintainService.getMaxVersion(tableName);
        if (StringUtils.isEmpty(maintainId)) {
            //创建新版本的字段
            nowMaintain = flowsService.createNowVerion(tableName, maintainId, userId);
            if (nowMaintain == null) {
            if (nowMaintain == null && dataMaintainMax != null) {
                return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
            }
@@ -204,17 +209,66 @@
                nowMaintain = maintainFieldService.selectById(maintainId);
            }
        }
        String nowMaintainId;
        if (dataMaintainMax == null) {
            nowMaintainId = null;
        }else {
            nowMaintainId = nowMaintain.getId();
        }
        if (StringUtils.isEmpty(nowMaintainId)) {
            //第一次默认都清空
            fieldService.delete(new EntityWrapper<SysField>().isNull("maintain_field_id").eq("table_name", tableName));
        }
        for (int i = 0; i < fieldList.size(); i++) {
            SysField sysField = fieldList.get(i);
            sysField.setCreateTime(new Date()).setId(DbUtils.getUUID()).setOperate(Operate.create).setMaintainFieldId(nowMaintain.getId()).setOrderNo(i).insert();
            sysField.setCreateTime(new Date()).setId(DbUtils.getUUID()).setMaintainFieldId(nowMaintainId).setOrderNo(i).insert();
        }
        nowMaintain.insertOrUpdate();
        if (nowMaintain != null) {
            nowMaintain.insertOrUpdate();
        }
        return Result.success(null);
    }
    @RequestMapping(value = "/change", method = RequestMethod.POST)
    public Result addOrUpdate(@RequestBody SysField sysField, HttpServletRequest request)  {
        String tableName = sysField.getTableName();
        Maintain dataMaxVersion = maintainService.getMaxVersion(tableName);
        boolean isInit = false;
        if (dataMaxVersion == null) {
            isInit = true;
        }
        Operate operate = sysField.getOperate();
        if (isInit && (operate.equals(Operate.update) || operate.equals(Operate.create))) {
            if (isInit) {
                if (StringUtils.isEmpty(sysField.getId())) {
                    sysField.setId(DbUtils.getUUID());
                }
                boolean update = sysField.insertOrUpdate();
                if (update) {
                    return Result.success(CodeMsg.SUCCESS);
                }else {
                    return Result.error(CodeMsg.INSERT_ERROR);
                }
            }
        }
        if (isInit && operate.equals(Operate.delete)) {
            boolean delete = sysField.deleteById();
            if (delete) {
                return Result.success(CodeMsg.SUCCESS);
            }else {
                return Result.error(CodeMsg.DELETE_ERROR);
            }
        }
        if (operate.equals(Operate.update)) {
            String id = sysField.getId();
            SysField field = fieldService.selectById(id);
@@ -223,7 +277,16 @@
            }
            boolean visiableEqual = field.getVisible().equals(sysField.getVisible());
            boolean aliasEqual = field.getAlias().equals(sysField.getAlias());
            boolean codeEqual = field.getCode().equals(sysField.getCode());
            String updateCode = field.getCode();
            String preCode = sysField.getCode();
            boolean codeEqual;
            if (StringUtils.isEmpty(updateCode) && StringUtils.isEmpty(preCode)) {
                codeEqual = true;
            }else if(!StringUtils.isEmpty(updateCode) && !StringUtils.isEmpty(preCode) && updateCode.equalsIgnoreCase(preCode)){
                codeEqual = true;
            }else {
                codeEqual = false;
            }
            String updateFormat = field.getFormat();
            String preFormat = sysField.getFormat();
            boolean formatterEqual;
@@ -253,6 +316,7 @@
        String userId = user.getUserId();
        if (operate.equals(Operate.create) || operate.equals(Operate.update)) {
            String alias = sysField.getAlias();
            List<SysField> fieldByMaintainField;
            if (nowMaintain == null) {
@@ -341,6 +405,7 @@
            sysField.updateById();
        }
        else if(operate.equals(Operate.delete)) {
            SysField relatedField = fieldService.getOneFieldByMaintainField(nowMaintain.getId(), sysField.getField());
            if (relatedField == null) {
                return Result.error(CodeMsg.OPERATR_ERROR);
src/main/java/com/highdatas/mdm/controller/SysMenuController.java
@@ -3,16 +3,12 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.highdatas.mdm.entity.DeletedTableLog;
import com.highdatas.mdm.entity.MenuMapping;
import com.highdatas.mdm.entity.SysField;
import com.highdatas.mdm.entity.SysMenu;
import com.highdatas.mdm.entity.*;
import com.highdatas.mdm.pojo.ActivitiBusinessType;
import com.highdatas.mdm.pojo.ActivitiStatus;
import com.highdatas.mdm.pojo.CodeMsg;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.service.IDeletedTableLogService;
import com.highdatas.mdm.service.IMenuMappingService;
import com.highdatas.mdm.service.ISysFieldService;
import com.highdatas.mdm.service.ISysMenuService;
import com.highdatas.mdm.service.*;
import com.highdatas.mdm.util.Constant;
import com.highdatas.mdm.util.DbUtils;
import org.apache.commons.lang3.StringUtils;
@@ -20,7 +16,9 @@
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.*;
import java.util.stream.Collectors;
/**
 * <p>
@@ -42,19 +40,56 @@
    ISysFieldService fieldService;
    @Autowired
    IDeletedTableLogService deletedTableLogService;
    @Autowired
    IFlowsService flowsService;
    @Autowired
    IMaintainService maintainService;
    @Autowired
    IMaintainFieldService maintainFieldService;
    @RequestMapping(value = "/all", method = RequestMethod.GET)
    public Result<List<SysMenu>> getAll() {
        EntityWrapper<SysMenu> sysMenuEntityWrapper = new EntityWrapper<>();
        sysMenuEntityWrapper.orderBy(" parent_id, order_no");
        sysMenuEntityWrapper.orderBy("parent_id, order_no");
        return Result.success(menuService.selectList(sysMenuEntityWrapper)) ;
    }
    @RequestMapping(value = "/audit", method = RequestMethod.GET)
    public Result<List<SysMenu>> audit(HttpServletRequest request) {
        HttpSession session = request.getSession();
        TUser user = (TUser) session.getAttribute("user");
        String userId = user.getUserId();
        List<Flows> flows = flowsService.selectList(new EntityWrapper<Flows>().ne("business_type", ActivitiBusinessType.exists).ne("status", ActivitiStatus.open).ne("status", ActivitiStatus.close));
        flows = flows.stream().filter(flow ->  flowsService.isNextAudit(flow, userId)).collect(Collectors.toList());
        HashSet<String> tableNameSet = new HashSet<>();
        List<String> maintainIds = flows.stream().map(Flows::getBusinessId).collect(Collectors.toList());
        if (maintainIds.size() == 0) {
            return  Result.success(null);
        }
        List<Maintain> maintains = maintainService.selectBatchIds(maintainIds);
        List<String> tableNameList = maintains.stream().map(Maintain::getTableName).collect(Collectors.toList());
        tableNameSet.addAll(tableNameList);
        //
        List<MaintainField> maintainFields = maintainFieldService.selectBatchIds(maintainIds);
        tableNameSet.addAll(maintainFields.stream().map(MaintainField::getTableName).collect(Collectors.toList()));
        if (tableNameSet.size() == 0) {
            return Result.success(null);
        }
        List<MenuMapping> menuMappingList = menuMappingService.selectList(new EntityWrapper<MenuMapping>().in("table_name", tableNameSet));
        List<String> menuIds = menuMappingList.stream().map(MenuMapping::getMenuId).collect(Collectors.toList());
        LinkedHashSet<String> parentIdSet = new LinkedHashSet<>(menuIds);
        Set<String> byParentId = menuService.getByParentId(parentIdSet);
        List<SysMenu> parentList = menuService.selectBatchIds(byParentId);
        return Result.success(parentList);
    }
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result<List<SysMenu>> getMenuList() {
        EntityWrapper<SysMenu> sysMenuEntityWrapper = new EntityWrapper<>();
        sysMenuEntityWrapper.eq("DataMenu", "DataMenu");
        sysMenuEntityWrapper.eq("menu_type", "DataMenu");
        sysMenuEntityWrapper.orderBy("parent_id, order_no");
        List<SysMenu> sysMenus = menuService.selectList(sysMenuEntityWrapper);
        LinkedHashSet<String> parentIdSet = new LinkedHashSet<>();
src/main/java/com/highdatas/mdm/entity/Flows.java
@@ -38,6 +38,40 @@
    @TableField("business_type")
    private ActivitiBusinessType businessType;
    private transient String businessTypeStr;
    private transient String processName;
    private transient String nextInfo;
    public String getProcessName() {
        return processName;
    }
    public Flows setProcessName(String processName) {
        this.processName = processName;
        return this;
    }
    public String getNextInfo() {
        return nextInfo;
    }
    public Flows setNextInfo(String nextInfo) {
        this.nextInfo = nextInfo;
        return this;
    }
    public String getUserName() {
        return userName;
    }
    public Flows setUserName(String userName) {
        this.userName = userName;
        return this;
    }
    private transient String userName;
    @TableField("create_time")
    private Date createTime;
@@ -47,6 +81,15 @@
    @TableField(exist = false)
    private Integer recordCount;
    public String getBusinessTypeStr() {
        return businessTypeStr;
    }
    public Flows setBusinessTypeStr(String businessTypeStr) {
        this.businessTypeStr = businessTypeStr;
        return this;
    }
    public Integer getRecordCount() {
        return recordCount;
    }
src/main/java/com/highdatas/mdm/entity/Maintain.java
@@ -46,6 +46,8 @@
    private transient Integer maintainType;
    private transient Integer recordCount;
    @Override
    protected Serializable pkVal() {
src/main/java/com/highdatas/mdm/mapper/MasterModifiedMapper.java
@@ -1,5 +1,6 @@
package com.highdatas.mdm.mapper;
import java.util.List;
import java.util.Map;
/**
@@ -12,4 +13,11 @@
 */
public interface MasterModifiedMapper {
    Map<String,String> selectByTableMasterId(String tableName, String masterId);
    List<Map<String, String>> selectByMaintainId(String recoedTableName, String maintainId);
    void insertUserByTableNameUserId(String maintainId, String tableName,String recordTableName, String userId, String fieldStr);
    void insertJsonByTableNameUserId(String maintainId, String tableName,String recordTableName, String jsonStr);
}
src/main/java/com/highdatas/mdm/pojo/ActivitiBusinessType.java
@@ -1,5 +1,20 @@
package com.highdatas.mdm.pojo;
public enum ActivitiBusinessType {
    maintain, exists, field
    maintain, exists, field;
    @Override
    public String toString() {
        switch (this){
            case maintain:
                return "主数据";
            case exists:
                return "业务系统";
            case field:
                return "字段";
            default:
                return super.toString();
        }
    }
}
src/main/java/com/highdatas/mdm/service/IFlowsService.java
@@ -18,4 +18,8 @@
    MaintainField createNowVerion(String tableName, String maintainId, String userId);
    ActivitiStatus getStatusByBusinessId(String maintainFieldId);
    boolean isNextAudit(Flows flows, String userId);
    void aduitFinish(Flows flows);
}
src/main/java/com/highdatas/mdm/service/IMaintainFieldService.java
@@ -36,4 +36,6 @@
    MaintainField getMaintainFromVersion(String tableName, String verison);
    void dealFlow(String maintainId, ActivitiStatus status);
    int getUnFlowCount(String tableName, String userId);
}
src/main/java/com/highdatas/mdm/service/IMasterModifiedService.java
@@ -1,5 +1,7 @@
package com.highdatas.mdm.service;
import com.highdatas.mdm.pojo.ActivitiStatus;
import java.util.List;
import java.util.Map;
@@ -17,6 +19,9 @@
    List<Map<String,String>> getModifiedUserByIds(String maintainId, List<String> masterId);
    boolean updateModifiedUserById(String maintainId, String masterId, List<String> modifiedFieldList);
    boolean updateModifiedUserById(String maintainId, String masterId, String userId, List<String> modifiedFieldList);
    void dealFlow(String maintainId, ActivitiStatus status);
    void dealAssemble(String maintainId, String userId, boolean audit);
}
src/main/java/com/highdatas/mdm/service/ISysAssembleDbService.java
@@ -24,4 +24,6 @@
    Connection getConnection(String dbId);
    List<String> getFieldsByTableName(String parentId, String tableName);
    boolean testConnection(SysAssembleDb sysAssembleDb);
}
src/main/java/com/highdatas/mdm/service/MasterDataService.java
@@ -27,6 +27,8 @@
    Result selectList(String tableName, List<String> fields);
    Long getCountByVersion(String maintainId, String tableName, String tableTempName, Integer fromOrderNo, Integer toOrderNo, String whereSegment);
    String getFields(String tableName);
    String getFields(String tableName, Maintain maintain);
src/main/java/com/highdatas/mdm/service/act/impl/TaskServiceImpl.java
@@ -122,6 +122,9 @@
        //TODO 需修改
        NextTaskUserInfo nextTaskUserInfo = new NextTaskUserInfo();
        Task nextTask = geTask(workflowId);
        if (nextTask == null) {
            return null;
        }
        String nextTaskAssignee = nextTask.getAssignee();
        if (!StringUtils.isEmpty(nextTaskAssignee)) {
            nextTaskUserInfo.setUserId(nextTaskAssignee);
src/main/java/com/highdatas/mdm/service/impl/FlowsServiceImpl.java
@@ -3,16 +3,21 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.highdatas.mdm.entity.Flows;
import com.highdatas.mdm.entity.MaintainField;
import com.highdatas.mdm.entity.TUserRole;
import com.highdatas.mdm.mapper.FlowsMapper;
import com.highdatas.mdm.mapper.SysFieldMapper;
import com.highdatas.mdm.pojo.ActivitiBusinessType;
import com.highdatas.mdm.pojo.ActivitiStatus;
import com.highdatas.mdm.service.IFlowsService;
import com.highdatas.mdm.pojo.NextTaskUserInfo;
import com.highdatas.mdm.service.*;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.highdatas.mdm.service.IMaintainFieldService;
import com.highdatas.mdm.service.act.TaskService;
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.List;
/**
 * <p>
@@ -27,7 +32,16 @@
    @Autowired
    IMaintainFieldService maintainFieldService;
    @Autowired
    TaskService taskService;
    @Autowired
    SysFieldMapper fieldMapper;
    @Autowired
    ITUserRoleService userRoleService;
    @Autowired
    IMasterModifiedService masterModifiedService;
    @Autowired
    IMaintainService maintainService;
    @Override
    public MaintainField createNowVerion(String tableName, String maintainId, String userId) {
        MaintainField nowMaintain = maintainFieldService.getNextMaintain(tableName, userId);
@@ -39,7 +53,11 @@
            maintainParams = "maintain_field_id = " + DbUtils.quotedStr(maintainId);
        }
        fieldMapper.tansNewVersion(DbUtils.quotedStr(nowMaintain.getId()), maintainParams);
        if (nowMaintain != null) {
            String maintainFieldId = DbUtils.quotedStr(nowMaintain.getId());
            fieldMapper.tansNewVersion(maintainFieldId, maintainParams);
        }
        return nowMaintain;
    }
@@ -51,4 +69,40 @@
        }
        return flows.getStatus();
    }
    @Override
    public boolean isNextAudit(Flows flows, String userId) {
        NextTaskUserInfo nestTaskAssignee = taskService.getNestTaskAssignee(flows.getWorkflowId());
        if (nestTaskAssignee == null){
            return false;
        }
        String taskAssigneeUserId = nestTaskAssignee.getUserId();
        if (!StringUtils.isEmpty(taskAssigneeUserId)){
            return taskAssigneeUserId.equalsIgnoreCase(userId);
        }
        String roleId = nestTaskAssignee.getRoleId();
        if (StringUtils.isEmpty(roleId)) {
            return false;
        }
        List<TUserRole> userRoles = userRoleService.selectList(new EntityWrapper<TUserRole>().eq("role_id", roleId));
        long count = userRoles.stream().map(tUserRole -> tUserRole.getUserId()).filter(s -> s.equalsIgnoreCase(userId)).count();
        if (count == 0) {
            return false;
        }else {
            return true;
        }
    }
    @Override
    public void aduitFinish(Flows flows) {
        if (flows.getBusinessType().equals(ActivitiBusinessType.maintain)){
            String maintainId = flows.getBusinessId();
            masterModifiedService.dealFlow(maintainId, flows.getStatus());
            maintainService.dealFlow(maintainId, flows.getStatus());
        }
        if (flows.getBusinessType().equals(ActivitiBusinessType.field)){
            String maintainId = flows.getBusinessId();
            maintainFieldService.dealFlow(maintainId, flows.getStatus());
        }
    }
}
src/main/java/com/highdatas/mdm/service/impl/MaintainFieldServiceImpl.java
@@ -227,4 +227,24 @@
            }
        }
    }
    @Override
    public int getUnFlowCount(String tableName, String userId) {
        List<MaintainField> maintainFields = selectList(new EntityWrapper<MaintainField>().eq("table_name", tableName));
        List<String> flowIdList = maintainFields.stream().filter(maintainField -> maintainField.getFlowId() != null).map(MaintainField::getFlowId).collect(Collectors.toList());
        if (flowIdList.size() == 0) {
            return 0;
        }
        List<Flows> flowsList = flowsService.selectBatchIds(flowIdList);
        List<Flows> unFlowedList = flowsList.stream().filter(flows -> flows.getStatus().equals(ActivitiStatus.working) || flows.getStatus().equals(ActivitiStatus.refuse)).collect(Collectors.toList());
        int cnt = 0;
        for (Flows flows : unFlowedList) {
            boolean nextAudit = flowsService.isNextAudit(flows, userId);
            if (nextAudit) {
                cnt++;
            }
        }
        return cnt;
    }
}
src/main/java/com/highdatas/mdm/service/impl/MasterDataServiceImpl.java
@@ -14,9 +14,12 @@
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;
@@ -43,10 +46,10 @@
    IMaintainDetailService maintainDetailService;
    @Autowired
    IFlowsService flowsService;
    @Autowired
    @Resource
    protected SqlSessionTemplate sqlSessionTemplate;
    protected DataSource dataSource;
    @Override
    public Result selectById(String tableName, String id) {
        try{
@@ -138,6 +141,8 @@
            return null;
        }
    }
    @Override
    public Long getCountByVersion (String maintainId, String tableName,String tableTempName,Integer fromOrderNo, Integer toOrderNo, String whereSegment) {
        try{
            Maintain maintain = maintainService.selectById(maintainId);
@@ -185,7 +190,7 @@
    @Override
    public String getFields(String tableName) {
        return getFields(tableName, Constant.EMPTY);
        return getFields(tableName, Constant.EMPTY_Str);
    }
    @Override
@@ -466,6 +471,7 @@
    @Override
    public Maintain uploadedData(String tableName, SysAssembleUpdateType uploadType, String userId) {
        MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("table_name",tableName));
        SysOperateLog operateLog = new SysOperateLog();
@@ -503,18 +509,18 @@
        maintain.setTableName(tableName);
        maintain.setCreateTime(new Date());
        Connection connection = sqlSessionTemplate.getConnection();
        Connection connection;
        try {
            connection = dataSource.getConnection();
            connection.setAutoCommit(false);
            mapper.insertMatintainDetailFromTemp(DbUtils.quotedStr(maintain.getId()), maintain.getTableName() + Constant.RECORD , DbUtils.quotedStr(Operate.create.toString()));
            connection.commit();
            mapper.updateStdId( maintain.getTableName() + Constant.RECORD);
            connection.commit();
            Integer aLong = mapper.tempDeal(maintain.getTableName() + Constant.RECORD, DbUtils.quotedStr(maintain.getId()));
            connection.commit();
            if (aLong == null) {
                maintain.setDesp("上传数据");
            }else {
                maintain.setDesp(MessageFormat.format("上传数据{0}条", aLong));
            }
            maintain.setDesp(MessageFormat.format("上传数据{0}条", aLong));
            if (uploadType.equals(SysAssembleUpdateType.All)) {
                List<TableSchemaResult> tableField = mapper.getTableField(tableName);
@@ -524,17 +530,15 @@
                        .map(s -> s.equalsIgnoreCase(Constant.STD_ID) ? MessageFormat.format(Constant.FieldAsAlias, Constant.ID, Constant.STD_ID) : s).collect(Collectors.joining(Constant.COMMA));
                mapper.insertRecordFromStandrad(maintain.getTableName(), maintain.getTableName() + Constant.RECORD, collect);
                connection.commit();
                mapper.insertMatintainDetailFromStandrad(DbUtils.quotedStr(maintain.getId()), maintain.getTableName() + Constant.RECORD);
                connection.commit();
                Integer standradCnt = mapper.tempDeal(maintain.getTableName() + Constant.RECORD, DbUtils.quotedStr(maintain.getId()));
                connection.commit();
                if (standradCnt != null) {
                    maintain.setDesp(maintain.getDesp() + MessageFormat.format("删除原数据{0}条", standradCnt));
                }else {
                    maintain.setDesp(maintain.getDesp() + "删除原数据");
                }
                maintain.setDesp(maintain.getDesp() + MessageFormat.format("删除原数据{0}条", standradCnt));
            }
            operateLog.setCreateTime(new Date())
@@ -542,7 +546,7 @@
                    .setId(DbUtils.getUUID())
                    .setMaintainId(menuMapping.getId())
                    .setOperate("open")
                    .setDesp(MessageFormat.format("上传数据{0}条", aLong));
                    .setDesp("批量上传数据");
            maintain.insert();
            connection.commit();
@@ -550,17 +554,8 @@
        catch (Exception e) {
            e.printStackTrace();
        }
        }
        finally {
            if (connection != null) {
                try {
                    connection.commit();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
        return maintain;
    }
src/main/java/com/highdatas/mdm/service/impl/MasterModifiedServiceImpl.java
@@ -1,18 +1,26 @@
package com.highdatas.mdm.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.highdatas.mdm.entity.Maintain;
import com.highdatas.mdm.entity.SysField;
import com.highdatas.mdm.entity.TUser;
import com.highdatas.mdm.entity.TableSchemaResult;
import com.highdatas.mdm.mapper.MaintainFieldMapper;
import com.highdatas.mdm.mapper.MasterModifiedMapper;
import com.highdatas.mdm.service.IMaintainService;
import com.highdatas.mdm.service.IMasterModifiedService;
import com.highdatas.mdm.service.ISysFieldService;
import com.highdatas.mdm.mapper.TableInfoMapper;
import com.highdatas.mdm.pojo.ActivitiStatus;
import com.highdatas.mdm.pojo.Segment;
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.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
 * <p>
@@ -30,9 +38,22 @@
    ISysFieldService fieldService;
    @Autowired
    MasterModifiedMapper masterModifiedMapper;
    @Autowired
    TableInfoMapper tableInfoMapper;
    @Autowired
    IMaintainFieldService maintainFieldService;
    @Autowired
    ITUserService userService;
    @Autowired
    MaintainFieldMapper maintainFieldMapper;
    @Autowired
    MasterDataService masterDataService;
    public static final String master_id = "master_id";
    public static final String pre_record = "pre_record";
    public static final String table_name = "table_name";
    public static final String master_modified = "master_modified";
    @Override
    public Map<String, String> getModifiedUserById(String maintainId, String masterId) {
        return null;
@@ -44,17 +65,156 @@
    }
    @Override
    public boolean updateModifiedUserById(String maintainId, String masterId, List<String> modifiedFieldList) {
    public boolean updateModifiedUserById(String maintainId, String masterId, String userId, List<String> modifiedFieldList) {
        if (StringUtils.isEmpty(maintainId)) {
            return false;
        }
        Maintain nowMaintain = maintainService.selectById(maintainId);
        List<SysField> fieldByMaintain = fieldService.getFieldByMaintain(maintainId);
        Map<String, String> masterModifiedMap = masterModifiedMapper.selectByTableMasterId(nowMaintain.getTableName(), masterId);
        String preRecordStr = masterModifiedMap.get(pre_record);
        JSONObject preRecordJSON = JSONObject.parseObject(preRecordStr);
        try {
            Maintain nowMaintain = maintainService.selectById(maintainId);
            List<SysField> fieldByMaintain = fieldService.getFieldByMaintain(maintainId);
            if (nowMaintain == null) {
                return false;
            }
            Map<String, String> masterModifiedMap = masterModifiedMapper.selectByTableMasterId(DbUtils.quotedStr(nowMaintain.getTableName()), DbUtils.quotedStr(masterId));
            if (masterModifiedMap == null) {
                masterModifiedMap = new HashMap<>();
                masterModifiedMap.put(table_name, nowMaintain.getTableName());
                masterModifiedMap.put(master_id, masterId);
            }
            String preRecordStr = masterModifiedMap.get(pre_record);
            JSONObject preRecordJSON = null;
            if (!StringUtils.isEmpty(preRecordStr)) {
                preRecordJSON = JSONObject.parseObject(preRecordStr);
            }else  {
                preRecordJSON = new JSONObject();
            }
            for (String field : modifiedFieldList) {
                preRecordJSON.fluentPut(field, userId);
            }
            masterModifiedMap.put(pre_record,  preRecordJSON.toJSONString());
            String id = masterModifiedMap.get(Constant.ID);
            if (StringUtils.isEmpty(id)) {
                masterModifiedMap.put(Constant.ID, DbUtils.getUUID());
                insert(masterModifiedMap);
            }else {
                updateById(masterModifiedMap);
            }
            return true;
        }
        catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }
        return false;
    private void insert(Map<String, String> masterModifiedMap) {
        String fields = masterModifiedMap.keySet().stream().collect(Collectors.joining(Constant.COMMA));
        String values = masterModifiedMap.values().stream().map(s -> DbUtils.quotedStr(s)).collect(Collectors.joining(Constant.COMMA));
        tableInfoMapper.insert(master_modified, fields, DbUtils.bracketStr(values));
    }
    private void updateById(Map<String, String> masterModifiedMap) {
        String id = masterModifiedMap.get(Constant.ID);
        Segment whereSegment = new Segment(Constant.ID, id);
        List<Segment> updateSgement = DbUtils.map2Segment(masterModifiedMap);
        String updateStr = updateSgement.stream().map(segment -> segment.toString()).collect(Collectors.joining(Constant.COMMA));
        tableInfoMapper.update(master_modified, updateStr, whereSegment.toString());
    }
    @Override
    @Async
    public void dealFlow(String maintainId, ActivitiStatus status) {
        Maintain maintain = maintainService.selectById(maintainId);
        String tableName = maintain.getTableName();
        String recordTableName = tableName + Constant.RECORD;
        List<Map<String,String>> modifiedList = masterModifiedMapper.selectByMaintainId(recordTableName, DbUtils.quotedStr(maintainId));
        switch (status) {
            case open:
                for (Map<String, String> masterModifiedMap : modifiedList) {
                    String preJson = masterModifiedMap.get(pre_record);
                    JSONObject jsonObject = JSONObject.parseObject(preJson);
                    if (jsonObject == null){
                        continue;
                    }
                    Set<String> keySet = jsonObject.keySet();
                    HashMap<String, String> userMap = new HashMap<>();
                    for (String field : keySet) {
                        String userId = jsonObject.getString(field);
                        if (userMap.containsKey(userId)) {
                            String preFieldStr = userMap.get(userId);
                            field = preFieldStr + Constant.SEMICOLON  + field;
                        }
                        userMap.put(userId, field);
                    }
                    List<TableSchemaResult> tableField = tableInfoMapper.getTableField(master_modified);
                    List<String> existsFieldList = tableField.stream().map(TableSchemaResult::getFieldName).collect(Collectors.toList());
                    Set<String> userIdList = userMap.keySet();
                    if (!existsFieldList.containsAll(userIdList)) {
                        //新增之前不存在的用户
                        List<String> unExistsUserList = userIdList.stream().filter(s -> !existsFieldList.contains(s)).collect(Collectors.toList());
                        for (String s : unExistsUserList) {
                            //新增字段
                            maintainFieldMapper.addCloumn(master_modified, s, Constant.Text);
                        }
                    }
                    masterModifiedMap.putAll(userMap);
                    updateById(masterModifiedMap);
                }
                break;
            case close:
                List<String> unUserIdList = new ArrayList<>();
                unUserIdList.add(Constant.ID);
                unUserIdList.add(master_id);
                unUserIdList.add(table_name);
                unUserIdList.add(pre_record);
                for (Map<String, String> masterModifiedMap : modifiedList) {
                    //todo   反更新 perjson  获取当前表所有可更改的用户 之后待修改 先从本地user表中拿
                    Set<String> keySet = masterModifiedMap.keySet();
                    List<String> userIdList = keySet.stream().filter(s -> !unUserIdList.contains(s)).collect(Collectors.toList());
                    JSONObject jsonObject = new JSONObject();
                    for (String s : userIdList) {
                        String fields = masterModifiedMap.get(s);
                        if (StringUtils.isEmpty(fields)) {
                            continue;
                        }
                        String[] split = fields.split(Constant.SEMICOLON);
                        for (String field : split) {
                            jsonObject.fluentPut(field, s);
                        }
                    }
                    masterModifiedMap.put(pre_record, jsonObject.toJSONString());
                    updateById(masterModifiedMap);
                }
                break;
        }
    }
    @Override
    public void dealAssemble(String maintainId, String userId, boolean audit) {
        List<SysField> fieldByMaintain = fieldService.getFieldByMaintain(maintainId);
        String fieldStr = fieldByMaintain.stream().map(SysField::getField).collect(Collectors.joining(Constant.SEMICOLON));
        List<TableSchemaResult> tableField = tableInfoMapper.getTableField(master_modified);
        long count = tableField.stream().map(tableSchemaResult -> tableSchemaResult.getFieldName()).filter(s -> s.equalsIgnoreCase(userId)).count();
        if (count == 0) {
            maintainFieldMapper.addCloumn(master_modified, userId, Constant.Text);
        }
        Maintain maintain = maintainService.selectById(maintainId);
        String tableName = maintain.getTableName();
        String recordTableName = tableName + Constant.RECORD;
        if (!audit) {
            masterModifiedMapper.insertUserByTableNameUserId(DbUtils.quotedStr(maintainId), DbUtils.quotedStr(tableName), recordTableName, userId, DbUtils.quotedStr(fieldStr));
        }
       else {
            JSONObject jsonObject = new JSONObject();
            for (SysField field : fieldByMaintain) {
                String oneField = field.getField();
                jsonObject.fluentPut(oneField, userId);
            }
            masterModifiedMapper.insertJsonByTableNameUserId(DbUtils.quotedStr(maintainId), DbUtils.quotedStr(tableName), recordTableName, DbUtils.quotedStr(jsonObject.toJSONString()));
        }
    }
}
src/main/java/com/highdatas/mdm/service/impl/SysAssembleDbServiceImpl.java
@@ -43,6 +43,11 @@
            return null;
        }
        return getConnection(assemble);
    }
    private Connection getConnection(SysAssembleDb assemble) {
        Connection connection  = null;
        try {
            SysAssembleDbdriver sysAssembleDbdriver = dbdriverService.selectOne(new EntityWrapper<SysAssembleDbdriver>().eq(Constant.TYPE, assemble.getDatasourceType()));
@@ -65,7 +70,6 @@
                e.printStackTrace();
                return null;
            }
    }
    @Override
@@ -112,6 +116,31 @@
    }
    @Override
    public boolean testConnection(SysAssembleDb sysAssembleDb) {
        Connection connection = null;
        try{
            connection = getConnection(sysAssembleDb);
            if (connection != null) {
                return true;
            }
            return false;
        }
        catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    @Override
    public boolean testConnection(String parentId) {
        Connection connection = null;
        try{
src/main/java/com/highdatas/mdm/service/impl/SysAssembleServiceImpl.java
@@ -83,9 +83,10 @@
    ITUserService userService;
    @Autowired
    RuleClient ruleClient;
    @Autowired
    IMasterModifiedService masterModifiedService;
    @Override
    @Transactional(rollbackFor=Exception.class)
    public Result run(String id) {
        if (StringUtils.isEmpty(id)) {
            return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
@@ -231,6 +232,9 @@
                //默认需要审批
                audit = true;
            }
            // 处理关联人
            if (audit) {
                String chargeId = menuMapping.getChargeId();
                TUser user = userService.selectById(chargeId);
@@ -243,6 +247,7 @@
                maintain.setFlowId(flows.getId());
                maintain.setDesp("启动汇集流程");
                maintain.updateById();
                masterModifiedService.dealAssemble(maintain.getId(), assemble.getUserId(), true);
            }else  {
                //直接运行
                Flows flows = new Flows().setStatus(ActivitiStatus.open).setBusinessId(maintain.getId()).setId(DbUtils.getUUID()).setCreateTime(new Date());
@@ -250,6 +255,7 @@
                maintain.setFlowId(flows.getId());
                maintain.updateById();
                maintainService.dealFlow(maintain.getId(), ActivitiStatus.open);
                masterModifiedService.dealAssemble(maintain.getId(), assemble.getUserId(), false);
            }
            return Result.success(null);
        }catch (Exception e) {
@@ -384,10 +390,9 @@
                    PreparedStatement updatedPreparedStatement = conn.prepareStatement(updatedSql);
                    int updateCnt = updatedPreparedStatement.executeUpdate();
                    cnt = updateCnt;
                    tableInfoMapper.insertMatintainDetailFromTemp(DbUtils.quotedStr(maintain.getId()), maintain.getTableName() + Constant.RECORD , DbUtils.quotedStr(Operate.update.toString()));
                }
            }
            tableInfoMapper.insertMatintainDetailFromTemp(DbUtils.quotedStr(maintain.getId()), maintain.getTableName() + Constant.RECORD , DbUtils.quotedStr(Operate.update.toString()));
            //tableInfoMapper.updateStdId( maintain.getTableName() + Constant.RECORD);
@@ -412,6 +417,7 @@
            }
        }
    }
    private Result temp2record(SysAssemble assemble) {
        Connection conn = null;
        try {
@@ -461,7 +467,6 @@
                String joinStr = getJoinFieldParse(unionCodeFields);
                // insert
                String insertFieldStr = fieldsFromTable.stream()
                        .map(s -> MessageFormat.format(Constant.Alias,Constant.T1,s))
                        .collect(Collectors.joining(Constant.COMMA));
src/main/java/com/highdatas/mdm/service/impl/SysFieldServiceImpl.java
@@ -3,12 +3,10 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.highdatas.mdm.entity.Flows;
import com.highdatas.mdm.entity.Maintain;
import com.highdatas.mdm.entity.MaintainField;
import com.highdatas.mdm.entity.SysField;
import com.highdatas.mdm.entity.*;
import com.highdatas.mdm.mapper.MaintainFieldMapper;
import com.highdatas.mdm.mapper.SysFieldMapper;
import com.highdatas.mdm.mapper.TableInfoMapper;
import com.highdatas.mdm.pojo.ActivitiStatus;
import com.highdatas.mdm.pojo.Operate;
import com.highdatas.mdm.pojo.Result;
@@ -46,6 +44,8 @@
    MaintainFieldMapper maintainFieldMapper;
    @Autowired
    IFlowsService flowsService;
    @Autowired
    TableInfoMapper tableInfoMapper;
    @Override
@@ -94,9 +94,9 @@
            fieldList = this.selectList(new EntityWrapper<SysField>().eq("table_name", maintain.getTableName()).isNull("maintain_field_id").orderBy("order_no"));
            return fieldList;
        }else {
            Integer preNo = maintainFieldOrderNo--;
            Integer preNo = maintainFieldOrderNo - 1;
            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", maintainFieldId).eq("table_name", tableName).orderBy("order_no"));
            fieldList = this.selectList(new EntityWrapper<SysField>().eq("maintain_field_id", maintainField.getId()).eq("table_name", tableName).orderBy("order_no"));
            return fieldList;
        }
@@ -107,7 +107,16 @@
    public List<SysField> getFieldByTable(String tableName) {
        Maintain nowVersion = maintainService.getNowVersion(tableName);
        if (nowVersion == null) {
            return null;
            List<SysField> fieldList = this.selectList(new EntityWrapper<SysField>().eq("table_name", tableName).isNull("maintain_field_id").orderBy("order_no"));
            if (fieldList.size() ==0) {
                List<TableSchemaResult> tableField = tableInfoMapper.getTableField(tableName);
                for (TableSchemaResult tableSchemaResult : tableField) {
                    String fieldName = tableSchemaResult.getFieldName();
                    SysField field = new SysField().setField(fieldName);
                    fieldList.add(field);
                }
            }
            return fieldList;
        }
        return getFieldByMaintain(nowVersion.getId());
    }
@@ -193,7 +202,16 @@
        Collections.sort(nowFields, new Comparator<SysField>() {
            @Override
            public int compare(SysField o1, SysField o2) {
                return o1.getOrderNo() - o2.getOrderNo() ;
                Integer o1OrderNo = o1.getOrderNo();
                Integer orderNo = o2.getOrderNo();
                if (o1OrderNo == null && orderNo == null) {
                    return 0;
                }else if (o1OrderNo == null) {
                    return -1;
                }else if  (orderNo == null) {
                    return 1;
                }
                return o1OrderNo - orderNo;
            }
        });
        return nowFields;
src/main/java/com/highdatas/mdm/util/CommonInterceptor.java
@@ -12,6 +12,7 @@
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -97,4 +98,10 @@
        session.setAttribute("user", user);
        return true;
    }
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
        //请求处理后
    }
}
src/main/java/com/highdatas/mdm/util/Constant.java
@@ -100,4 +100,5 @@
    String sucPercent = "sucPercent";
    String varchar = "varchar";
    String varcharSize = " (255) ";
    String Text = " text ";
}
src/main/java/com/highdatas/mdm/util/DbUtils.java
@@ -305,4 +305,14 @@
        return Bit32(SourceString).substring(8, 24);
    }
    public static List<Segment> map2Segment(Map<String, String> masterModifiedMap) {
        ArrayList<Segment> result = new ArrayList<>();
        Set<String> keys = masterModifiedMap.keySet();
        for (String key : keys) {
            String value = masterModifiedMap.get(key);
            Segment segment = new Segment(key, value);
            result.add(segment);
        }
        return result;
    }
}
src/main/java/com/highdatas/mdm/util/FilterConfig.java
New file
@@ -0,0 +1,25 @@
package com.highdatas.mdm.util;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * @author kimi
 * @description
 * @date 2019-12-12 16:45
 */
@Configuration
@ConditionalOnWebApplication
public class FilterConfig {
    @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
    static class ServletTraceFilterConfiguration {
        @Bean
        public HttpTraceLogFilter httpTraceLogFilter() {
            return new HttpTraceLogFilter();
        }
    }
}
src/main/java/com/highdatas/mdm/util/HttpTraceLogFilter.java
New file
@@ -0,0 +1,139 @@
package com.highdatas.mdm.util;
import com.alibaba.fastjson.JSON;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.core.Ordered;
import org.springframework.http.HttpStatus;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;
import org.springframework.web.util.ContentCachingResponseWrapper;
import org.springframework.web.util.WebUtils;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.Objects;
/**
 * @author kimi
 * @description
 * @date 2020-03-17 18:53
 */
@Slf4j
public class HttpTraceLogFilter extends OncePerRequestFilter implements Ordered {
    private static final String NEED_TRACE_PATH_PREFIX = "/api";
    private static final String IGNORE_CONTENT_TYPE = "multipart/form-data";
    @Override
    public int getOrder() {
        return Ordered.LOWEST_PRECEDENCE - 10;
    }
    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
            throws ServletException, IOException {
        if (!isRequestValid(request)) {
            filterChain.doFilter(request, response);
            return;
        }
        if (!(request instanceof ContentCachingRequestWrapper)) {
            request = new ContentCachingRequestWrapper(request);
        }
        if (!(response instanceof ContentCachingResponseWrapper)) {
            response = new ContentCachingResponseWrapper(response);
        }
        int status = HttpStatus.INTERNAL_SERVER_ERROR.value();
        long startTime = System.currentTimeMillis();
        try {
            filterChain.doFilter(request, response);
            status = response.getStatus();
        } finally {
            String path = request.getRequestURI();
            boolean isFilterPath = path.startsWith(NEED_TRACE_PATH_PREFIX);
            isFilterPath = true;
            if (isFilterPath) {
                String requestBody = IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8.name());
                log.info(requestBody);
                //1. 记录日志
                HttpTraceLog traceLog = new HttpTraceLog();
                traceLog.setPath(path);
                traceLog.setMethod(request.getMethod());
                long latency = System.currentTimeMillis() - startTime;
                traceLog.setTimeTaken(latency);
                traceLog.setTime(LocalDateTime.now().toString());
                traceLog.setParameterMap(JSON.toJSONString(request.getParameterMap()));
                traceLog.setStatus(status);
                traceLog.setRequestBody(getRequestBody(request));
                traceLog.setResponseBody(getResponseBody(response));
                log.info("Http trace log: {}", JSON.toJSONString(traceLog));
            }
            updateResponse(response);
        }
    }
    private boolean isRequestValid(HttpServletRequest request) {
        try {
            new URI(request.getRequestURL().toString());
            return true;
        } catch (URISyntaxException ex) {
            return false;
        }
    }
    private String getRequestBody(HttpServletRequest request) {
        String requestBody = "";
        ContentCachingRequestWrapper wrapper = WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class);
        if (wrapper != null) {
            try {
                requestBody = IOUtils.toString(wrapper.getContentAsByteArray(), wrapper.getCharacterEncoding());
            } catch (IOException e) {
                // NOOP
            }
        }
        return requestBody;
    }
    private String getResponseBody(HttpServletResponse response) {
        String responseBody = "";
        ContentCachingResponseWrapper wrapper = WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class);
        if (wrapper != null) {
            try {
                responseBody = IOUtils.toString(wrapper.getContentAsByteArray(), wrapper.getCharacterEncoding());
            } catch (IOException e) {
                // NOOP
            }
        }
        return responseBody;
    }
    private void updateResponse(HttpServletResponse response) throws IOException {
        ContentCachingResponseWrapper responseWrapper = WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class);
        Objects.requireNonNull(responseWrapper).copyBodyToResponse();
    }
    @Data
    private static class HttpTraceLog {
        private String path;
        private String parameterMap;
        private String method;
        private Long timeTaken;
        private String time;
        private Integer status;
        private String requestBody;
        private String responseBody;
    }
}
src/main/java/com/highdatas/mdm/util/OriginConfig.java
@@ -1,11 +1,17 @@
package com.highdatas.mdm.util;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.concurrent.Executor;
/**
 * @author kimi
@@ -14,7 +20,7 @@
 */
@Configuration
public class OriginConfig implements WebMvcConfigurer {
public class OriginConfig implements WebMvcConfigurer, AsyncConfigurer {
    @Autowired
    CommonInterceptor commonInterceptor;
@@ -33,4 +39,30 @@
        interceptorRegistration.excludePathPatterns("/designer/**","/upload/**", "/process/**", "/processes/**", "/swagger-ui.html", "/webjars/**", "/swagger-resources/**", "/v2/api-docs", "/");
    }
    @Override
    @Bean
    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor threadPool = new ThreadPoolTaskExecutor();
        //设置核心线程数
        threadPool.setCorePoolSize(10);
        //设置最大线程数
        threadPool.setMaxPoolSize(100);
        //线程池所使用的缓冲队列
        threadPool.setQueueCapacity(10);
        //等待任务在关机时完成--表明等待所有线程执行完
        threadPool.setWaitForTasksToCompleteOnShutdown(true);
        // 等待时间 (默认为0,此时立即停止),并没等待xx秒后强制停止
        threadPool.setAwaitTerminationSeconds(60);
        //  线程名称前缀
        threadPool.setThreadNamePrefix("MDM-Async-");
        // 初始化线程
        threadPool.initialize();
        return threadPool;
    }
    @Override
    public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
        return null;
    }
}
src/main/resources/application-prod.yml
@@ -61,10 +61,10 @@
    accessToken:
    executor:
      ip:
                             port: 9909
                             logpath: /data/applogs/xxl-job/jobhandler
                             logretentiondays: 1
                             appname: assemble
      port: 9909
      logpath: /data/applogs/xxl-job/jobhandler
      logretentiondays: 1
      appname: assemble
    admin:
      addresses: http://192.168.2.68:8090/xxl-job-admin
src/main/resources/application.yml
@@ -2,5 +2,6 @@
  profiles:
    active:
      dev
  main:
    allow-bean-definition-overriding: true
src/main/resources/lib/common-1.0.jar
Binary files differ
src/main/resources/mapping/MasterModifiedMapper.xml
@@ -4,7 +4,39 @@
    <select id="selectByTableMasterId" resultType="java.util.Map" statementType="STATEMENT" >
        select * from master_modified where table_name = #{tableName} and master_id =  #{fields}
        select * from master_modified where table_name = ${tableName} and master_id =  ${masterId}
    </select>
    <insert id="insertUserByTableNameUserId" statementType="STATEMENT" >
      INSERT INTO master_modified (id, table_name, master_id, ${userId}) SELECT replace(uuid(),'-', '') as id, ${tableName} as table_name, a.id  as master_id, ${fieldStr} as ${userId} from
      (
      SELECT temp.id from maintain_detail LEFT JOIN
        ${recordTableName} temp on temp.id = maintain_detail.pre_merge_id
         WHERE maintain_detail.parent_id = ${maintainId}
      ) a
    </insert>
    <insert id="insertJsonByTableNameUserId" statementType="STATEMENT" >
      INSERT INTO master_modified (id, table_name, master_id, pre_record ) SELECT replace(uuid(),'-', '') as id, ${tableName} as table_name, a.id  as master_id, ${jsonStr} as pre_record from
      (
      SELECT temp.id from maintain_detail LEFT JOIN
        ${recordTableName} temp on temp.id = maintain_detail.pre_merge_id
         WHERE maintain_detail.parent_id = ${maintainId}
      ) a
    </insert>
    <select id="selectByMaintainId" resultType="java.util.Map" statementType="STATEMENT" >
      SELECT * from master_modified
        WHERE EXISTS
        (
        select id from
        (SELECT std_id as id from maintain_detail LEFT JOIN
        ${recoedTableName} temp on temp.id = maintain_detail.pre_merge_id
         WHERE maintain_detail.parent_id = ${maintainId})
        a
        where  a.id = master_modified.master_id)
    </select>
</mapper>
src/main/resources/mapping/TableInfoMapper.xml
@@ -200,7 +200,7 @@
        UPDATE ${tableTempName} t
        SET deal = 1
        where EXISTS (
        SELECT pre_merge_id from maintain_detail WHERE parent_id = ${maintainFieldId}
        SELECT pre_merge_id from maintain_detail WHERE parent_id = ${maintainId}
        and maintain_detail.pre_merge_id = t.id
        )
        </select>
@@ -388,9 +388,9 @@
         ]]>
    </select>
    <select id="insert" resultType="java.lang.Boolean" statementType="STATEMENT" >
    <insert id="insert"  statementType="STATEMENT" >
       INSERT INTO ${tableName} (${fields}) VALUES ${values}
    </select>
    </insert>
    <update id="update">
       update  ${tableName} set ${updateSegment}
@@ -404,12 +404,12 @@
    <delete id="deleteTempByMaintainId">
        DELETE FROM ${tableTempName}  where EXISTS (
        SELECT pre_merge_id from maintain_detail d
        where parent_id = ${maintainFieldId} and d.pre_merge_id = ${tableTempName}.id
        where parent_id = ${maintainId} and d.pre_merge_id = ${tableTempName}.id
        )
    </delete>
    <!-- temp 2 standrad-->
    <select id="tempCreate2std" statementType="STATEMENT"  >
    <insert id="tempCreate2std" statementType="STATEMENT"  >
        INSERT INTO ${tableName}
        SELECT
        ${tempFields}
@@ -419,11 +419,11 @@
        (
        SELECT  std_id from ${tableTempName} tm
        LEFT JOIN maintain_detail on tm.id = maintain_detail.pre_merge_id
        WHERE maintain_detail.parent_id = ${maintainFieldId}
        WHERE maintain_detail.parent_id = ${maintainId}
        and operate = 'create'
        and tm.id = t.id
        )
    </select>
    </insert>
    <select id="getTempIdByStdId" statementType="STATEMENT" resultType="java.lang.String">
      SELECT  tm.id from ${tableTempName} tm
@@ -432,35 +432,35 @@
    </select>
    <select id="insertMatintainDetailFromTemp" statementType="STATEMENT" resultType="java.lang.Integer">
    <insert id="insertMatintainDetailFromTemp" statementType="STATEMENT" >
        INSERT INTO maintain_detail
        SELECT md5(uuid()) as id, ${maintainFieldId} as parent_id, ${operate} as operate, id as pre_merge_id, NOW() as create_time
        SELECT md5(uuid()) as id, ${maintainId} as parent_id, ${operate} as operate, id as pre_merge_id, NOW() as create_time
        from ${tableTempName}  m WHERE m.deal = 0
    </select>
    </insert>
    <select id="insertMatintainDetailFromStandrad" statementType="STATEMENT" resultType="java.lang.Integer">
    <insert id="insertMatintainDetailFromStandrad" statementType="STATEMENT" >
        INSERT INTO maintain_detail
        SELECT md5(uuid()) as id, ${maintainFieldId} as parent_id, 'delete' as operate, id as pre_merge_id, NOW() as create_time
        SELECT md5(uuid()) as id, ${maintainId} as parent_id, 'delete' as operate, id as pre_merge_id, NOW() as create_time
        from ${tableTempName}  m WHERE m.deal = 0
    </select>
    </insert>
    <select id="updateStdId" statementType="STATEMENT" resultType="java.lang.Integer">
    <update id="updateStdId" statementType="STATEMENT" >
        update ${tableTempName}
        set std_id = md5(uuid()) WHERE deal = 0
    </select>
    </update>
    <select id="insertRecordFromStandrad" statementType="STATEMENT" resultType="java.lang.Integer">
    <insert id="insertRecordFromStandrad" statementType="STATEMENT" >
         INSERT INTO ${recordTableName}
        SELECT ${tempFieldList}, 0 as deal
        from  ${tableName}
    </select>
    </insert>
    <select id="tempByOperate" statementType="STATEMENT" resultType="java.util.Map">
        SELECT
@@ -471,27 +471,27 @@
        (
        SELECT  pre_merge_id from maintain_detail
        LEFT JOIN maintain on maintain.id = maintain_detail.parent_id
        WHERE maintain.id = ${maintainFieldId}
        WHERE maintain.id = ${maintainId}
        and operate = ${operate}
        and maintain_detail.pre_merge_id = t.id
        )
    </select>
    <select id="updateRecordByMaintainId" statementType="STATEMENT" resultType="java.lang.Integer">
    <update id="updateRecordByMaintainId" statementType="STATEMENT" >
         update ${tableTempName}
        INNER JOIN maintain_detail on ${tableTempName}.id = maintain_detail.pre_merge_id
        set ${updateSegment}
        WHERE maintain_detail.parent_id = ${maintainFieldId}
        WHERE maintain_detail.parent_id = ${maintainId}
    </select>
    </update>
    <select id="deleteRecordByMaintainId" statementType="STATEMENT" resultType="java.lang.Integer">
    <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 = ${maintainFieldId} and  ${tableTempName}.std_id = ${stdId}
        WHERE maintain_detail.parent_id = ${maintainId} and  ${tableTempName}.std_id = ${stdId}
    </select>
    </delete>
</mapper>