| | |
| | | import com.highdatas.mdm.pojo.*; |
| | | import com.highdatas.mdm.pojo.kettle.UnBigDataDataSourceInfo; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.ContentBuilder; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import com.highdatas.mdm.util.ExcelUtil; |
| | | import com.highdatas.mdm.util.*; |
| | | import com.highdatas.mdm.util.pool.MqEntity; |
| | | import com.highdatas.mdm.util.pool.MqMessage; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | * @since 2020-04-15 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class SysViewServiceImpl extends ServiceImpl<SysViewMapper, SysView> implements ISysViewService { |
| | | @Autowired |
| | | ISysViewJoinService joinService; |
| | |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | DispenseService dispenseService; |
| | | |
| | | @Autowired |
| | | RuleClient ruleClient; |
| | | @Autowired |
| | | AntianaphylaxisClient antianaphylaxisClient; |
| | | @Autowired |
| | | RedisClient redisClient; |
| | | /** |
| | | * |
| | | * @description: 通过id获取视图分发的分页的回信 |
| | | * @param viewId 视图id |
| | | * @return: 分页对象 |
| | | * |
| | | */ |
| | | @Override |
| | | public Page getInitPageInfo(String viewId) { |
| | | Page page = new Page(0); |
| | | |
| | | |
| | | SysView sysView = selectById(viewId); |
| | | String userId = sysView.getUserId(); |
| | | String realRedisKey = RedisClient.getRealRedisKey(userId + "-" + sysView.getId()); |
| | | Object redisValObj = redisClient.getRedisValObj(realRedisKey); |
| | | if (redisValObj != null) { |
| | | JSONObject object = (JSONObject) redisValObj; |
| | | Page page = JSONObject.parseObject(object.toJSONString(), Page.class); |
| | | return page; |
| | | } |
| | | |
| | | Page page = new Page(0); |
| | | String viewTableName = sysView.getViewTableName(); |
| | | List<TableSchemaResult> tableField = tableInfoMapper.getTableField(viewTableName); |
| | | int totalLength = 0; |
| | |
| | | page.setPageSize(pageSize); |
| | | Long viewCount = getViewCount(sysView); |
| | | if (viewCount == 0) { |
| | | return null; |
| | | redisClient.putRedisValObj(realRedisKey, page); |
| | | return page; |
| | | } |
| | | page.setRecordCount(viewCount.intValue()); |
| | | int pages; |
| | | if (viewCount % pageSize == 0) { |
| | | pages = Long.valueOf(viewCount/pageSize).intValue(); |
| | |
| | | pages = (Long.valueOf(viewCount/pageSize).intValue()) + 1; |
| | | } |
| | | page.setPages(pages); |
| | | |
| | | redisClient.putRedisValObj(realRedisKey, page); |
| | | return page; |
| | | } |
| | | /** |
| | | * |
| | | * @description: 创建视图 |
| | | * @param viewId 视图id |
| | | * @return: 创建是否成功 |
| | | * |
| | | */ |
| | | @Override |
| | | public boolean createView(String viewId) { |
| | | SysView sysView = selectById(viewId); |
| | | if (sysView == null) { |
| | | return false; |
| | | try { |
| | | SysView sysView = selectById(viewId); |
| | | |
| | | if (sysView == null) { |
| | | log.error("view not found"); |
| | | return false; |
| | | } |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | log.error("user not found"); |
| | | return false; |
| | | } |
| | | |
| | | Maintain baseMaintain = getBaseMaintain(sysView); |
| | | if (baseMaintain == null) { |
| | | log.error("baseMaintain not found"); |
| | | return false; |
| | | } |
| | | String baseTableName = baseMaintain.getTableName(); |
| | | sysView.setBaseTableName(baseTableName); |
| | | |
| | | List<String> totalFieldList = getTotalFieldList(sysView); |
| | | |
| | | // |
| | | String tableName = getViewTableName(sysView); |
| | | log.info("View TABLE name:" + tableName); |
| | | totalFieldList.add(Constant.ID); |
| | | boolean created = dropCreateViewTable(totalFieldList, tableName); |
| | | |
| | | //TODO 主键 |
| | | if (!created) { |
| | | log.info("un create view table:" + tableName); |
| | | return false; |
| | | } |
| | | totalFieldList.remove(Constant.ID); |
| | | List<String> baseFieldList = getBaseFieldList(sysView); |
| | | //trans first |
| | | if (baseFieldList == null && baseFieldList.isEmpty()) { |
| | | log.error("base field not found:"); |
| | | return false; |
| | | } |
| | | baseFieldList.add(Constant.ID); |
| | | String baseFields = baseFieldList.stream() |
| | | .map(s -> Constant.ID.equalsIgnoreCase(s) ? Constant.MYSQL_UUID : s) |
| | | .collect(Collectors.joining(Constant.COMMA)); |
| | | String fixBaseFields = baseFieldList.stream() |
| | | .map(s -> Constant.ID.equalsIgnoreCase(s) ? Constant.ID : changeFieldName(baseTableName, s)) |
| | | .collect(Collectors.joining(Constant.COMMA)); |
| | | |
| | | baseFieldList.remove(Constant.ID); |
| | | |
| | | String filter = masterAuthorService.getFilter(user, baseMaintain.getId()); |
| | | if (StringUtils.isEmpty(filter)) { |
| | | filter = Constant.WHERE_DEFAULT; |
| | | } |
| | | |
| | | log.info("View base filter:" + filter); |
| | | String s = masterDataService.selectByVersionSql(null, baseTableName, baseFieldList, filter, baseMaintain.getVersion(), false); |
| | | log.info("View base select sql:" + s); |
| | | //base INSERT |
| | | tableInfoMapper.insertOneSelect(tableName, fixBaseFields, baseFields, s); |
| | | |
| | | log.info("insert select"); |
| | | // left insert |
| | | InsertJoin(sysView); |
| | | log.info("insert left join"); |
| | | // change val common |
| | | changeValCommon(sysView); |
| | | log.info("changeValCommon"); |
| | | //change logic |
| | | |
| | | |
| | | boolean checked = checkTempData(sysView); |
| | | if (!checked) { |
| | | sysView.setStatus(ViewStatus.unChecked).updateById(); |
| | | } else { |
| | | sysView.setStatus(ViewStatus.working).updateById(); |
| | | } |
| | | |
| | | // |
| | | return true; |
| | | } |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | | if (user == null) { |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | |
| | | Maintain baseMaintain = getBaseMaintain(sysView); |
| | | if (baseMaintain == null) { |
| | | } |
| | | /** |
| | | * |
| | | * @description: 视图质量检验 |
| | | * @param sysView 视图 |
| | | * @return: 是否通过检验 |
| | | * |
| | | */ |
| | | private boolean checkTempData(SysView sysView) { |
| | | SysAssembleCheckType checkType = sysView.getCheckType(); |
| | | if (checkType == null) { |
| | | return false; |
| | | } |
| | | String baseTableName = baseMaintain.getTableName(); |
| | | sysView.setBaseTableName(baseTableName); |
| | | |
| | | List<String> totalFieldList = getTotalFieldList(sysView); |
| | | |
| | | // |
| | | String tableName = getViewTableName(sysView); |
| | | totalFieldList.add(Constant.ID); |
| | | boolean created = dropCreateViewTable(totalFieldList, tableName); |
| | | //TODO 主键 |
| | | if (!created) { |
| | | return false; |
| | | if (checkType.equals(SysAssembleCheckType.unlimited)) { |
| | | return true; |
| | | } |
| | | totalFieldList.remove(Constant.ID); |
| | | List<String> baseFieldList = getBaseFieldList(sysView); |
| | | //trans first |
| | | baseFieldList.add(Constant.ID); |
| | | String baseFields = baseFieldList.stream() |
| | | .map(s -> Constant.ID.equalsIgnoreCase(s) ? Constant.MYSQL_UUID : s) |
| | | .collect(Collectors.joining(Constant.COMMA)); |
| | | String fixBaseFields = baseFieldList.stream() |
| | | .map(s -> Constant.ID.equalsIgnoreCase(s) ? Constant.ID : changeFieldName(baseTableName, s)) |
| | | .collect(Collectors.joining(Constant.COMMA)); |
| | | |
| | | baseFieldList.remove(Constant.ID); |
| | | |
| | | String filter = masterAuthorService.getFilter(user, baseMaintain.getId()); |
| | | |
| | | String s = masterDataService.selectByVersionSql(null, baseTableName, baseFieldList, filter, baseMaintain.getVersion(), false); |
| | | |
| | | //base INSERT |
| | | tableInfoMapper.insertOneSelect(tableName, fixBaseFields, baseFields, s); |
| | | |
| | | // left insert |
| | | InsertJoin(sysView); |
| | | |
| | | // change val common |
| | | changeValCommon(sysView); |
| | | sysView.setStatus(ViewStatus.working).updateById(); |
| | | // |
| | | HashMap<String,Boolean> fieldResultSet = ruleClient.execuImmeForCollect(sysView.getViewTableName(), sysView.getUserId()); |
| | | switch (checkType){ |
| | | case successAdd: |
| | | String unSuccessFields = fieldResultSet.keySet().stream().filter(s -> !fieldResultSet.get(s)).collect(Collectors.joining(Constant.COMMA)); |
| | | if (fieldResultSet.keySet().contains(false)) { |
| | | return false; |
| | | } |
| | | break; |
| | | case partSuccessAdd: |
| | | String checkFields = sysView.getCheckField(); |
| | | String[] split = checkFields.split(Constant.SEMICOLON); |
| | | for (String s : split) { |
| | | Boolean checked = fieldResultSet.get(s); |
| | | if (checked == null || !checked) { |
| | | return false; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 插入关联表数据 |
| | | * @param sysView 视图 |
| | | * @return: |
| | | * |
| | | */ |
| | | private void InsertJoin(SysView sysView) { |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | |
| | | List<SysViewJoin> viewJoinList = sysView.getViewJoinList(); |
| | | |
| | | for (SysViewJoin sysViewJoin : viewJoinList) { |
| | | sysViewJoin.setBaseField(changeFieldName(baseTableName, sysViewJoin.getBaseField())); |
| | | sysViewJoin.setBaseField(changeFieldName(sysView.getBaseTableName(), sysViewJoin.getBaseField())); |
| | | Maintain joinMaintain = getJoinMaintain(sysViewJoin); |
| | | String joinTableName = joinMaintain.getTableName(); |
| | | |
| | | sysViewJoin.setBaseTableName(sysView.getViewTableName()); |
| | | String joinStr = sysViewJoin.createJoinStr(); |
| | | if (StringUtils.isEmpty(joinStr)) { |
| | |
| | | // JOIN |
| | | String joinSql = joinBuilder.toString(); |
| | | if (StringUtils.isEmpty(joinSql)) { |
| | | log.info("sysViewJoin sql is null"); |
| | | return; |
| | | } |
| | | tableInfoMapper.updateJoin(tableName, joinSql, updateFieldBuilder.toString(), Constant.WHERE_DEFAULT); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 1对1 数据转换 |
| | | * @param sysView 视图 |
| | | * @return: |
| | | * |
| | | */ |
| | | private void changeValCommon(SysView sysView) { |
| | | String mappingField = sysView.getMappingField(); |
| | | String tableName = sysView.getViewTableName(); |
| | | String mappingTable = sysView.getMappingTable(); |
| | | |
| | | mappingTable = tableInfoMapper.selectTableByName(mappingTable); |
| | | if (StringUtils.isEmpty(mappingTable)) { |
| | | return; |
| | | } |
| | | List<String> split = DbUtils.split(mappingField); |
| | | for (String oneMapField : split) { |
| | | String base = MessageFormat.format(Constant.Alias, tableName, oneMapField); |
| | |
| | | tableInfoMapper.updateJoin(tableName, changeJoinStr, updateSegment.toRawString(), filterSegment.toString()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 从新生成视图表 |
| | | * @param tableName 表名 |
| | | * @param totalFieldList 字段列表 |
| | | * @return: 生成是否成功 |
| | | * |
| | | */ |
| | | private boolean dropCreateViewTable(List<String> totalFieldList, String tableName) { |
| | | boolean created = unBigDataDataSourceInfo.dropData(tableName); |
| | | if (!created) { |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 获取视图的物理表名 |
| | | * @param view 视图对象 |
| | | * @return: 物理表名 |
| | | * |
| | | */ |
| | | @Override |
| | | public String getViewTableName(SysView view) { |
| | | String viewTableName = view.getViewTableName(); |
| | |
| | | } |
| | | return viewTableName; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 获取视图 mapping的物理表名 |
| | | * @param view 视图对象 |
| | | * @return: mapping的物理表名 |
| | | * |
| | | */ |
| | | @Override |
| | | public String getMappingTableName(SysView view) { |
| | | String id = view.getId(); |
| | |
| | | view.setMappingTable(mappingTableName).updateById(); |
| | | return mappingTableName; |
| | | } |
| | | /** |
| | | * |
| | | * @description: 获取关联主题的有权限的字段 |
| | | * @param user 用户 |
| | | * @param join 关联主题对象 |
| | | * @return: 关联主题的有权限的字段 |
| | | * |
| | | */ |
| | | |
| | | @Override |
| | | public List<String> getSubFieldList(SysViewJoin join, TUser user) { |
| | | String fieldsStr = join.getFields(); |
| | |
| | | if (Constant.All.equalsIgnoreCase(fieldsStr)) { |
| | | Maintain joinMaintain = getJoinMaintain(join); |
| | | List<SysField> fieldList = masterAuthorService.getField(user, joinMaintain.getId()); |
| | | baseFieldList = fieldList.stream().map(sysField -> sysField.getField()).collect(Collectors.toList()); |
| | | if (fieldList != null) { |
| | | baseFieldList = fieldList.stream().map(sysField -> sysField.getField()).collect(Collectors.toList()); |
| | | } |
| | | }else { |
| | | baseFieldList = DbUtils.split(fieldsStr); |
| | | } |
| | | |
| | | return baseFieldList; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 获取基准主题的有权限的字段 |
| | | * @param sysView 主题 |
| | | * @return: 基准主题的有权限的字段 |
| | | * |
| | | */ |
| | | private List<String> getBaseFieldList(SysView sysView) { |
| | | String fieldsStr = sysView.getFields(); |
| | | List<String> baseFieldList = new ArrayList<>(); |
| | |
| | | |
| | | return baseFieldList; |
| | | } |
| | | /** |
| | | * |
| | | * @description: 获取1对1转换的字段 |
| | | * @param sysView 视图 |
| | | * @return: 1对1转换的字段列表 |
| | | * |
| | | */ |
| | | @Override |
| | | public List<ViewMapFieldItem> getMapField(SysView sysView) { |
| | | List<ViewMapFieldItem> result = new ArrayList<>(); |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 获取关联主题对象 |
| | | * @param sysView 视图 |
| | | * @return: 获取关联主题对象 |
| | | * |
| | | */ |
| | | private List<SysViewJoin> getJoinList(SysView sysView) { |
| | | String id = sysView.getId(); |
| | | Wrapper<SysViewJoin> eq = new EntityWrapper<SysViewJoin>().eq(Constant.PARENT_ID, id); |
| | | List<SysViewJoin> joinList = joinService.selectList(eq); |
| | | return joinList; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 获取全部字段列表 |
| | | * @param sysView 视图 |
| | | * @return: 全部字段列表 |
| | | * |
| | | */ |
| | | public List<String> getTotalFieldList(SysView sysView) { |
| | | String userId = sysView.getUserId(); |
| | | TUser user = DbUtils.getUserById(userId); |
| | |
| | | sysView.setViewJoinList(sysViewJoins); |
| | | return totalFieldList; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 获取基准主题对象 |
| | | * @param sysView 视图 |
| | | * @return: 获取基准主题对象 |
| | | * |
| | | */ |
| | | @Override |
| | | public Maintain getBaseMaintain(SysView sysView) { |
| | | |
| | |
| | | } |
| | | return baseMaintain; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 获取关联主题对象 |
| | | * @param viewJoin 视图关联主题 |
| | | * @return: 获取关联主题对象 |
| | | * |
| | | */ |
| | | @Override |
| | | public Maintain getJoinMaintain(SysViewJoin viewJoin) { |
| | | |
| | |
| | | } |
| | | return baseMaintain; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 获取视图实际使用的字段 |
| | | * @param field 主题字段 |
| | | * @param baseTableName 表名 |
| | | * @return: 视图实际使用的字段 |
| | | * |
| | | */ |
| | | @Override |
| | | public String changeFieldName(String baseTableName, String field) { |
| | | return DbUtils.StrJoinLink(Constant.EMPTY_Str, baseTableName, Constant.UnderLine, field); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 审批结束后根据条件重新生成视图并分发 |
| | | * @param maintainId 版本id |
| | | * @param status 审批状态 |
| | | * @return: |
| | | * |
| | | */ |
| | | @Override |
| | | public void dealFlow(String maintainId, ActivitiStatus status) { |
| | | if (!ActivitiStatus.open.equals(status)) { |
| | | try { |
| | | if (!ActivitiStatus.open.equals(status)) { |
| | | return; |
| | | } |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | String maintainTableName = maintain.getTableName(); |
| | | |
| | | Wrapper<SysView> eq = new EntityWrapper<SysView>() |
| | | .eq("need_update", true) |
| | | .eq("base_maintain", maintainTableName); |
| | | List<SysView> sysViews = selectList(eq); |
| | | for (SysView sysView : sysViews) { |
| | | ViewStatus viewStatus = sysView.getStatus(); |
| | | if (!ViewStatus.working.equals(viewStatus)) { |
| | | continue; |
| | | } |
| | | createView(sysView.getId()); |
| | | |
| | | Boolean subscribe = sysView.getSubscribe(); |
| | | if (!subscribe) { |
| | | continue; |
| | | } |
| | | MqEntity mqEntity = new MqEntity(); |
| | | mqEntity.setUserId(sysView.getUserId()); |
| | | mqEntity.setMsgTopicName(Constant.View); |
| | | mqEntity.setType(Constant.View); |
| | | mqEntity.setDataId(sysView.getId()); |
| | | mqEntity.setMsgTagName(sysView.getId()); |
| | | mqEntity.setMsgKey(DbUtils.getUUID(16)); |
| | | MqMessage mqMessage = new MqMessage(mqEntity); |
| | | dispenseService.pushActiveMq(mqMessage); |
| | | } |
| | | return; |
| | | } |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | | String maintainTableName = maintain.getTableName(); |
| | | |
| | | Wrapper<SysView> eq = new EntityWrapper<SysView>() |
| | | .eq("need_update", true) |
| | | .eq("base_maintain", maintainTableName); |
| | | List<SysView> sysViews = selectList(eq); |
| | | for (SysView sysView : sysViews) { |
| | | ViewStatus viewStatus = sysView.getStatus(); |
| | | if (!ViewStatus.working.equals(viewStatus)) { |
| | | continue; |
| | | } |
| | | createView(sysView.getId()); |
| | | |
| | | Boolean subscribe = sysView.getSubscribe(); |
| | | if (!subscribe) { |
| | | continue; |
| | | } |
| | | MqEntity mqEntity = new MqEntity(); |
| | | mqEntity.setUserId(sysView.getUserId()); |
| | | mqEntity.setMsgTopicName(Constant.View); |
| | | mqEntity.setType(Constant.View); |
| | | mqEntity.setDataId(sysView.getId()); |
| | | mqEntity.setMsgTagName(sysView.getId()); |
| | | mqEntity.setMsgKey(DbUtils.getUUID(16)); |
| | | MqMessage mqMessage = new MqMessage(mqEntity); |
| | | dispenseService.pushActiveMq(mqMessage); |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return; |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public Result getMapData(SysView sysView, String changedField, Integer pageNo, int pageSize) { |
| | | String mappingTable = sysView.getMappingTable(); |
| | | if (StringUtils.isEmpty(mappingTable)) { |
| | | return null; |
| | | |
| | | if (StringUtils.isEmpty(mappingTable) && !StringUtils.isEmpty(sysView.getMappingField())) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | boolean exists = unBigDataDataSourceInfo.checkTableExists(mappingTable); |
| | | if (!exists) { |
| | |
| | | public long getViewCount(SysView sysView) { |
| | | String viewTableName = sysView.getViewTableName(); |
| | | if (StringUtils.isEmpty(viewTableName)) { |
| | | log.info(" view table is null"); |
| | | return 0; |
| | | } |
| | | boolean exists = unBigDataDataSourceInfo.checkTableExists(viewTableName); |
| | | if (!exists) { |
| | | log.info(" view table is not exist" + viewTableName); |
| | | return 0; |
| | | } |
| | | |
| | | Long count = tableInfoMapper.getCount(viewTableName, Constant.WHERE_DEFAULT); |
| | | log.info(" view table count" + count); |
| | | if (count == null) { |
| | | return 0L; |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | @Override |
| | | public Result getViewData(SysView sysView, Integer pageNo, int pageSize) { |
| | | return getViewData(sysView, pageNo, pageSize,null); |
| | | } |
| | | |
| | | @Override |
| | | public Result getViewData(SysView sysView, Integer pageNo, int pageSize, Page page) { |
| | | String viewTableName = sysView.getViewTableName(); |
| | | long count = getViewCount(sysView); |
| | | long count = 0; |
| | | |
| | | if (page == null) { |
| | | count = getViewCount(sysView); |
| | | page = new Page(count); |
| | | page.setPageSize(pageSize); |
| | | page.setPageNo(pageNo); |
| | | }else { |
| | | count = page.getRecordCount(); |
| | | } |
| | | |
| | | log.info(" view count "+count); |
| | | if (count == 0) { |
| | | return null; |
| | | } |
| | | Page page = new Page(count); |
| | | page.setPageSize(pageSize); |
| | | page.setPageNo(pageNo); |
| | | |
| | | List<TableSchemaResult> tableField = tableInfoMapper.getTableField(viewTableName); |
| | | String fields = tableField.stream().map(tableSchemaResult -> tableSchemaResult.getFieldName()).collect(Collectors.joining(Constant.COMMA)); |
| | | log.info(" view field" + fields); |
| | | |
| | | List<Map<String, Object>> maps = tableInfoMapper.selectByPage(viewTableName, fields, Constant.WHERE_DEFAULT, page.getLimitSQL()); |
| | | if (maps == null || maps.isEmpty()) { |
| | | log.info(" view data is null"); |
| | | } |
| | | Map<String, AntianaphylaxisResult> helpfulField = antianaphylaxisClient.getHelpfulField(fields, viewTableName); |
| | | antianaphylaxisClient.fixMasterData(maps,helpfulField); |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("records", maps); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", pageNo); |
| | | object.fluentPut("total", count); |
| | | object.fluentPut("pageSize", page.getPageSize()); |
| | | if (page == null) { |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", pageNo); |
| | | object.fluentPut("total", count); |
| | | object.fluentPut("pageSize", page.getPageSize()); |
| | | } |
| | | |
| | | |
| | | //fields |
| | | ArrayList<ViewField> sysFields = new ArrayList<>(); |
| | |
| | | ViewField viewField = new ViewField(); |
| | | viewField.setChangedField(changeFieldName); |
| | | viewField.setField(field); |
| | | viewField.setFieldName(oneFieldByMaintain.getAlias()); |
| | | viewField.setAlias(oneFieldByMaintain.getAlias()); |
| | | viewField.setMenuId(sysView.getId()); |
| | | viewField.setMenuName(sysView.getName()); |
| | | sysFields.add(viewField); |
| | |
| | | ViewField viewField = new ViewField(); |
| | | viewField.setChangedField(changeFieldName); |
| | | viewField.setField(subField); |
| | | viewField.setFieldName(oneFieldByMaintain.getAlias()); |
| | | viewField.setAlias(oneFieldByMaintain.getAlias()); |
| | | viewField.setMenuId(sysView.getId()); |
| | | viewField.setMenuName(sysView.getName()); |
| | | sysFields.add(viewField); |
| | |
| | | fields.add(field); |
| | | fields.add(Constant.ID); |
| | | String filter = masterAuthorService.getFilter(user, maintain.getId()); |
| | | if (StringUtils.isEmpty(filter)) { |
| | | filter = Constant.WHERE_DEFAULT; |
| | | } |
| | | String sql = masterDataService.selectByVersionSql(user, maintain.getTableName(), fields, filter, maintain.getVersion(), false); |
| | | String tableName = MessageFormat.format(Constant.asTempSql, sql, Constant.H); |
| | | String mappingTable = sysView.getMappingTable(); |
| | |
| | | maps = tableInfoMapper.selectDistinct(tableName, MessageFormat.format(Constant.FieldAsAlias, field, Constant.Pre), Constant.WHERE_DEFAULT); |
| | | |
| | | } |
| | | |
| | | |
| | | //todo 大数据量优化 |
| | | fields.remove(Constant.ID); |
| | | ArrayList<SysField> sysFields = new ArrayList<>(); |
| | |
| | | if (StringUtils.isEmpty(mappingTable) || StringUtils.isEmpty(mappingfield)) { |
| | | return true; |
| | | } |
| | | tableInfoMapper.delete(mappingTable, segment.toString()); |
| | | mappingTable = tableInfoMapper.selectTableByName(mappingTable); |
| | | if (!StringUtils.isEmpty(mappingTable)){ |
| | | tableInfoMapper.delete(mappingTable, segment.toString()); |
| | | } |
| | | |
| | | String mappingField = sysView.getMappingField(); |
| | | List<String> split = DbUtils.split(mappingField); |
| | | String collect = split.stream().filter(s -> !s.equalsIgnoreCase(changedField)).collect(Collectors.joining(Constant.SEMICOLON)); |