Browse Source

添加节点类型、标签等

master
陈裕财 4 years ago
parent
commit
fe2aa7756e
  1. 40
      xm-core/src/main/java/com/xm/core/ctrl/XmProductController.java
  2. 32
      xm-core/src/main/java/com/xm/core/entity/XmProductCopyVo.java
  3. 63
      xm-core/src/main/java/com/xm/core/service/XmProductService.java

40
xm-core/src/main/java/com/xm/core/ctrl/XmProductController.java

@ -3,11 +3,14 @@ package com.xm.core.ctrl;
import com.mdp.core.entity.Tips; import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException; import com.mdp.core.err.BizException;
import com.mdp.core.utils.RequestUtils; import com.mdp.core.utils.RequestUtils;
import com.mdp.core.utils.ResponseHelper;
import com.mdp.mybatis.PageUtils; import com.mdp.mybatis.PageUtils;
import com.mdp.qx.HasQx; import com.mdp.qx.HasQx;
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.XmProduct;
import com.xm.core.entity.XmProductCopyVo;
import com.xm.core.entity.XmProject;
import com.xm.core.service.XmProductService; import com.xm.core.service.XmProductService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -144,28 +147,29 @@ public class XmProductController {
}) })
@HasQx(value = "xm_core_xmProduct_copyTo",name = "通过复制创建产品/战略规划等",categoryId = "admin-xm",categoryName = "管理端-项目管理系统") @HasQx(value = "xm_core_xmProduct_copyTo",name = "通过复制创建产品/战略规划等",categoryId = "admin-xm",categoryName = "管理端-项目管理系统")
@RequestMapping(value="/copyTo",method=RequestMethod.POST) @RequestMapping(value="/copyTo",method=RequestMethod.POST)
public Map<String,Object> copyTo(@RequestBody XmProduct xmProduct) {
public Map<String,Object> copyTo(@RequestBody XmProductCopyVo xmProduct) {
Map<String,Object> m = new HashMap<>(); Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功新增一条数据");
Tips tips=new Tips("拷贝成功");
try{ try{
if(StringUtils.isEmpty(xmProduct.getId())) {
xmProduct.setId(xmProductService.createKey("id"));
}else{
XmProduct xmProductQuery = new XmProduct(xmProduct.getId());
if(xmProductService.countByWhere(xmProductQuery)>0){
tips.setFailureMsg("编号重复,请修改编号再提交");
m.put("tips", tips);
return m;
}
User user= LoginUtils.getCurrentUserInfo();
if( !StringUtils.hasText(xmProduct.getId())){
return ResponseHelper.failed("id-0","请上送原产品编号参数id");
} }
User user=LoginUtils.getCurrentUserInfo();
if(StringUtils.isEmpty(xmProduct.getPmUserid())) {
xmProduct.setPmUserid(user.getUserid());
xmProduct.setPmUsername(user.getUsername());
if( !StringUtils.hasText(xmProduct.getProductName())){
return ResponseHelper.failed("productName-0","请上送新产品名称");
} }
xmProduct.setCtime(new Date());
xmProductService.insert(xmProduct);
m.put("data",xmProduct);
if(StringUtils.hasText(xmProduct.getCode())){
XmProduct pq=new XmProduct();
pq.setBranchId(user.getBranchId());
pq.setCode(xmProduct.getCode());
List<XmProduct> xmProductList=this.xmProductService.selectListByWhere(pq);
if(xmProductList!=null && xmProductList.size()>0){
return ResponseHelper.failed("code-exists","产品编码【"+xmProduct.getCode()+"】已存在,,请重新输入新的产品编码,如果为空,后台自动生成");
}
}
XmProduct xmProductNew=xmProductService.copyTo(user,xmProduct);
m.put("data",xmProductNew);
}catch (BizException e) { }catch (BizException e) {
tips=e.getTips(); tips=e.getTips();
logger.error("",e); logger.error("",e);

32
xm-core/src/main/java/com/xm/core/entity/XmProductCopyVo.java

@ -18,4 +18,36 @@ public class XmProductCopyVo {
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getIsTpl() {
return isTpl;
}
public void setIsTpl(String isTpl) {
this.isTpl = isTpl;
}
public String getCopyMenu() {
return copyMenu;
}
public void setCopyMenu(String copyMenu) {
this.copyMenu = copyMenu;
}
} }

63
xm-core/src/main/java/com/xm/core/service/XmProductService.java

@ -1,10 +1,17 @@
package com.xm.core.service; package com.xm.core.service;
import com.mdp.core.err.BizException;
import com.mdp.core.service.BaseService; import com.mdp.core.service.BaseService;
import com.mdp.safe.client.entity.User;
import com.xm.core.entity.XmMenu; import com.xm.core.entity.XmMenu;
import com.xm.core.entity.XmProduct;
import com.xm.core.entity.XmProductCopyVo;
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 java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -40,12 +47,66 @@ public class XmProductService extends BaseService {
/** /**
* 连同产品关联的状态数据一起带出 * 连同产品关联的状态数据一起带出
* @param xmMenu
* @param iterationMap
* @return * @return
*/ */
public List<Map<String, Object>> selectListMapByWhereWithState(Map<String, Object> iterationMap) { public List<Map<String, Object>> selectListMapByWhereWithState(Map<String, Object> iterationMap) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return this.selectList("selectListMapByWhereWithState", iterationMap); return this.selectList("selectListMapByWhereWithState", iterationMap);
} }
public XmProduct copyTo(User user, XmProductCopyVo xmProduct) {
XmProduct pq=new XmProduct();
pq.setId(xmProduct.getId());
XmProduct xmProductDb=this.selectOneObject(pq);
if(xmProductDb==null){
throw new BizException("产品不存在");
}
XmProduct xmProductTo=new XmProduct();
BeanUtils.copyProperties(xmProductDb,xmProductTo);
xmProductTo.setId(null);
xmProductTo.setProductName(xmProduct.getProductName());
xmProductTo.setCode(xmProduct.getCode());
xmProductTo.setBranchId(user.getBranchId());
xmProductTo.setDeptid(user.getDeptid());
xmProductTo.setDeptName(user.getDeptName());
xmProductTo.setAdmUserid(user.getUserid());
xmProductTo.setAdmUsername(user.getUsername());
xmProductTo.setPmUserid(user.getUserid());
xmProductTo.setPmUsername(user.getUsername());
xmProductTo.setCtime(new Date());
xmProductTo.setAssistantUserid(user.getUserid());
xmProductTo.setAssistantUsername(user.getUsername());
if(xmProduct.getProductName().equals(xmProductDb.getProductName())){
xmProductTo.setProductName(xmProduct.getProductName()+"(复制)");
}
if("1".equals(xmProduct.getIsTpl())){
xmProductTo.setIsTpl("1");
}
if("1".equals(xmProduct.getCopyMenu())){
XmMenu mq=new XmMenu();
mq.setProductId(xmProduct.getId());
List<XmMenu> xmMenus=this.xmMenuService.selectListByWhere(mq);
Map<String,String> idMap=new HashMap<>();
if(xmMenus!=null && xmMenus.size()>0){
for (XmMenu node : xmMenus) {
idMap.put(node.getMenuId(),this.xmMenuService.createKey("id"));
}
for (XmMenu node : xmMenus) {
String oldId=node.getMenuId();
String newId=idMap.get(oldId);
node.setMenuId(newId);
node.setProductId(xmProductTo.getId());
node.setPmenuId(idMap.get(node.getPmenuId()));
node.setCtime(new Date());
node.setMmUserid(user.getUserid());
node.setMmUsername(user.getUsername());
}
this.xmMenuService.parentIdPathsCalcBeforeSave(xmMenus);
this.xmMenuService.doBatchInsert(xmMenus);
}
}
return xmProductTo;
}
} }
Loading…
Cancel
Save