添加机构信息管理功能
This commit is contained in:
@@ -3,8 +3,8 @@ package com.jsh.erp.constants;
|
||||
/**
|
||||
* @ClassName:BusinessConstants
|
||||
* @Description 业务字典类
|
||||
* @Author linshengming
|
||||
* @Date 2018-9-15 17:58
|
||||
* @Author qiankunpingtai
|
||||
* @Date 2019-3-6 17:58
|
||||
* @Version 1.0
|
||||
**/
|
||||
public class BusinessConstants {
|
||||
@@ -85,6 +85,21 @@ public class BusinessConstants {
|
||||
public static final String MATERIAL_CATEGORY_STATUS_DEFAULT = "0";
|
||||
public static final String MATERIAL_CATEGORY_STATUS_ENABLE = "1";
|
||||
public static final String MATERIAL_CATEGORY_STATUS_DELETE = "2";
|
||||
/**
|
||||
* 机构状态
|
||||
* 1未营业、2正常营业、3暂停营业、4终止营业,5已除名
|
||||
* */
|
||||
public static final String ORGANIZATION_STCD_NOT_OPEN = "1";
|
||||
public static final String ORGANIZATION_STCD_OPEN = "2";
|
||||
public static final String ORGANIZATION_STCD_BUSINESS_SUSPENDED = "3";
|
||||
public static final String ORGANIZATION_STCD_BUSINESS_TERMINATED = "4";
|
||||
public static final String ORGANIZATION_STCD_REMOVED = "5";
|
||||
/**
|
||||
* 根机构编号
|
||||
* 根机构编号默认为01
|
||||
* */
|
||||
public static final String ORGANIZATION_ROOT_NO = "01";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -75,6 +75,28 @@ public class ExceptionConstants {
|
||||
//商品类别编号已存在
|
||||
public static final int MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE = 7500003;
|
||||
public static final String MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG = "商品类别编号已存在";
|
||||
/**
|
||||
* 机构
|
||||
* type = 110
|
||||
* */
|
||||
//添加机构信息失败
|
||||
public static final int ORGANIZATION_ADD_FAILED_CODE = 11000000;
|
||||
public static final String ORGANIZATION_ADD_FAILED_MSG = "添加机构信息失败";
|
||||
//删除机构信息失败
|
||||
public static final int ORGANIZATION_DELETE_FAILED_CODE = 11000001;
|
||||
public static final String ORGANIZATION_DELETE_FAILED_MSG = "删除机构信息失败";
|
||||
//修改机构信息失败
|
||||
public static final int ORGANIZATION_EDIT_FAILED_CODE = 11000002;
|
||||
public static final String ORGANIZATION_EDIT_FAILED_MSG = "修改机构信息失败";
|
||||
//机构编号已存在
|
||||
public static final int ORGANIZATION_NO_ALREADY_EXISTS_CODE = 11000003;
|
||||
public static final String ORGANIZATION_NO_ALREADY_EXISTS_MSG = "机构编号已存在";
|
||||
//根机构不允许删除
|
||||
public static final int ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_CODE = 11000004;
|
||||
public static final String ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_MSG = "根机构不允许删除";
|
||||
//根机构不允许修改
|
||||
public static final int ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE = 11000005;
|
||||
public static final String ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG = "根机构不允许修改";
|
||||
|
||||
/**
|
||||
* 标准正常返回/操作成功返回
|
||||
|
||||
@@ -137,8 +137,8 @@ public class MaterialCategoryController {
|
||||
MaterialCategory mc= JSON.parseObject(beanJson, MaterialCategory.class);
|
||||
int i= materialCategoryService.editMaterialCategory(mc);
|
||||
if(i<1){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_ADD_FAILED_CODE,
|
||||
ExceptionConstants.MATERIAL_CATEGORY_ADD_FAILED_MSG);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_EDIT_FAILED_CODE,
|
||||
ExceptionConstants.MATERIAL_CATEGORY_EDIT_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
159
src/main/java/com/jsh/erp/controller/OrganizationController.java
Normal file
159
src/main/java/com/jsh/erp/controller/OrganizationController.java
Normal file
@@ -0,0 +1,159 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.MaterialCategory;
|
||||
import com.jsh.erp.datasource.entities.Organization;
|
||||
import com.jsh.erp.datasource.vo.TreeNode;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.materialCategory.MaterialCategoryService;
|
||||
import com.jsh.erp.service.organization.OrganizationService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
*
|
||||
* create time: 2019/3/6 10:54
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/organization")
|
||||
public class OrganizationController {
|
||||
private Logger logger = LoggerFactory.getLogger(OrganizationController.class);
|
||||
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
/**
|
||||
* 根据id来查询机构信息
|
||||
* @param id
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/findById")
|
||||
public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
try {
|
||||
List<Organization> dataList = organizationService.findById(id);
|
||||
JSONObject outer = new JSONObject();
|
||||
if (null != dataList) {
|
||||
for (Organization org : dataList) {
|
||||
outer.put("id", org.getId());
|
||||
outer.put("orgFullName", org.getOrgFullName());
|
||||
outer.put("orgAbr", org.getOrgAbr());
|
||||
outer.put("orgParentNo", org.getOrgParentNo());
|
||||
List<Organization> dataParentList = organizationService.findByOrgNo(org.getOrgNo());
|
||||
if(dataParentList!=null&&dataParentList.size()>0){
|
||||
//父级机构名称显示简称
|
||||
outer.put("orgParentName", dataParentList.get(0).getOrgAbr());
|
||||
}
|
||||
outer.put("orgTpcd", org.getOrgTpcd());
|
||||
outer.put("orgStcd", org.getOrgStcd());
|
||||
outer.put("orgNo", org.getOrgNo());
|
||||
outer.put("sort", org.getSort());
|
||||
outer.put("orgCreateTime", sdf.format(org.getOrgCreateTime()));
|
||||
outer.put("orgStopTime", sdf.format(org.getOrgStopTime()));
|
||||
outer.put("remark", org.getRemark());
|
||||
}
|
||||
}
|
||||
res.code = 200;
|
||||
res.data = outer;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 获取机构树数据
|
||||
* create time: 2019/2/19 11:49
|
||||
* @Param:
|
||||
* @return com.alibaba.fastjson.JSONArray
|
||||
*/
|
||||
@RequestMapping(value = "/getOrganizationTree")
|
||||
public JSONArray getOrganizationTree() throws Exception{
|
||||
JSONArray arr=new JSONArray();
|
||||
List<TreeNode> organizationTree= organizationService.getOrganizationTree();
|
||||
if(organizationTree!=null&&organizationTree.size()>0){
|
||||
for(TreeNode node:organizationTree){
|
||||
String str=JSON.toJSONString(node);
|
||||
JSONObject obj=JSON.parseObject(str);
|
||||
arr.add(obj) ;
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 新增机构信息
|
||||
* create time: 2019/2/19 17:17
|
||||
* @Param: beanJson
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@RequestMapping(value = "/addOrganization")
|
||||
public Object addOrganization(@RequestParam("info") String beanJson) throws Exception {
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
Organization org= JSON.parseObject(beanJson, Organization.class);
|
||||
int i= organizationService.addOrganization(org);
|
||||
if(i<1){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_ADD_FAILED_CODE,
|
||||
ExceptionConstants.ORGANIZATION_ADD_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 修改机构信息
|
||||
* create time: 2019/2/20 9:30
|
||||
* @Param: beanJson
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@RequestMapping(value = "/editOrganization")
|
||||
public Object editOrganization(@RequestParam("info") String beanJson) throws Exception {
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
Organization org= JSON.parseObject(beanJson, Organization.class);
|
||||
int i= organizationService.editOrganization(org);
|
||||
if(i<1){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_EDIT_FAILED_CODE,
|
||||
ExceptionConstants.ORGANIZATION_EDIT_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 批量删除机构信息
|
||||
* create time: 2019/2/19 17:26
|
||||
* @Param: ids
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@RequestMapping(value = "/batchDeleteOrganization")
|
||||
public Object batchDeleteOrganization(@RequestParam("ids") String ids) throws Exception {
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
int i= organizationService.batchDeleteOrganizationByIds(ids);
|
||||
if(i<1){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_DELETE_FAILED_CODE,
|
||||
ExceptionConstants.ORGANIZATION_DELETE_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.jsh.erp.datasource.mappers;
|
||||
|
||||
import com.jsh.erp.datasource.entities.MaterialCategory;
|
||||
import com.jsh.erp.datasource.entities.Organization;
|
||||
import com.jsh.erp.datasource.vo.TreeNode;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @Author: cjl
|
||||
* @Date: 2019/3/6 15:51
|
||||
*/
|
||||
public interface OrganizationMapperEx {
|
||||
|
||||
|
||||
List<TreeNode> getNodeTree();
|
||||
List<TreeNode> getNextNodeTree(@Param("id") Long id);
|
||||
|
||||
int addOrganization(Organization org);
|
||||
|
||||
int batchDeleteOrganizationByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
|
||||
|
||||
int editOrganization(Organization org);
|
||||
List <Organization> getOrganizationRootByIds(@Param("ids") String ids[]);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.jsh.erp.service.organization;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.utils.Constants;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @Author: cjl
|
||||
* @Date: 2019/3/6 15:09
|
||||
*/
|
||||
@Service(value = "organization_component")
|
||||
@OrganizationResource
|
||||
public class OrganizationComponent implements ICommonQuery {
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> parameterMap) {
|
||||
return getOrganizationList(parameterMap);
|
||||
}
|
||||
private List<?> getOrganizationList(Map<String, String> map) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Long counts(Map<String, String> parameterMap) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return organizationService.insertOrganization(beanJson,request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return organizationService.updateOrganization(beanJson,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return organizationService.deleteOrganization(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return organizationService.batchDeleteOrganization(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.jsh.erp.service.organization;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Description
|
||||
* 机构
|
||||
* @Author: cjl
|
||||
* @Date: 2019/3/6 15:10
|
||||
*/
|
||||
@ResourceInfo(value = "organization", type = 110)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface OrganizationResource {
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.jsh.erp.service.organization;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.Organization;
|
||||
import com.jsh.erp.datasource.entities.OrganizationExample;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.mappers.OrganizationMapper;
|
||||
import com.jsh.erp.datasource.mappers.OrganizationMapperEx;
|
||||
import com.jsh.erp.datasource.vo.TreeNode;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @Author: cjl
|
||||
* @Date: 2019/3/6 15:10
|
||||
*/
|
||||
@Service
|
||||
public class OrganizationService {
|
||||
private Logger logger = LoggerFactory.getLogger(OrganizationService.class);
|
||||
|
||||
@Resource
|
||||
private OrganizationMapper organizationMapper;
|
||||
@Resource
|
||||
private OrganizationMapperEx organizationMapperEx;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int insertOrganization(String beanJson, HttpServletRequest request) {
|
||||
Organization organization = JSONObject.parseObject(beanJson, Organization.class);
|
||||
return organizationMapper.insertSelective(organization);
|
||||
}
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int updateOrganization(String beanJson, Long id) {
|
||||
Organization organization = JSONObject.parseObject(beanJson, Organization.class);
|
||||
organization.setId(id);
|
||||
return organizationMapper.updateByPrimaryKeySelective(organization);
|
||||
}
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int deleteOrganization(Long id) {
|
||||
return organizationMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchDeleteOrganization(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
OrganizationExample example = new OrganizationExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return organizationMapper.deleteByExample(example);
|
||||
}
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int addOrganization(Organization org) throws Exception{
|
||||
//新增时间
|
||||
Date date=new Date();
|
||||
User userInfo=userService.getCurrentUser();
|
||||
org.setCreateTime(date);
|
||||
//新增人
|
||||
org.setCreator(userInfo==null?null:userInfo.getId());
|
||||
//修改时间
|
||||
org.setUpdateTime(date);
|
||||
//修改人
|
||||
org.setUpdater(userInfo==null?null:userInfo.getId());
|
||||
/**
|
||||
*添加的时候检测机构编号是否已存在
|
||||
* */
|
||||
if(StringUtil.isNotEmpty(org.getOrgNo())){
|
||||
checkOrgNoIsExists(org.getOrgNo(),null);
|
||||
}
|
||||
/**
|
||||
* 未指定父级机构的时候默认放在根机构下
|
||||
* */
|
||||
if(StringUtil.isEmpty(org.getOrgParentNo())){
|
||||
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_NO);
|
||||
}
|
||||
return organizationMapperEx.addOrganization(org);
|
||||
}
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int editOrganization(Organization org)throws Exception {
|
||||
//修改时间
|
||||
org.setUpdateTime(new Date());
|
||||
User userInfo=userService.getCurrentUser();
|
||||
//修改人
|
||||
org.setUpdater(userInfo==null?null:userInfo.getId());
|
||||
/**
|
||||
* 修改的时候检测机构编号是否已存在
|
||||
* */
|
||||
if(StringUtil.isNotEmpty(org.getOrgNo())){
|
||||
checkOrgNoIsExists(org.getOrgNo(),org.getId());
|
||||
}
|
||||
/**
|
||||
* 未指定父级机构的时候默认放在根机构下
|
||||
* */
|
||||
if(StringUtil.isEmpty(org.getOrgParentNo())){
|
||||
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_NO);
|
||||
}
|
||||
/**
|
||||
* 添加一个限制,根机构不允许修改
|
||||
* */
|
||||
if(BusinessConstants.ORGANIZATION_ROOT_NO.equals(org.getOrgNo())){
|
||||
logger.error("异常码[{}],异常提示[{}],参数,orgNo[{}]",
|
||||
ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE,ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG,org.getOrgNo());
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE,
|
||||
ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG);
|
||||
}
|
||||
return organizationMapperEx.editOrganization(org);
|
||||
}
|
||||
|
||||
public List<TreeNode> getOrganizationTree()throws Exception {
|
||||
return organizationMapperEx.getNodeTree();
|
||||
}
|
||||
|
||||
public List<Organization> findById(Long id) throws Exception{
|
||||
OrganizationExample example = new OrganizationExample();
|
||||
example.createCriteria().andIdEqualTo(id);
|
||||
return organizationMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Organization> findByOrgNo(String orgNo)throws Exception {
|
||||
OrganizationExample example = new OrganizationExample();
|
||||
example.createCriteria().andOrgNoEqualTo(orgNo).andOrgStcdNotEqualTo(BusinessConstants.ORGANIZATION_STCD_REMOVED);
|
||||
return organizationMapper.selectByExample(example);
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 检查机构编号是否已经存在
|
||||
* create time: 2019/3/7 10:01
|
||||
* @Param: orgNo
|
||||
* @return void
|
||||
*/
|
||||
public void checkOrgNoIsExists(String orgNo,Long id)throws Exception {
|
||||
List<Organization> orgList=findByOrgNo(orgNo);
|
||||
if(orgList!=null&&orgList.size()>0){
|
||||
if(orgList.size()>1){
|
||||
logger.error("异常码[{}],异常提示[{}],参数,orgNo[{}]",
|
||||
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG,orgNo);
|
||||
//获取的数据条数大于1,机构编号已存在
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,
|
||||
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG);
|
||||
}
|
||||
if(id!=null){
|
||||
if(!orgList.get(0).getId().equals(id)){
|
||||
//数据条数等于1,但是和编辑的数据的id不相同
|
||||
logger.error("异常码[{}],异常提示[{}],参数,orgNo[{}],id[{}]",
|
||||
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG,orgNo,id);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,
|
||||
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG);
|
||||
}
|
||||
}else{
|
||||
logger.error("异常码[{}],异常提示[{}],参数,orgNo[{}]",
|
||||
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG,orgNo);
|
||||
//数据条数等于1,但此时是新增
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,
|
||||
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchDeleteOrganizationByIds(String ids) throws Exception{
|
||||
User userInfo=userService.getCurrentUser();
|
||||
String [] idArray=ids.split(",");
|
||||
/**
|
||||
* 添加一个限制,根机构不允许删除
|
||||
* */
|
||||
List<Organization> orgRootList=organizationMapperEx.getOrganizationRootByIds(idArray);
|
||||
if(orgRootList!=null&&orgRootList.size()>0){
|
||||
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
|
||||
ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_CODE,ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_MSG,ids);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_CODE,
|
||||
ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_MSG);
|
||||
}
|
||||
|
||||
return organizationMapperEx.batchDeleteOrganizationByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||
}
|
||||
}
|
||||
92
src/main/resources/mapper_xml/OrganizationMapperEx.xml
Normal file
92
src/main/resources/mapper_xml/OrganizationMapperEx.xml
Normal file
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jsh.erp.datasource.mappers.OrganizationMapperEx">
|
||||
|
||||
<resultMap id="BaseTreeResultMap" type="com.jsh.erp.datasource.vo.TreeNode">
|
||||
<result column="id" property="id"/>
|
||||
<result column="org_abr" property="text"/>
|
||||
<result column="org_no" property="attributes"/>
|
||||
<collection column="org_no" property="children" javaType="java.util.ArrayList"
|
||||
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="NextTreeResultMap" type="com.jsh.erp.datasource.vo.TreeNode">
|
||||
<result column="id" property="id"/>
|
||||
<result column="org_abr" property="text"/>
|
||||
<result column="org_no" property="attributes"/>
|
||||
<collection column="org_no" property="children" javaType="java.util.ArrayList"
|
||||
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, org_abr,org_no
|
||||
</sql>
|
||||
|
||||
<select id="getNextNodeTree" resultMap="NextTreeResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM jsh_organization
|
||||
WHERE org_parent_no = #{org_no}
|
||||
and org_stcd !='5'
|
||||
order by sort asc
|
||||
</select>
|
||||
|
||||
<select id="getNodeTree" resultMap="BaseTreeResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM jsh_organization
|
||||
WHERE org_parent_no = -1
|
||||
and org_stcd !='5'
|
||||
order by sort asc
|
||||
</select>
|
||||
<insert id="addOrganization" parameterType="com.jsh.erp.datasource.entities.Organization"
|
||||
useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||
insert into jsh_organization
|
||||
(org_no, org_full_name,
|
||||
org_abr, org_tpcd, org_stcd,
|
||||
org_parent_no, sort, remark,
|
||||
create_time, creator, update_time,
|
||||
updater, org_create_time, org_stop_time)
|
||||
values
|
||||
(#{orgNo,jdbcType=VARCHAR}, #{orgFullName,jdbcType=VARCHAR},
|
||||
#{orgAbr,jdbcType=VARCHAR}, #{orgTpcd,jdbcType=VARCHAR}, #{orgStcd,jdbcType=CHAR},
|
||||
#{orgParentNo,jdbcType=VARCHAR}, #{sort,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=TIMESTAMP}, #{creator,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP},
|
||||
#{updater,jdbcType=BIGINT}, #{orgCreateTime,jdbcType=TIMESTAMP}, #{orgStopTime,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
<update id="batchDeleteOrganizationByIds">
|
||||
update jsh_organization
|
||||
set update_Time=#{updateTime},updater=#{updater},org_stcd='5'
|
||||
where id in (
|
||||
<foreach collection="ids" item="id" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</update>
|
||||
<update id="editOrganization">
|
||||
update jsh_organization
|
||||
set update_time=#{updateTime},updater=#{updater},
|
||||
org_no = #{orgNo},org_full_name = #{orgFullName},
|
||||
org_abr = #{orgAbr},org_tpcd = #{orgTpcd},
|
||||
org_stcd = #{orgStcd},org_parent_no = #{orgParentNo},
|
||||
sort = #{sort},remark = #{remark},
|
||||
org_create_time = #{orgCreateTime},org_stop_time = #{orgStopTime}
|
||||
where id =#{id}
|
||||
</update>
|
||||
|
||||
<select id="getOrganizationRootByIds" resultMap="com.jsh.erp.datasource.mappers.OrganizationMapper.BaseResultMap">
|
||||
select * from jsh_organization
|
||||
where
|
||||
1=1
|
||||
and org_stcd!='5'
|
||||
and org_parent_no='-1'
|
||||
and org_abr='根机构'
|
||||
and id in (
|
||||
<foreach collection="ids" item="id" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -48,7 +48,7 @@
|
||||
<table tableName="jsh_asset" domainObjectName="Asset"></table>
|
||||
<table tableName="jsh_assetcategory" domainObjectName="AssetCategory"></table>
|
||||
<table tableName="jsh_assetname" domainObjectName="AssetName"></table>-->
|
||||
<table tableName="jsh_depot" domainObjectName="Depot"></table>
|
||||
<!--<table tableName="jsh_depot" domainObjectName="Depot"></table>-->
|
||||
<!--<table tableName="jsh_depothead" domainObjectName="DepotHead"></table>
|
||||
<table tableName="jsh_depotitem" domainObjectName="DepotItem"></table>
|
||||
<table tableName="jsh_functions" domainObjectName="Functions"></table>
|
||||
@@ -65,5 +65,7 @@
|
||||
<table tableName="jsh_user" domainObjectName="User"></table>
|
||||
<table tableName="jsh_userbusiness" domainObjectName="UserBusiness"></table>-->
|
||||
<!--<table tableName="jsh_serial_number" domainObjectName="SerialNumber"></table>-->
|
||||
<table tableName="jsh_organization" domainObjectName="Organization"></table>
|
||||
<!--<table tableName="jsh_orga_user_rel" domainObjectName="OrgaUserRel"></table>-->
|
||||
</context>
|
||||
</generatorConfiguration>
|
||||
|
||||
Reference in New Issue
Block a user