去除外键之仓库表jsh_depot相关修改

This commit is contained in:
qiankunpingtai
2019-04-10 17:54:35 +08:00
parent bb1f9b7e97
commit 9fa082f25c
7 changed files with 162 additions and 10 deletions

View File

@@ -185,9 +185,20 @@ public class DepotController {
* @return java.lang.Object
*/
@RequestMapping(value = "/batchDeleteDepotByIds")
public Object batchDeleteDepotByIds(@RequestParam("ids") String ids) throws Exception {
public Object batchDeleteDepotByIds(@RequestParam("ids") String ids,@RequestParam(value="deleteType",
required =false,defaultValue=BusinessConstants.DELETE_TYPE_NORMAL)String deleteType) throws Exception {
JSONObject result = ExceptionConstants.standardSuccess();
int i= depotService.batchDeleteDepotByIds(ids);
int i=0;
if(BusinessConstants.DELETE_TYPE_NORMAL.equals(deleteType)){
i= depotService.batchDeleteDepotByIdsNormal(ids);
}else if(BusinessConstants.DELETE_TYPE_FORCE.equals(deleteType)){
i= depotService.batchDeleteDepotByIds(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.DEPOT_DELETE_FAILED_CODE,ExceptionConstants.DEPOT_DELETE_FAILED_MSG,ids);

View File

@@ -121,4 +121,6 @@ public interface DepotHeadMapperEx {
List<DepotHead> getDepotHeadListByOrganIds(@Param("organIds") String[] organIds);
List<DepotHead> getDepotHeadListByHandsPersonIds(@Param("handsPersonIds") String[] handsPersonIds);
List<DepotHead> getDepotHeadListByDepotIds(@Param("depotIds") String[] depotIds);
}

View File

@@ -168,4 +168,6 @@ public interface DepotItemMapperEx {
int batchDeleteDepotItemByDepotHeadIds(@Param("depotheadIds")Long []depotHeadIds);
int batchDeleteDepotItemByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
List<DepotItem> getDepotItemListListByDepotIds(@Param("depotIds") String[] depotIds);
}

View File

@@ -1,13 +1,12 @@
package com.jsh.erp.service.depot;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.datasource.entities.Depot;
import com.jsh.erp.datasource.entities.DepotEx;
import com.jsh.erp.datasource.entities.DepotExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.DepotMapper;
import com.jsh.erp.datasource.mappers.DepotMapperEx;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.*;
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;
@@ -37,6 +36,10 @@ public class DepotService {
private UserService userService;
@Resource
private LogService logService;
@Resource
private DepotHeadMapperEx depotHeadMapperEx;
@Resource
private DepotItemMapperEx depotItemMapperEx;
public Depot getDepot(long id) {
return depotMapper.selectByPrimaryKey(id);
@@ -122,4 +125,54 @@ public class DepotService {
String [] idArray=ids.split(",");
return depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}
/**
* create by: qiankunpingtai
* websitehttps://qiankunpingtai.cn
* description:
* 正常删除,要考虑数据完整性,进行完整性校验
* create time: 2019/4/10 16:52
* @Param: ids
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotByIdsNormal(String ids) throws Exception {
/**
* 校验
* 1、单据主表 jsh_depothead
* 2、单据子表 jsh_depotitem
* 是否有相关数据
* */
int deleteTotal=0;
if(StringUtils.isEmpty(ids)){
return deleteTotal;
}
String [] idArray=ids.split(",");
/**
* 校验单据主表 jsh_depothead
* */
List<DepotHead> depotHeadList=depotHeadMapperEx.getDepotHeadListByDepotIds(idArray);
if(depotHeadList!=null&&depotHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
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_depotitem
* */
List<DepotItem> depotItemList=depotItemMapperEx.getDepotItemListListByDepotIds(idArray);
if(depotItemList!=null&&depotItemList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
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= batchDeleteDepotByIds(ids);
return deleteTotal;
}
}

View File

@@ -474,5 +474,25 @@
)
and ifnull(delete_Flag,'0') !='1'
</select>
<select id="getDepotHeadListByDepotIds" 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
(ProjectId in (
<foreach collection="depotIds" item="depotId" separator=",">
#{depotId}
</foreach>
)
OR
AllocationProjectId in (
<foreach collection="depotIds" item="depotId" separator=",">
#{depotId}
</foreach>
)
)
and ifnull(delete_Flag,'0') !='1'
</select>
</mapper>

View File

@@ -411,6 +411,18 @@
</foreach>
)
</update>
<select id="getDepotItemListListByDepotIds" resultMap="com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap">
select
<include refid="com.jsh.erp.datasource.mappers.DepotItemMapper.Base_Column_List" />
from jsh_depotitem
where 1=1
and DepotId in (
<foreach collection="depotIds" item="depotId" separator=",">
#{depotId}
</foreach>
)
and ifnull(delete_Flag,'0') !='1'
</select>