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/controller/MaintainController.java | 110 ++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 81 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/highdatas/mdm/controller/MaintainController.java b/src/main/java/com/highdatas/mdm/controller/MaintainController.java index 7d22c7f..662d38c 100644 --- a/src/main/java/com/highdatas/mdm/controller/MaintainController.java +++ b/src/main/java/com/highdatas/mdm/controller/MaintainController.java @@ -13,11 +13,9 @@ 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 com.highdatas.mdm.util.DbUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -25,10 +23,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.stream.Collectors; +import java.util.*; /** * <p> @@ -51,6 +46,10 @@ TableInfoMapper tableInfoMapper; @Autowired IFlowsService flowsService; + @Autowired + IMaintainFieldService maintainFieldService; + @Autowired + IMasterAuthorService masterAuthorService; @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) public Result get(@PathVariable String id) { @@ -65,19 +64,20 @@ public Result unSubmit(@PathVariable String tableName, @PathVariable Integer pageNo, HttpServletRequest request) throws UnsupportedEncodingException { String pageSize = request.getParameter("pageSize"); String whereSegment = request.getParameter("whereSegment"); - + TUser user = DbUtils.getUser(request); if (StringUtils.isEmpty(whereSegment)) { whereSegment = Constant.WHERE_DEFAULT; }else { whereSegment = URLDecoder.decode(whereSegment, "UTF-8"); } - return maintainService.getUnSubmitData(tableName, pageNo, pageSize, whereSegment); + return maintainService.getUnSubmitData(user, tableName, pageNo, pageSize, whereSegment); } @RequestMapping(value = "{tableName}/unflow/{pageNo}", method = RequestMethod.GET) public Result unflow(@PathVariable String tableName, @PathVariable Integer pageNo, HttpServletRequest request) throws UnsupportedEncodingException { String pageSize = request.getParameter("pageSize"); String whereSegment = request.getParameter("whereSegment"); + TUser user = DbUtils.getUser(request); if (StringUtils.isEmpty(whereSegment)) { whereSegment = Constant.WHERE_DEFAULT; @@ -85,33 +85,74 @@ whereSegment = URLDecoder.decode(whereSegment, "UTF-8"); } if (StringUtils.isEmpty(pageSize)) { - return maintainService.getInvalidVerionData(tableName, whereSegment, pageNo, null); + return maintainService.getInvalidVerionData(user, tableName, whereSegment, pageNo, null); } else { - return maintainService.getInvalidVerionData(tableName, whereSegment, pageNo, Integer.valueOf(pageSize)); + return maintainService.getInvalidVerionData(user, tableName, whereSegment, pageNo, Integer.valueOf(pageSize)); } } - @RequestMapping(value = "/history/{tableName}", method = RequestMethod.GET) - public Result getHistory(@PathVariable String tableName) { + @RequestMapping(value = "/version/{tableName}", method = RequestMethod.GET) + 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,"鏃犲綋鍓嶇増鏈�")); } - List<Maintain> maintainList = maintainService.selectList(new EntityWrapper<Maintain>().eq("table_name", tableName).le("order_no",nowVersion.getOrderNo() - 1).orderBy("order_no",false)); + Maintain nowVersion = maintainService.getNowVersion(tableName); - if (maintainList == null) { - return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); + 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)) { + continue; + } + boolean author = masterAuthorService.checkMaintainAuthor(userId, maintain.getId()); + if (!author) { + continue; + } + Flows flows = flowsService.selectById(maintain.getFlowId()); + if (flows.getStatus().equals(ActivitiStatus.close)) { + continue; + } + if (flows.getStatus().equals(ActivitiStatus.working) || flows.getStatus().equals(ActivitiStatus.refuse)) { + boolean nextAudit = flowsService.isNextAudit(flows, userId); + if (nextAudit) { + count++; + } +// count++; + continue; + }else if(flows.getStatus().equals(ActivitiStatus.open)){ + maintain.setMaintainType(1); + } + 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); } - List<String> result = maintainList.stream() - .filter(maintain -> !StringUtils.isEmpty(maintain.getFlowId())) - .filter(maintain -> flowsService.selectById(maintain.getFlowId()).getStatus().equals(ActivitiStatus.open)) - .map(maintain -> maintain.getVersion()) - .collect(Collectors.toList()); - + 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) { @@ -142,7 +183,7 @@ result = maintainService.selectPage(maintainPage); } else { Wrapper<Maintain> tableNameWrapper = new EntityWrapper<Maintain>().eq("table_name", tableName); - tableNameWrapper.orderBy("version desc"); + tableNameWrapper.orderBy("order_no desc"); result = maintainService.selectPage(maintainPage, tableNameWrapper); } List<Maintain> records = result.getRecords(); @@ -172,17 +213,28 @@ 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"); String pageSize = request.getParameter("pageSize"); + TUser user = DbUtils.getUser(request); if (StringUtils.isEmpty(whereSegment)) { whereSegment = Constant.WHERE_DEFAULT; } if (StringUtils.isEmpty(pageSize)) { - return maintainService.tempDataByVersionByFlow(flowId, whereSegment, pageNo, null); + return maintainService.tempDataByVersionByFlow(user, flowId, whereSegment, pageNo, null); } - return maintainService.tempDataByVersionByFlow(flowId, whereSegment, pageNo, Integer.valueOf(pageSize)); + return maintainService.tempDataByVersionByFlow(user, flowId, whereSegment, pageNo, Integer.valueOf(pageSize)); } -- Gitblit v1.8.0