From 74472c9d22dddcb41383794caf0011043b20f817 Mon Sep 17 00:00:00 2001 From: kimi <kimi42345@gmail.com> Date: 星期二, 31 三月 2020 13:25:47 +0800 Subject: [PATCH] fix 数据权限 --- src/main/java/com/highdatas/mdm/service/impl/SysAssembleServiceImpl.java | 95 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 75 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/highdatas/mdm/service/impl/SysAssembleServiceImpl.java b/src/main/java/com/highdatas/mdm/service/impl/SysAssembleServiceImpl.java index 0567a31..1eb63cb 100644 --- a/src/main/java/com/highdatas/mdm/service/impl/SysAssembleServiceImpl.java +++ b/src/main/java/com/highdatas/mdm/service/impl/SysAssembleServiceImpl.java @@ -1,6 +1,7 @@ package com.highdatas.mdm.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.highdatas.mdm.entity.*; import com.highdatas.mdm.mapper.SysAssembleMapper; import com.highdatas.mdm.mapper.TableInfoMapper; @@ -9,22 +10,17 @@ import com.highdatas.mdm.pojo.kettle.DataSourceInfo; import com.highdatas.mdm.pojo.kettle.UnBigDataDataSourceInfo; import com.highdatas.mdm.service.*; -import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.highdatas.mdm.util.Constant; import com.highdatas.mdm.util.ContentBuilder; import com.highdatas.mdm.util.DbUtils; -import lombok.Data; +import com.highdatas.mdm.util.RuleClient; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.ibatis.session.SqlSession; -import org.apache.regexp.RE; import org.mybatis.spring.SqlSessionTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import javax.servlet.http.HttpSession; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; @@ -77,11 +73,15 @@ BigDataDataSourceInfo bigDataDataSourceInfo; @Autowired MasterDataService masterDataService; - + @Autowired + ITUserService userService; + @Autowired + RuleClient ruleClient; + @Autowired + IMasterModifiedService masterModifiedService; @Override - @Transactional(rollbackFor=Exception.class) - public Result run(String id, HttpSession session) { + public Result run(String id) { if (StringUtils.isEmpty(id)) { return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); } @@ -90,9 +90,17 @@ if (assemble == null) { return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); } + assemble.setPreTime(new Date()); + assemble.setPreStatus(SysAssembleRunStatus.working); + assemble.updateById(); if (!assemble.getStatus().equals(SysAssembleStatus.working)) { + assemble.setPreStatus(SysAssembleRunStatus.fail); + assemble.setPreCnt(0); + assemble.setPreMsg("褰撳墠浠诲姟涓嶅湪宸ヤ綔涓�,鐘舵��:" + assemble.getStatus()); + assemble.updateById(); return Result.error(new CodeMsg(6009,"褰撳墠浠诲姟涓嶅湪宸ヤ綔涓�,鐘舵��:" + assemble.getStatus())); + } String flowId = assemble.getFlowId(); @@ -101,13 +109,15 @@ if (flows != null) { ActivitiStatus status = flows.getStatus(); if (!status.equals(ActivitiStatus.close) && !status.equals(ActivitiStatus.open)) { + assemble.setPreStatus(SysAssembleRunStatus.fail); + assemble.setPreCnt(0); + assemble.setPreMsg("褰撳墠鏈夋祦绋嬫鍦ㄨ繍琛�,鏆傛椂鏃犳硶姹囬泦涓嬫鏁版嵁:" + status.toString()); + assemble.updateById(); return Result.error(new CodeMsg(6009,"褰撳墠鏈夋祦绋嬫鍦ㄨ繍琛�,鏆傛椂鏃犳硶姹囬泦涓嬫鏁版嵁:" + status.toString())); + } } } - assemble.setPreTime(new Date()); - assemble.setPreStatus(SysAssembleRunStatus.working); - assemble.updateById(); Boolean bigData = assemble.getBigdata(); @@ -147,7 +157,7 @@ } //5 check temp data - result = checkTempData(id, assemble.getCheckType(), assemble.getCheckFields()); + result = checkTempData(assemble); if (!result.getSuccess()) { assemble.setPreStatus(SysAssembleRunStatus.fail); @@ -166,7 +176,7 @@ } //7 record 閾炬帴 鐗堟湰 - result = linkMaintain(assemble, session); + result = linkMaintain(assemble); if (!result.getSuccess()) { assemble.setPreStatus(SysAssembleRunStatus.fail); assemble.setPreMsg("鑱旀帴鐗堟湰鍑虹幇閿欒" ); @@ -196,7 +206,7 @@ } } - private Result linkMaintain(SysAssemble assemble, HttpSession session) { + private Result linkMaintain(SysAssemble assemble) { try{ String menuId = assemble.getMenuId(); MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("menu_id", menuId)); @@ -215,12 +225,22 @@ //榛樿闇�瑕佸鎵� audit = true; } + // 澶勭悊鍏宠仈浜� + + if (audit) { - Flows flows = activitiService.start("process", session, maintain.getId(), ActivitiBusinessType.maintain); + String chargeId = menuMapping.getChargeId(); + TUser user = userService.selectById(chargeId); + if (user == null) { + return Result.error(new CodeMsg(6009, "鎵句笉鍒板搴旂殑璐熻矗浜�:" + chargeId)); + } + activitiService.setUser(user); + Flows flows = activitiService.start("process", null, maintain.getId(), ActivitiBusinessType.maintain); assemble.setFlowId(flows.getId()).updateById(); 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()); @@ -228,6 +248,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) { @@ -362,10 +383,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); @@ -390,6 +410,7 @@ } } } + private Result temp2record(SysAssemble assemble) { Connection conn = null; try { @@ -439,7 +460,6 @@ String joinStr = getJoinFieldParse(unionCodeFields); // insert - String insertFieldStr = fieldsFromTable.stream() .map(s -> MessageFormat.format(Constant.Alias,Constant.T1,s)) .collect(Collectors.joining(Constant.COMMA)); @@ -486,8 +506,43 @@ return builder.toString(); } - private Result checkTempData(String s,SysAssembleCheckType checkType, String id) { + private Result checkTempData(SysAssemble assemble) { //TODO + + SysAssembleCheckType checkType = assemble.getCheckType(); + if (checkType == null) { + return Result.error(new CodeMsg(6009,"瑙勫垯鏍¢獙绫诲瀷涓虹┖")); + } + if (checkType.equals(SysAssembleCheckType.unlimited)) { + return Result.success(null); + } + + String menuId = assemble.getMenuId(); + MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("menu_id", menuId)); + String tableName = menuMapping.getTableName(); + String tempTableName = Constant.Temp + tableName; + HashMap<String,Boolean> fieldResultSet = ruleClient.execuImmeForCollect(tempTableName, assemble.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 Result.error(new CodeMsg(6009,"瑙勫垯鏍¢獙涓嶉�氳繃 瀛楁:" + unSuccessFields)); + } + break; + case partSuccessAdd: + String checkFields = assemble.getCheckFields(); + String[] split = checkFields.split(Constant.SEMICOLON); + for (String s : split) { + Boolean checked = fieldResultSet.get(s); + if (checked == null || !checked) { + return Result.error(new CodeMsg(6009,"瑙勫垯鏍¢獙涓嶉�氳繃 瀛楁:" + s)); + } + } + break; + } + + + return Result.success(null); } -- Gitblit v1.8.0