Browse Source

添加节点类型、标签等

master
陈裕财 4 years ago
parent
commit
09ea8804bb
  1. 104
      xm-core/src/main/java/com/xm/core/ctrl/XmMenuController.java
  2. 215
      xm-core/src/main/java/com/xm/core/ctrl/XmPhaseMenuController.java
  3. 16
      xm-core/src/main/java/com/xm/core/service/XmMenuService.java
  4. 28
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMenuMapper.xml

104
xm-core/src/main/java/com/xm/core/ctrl/XmMenuController.java

@ -168,13 +168,113 @@ public class XmMenuController {
} }
} }
m.put("data",xmMenuList);
m.put("data",xmMenuList);
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
@RequestMapping(value="/listWithPlan",method=RequestMethod.GET) @RequestMapping(value="/listWithPlan",method=RequestMethod.GET)
public Map<String,Object> listWithPlan( @RequestParam Map<String,Object> xmMenu){ public Map<String,Object> listWithPlan( @RequestParam Map<String,Object> xmMenu){
return listWithState(xmMenu);
Map<String,Object> m = new HashMap<>();
RequestUtils.transformArray(xmMenu, "menuIds");
RequestUtils.transformArray(xmMenu, "tagIdList");
PageUtils.startPage(xmMenu);
Tips tips=new Tips("查询成功");
String menuId= (String) xmMenu.get("menuId");
Object menuIds= xmMenu.get("menuIds");
String projectId= (String) xmMenu.get("projectId");
String mmUserid= (String) xmMenu.get("mmUserid");
String pmenuId= (String) xmMenu.get("pmenuId");
String productId= (String) xmMenu.get("productId");
String excludeIterationId= (String) xmMenu.get("excludeIterationId");
User user = LoginUtils.getCurrentUserInfo();
xmMenu.put("userid",user.getUserid());
if( !StringUtils.hasText(menuId) && !(StringUtils.hasText(projectId) || StringUtils.hasText(mmUserid)|| StringUtils.hasText(pmenuId)||menuIds!=null
|| StringUtils.hasText(productId) || StringUtils.hasText(excludeIterationId) ) ){
xmMenu.put("compete",user.getUserid());
}
List<Map<String,Object>> xmMenuList = xmMenuService.selectListMapByWhereWithPlan(xmMenu); //列出XmMenu列表
PageUtils.responePage(m, xmMenuList);
if("1".equals(xmMenu.get("withParents")) && !"1".equals(xmMenu.get("isTop"))&& xmMenuList.size()>0){
Set<String> pidPathsSet=new HashSet<>();
Set<String> idSet=new HashSet<>();
for (Map<String, Object> map : xmMenuList) {
String id= (String) map.get("menuId");
idSet.add(id);
String pidPaths= (String) map.get("pidPaths");
pidPaths=PubTool.getPidPaths(pidPaths,id);
if(pidPaths.length()<=2){
continue;
}
pidPathsSet.add(pidPaths);
}
if(pidPathsSet!=null && pidPathsSet.size()>0){
List<Map<String,Object>> parentList=xmMenuService.selectListMapByWhereWithPlan(map("pidPathsList",pidPathsSet.stream().collect(Collectors.toList())));
parentList=parentList.stream().filter(i->!idSet.contains(i.get("menuId"))).collect(Collectors.toList());
if(parentList!=null && parentList.size()>0){
xmMenuList.addAll(parentList);
m.put("total", NumberUtil.getInteger(m.get("total"),0)+parentList.size());
}
}
}
m.put("data",xmMenuList);
m.put("tips", tips);
return m;
}
@RequestMapping(value="/listWithPhase",method=RequestMethod.GET)
public Map<String,Object> listWithPhase( @RequestParam Map<String,Object> xmMenu){
Map<String,Object> m = new HashMap<>();
RequestUtils.transformArray(xmMenu, "menuIds");
RequestUtils.transformArray(xmMenu, "tagIdList");
PageUtils.startPage(xmMenu);
Tips tips=new Tips("查询成功");
String menuId= (String) xmMenu.get("menuId");
Object menuIds= xmMenu.get("menuIds");
String projectId= (String) xmMenu.get("projectId");
String mmUserid= (String) xmMenu.get("mmUserid");
String pmenuId= (String) xmMenu.get("pmenuId");
String productId= (String) xmMenu.get("productId");
String excludeIterationId= (String) xmMenu.get("excludeIterationId");
User user = LoginUtils.getCurrentUserInfo();
xmMenu.put("userid",user.getUserid());
if( !StringUtils.hasText(menuId) && !(StringUtils.hasText(projectId) || StringUtils.hasText(mmUserid)|| StringUtils.hasText(pmenuId)||menuIds!=null
|| StringUtils.hasText(productId) || StringUtils.hasText(excludeIterationId) ) ){
xmMenu.put("compete",user.getUserid());
}
List<Map<String,Object>> xmMenuList = xmMenuService.selectListMapByWhereWithPhase(xmMenu); //列出XmMenu列表
PageUtils.responePage(m, xmMenuList);
if("1".equals(xmMenu.get("withParents")) && !"1".equals(xmMenu.get("isTop"))&& xmMenuList.size()>0){
Set<String> pidPathsSet=new HashSet<>();
Set<String> idSet=new HashSet<>();
for (Map<String, Object> map : xmMenuList) {
String id= (String) map.get("menuId");
idSet.add(id);
String pidPaths= (String) map.get("pidPaths");
pidPaths=PubTool.getPidPaths(pidPaths,id);
if(pidPaths.length()<=2){
continue;
}
pidPathsSet.add(pidPaths);
}
if(pidPathsSet!=null && pidPathsSet.size()>0){
List<Map<String,Object>> parentList=xmMenuService.selectListMapByWhereWithPhase(map("pidPathsList",pidPathsSet.stream().collect(Collectors.toList())));
parentList=parentList.stream().filter(i->!idSet.contains(i.get("menuId"))).collect(Collectors.toList());
if(parentList!=null && parentList.size()>0){
xmMenuList.addAll(parentList);
m.put("total", NumberUtil.getInteger(m.get("total"),0)+parentList.size());
}
}
}
m.put("data",xmMenuList);
m.put("tips", tips);
return m;
} }
/***/ /***/
@ApiOperation( value = "新增一条项目菜单表信息",notes="addXmMenu,主键如果为空,后台自动生成") @ApiOperation( value = "新增一条项目菜单表信息",notes="addXmMenu,主键如果为空,后台自动生成")

