去除外键之账户信息表jsh_account相关修改

This commit is contained in:
qiankunpingtai
2019-04-10 14:37:36 +08:00
parent 85bc297e3b
commit 76034a1298
11 changed files with 197 additions and 6 deletions

View File

@@ -200,6 +200,14 @@ public class BusinessConstants {
public static final String TYPE_NAME_ROLE_APP = "RoleAPP";
public static final String TYPE_NAME_ROLE_FUNCTIONS = "RoleFunctions";
/**
* 删除类型
* 1正常删除
* 2强制删除
* */
public static final String DELETE_TYPE_NORMAL = "1";
public static final String DELETE_TYPE_FORCE = "2";

View File

@@ -23,6 +23,17 @@ public class ExceptionConstants {
**/
public static final int SERVICE_SYSTEM_ERROR_CODE = 500;
public static final String SERVICE_SYSTEM_ERROR_MSG = "未知异常";
/**
* 删除操作被拒绝,请联系管理员
**/
public static final int DELETE_REFUSED_CODE = 600;
public static final String DELETE_REFUSED_MSG = "删除操作被拒绝,请联系管理员";
/**
* 检测到存在依赖数据,是否强制删除?
**/
public static final int DELETE_FORCE_CONFIRM_CODE = 601;
public static final String DELETE_FORCE_CONFIRM_MSG = "检测到存在依赖数据,是否强制删除?";
/**
* 用户信息
* type = 5

View File

@@ -1,7 +1,9 @@
package com.jsh.erp.controller;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Account;
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
@@ -150,10 +152,28 @@ public class AccountController {
* @return java.lang.Object
*/
@RequestMapping(value = "/batchDeleteAccountByIds")
public Object batchDeleteAccountByIds(@RequestParam("ids") String ids) throws Exception {
public Object batchDeleteAccountByIds(@RequestParam("ids") String ids,@RequestParam(value="deleteType",
required =false,defaultValue=BusinessConstants.DELETE_TYPE_NORMAL)String deleteType) throws Exception {
JSONObject result = ExceptionConstants.standardSuccess();
int i= accountService.batchDeleteAccountByIds(ids);
/**
* create by: qiankunpingtai
* create time: 2019/4/10 10:19
* websitehttps://qiankunpingtai.cn
* description:
* 出于兼容性考虑,没有传递删除类型时,默认为正常删除
*/
int i=0;
if(BusinessConstants.DELETE_TYPE_NORMAL.equals(deleteType)){
i= accountService.batchDeleteAccountByIdsNormal(ids);
}else if(BusinessConstants.DELETE_TYPE_FORCE.equals(deleteType)){
i= accountService.batchDeleteAccountByIds(ids);
}else{
logger.error("异常码[{}],异常提示[{}],参数,ids[{}],deleteType[{}]",
ExceptionConstants.DELETE_REFUSED_CODE,ExceptionConstants.DELETE_REFUSED_MSG,ids,deleteType);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_REFUSED_CODE,
ExceptionConstants.DELETE_REFUSED_MSG);
}
if(i<1){
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
ExceptionConstants.ACCOUNT_DELETE_FAILED_CODE,ExceptionConstants.ACCOUNT_DELETE_FAILED_MSG,ids);

View File

@@ -36,5 +36,7 @@ public interface AccountHeadMapperEx {
List<AccountHeadVo4ListEx> getDetailByNumber(
@Param("billNo") String billNo);
int batchDeleteAccountHeadByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
int batchDeleteAccountHeadByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String[] ids);
List<AccountHead> getAccountHeadListByAccountIds(@Param("accountIds") String[] accountIds);
}

View File

@@ -25,5 +25,7 @@ public interface AccountItemMapperEx {
List<AccountItemVo4List> getDetailList(
@Param("headerId") Long headerId);
int batchDeleteAccountItemByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
int batchDeleteAccountItemByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String[] ids);
List<AccountItem> getAccountItemListByAccountIds(@Param("accountIds") String[] accountIds);
}

View File

@@ -115,4 +115,6 @@ public interface DepotHeadMapperEx {
Long getBuildOnlyNumber(@Param("seq_name") String seq_name);
int batchDeleteDepotHeadByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
List<DepotHead> getDepotHeadListByAccountIds(@Param("accountIds") String[] accountIds);
}

View File

@@ -1,11 +1,14 @@
package com.jsh.erp.service.account;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.*;
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
import com.jsh.erp.datasource.vo.AccountVo4List;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil;
@@ -38,13 +41,19 @@ public class AccountService {
@Resource
private DepotHeadMapper depotHeadMapper;
@Resource
private DepotHeadMapperEx depotHeadMapperEx;
@Resource
private AccountHeadMapper accountHeadMapper;
@Resource
private AccountHeadMapperEx accountHeadMapperEx;
@Resource
private AccountItemMapper accountItemMapper;
@Resource
private AccountItemMapperEx accountItemMapperEx;
@Resource
private LogService logService;
@Resource
private UserService userService;
@@ -330,4 +339,64 @@ public class AccountService {
String [] idArray=ids.split(",");
return accountMapperEx.batchDeleteAccountByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}
/**
* create by: qiankunpingtai
* websitehttps://qiankunpingtai.cn
* description:
* 正常删除,要考虑数据完整性,进行完整性校验
* create time: 2019/4/10 10:31
* @Param: ids
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountByIdsNormal(String ids) throws Exception{
/**
* 校验:
* 1、财务主表 jsh_accounthead
* 2、财务子表 jsh_accountitem
* 3、单据主表 jsh_depothead
* 是否有相关数据
* */
int deleteTotal=0;
if(StringUtils.isEmpty(ids)){
return deleteTotal;
}
String [] idArray=ids.split(",");
/**
* 校验财务主表 jsh_accounthead
* */
List<AccountHead> accountHeadList=accountHeadMapperEx.getAccountHeadListByAccountIds(idArray);
if(accountHeadList!=null&&accountHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
}
/**
* 校验财务子表 jsh_accountitem
* */
List<AccountItem> accountItemList=accountItemMapperEx.getAccountItemListByAccountIds(idArray);
if(accountItemList!=null&&accountItemList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
}
/**
* 校验单据主表 jsh_depothead
* */
List<DepotHead> depotHeadList=depotHeadMapperEx.getDepotHeadListByAccountIds(idArray);
if(depotHeadList!=null&&depotHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
}
/**
* 校验通过执行删除操作
* */
deleteTotal= batchDeleteAccountByIds(ids);
return deleteTotal;
}
}

