去除外键之账户信息表jsh_account相关修改
This commit is contained in:
@@ -234,7 +234,14 @@
|
|||||||
if(res && res.code == 200) {
|
if(res && res.code == 200) {
|
||||||
$("#searchBtn").click();
|
$("#searchBtn").click();
|
||||||
} else {
|
} else {
|
||||||
$.messager.alert('删除提示', '删除结算账户失败,请稍后再试!', 'error');
|
if(res && res.code == 601){
|
||||||
|
var jsondata={};
|
||||||
|
jsondata.ids=accountTotalInfo[0];
|
||||||
|
jsondata.deleteType='2';
|
||||||
|
batDeleteAccountForceConfirm(res,"/account/batchDeleteAccountByIds",jsondata);
|
||||||
|
}else{
|
||||||
|
$.messager.alert('删除提示', '删除结算账户失败,请稍后再试!', 'error');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//此处添加错误处理
|
//此处添加错误处理
|
||||||
@@ -278,7 +285,14 @@
|
|||||||
$("#searchBtn").click();
|
$("#searchBtn").click();
|
||||||
$(":checkbox").attr("checked", false);
|
$(":checkbox").attr("checked", false);
|
||||||
} else {
|
} else {
|
||||||
$.messager.alert('删除提示', '删除结算账户失败,请稍后再试!', 'error');
|
if(res && res.code == 601){
|
||||||
|
var jsondata={};
|
||||||
|
jsondata.ids=ids;
|
||||||
|
jsondata.deleteType='2';
|
||||||
|
batDeleteAccountForceConfirm(res,"/account/batchDeleteAccountByIds",jsondata);
|
||||||
|
}else{
|
||||||
|
$.messager.alert('删除提示', '删除结算账户失败,请稍后再试!', 'error');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//此处添加错误处理
|
//此处添加错误处理
|
||||||
@@ -291,6 +305,33 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 确认强制删除
|
||||||
|
* */
|
||||||
|
function batDeleteAccountForceConfirm(res,url,jsondata) {
|
||||||
|
$.messager.confirm('删除确认', res.msg, function (r) {
|
||||||
|
if (r) {
|
||||||
|
$.ajax({
|
||||||
|
type: "post",
|
||||||
|
url: url,
|
||||||
|
dataType: "json",
|
||||||
|
data: (jsondata),
|
||||||
|
success: function (res) {
|
||||||
|
if(res && res.code == 200) {
|
||||||
|
$("#searchBtn").click();
|
||||||
|
} else {
|
||||||
|
$.messager.alert('删除提示', '删除结算账户失败,请稍后再试!', 'error');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//此处添加错误处理
|
||||||
|
error: function () {
|
||||||
|
$.messager.alert('删除提示', '删除结算账户异常,请稍后再试!', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//增加结算账户
|
//增加结算账户
|
||||||
var url;
|
var url;
|
||||||
|
|||||||
@@ -200,6 +200,14 @@ public class BusinessConstants {
|
|||||||
public static final String TYPE_NAME_ROLE_APP = "RoleAPP";
|
public static final String TYPE_NAME_ROLE_APP = "RoleAPP";
|
||||||
public static final String TYPE_NAME_ROLE_FUNCTIONS = "RoleFunctions";
|
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";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,17 @@ public class ExceptionConstants {
|
|||||||
**/
|
**/
|
||||||
public static final int SERVICE_SYSTEM_ERROR_CODE = 500;
|
public static final int SERVICE_SYSTEM_ERROR_CODE = 500;
|
||||||
public static final String SERVICE_SYSTEM_ERROR_MSG = "未知异常";
|
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
|
* type = 5
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.jsh.erp.controller;
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.druid.util.StringUtils;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.Account;
|
import com.jsh.erp.datasource.entities.Account;
|
||||||
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
|
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
|
||||||
@@ -150,10 +152,28 @@ public class AccountController {
|
|||||||
* @return java.lang.Object
|
* @return java.lang.Object
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/batchDeleteAccountByIds")
|
@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();
|
JSONObject result = ExceptionConstants.standardSuccess();
|
||||||
int i= accountService.batchDeleteAccountByIds(ids);
|
/**
|
||||||
|
* create by: qiankunpingtai
|
||||||
|
* create time: 2019/4/10 10:19
|
||||||
|
* website:https://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){
|
if(i<1){
|
||||||
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
|
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
|
||||||
ExceptionConstants.ACCOUNT_DELETE_FAILED_CODE,ExceptionConstants.ACCOUNT_DELETE_FAILED_MSG,ids);
|
ExceptionConstants.ACCOUNT_DELETE_FAILED_CODE,ExceptionConstants.ACCOUNT_DELETE_FAILED_MSG,ids);
|
||||||
|
|||||||
@@ -36,5 +36,7 @@ public interface AccountHeadMapperEx {
|
|||||||
List<AccountHeadVo4ListEx> getDetailByNumber(
|
List<AccountHeadVo4ListEx> getDetailByNumber(
|
||||||
@Param("billNo") String billNo);
|
@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);
|
||||||
}
|
}
|
||||||
@@ -25,5 +25,7 @@ public interface AccountItemMapperEx {
|
|||||||
List<AccountItemVo4List> getDetailList(
|
List<AccountItemVo4List> getDetailList(
|
||||||
@Param("headerId") Long headerId);
|
@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);
|
||||||
}
|
}
|
||||||
@@ -115,4 +115,6 @@ public interface DepotHeadMapperEx {
|
|||||||
Long getBuildOnlyNumber(@Param("seq_name") String seq_name);
|
Long getBuildOnlyNumber(@Param("seq_name") String seq_name);
|
||||||
|
|
||||||
int batchDeleteDepotHeadByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
|
int batchDeleteDepotHeadByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
|
||||||
|
|
||||||
|
List<DepotHead> getDepotHeadListByAccountIds(@Param("accountIds") String[] accountIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
package com.jsh.erp.service.account;
|
package com.jsh.erp.service.account;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import com.jsh.erp.constants.BusinessConstants;
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.*;
|
import com.jsh.erp.datasource.entities.*;
|
||||||
import com.jsh.erp.datasource.mappers.*;
|
import com.jsh.erp.datasource.mappers.*;
|
||||||
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
|
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
|
||||||
import com.jsh.erp.datasource.vo.AccountVo4List;
|
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.log.LogService;
|
||||||
import com.jsh.erp.service.user.UserService;
|
import com.jsh.erp.service.user.UserService;
|
||||||
import com.jsh.erp.utils.StringUtil;
|
import com.jsh.erp.utils.StringUtil;
|
||||||
@@ -38,13 +41,19 @@ public class AccountService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DepotHeadMapper depotHeadMapper;
|
private DepotHeadMapper depotHeadMapper;
|
||||||
|
@Resource
|
||||||
|
private DepotHeadMapperEx depotHeadMapperEx;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AccountHeadMapper accountHeadMapper;
|
private AccountHeadMapper accountHeadMapper;
|
||||||
|
@Resource
|
||||||
|
private AccountHeadMapperEx accountHeadMapperEx;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AccountItemMapper accountItemMapper;
|
private AccountItemMapper accountItemMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
private AccountItemMapperEx accountItemMapperEx;
|
||||||
|
@Resource
|
||||||
private LogService logService;
|
private LogService logService;
|
||||||
@Resource
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@@ -330,4 +339,64 @@ public class AccountService {
|
|||||||
String [] idArray=ids.split(",");
|
String [] idArray=ids.split(",");
|
||||||
return accountMapperEx.batchDeleteAccountByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
return accountMapperEx.batchDeleteAccountByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* create by: qiankunpingtai
|
||||||
|
* website:https://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;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,4 +88,16 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
)
|
)
|
||||||
</update>
|
</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>
|
</mapper>
|
||||||
@@ -60,4 +60,16 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
)
|
)
|
||||||
</update>
|
</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>
|
</mapper>
|
||||||
@@ -438,5 +438,17 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
)
|
)
|
||||||
</update>
|
</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>
|
</mapper>
|
||||||
Reference in New Issue
Block a user