215
xm-core/src/main/java/com/xm/core/ctrl/XmPhaseMenuController.java

@ -0,0 +1,215 @@
package com.xm.core.ctrl;
import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.mdp.core.utils.ResponseHelper;
import com.xm.core.entity.XmMenu;
import com.xm.core.service.XmMenuService;
import com.xm.core.service.push.XmMenuPushMsgService;
import com.xm.core.vo.XmPhaseMenusVo;
import com.xm.core.vo.XmPhaseMenusVo;
import io.swagger.annotations.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* url编制采用rest风格,如对XM.xm_iteration_menu 计划定义的操作有增删改查,对应的url分别为:<br>
* 新增: xm/xmPhaseMenu/add <br>
* 查询: xm/xmPhaseMenu/list<br>
* 模糊查询: xm/xmPhaseMenu/listKey<br>
* 修改: xm/xmPhaseMenu/edit <br>
* 删除: xm/xmPhaseMenu/del<br>
* 批量删除: xm/xmPhaseMenu/batchDel<br>
* 组织 com.qqkj 顶级模块 oa 大模块 xm 小模块 <br>
* 实体 XmIterationMenu XM.xm_iteration_menu 当前主键(包括多主键): id;
***/
@RestController("xm.core.xmPhaseMenuController")
@RequestMapping(value="/**/xm/core/xmPhaseMenu")
@Api(tags={"计划定义操作接口"})
public class XmPhaseMenuController {
static Log logger=LogFactory.getLog(XmPhaseMenuController.class);
@Autowired
XmMenuPushMsgService xmMenuPushMsgService;
@Autowired
XmMenuService xmMenuService;
@Autowired
XmMenuController xmMenuController;
@ApiOperation( value = "查询计划定义信息列表",notes="listXmIterationMenu,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}")
@ApiImplicitParams({
@ApiImplicitParam(name="id",value="主键,主键",required=false),
@ApiImplicitParam(name="phaseId",value="对应的计划编号",required=false),
@ApiImplicitParam(name="menuId",value="需求编号",required=false),
@ApiImplicitParam(name="productId",value="产品编号",required=false),
@ApiImplicitParam(name="ctime",value="关联时间",required=false),
@ApiImplicitParam(name="relStatus",value="关联状态0不再关联1正常关联",required=false),
@ApiImplicitParam(name="pageSize",value="每页记录数",required=false),
@ApiImplicitParam(name="currentPage",value="当前页码,从1开始",required=false),
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false),
@ApiImplicitParam(name="orderFields",value="排序列 如性别、学生编号排序 ['sex','studentId']",required=false),
@ApiImplicitParam(name="orderDirs",value="排序方式,与orderFields对应,升序 asc,降序desc 如 性别 升序、学生编号降序 ['asc','desc']",required=false)
})
@ApiResponses({
@ApiResponse(code = 200,response= Map.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}")
})
@RequestMapping(value="/list",method=RequestMethod.GET)
public Map<String,Object> listWithPhase( @RequestParam Map<String,Object> xmPhaseMenu){
return xmMenuController.listWithPhase(xmPhaseMenu);
}
@ApiOperation( value = "根据主键列表批量删除计划定义信息",notes="batchDelXmIterationMenu,仅需要上传主键字段")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
})
@RequestMapping(value="/batchDel",method=RequestMethod.POST)
public Map<String,Object> batchDelXmIterationMenu(@RequestBody XmPhaseMenusVo xmPhaseMenus) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功将需求移出计划");
try{
List<String> menuIds=xmPhaseMenus.getMenuIds();
if(menuIds==null || menuIds.size()==0){
return ResponseHelper.failed("menuIds-0","需求编号不能为空");
}
List<XmMenu> menus=xmMenuService.selectListByIds(menuIds);
if(menus==null || menus.size()==0){
return ResponseHelper.failed("menus-0","需求已不存在");
}
/**
String productId=menus.get(0).getProductId();
if(menus.stream().filter(i->!productId.equals(i.getProductId())).findAny().isPresent()){
return ResponseHelper.failed("productId-0","批量操作的需求必须是同一个产品下的需求。");
}
**/
List<XmMenu> notJoins=new ArrayList<>();
List<XmMenu> status7=new ArrayList<>();
List<XmMenu> canDels=new ArrayList<>();
for (XmMenu menu : menus) {
if(!StringUtils.hasText(menu.getIterationId())){
notJoins.add(menu);
continue;
}
if("7".equals(menu.getStatus())){
status7.add(menu);
continue;
}
canDels.add(menu);
}
List<String> msgs=new ArrayList<>();
if(canDels.size()>0){
msgs.add("成功将"+canDels.size()+"个需求移出计划");
xmPhaseMenus.setMenuIds(canDels.stream().map(i->i.getMenuId()).collect(Collectors.toList()));
xmMenuService.batchUnProductPhase(xmPhaseMenus);
//this.xmMenuPushMsgService.pushMenuRelUsersMsg(user.getBranchId(), xmPhaseMenu.getMenuId(), user.getUserid(), user.getUsername(), user.getUsername()+"将需求【"+xmPhaseMenu.getMenuId()+"】加入计划");
}
if(status7.size()>0){
msgs.add("有"+status7.size()+"个需求状态为已上线,不能移出计划。【"+status7.stream().map(i->i.getMenuName()).collect(Collectors.joining(","))+"】");
}
if(notJoins.size()>0){
msgs.add("有"+notJoins.size()+"个需求未加入计划,无需移出。【"+notJoins.stream().map(i->i.getMenuName()).collect(Collectors.joining(","))+"】");
}
if(canDels.size()==0){
tips.setFailureMsg(msgs.stream().collect(Collectors.joining("\n")));
}else {
tips.setOkMsg(msgs.stream().collect(Collectors.joining("\n")));
}
}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;
}
@RequestMapping(value="/batchAdd",method=RequestMethod.POST)
public Map<String,Object> batchAddXmIterationMenu(@RequestBody XmPhaseMenusVo xmPhaseMenus) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功将需求与计划关联");
try{
if(!StringUtils.hasText(xmPhaseMenus.getPhaseId())){
return ResponseHelper.failed("phaseId-0","计划编号不能为空");
}
List<String> menuIds=xmPhaseMenus.getMenuIds();
if(menuIds==null || menuIds.size()==0){
return ResponseHelper.failed("menuIds-0","需求编号不能为空");
}
List<XmMenu> menus=xmMenuService.selectListByIds(menuIds);
if(menus==null || menus.size()==0){
return ResponseHelper.failed("menus-0","需求已不存在");
}
/**
String productId=menus.get(0).getProductId();
if(menus.stream().filter(i->!productId.equals(i.getProductId())).findAny().isPresent()){
return ResponseHelper.failed("productId-0","批量操作的需求必须是同一个产品下的需求。");
}
**/
List<XmMenu> hadJoin=new ArrayList<>();
List<XmMenu> ntype1=new ArrayList<>();
List<XmMenu> status789=new ArrayList<>();
List<XmMenu> canAdds=new ArrayList<>();
for (XmMenu menu : menus) {
if(StringUtils.hasText(menu.getIterationId())){
hadJoin.add(menu);
continue;
}
if("1".equals(menu.getNtype())){
ntype1.add(menu);
continue;
}
if("7".equals(menu.getStatus())||"8".equals(menu.getStatus())||"9".equals(menu.getStatus())){
status789.add(menu);
continue;
}
canAdds.add(menu);
}
List<String> msgs=new ArrayList<>();
if(canAdds.size()>0){
msgs.add("成功将"+canAdds.size()+"个需求加入计划");
xmPhaseMenus.setMenuIds(canAdds.stream().map(i->i.getMenuId()).collect(Collectors.toList()));
xmMenuService.batchProductPhase(xmPhaseMenus);
//this.xmMenuPushMsgService.pushMenuRelUsersMsg(user.getBranchId(), xmPhaseMenu.getMenuId(), user.getUserid(), user.getUsername(), user.getUsername()+"将需求【"+xmPhaseMenu.getMenuId()+"】加入计划");
}
if(status789.size()>0){
msgs.add("有"+status789.size()+"个需求状态为已上线、已下线、已删除状态,不能加入计划。【"+status789.stream().map(i->i.getMenuName()).collect(Collectors.joining(","))+"】");
}
if(hadJoin.size()>0){
msgs.add("有"+hadJoin.size()+"个需求已加入计划,不能重复加入。【"+hadJoin.stream().map(i->i.getMenuName()).collect(Collectors.joining(","))+"】");
}
if(ntype1.size()>0){
msgs.add("有"+ntype1.size()+"个为需求集,不用加入计划。【"+ntype1.stream().map(i->i.getMenuName()).collect(Collectors.joining(","))+"】");
}
if(canAdds.size()==0){
tips.setFailureMsg(msgs.stream().collect(Collectors.joining("\n")));
}else {
tips.setOkMsg(msgs.stream().collect(Collectors.joining("\n")));
}
}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;
}
}

