Browse Source

团队重构

master
陈裕财 3 years ago
parent
commit
1cb9e0db2c
  1. 210
      xm-core/src/main/java/com/xm/core/ctrl/XmQuestionController.java
  2. 11
      xm-core/src/main/java/com/xm/core/service/XmQuestionService.java

210
xm-core/src/main/java/com/xm/core/ctrl/XmQuestionController.java

@ -291,89 +291,15 @@ public class XmQuestionController {
ResponseHelper.failed("bugs-0","该bug已不存在");
}
List<XmQuestion> canOper=new ArrayList<>();
List<XmQuestion> canDel=new ArrayList<>();
List<XmQuestion> noOper=new ArrayList<>();
List<XmQuestion> noDel=new ArrayList<>();
List<Tips> noDelTips=new ArrayList<>();
/**
* 如果有测试计划有产品编号走产品团队判断权限
* 如果未通过继续走项目权限判断
*/
Map<String,List<XmQuestion>> productsMap=new HashMap<>();//有产品的数据
Map<String,List<XmQuestion>> projectsMap=new HashMap<>();//没有产品但有项目的数据
for (XmQuestion xmQuestion : xmQuestionsDb) {
if(StringUtils.hasText(xmQuestion.getProductId())){
List<XmQuestion> datas=productsMap.get(xmQuestion.getProductId());
if(datas==null){
datas=new ArrayList<>();
datas.add(xmQuestion);
productsMap.put(xmQuestion.getProductId(),datas);
}else {
datas.add(xmQuestion);
}
}else if(StringUtils.hasText(xmQuestion.getProjectId())) {
List<XmQuestion> datas=projectsMap.get(xmQuestion.getProjectId());
if(datas==null){
datas=new ArrayList<>();
datas.add(xmQuestion);
projectsMap.put(xmQuestion.getProjectId(),datas);
}else {
datas.add(xmQuestion);
}
}
}
if(productsMap.size()>0){
for (String productId : productsMap.keySet()) {
XmProduct xmProduct=productService.getProductFromCache(productId);
Tips tips1=groupService.checkProductQx(xmProduct,1,user);
if(!tips1.isOk()){
noDel.addAll(productsMap.get(productId));
productsMap.remove(productId);
noDelTips.add(tips1);
}else{
List<XmQuestion> questions=productsMap.get(productId);
for (XmQuestion question : questions) {
tips1=groupService.checkProductQx(xmProduct,1,user,question.getCreateUserid(),question.getHandlerUserid());
if(!tips1.isOk()){
noDel.add(question);
noDelTips.add(tips1);
}else {
canDel.add(question);
}
}
}
}
}
if(projectsMap.size()>0){
for (String projectId : projectsMap.keySet()) {
XmProject xmProject=projectService.getProjectFromCache(projectId);
Tips tips1=groupService.checkProjectQx(xmProject,user);
if(!tips1.isOk()){
noDel.addAll(projectsMap.get(projectId));
projectsMap.remove(projectId);
noDelTips.add(tips1);
}else{
List<XmQuestion> questions=projectsMap.get(projectId);
for (XmQuestion question : questions) {
tips1=groupService.checkProjectQx(xmProject,user,question.getCreateUserid(),question.getHandlerUserid());
if(!tips1.isOk()){
noDel.add(question);
noDelTips.add(tips1);
}else {
canDel.add(question);
}
}
}
}
}
Map<String,Tips> noOperTips=new HashMap<>();
this.checkQx(xmQuestionsDb,canOper,noOper,noOperTips);
xmQuestionMap.put("ids",canOper.stream().map(k->k.getId()).collect(Collectors.toList()));
Set<String> fieldKey=xmQuestionMap.keySet().stream().filter(i->fieldsMap.containsKey(i)).collect(Collectors.toSet());
fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(xmQuestionMap.get(i) )).collect(Collectors.toSet());
@ -394,7 +320,7 @@ public class XmQuestionController {
Map<String,Object> map=new HashMap<>();
map.putAll(xmQuestionMap);
map.remove("ids");
for (XmQuestion xmQuestionVo : xmQuestionsDb) {
for (XmQuestion xmQuestionVo : canOper) {
Map<String,Object> m2=BaseUtils.toMap(xmQuestionVo);
m2.putAll(map);
xmQuestionVo=BaseUtils.fromMap(m2,XmQuestion.class);
@ -431,7 +357,26 @@ public class XmQuestionController {
}
List<String> msgs=new ArrayList<>();
if(canOper.size()>0){
for (XmQuestion xmQuestion : canOper) {
noOperTips.remove(xmQuestion.getId());
}
msgs.add(String.format("修改了%s个缺陷。",canOper.size()));
}
if(noOper.size()>0){
Set<String> noDelTips2=new HashSet<>();
for (XmQuestion xmQuestion : noOper) {
Tips tips1=noOperTips.get(xmQuestion.getId());
noDelTips2.add(tips1.getMsg());
}
msgs.add(String.format("其中%s个缺陷,无权限修改。原因【%s】",noOper.size(),noDelTips2.stream().collect(Collectors.joining(";"))));
}
if(canOper.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else{
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
//m.put("data",xmMenu);
}catch (BizException e) {
tips=e.getTips();
@ -461,13 +406,54 @@ public class XmQuestionController {
if(xmQuestionsDb==null || xmQuestionsDb.size()==0){
return ResponseHelper.failed("data-0","所有数据已不存在");
}
List<XmQuestion> canDel=new ArrayList<>();
List<XmQuestion> canOper=new ArrayList<>();
List<XmQuestion> noOper=new ArrayList<>();
Map<String,Tips> noOperTips=new HashMap<>();
this.checkQx(xmQuestionsDb,canOper,noOper,noOperTips);
if(canOper.size()>0){
xmQuestionService.batchDelete(canOper);
}
List<XmQuestion> noDel=new ArrayList<>();
List<String> msgs=new ArrayList<>();
if(canOper.size()>0){
for (XmQuestion xmQuestion : canOper) {
noOperTips.remove(xmQuestion.getId());
}
msgs.add(String.format("删除了%s个缺陷。",canOper.size()));
}
if(noOper.size()>0){
Set<String> noDelTips2=new HashSet<>();
for (XmQuestion xmQuestion : noOper) {
Tips tips1=noOperTips.get(xmQuestion.getId());
noDelTips2.add(tips1.getMsg());
}
msgs.add(String.format("其中%s个缺陷,无权限删除。原因【%s】",noOper.size(),noDelTips2.stream().collect(Collectors.joining(";"))));
}
if(canOper.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else{
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
Map<String,Tips> noDelTips=new HashMap<>();
public void checkQx(List<XmQuestion> xmQuestionsDb, List<XmQuestion> canOper, List<XmQuestion> noOper, Map<String,Tips> noOperTips){
User user=LoginUtils.getCurrentUserInfo();
/**
* 如果有测试计划有产品编号走产品团队判断权限
* 如果未通过继续走项目权限判断
@ -504,7 +490,7 @@ public class XmQuestionController {
if(!tips1.isOk()){
productNoDel.addAll(productsMap.get(productId));
for (XmQuestion xmQuestion : productsMap.get(productId)) {
noDelTips.put(xmQuestion.getId(),tips1);
noOperTips.put(xmQuestion.getId(),tips1);
}
productsMap.remove(productId);
}else{
@ -513,9 +499,9 @@ public class XmQuestionController {
tips1=groupService.checkProductQx(xmProduct,1,user,question.getCreateUserid(),question.getHandlerUserid());
if(!tips1.isOk()){
productNoDel.add(question);
noDelTips.put(question.getId(),tips1);
noOperTips.put(question.getId(),tips1);
}else {
canDel.add(question);
canOper.add(question);
}
}
@ -536,7 +522,7 @@ public class XmQuestionController {
}
}else{
noDel.add(xmQuestion);
noOper.add(xmQuestion);
}
}
if(projectsMap.size()>0){
@ -544,9 +530,9 @@ public class XmQuestionController {
XmProject xmProject=projectService.getProjectFromCache(projectId);
Tips tips1=groupService.checkProjectQx(xmProject,user);
if(!tips1.isOk()){
noDel.addAll(projectsMap.get(projectId));
noOper.addAll(projectsMap.get(projectId));
for (XmQuestion xmQuestion : projectsMap.get(projectId)) {
noDelTips.put(xmQuestion.getId(),tips1);
noOperTips.put(xmQuestion.getId(),tips1);
}
projectsMap.remove(projectId);
}else{
@ -554,55 +540,17 @@ public class XmQuestionController {
for (XmQuestion question : questions) {
tips1=groupService.checkProjectQx(xmProject,user,question.getCreateUserid(),question.getHandlerUserid());
if(!tips1.isOk()){
noDel.add(question);
noDelTips.put(question.getId(),tips1);
noOper.add(question);
noOperTips.put(question.getId(),tips1);
}else {
canDel.add(question);
canOper.add(question);
}
}
}
}
}
if(canDel.size()>0){
xmQuestionService.batchDelete(canDel);
}
List<String> msgs=new ArrayList<>();
if(canDel.size()>0){
for (XmQuestion xmQuestion : canDel) {
noDelTips.remove(xmQuestion.getId());
}
msgs.add(String.format("删除了%s个缺陷。",canDel.size()));
}
if(noDel.size()>0){
Set<String> noDelTips2=new HashSet<>();
for (XmQuestion xmQuestion : noDel) {
Tips tips1=noDelTips.get(xmQuestion.getId());
noDelTips2.add(tips1.getMsg());
}
msgs.add(String.format("其中%s个缺陷,无权限删除。原因【%s】",noDel.size(),noDelTips2.stream().collect(Collectors.joining(";"))));
}
if(canDel.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else{
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
/**
* 流程审批过程中回调该接口更新业务数据
* 如果发起流程时上送了restUrl则无论流程中是否配置了监听器都会在流程发生以下事件时推送数据过来

11
xm-core/src/main/java/com/xm/core/service/XmQuestionService.java

@ -6,18 +6,18 @@ import com.mdp.core.service.BaseService;
import com.mdp.core.utils.BaseUtils;
import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils;
import com.xm.core.entity.XmProduct;
import com.xm.core.entity.XmProject;
import com.xm.core.entity.XmQuestion;
import com.xm.core.entity.XmQuestionHandle;
import com.xm.core.vo.XmQuestionVo;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br>
@ -36,6 +36,9 @@ public class XmQuestionService extends BaseService {
@Autowired
XmRecordService xmRecordService;
/** 请在此类添加自定义函数 */
public List<Map<String,Object>> getQuestion (Map<String,Object> params) {

Loading…
Cancel
Save