Browse Source

团队重构

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

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

@ -291,89 +291,15 @@ public class XmQuestionController {
ResponseHelper.failed("bugs-0","该bug已不存在"); 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()); 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()); 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<String,Object> map=new HashMap<>();
map.putAll(xmQuestionMap); map.putAll(xmQuestionMap);
map.remove("ids"); map.remove("ids");
for (XmQuestion xmQuestionVo : xmQuestionsDb) {
for (XmQuestion xmQuestionVo : canOper) {
Map<String,Object> m2=BaseUtils.toMap(xmQuestionVo); Map<String,Object> m2=BaseUtils.toMap(xmQuestionVo);
m2.putAll(map); m2.putAll(map);
xmQuestionVo=BaseUtils.fromMap(m2,XmQuestion.class); 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); //m.put("data",xmMenu);
}catch (BizException e) { }catch (BizException e) {
tips=e.getTips(); tips=e.getTips();
@ -461,129 +406,34 @@ public class XmQuestionController {
if(xmQuestionsDb==null || xmQuestionsDb.size()==0){ if(xmQuestionsDb==null || xmQuestionsDb.size()==0){
return ResponseHelper.failed("data-0","所有数据已不存在"); return ResponseHelper.failed("data-0","所有数据已不存在");
} }
List<XmQuestion> canDel=new ArrayList<>();
List<XmQuestion> noDel=new ArrayList<>();
Map<String,Tips> noDelTips=new HashMap<>();
/**
* 如果有测试计划有产品编号走产品团队判断权限
* 如果未通过继续走项目权限判断
*/
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);
}
}
}
List<XmQuestion> canOper=new ArrayList<>();
List<XmQuestion> productNoDel=new ArrayList<>();
if(productsMap.size()>0){
for (String productId : productsMap.keySet()) {
XmProduct xmProduct=productService.getProductFromCache(productId);
Tips tips1=groupService.checkProductQx(xmProduct,1,user);
if(!tips1.isOk()){
productNoDel.addAll(productsMap.get(productId));
for (XmQuestion xmQuestion : productsMap.get(productId)) {
noDelTips.put(xmQuestion.getId(),tips1);
}
productsMap.remove(productId);
}else{
List<XmQuestion> questions=productsMap.get(productId);
for (XmQuestion question : questions) {
tips1=groupService.checkProductQx(xmProduct,1,user,question.getCreateUserid(),question.getHandlerUserid());
if(!tips1.isOk()){
productNoDel.add(question);
noDelTips.put(question.getId(),tips1);
}else {
canDel.add(question);
}
}
List<XmQuestion> noOper=new ArrayList<>();
}
}
}
for (XmQuestion xmQuestion : productNoDel) {
if(StringUtils.hasText(xmQuestion.getProjectId())){
List<XmQuestion> ques=projectsMap.get(xmQuestion.getProjectId());
if(ques!=null){
if(!ques.stream().filter(k->k.getId().equals(xmQuestion.getId())).findAny().isPresent()){
ques.add(xmQuestion);
}
}else{
ques=new ArrayList<>();
ques.add(xmQuestion);
projectsMap.put(xmQuestion.getProjectId(),ques);
}
Map<String,Tips> noOperTips=new HashMap<>();
}else{
noDel.add(xmQuestion);
}
}
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));
for (XmQuestion xmQuestion : projectsMap.get(projectId)) {
noDelTips.put(xmQuestion.getId(),tips1);
}
projectsMap.remove(projectId);
}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.put(question.getId(),tips1);
}else {
canDel.add(question);
}
}
}
}
}
this.checkQx(xmQuestionsDb,canOper,noOper,noOperTips);
if(canDel.size()>0){
xmQuestionService.batchDelete(canDel);
if(canOper.size()>0){
xmQuestionService.batchDelete(canOper);
} }
List<String> msgs=new ArrayList<>(); List<String> msgs=new ArrayList<>();
if(canDel.size()>0){
for (XmQuestion xmQuestion : canDel) {
noDelTips.remove(xmQuestion.getId());
if(canOper.size()>0){
for (XmQuestion xmQuestion : canOper) {
noOperTips.remove(xmQuestion.getId());
} }
msgs.add(String.format("删除了%s个缺陷。",canDel.size()));
msgs.add(String.format("删除了%s个缺陷。",canOper.size()));
} }
if(noDel.size()>0){
if(noOper.size()>0){
Set<String> noDelTips2=new HashSet<>(); Set<String> noDelTips2=new HashSet<>();
for (XmQuestion xmQuestion : noDel) {
Tips tips1=noDelTips.get(xmQuestion.getId());
for (XmQuestion xmQuestion : noOper) {
Tips tips1=noOperTips.get(xmQuestion.getId());
noDelTips2.add(tips1.getMsg()); noDelTips2.add(tips1.getMsg());
} }
msgs.add(String.format("其中%s个缺陷,无权限删除。原因【%s】",noDel.size(),noDelTips2.stream().collect(Collectors.joining(";"))));
msgs.add(String.format("其中%s个缺陷,无权限删除。原因【%s】",noOper.size(),noDelTips2.stream().collect(Collectors.joining(";"))));
} }
if(canDel.size()>0){
if(canOper.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining())); tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else{ }else{
tips.setFailureMsg(msgs.stream().collect(Collectors.joining())); tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
@ -598,11 +448,109 @@ public class XmQuestionController {
} }
m.put("tips", tips); m.put("tips", tips);
return m; return m;
}
}
public void checkQx(List<XmQuestion> xmQuestionsDb, List<XmQuestion> canOper, List<XmQuestion> noOper, Map<String,Tips> noOperTips){
User user=LoginUtils.getCurrentUserInfo();
/**
* 如果有测试计划有产品编号走产品团队判断权限
* 如果未通过继续走项目权限判断
*/
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);
}
}
}
List<XmQuestion> productNoDel=new ArrayList<>();
if(productsMap.size()>0){
for (String productId : productsMap.keySet()) {
XmProduct xmProduct=productService.getProductFromCache(productId);
Tips tips1=groupService.checkProductQx(xmProduct,1,user);
if(!tips1.isOk()){
productNoDel.addAll(productsMap.get(productId));
for (XmQuestion xmQuestion : productsMap.get(productId)) {
noOperTips.put(xmQuestion.getId(),tips1);
}
productsMap.remove(productId);
}else{
List<XmQuestion> questions=productsMap.get(productId);
for (XmQuestion question : questions) {
tips1=groupService.checkProductQx(xmProduct,1,user,question.getCreateUserid(),question.getHandlerUserid());
if(!tips1.isOk()){
productNoDel.add(question);
noOperTips.put(question.getId(),tips1);
}else {
canOper.add(question);
}
}
}
}
}
for (XmQuestion xmQuestion : productNoDel) {
if(StringUtils.hasText(xmQuestion.getProjectId())){
List<XmQuestion> ques=projectsMap.get(xmQuestion.getProjectId());
if(ques!=null){
if(!ques.stream().filter(k->k.getId().equals(xmQuestion.getId())).findAny().isPresent()){
ques.add(xmQuestion);
}
}else{
ques=new ArrayList<>();
ques.add(xmQuestion);
projectsMap.put(xmQuestion.getProjectId(),ques);
}
}else{
noOper.add(xmQuestion);
}
}
if(projectsMap.size()>0){
for (String projectId : projectsMap.keySet()) {
XmProject xmProject=projectService.getProjectFromCache(projectId);
Tips tips1=groupService.checkProjectQx(xmProject,user);
if(!tips1.isOk()){
noOper.addAll(projectsMap.get(projectId));
for (XmQuestion xmQuestion : projectsMap.get(projectId)) {
noOperTips.put(xmQuestion.getId(),tips1);
}
projectsMap.remove(projectId);
}else{
List<XmQuestion> questions=projectsMap.get(projectId);
for (XmQuestion question : questions) {
tips1=groupService.checkProjectQx(xmProject,user,question.getCreateUserid(),question.getHandlerUserid());
if(!tips1.isOk()){
noOper.add(question);
noOperTips.put(question.getId(),tips1);
}else {
canOper.add(question);
}
}
}
}
}
}
/** /**
* 流程审批过程中回调该接口更新业务数据 * 流程审批过程中回调该接口更新业务数据
* 如果发起流程时上送了restUrl则无论流程中是否配置了监听器都会在流程发生以下事件时推送数据过来 * 如果发起流程时上送了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.core.utils.BaseUtils;
import com.mdp.safe.client.entity.User; import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils; 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.XmQuestion;
import com.xm.core.entity.XmQuestionHandle; import com.xm.core.entity.XmQuestionHandle;
import com.xm.core.vo.XmQuestionVo; import com.xm.core.vo.XmQuestionVo;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; 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> * 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br>
@ -35,6 +35,9 @@ public class XmQuestionService extends BaseService {
@Autowired @Autowired
XmRecordService xmRecordService; XmRecordService xmRecordService;
/** 请在此类添加自定义函数 */ /** 请在此类添加自定义函数 */
public List<Map<String,Object>> getQuestion (Map<String,Object> params) { public List<Map<String,Object>> getQuestion (Map<String,Object> params) {

Loading…
Cancel
Save