16
xm-core/src/main/java/com/xm/core/service/XmMenuService.java

@ -27,12 +27,11 @@ public class XmMenuService extends BaseService {
XmMenuStateService xmMenuStateService; XmMenuStateService xmMenuStateService;
/** /**
* 连同功能关联的计划数据一起带出
* 连同功能关联的项目需求计划数据一起带出
* @param xmMenu * @param xmMenu
* @return * @return
*/ */
public List<Map<String, Object>> selectListMapByWhereWithPlan(Map<String, Object> xmMenu) { public List<Map<String, Object>> selectListMapByWhereWithPlan(Map<String, Object> xmMenu) {
// TODO Auto-generated method stub
return this.selectList("selectListMapByWhereWithPlan", xmMenu); return this.selectList("selectListMapByWhereWithPlan", xmMenu);
} }
/** /**
@ -41,10 +40,21 @@ public class XmMenuService extends BaseService {
* @return * @return
*/ */
public List<Map<String, Object>> selectListMapByWhereWithState(Map<String, Object> xmMenu) { public List<Map<String, Object>> selectListMapByWhereWithState(Map<String, Object> xmMenu) {
// TODO Auto-generated method stub
return this.selectList("selectListMapByWhereWithState", xmMenu); return this.selectList("selectListMapByWhereWithState", xmMenu);
} }
/**
* 连同功能关联的产品计划一并带出
* @param xmMenu
* @return
*/
public List<Map<String, Object>> selectListMapByWhereWithPhase(Map<String, Object> xmMenu) {
return this.selectList("selectListMapByWhereWithPhase", xmMenu);
}
public void updateMenuChildrenCntByMenuId(String menuId){ public void updateMenuChildrenCntByMenuId(String menuId){
super.update("updateMenuChildrenCntByMenuId",menuId); super.update("updateMenuChildrenCntByMenuId",menuId);

28
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMenuMapper.xml

@ -63,6 +63,17 @@
order by res.seq_no asc order by res.seq_no asc
</select> </select>
<select id="selectListMapByWhereWithPhase" parameterType="HashMap" resultType="HashMap">
select res.*,p.phase_name from xm_menu res left join xm_project_phase p on res.phase_id=p.id and res.product_id=p.product_id
<where>
<include refid="whereForMap"/>
<include refid="where"/>
</where>
order by res.seq_no asc
</select>
<update id="updateMenuChildrenCntByMenuId" parameterType="String"> <update id="updateMenuChildrenCntByMenuId" parameterType="String">
UPDATE xm_menu t UPDATE xm_menu t
LEFT JOIN ( SELECT count( 1 ) AS children_cnt, tt.pmenu_id AS menu_id FROM xm_menu tt WHERE tt.pmenu_id = #{menuId} ) t2 ON t2.menu_id = t.menu_id LEFT JOIN ( SELECT count( 1 ) AS children_cnt, tt.pmenu_id AS menu_id FROM xm_menu tt WHERE tt.pmenu_id = #{menuId} ) t2 ON t2.menu_id = t.menu_id
@ -116,6 +127,23 @@
#{item} #{item}
</foreach> </foreach>
</update> </update>
<update id="batchUnProductPhase" parameterType="com.xm.core.vo.XmPhaseMenusVo">
update xm_menu res set res.phase_id = null where res.menu_id in
<foreach collection="menuIds" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
<if test="phaseId!=null and phaseId!=''">
and res.phase_id=#{phaseId}
</if>
</update>
<update id="batchProductPhase" parameterType="com.xm.core.vo.XmPhaseMenusVo">
update xm_menu res set res.phase_id = #{phaseId} where res.menu_id in
<foreach collection="menuIds" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
</update>
<!--结束 自定义sql函数区域--> <!--结束 自定义sql函数区域-->

Loading…
Cancel
Save