View File

@@ -88,4 +88,16 @@
</foreach>
)
</update>
<select id="getAccountHeadListByAccountIds" resultMap="com.jsh.erp.datasource.mappers.AccountHeadMapper.BaseResultMap">
select
<include refid="com.jsh.erp.datasource.mappers.AccountHeadMapper.Base_Column_List" />
from jsh_accounthead
where 1=1
and accountId in (
<foreach collection="accountIds" item="accountId" separator=",">
#{accountId}
</foreach>
)
and ifnull(delete_Flag,'0') !='1'
</select>
</mapper>

View File

@@ -60,4 +60,16 @@
</foreach>
)
</update>
<select id="getAccountItemListByAccountIds" resultMap="com.jsh.erp.datasource.mappers.AccountItemMapper.BaseResultMap">
select
<include refid="com.jsh.erp.datasource.mappers.AccountItemMapper.Base_Column_List" />
from jsh_accountitem
where 1=1
and accountId in (
<foreach collection="accountIds" item="accountId" separator=",">
#{accountId}
</foreach>
)
and ifnull(delete_Flag,'0') !='1'
</select>
</mapper>

View File

@@ -438,5 +438,17 @@
</foreach>
)
</update>
<select id="getDepotHeadListByAccountIds" resultMap="com.jsh.erp.datasource.mappers.DepotHeadMapper.BaseResultMap">
select
<include refid="com.jsh.erp.datasource.mappers.DepotHeadMapper.Base_Column_List" />
from jsh_depothead
where 1=1
and accountId in (
<foreach collection="accountIds" item="accountId" separator=",">
#{accountId}
</foreach>
)
and ifnull(delete_Flag,'0') !='1'
</select>
</mapper>