去除外键之产品表jsh_material相关修改

This commit is contained in:
qiankunpingtai
2019-04-10 18:14:51 +08:00
parent 9fa082f25c
commit bce05cf062
6 changed files with 127 additions and 5 deletions

View File

@@ -353,9 +353,20 @@ public class MaterialController {
* @return java.lang.Object
*/
@RequestMapping(value = "/batchDeleteMaterialByIds")
public Object batchDeleteMaterialByIds(@RequestParam("ids") String ids) throws Exception {
public Object batchDeleteMaterialByIds(@RequestParam("ids") String ids,@RequestParam(value="deleteType",
required =false,defaultValue= BusinessConstants.DELETE_TYPE_NORMAL)String deleteType) throws Exception {
JSONObject result = ExceptionConstants.standardSuccess();
int i= materialService.batchDeleteMaterialByIds(ids);
int i=0;
if(BusinessConstants.DELETE_TYPE_NORMAL.equals(deleteType)){
i= materialService.batchDeleteMaterialByIdsNormal(ids);
}else if(BusinessConstants.DELETE_TYPE_FORCE.equals(deleteType)){
i= materialService.batchDeleteMaterialByIds(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.MATERIAL_DELETE_FAILED_CODE,ExceptionConstants.MATERIAL_DELETE_FAILED_MSG,ids);

View File

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

View File

@@ -1,10 +1,14 @@
package com.jsh.erp.service.material;
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.DepotItemMapperEx;
import com.jsh.erp.datasource.mappers.MaterialMapper;
import com.jsh.erp.datasource.mappers.MaterialMapperEx;
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.BaseResponseInfo;
@@ -32,6 +36,8 @@ public class MaterialService {
private LogService logService;
@Resource
private UserService userService;
@Resource
private DepotItemMapperEx depotItemMapperEx;
public Material getMaterial(long id) {
return materialMapper.selectByPrimaryKey(id);
@@ -217,4 +223,43 @@ public class MaterialService {
String [] idArray=ids.split(",");
return materialMapperEx.batchDeleteMaterialByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}
/**
* create by: qiankunpingtai
* websitehttps://qiankunpingtai.cn
* description:
* 正常删除,要考虑数据完整性,进行完整性校验
* create time: 2019/4/10 18:00
* @Param: ids
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialByIdsNormal(String ids) throws Exception{
/**
* 校验
* 1、单据子表 jsh_depotitem
* 是否有相关数据
* */
int deleteTotal=0;
if(StringUtils.isEmpty(ids)){
return deleteTotal;
}
String [] idArray=ids.split(",");
/**
* 校验单据子表 jsh_depotitem
* */
List<DepotItem> depotItemList=depotItemMapperEx.getDepotItemListListByMaterialIds(idArray);
if(depotItemList!=null&&depotItemList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,MaterialIds[{}]",
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= batchDeleteMaterialByIds(ids);
return deleteTotal;
}
}