去除外键之产品类型表jsh_materialcategory相关修改
This commit is contained in:
@@ -196,11 +196,21 @@
|
||||
ids: ids
|
||||
}),
|
||||
success: function (res) {
|
||||
if(res.code!=200){
|
||||
$.messager.alert('提示', res.msg, 'error');
|
||||
return;
|
||||
if(res && res.code === 200) {
|
||||
$('#tt').tree('reload');
|
||||
} else {
|
||||
if(res && res.code == 601){
|
||||
var jsondata={};
|
||||
jsondata.ids=ids;
|
||||
jsondata.deleteType='2';
|
||||
var type='batch';
|
||||
batDeleteMaterialCategoryForceConfirm(res,"/materialCategory/batchDeleteMaterialCategory",jsondata,type);
|
||||
}else if(res && res.code == 600){
|
||||
$.messager.alert('删除提示', res.msg, 'error');
|
||||
}else{
|
||||
$.messager.alert('删除提示', '删除商品信息异常,请稍后再试!', 'error');
|
||||
}
|
||||
}
|
||||
$('#tt').tree('reload');
|
||||
},
|
||||
//此处添加错误处理
|
||||
error: function () {
|
||||
@@ -212,6 +222,35 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 确认强制删除
|
||||
* */
|
||||
function batDeleteMaterialCategoryForceConfirm(res,url,jsondata,type) {
|
||||
$.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) {
|
||||
$('#tt').tree('reload');
|
||||
}else if(res && res.code == 600){
|
||||
$.messager.alert('删除提示', res.msg, 'error');
|
||||
}else {
|
||||
$.messager.alert('删除提示', '删除商品类别信息异常,请稍后再试!', 'error');
|
||||
}
|
||||
},
|
||||
//此处添加错误处理
|
||||
error: function () {
|
||||
$.messager.alert('删除提示', '删除商品类别信息异常,请稍后再试!', 'error');
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//保存信息
|
||||
$("#saveMaterialCategory").off("click").on("click", function () {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.MaterialCategory;
|
||||
import com.jsh.erp.datasource.entities.SerialNumberEx;
|
||||
@@ -151,9 +152,20 @@ public class MaterialCategoryController {
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@RequestMapping(value = "/batchDeleteMaterialCategory")
|
||||
public Object batchDeleteMaterialCategory(@RequestParam("ids") String ids) throws Exception {
|
||||
public Object batchDeleteMaterialCategory(@RequestParam("ids") String ids,@RequestParam(value="deleteType",
|
||||
required =false,defaultValue= BusinessConstants.DELETE_TYPE_NORMAL)String deleteType) throws Exception {
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
int i= materialCategoryService.batchDeleteMaterialCategoryByIds(ids);
|
||||
int i=0;
|
||||
if(BusinessConstants.DELETE_TYPE_NORMAL.equals(deleteType)){
|
||||
i= materialCategoryService.batchDeleteMaterialCategoryByIdsNormal(ids);
|
||||
}else if(BusinessConstants.DELETE_TYPE_FORCE.equals(deleteType)){
|
||||
i= materialCategoryService.batchDeleteMaterialCategoryByIds(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){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_DELETE_FAILED_CODE,
|
||||
ExceptionConstants.MATERIAL_CATEGORY_DELETE_FAILED_MSG);
|
||||
|
||||
@@ -35,4 +35,6 @@ public interface MaterialCategoryMapperEx {
|
||||
int editMaterialCategory(MaterialCategory mc);
|
||||
|
||||
List<MaterialCategory> getMaterialCategoryBySerialNo(@Param("serialNo") String serialNo);
|
||||
|
||||
List<MaterialCategory> getMaterialCategoryListByCategoryIds(@Param("parentIds") String[] categoryIds);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jsh.erp.datasource.mappers;
|
||||
|
||||
import com.jsh.erp.datasource.entities.AccountHead;
|
||||
import com.jsh.erp.datasource.entities.Material;
|
||||
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -57,4 +58,6 @@ public interface MaterialMapperEx {
|
||||
List<Material> getMaterialEnableSerialNumberList(Map<String, Object> parameterMap);
|
||||
|
||||
int batchDeleteMaterialByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
|
||||
|
||||
List<Material> getMaterialListByCategoryIds(@Param("categoryIds") String[] categoryIds);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.jsh.erp.service.materialCategory;
|
||||
|
||||
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.MaterialCategory;
|
||||
import com.jsh.erp.datasource.entities.MaterialCategoryExample;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.mappers.MaterialCategoryMapper;
|
||||
import com.jsh.erp.datasource.mappers.MaterialCategoryMapperEx;
|
||||
import com.jsh.erp.datasource.mappers.MaterialMapperEx;
|
||||
import com.jsh.erp.datasource.vo.TreeNode;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
@@ -37,6 +37,8 @@ public class MaterialCategoryService {
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private LogService logService;
|
||||
@Resource
|
||||
private MaterialMapperEx materialMapperEx;
|
||||
|
||||
public MaterialCategory getMaterialCategory(long id) {
|
||||
return materialCategoryMapper.selectByPrimaryKey(id);
|
||||
@@ -216,5 +218,52 @@ public class MaterialCategoryService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* create by: qiankunpingtai
|
||||
* website:https://qiankunpingtai.cn
|
||||
* description:
|
||||
* 正常删除,要考虑数据完整性,进行完整性校验
|
||||
* create time: 2019/4/11 9:26
|
||||
* @Param: ids
|
||||
* @return int
|
||||
*/
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchDeleteMaterialCategoryByIdsNormal(String ids) throws Exception {
|
||||
/**
|
||||
* 校验
|
||||
* 1、产品表 jsh_material
|
||||
* 2、产品类型表 jsh_materialcategory
|
||||
* 是否有相关数据
|
||||
* */
|
||||
int deleteTotal=0;
|
||||
if(StringUtils.isEmpty(ids)){
|
||||
return deleteTotal;
|
||||
}
|
||||
String [] idArray=ids.split(",");
|
||||
/**
|
||||
* 校验产品表 jsh_material
|
||||
* */
|
||||
List<Material> materialList=materialMapperEx.getMaterialListByCategoryIds(idArray);
|
||||
if(materialList!=null&&materialList.size()>0){
|
||||
logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]",
|
||||
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_materialcategory
|
||||
* */
|
||||
List<MaterialCategory> materialCategoryList=materialCategoryMapperEx.getMaterialCategoryListByCategoryIds(idArray);
|
||||
if(materialCategoryList!=null&&materialCategoryList.size()>0){
|
||||
logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]",
|
||||
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= batchDeleteMaterialCategoryByIds(ids);
|
||||
return deleteTotal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,5 +107,17 @@
|
||||
and serial_no=#{serialNo}
|
||||
and ifnull(status,'0') !='2'
|
||||
</select>
|
||||
<select id="getMaterialCategoryListByCategoryIds" resultMap="com.jsh.erp.datasource.mappers.MaterialCategoryMapper.BaseResultMap">
|
||||
select
|
||||
<include refid="com.jsh.erp.datasource.mappers.MaterialCategoryMapper.Base_Column_List" />
|
||||
from jsh_materialcategory
|
||||
where 1=1
|
||||
and parentId in (
|
||||
<foreach collection="parentIds" item="parentId" separator=",">
|
||||
#{parentId}
|
||||
</foreach>
|
||||
)
|
||||
and ifnull(status,'0') !='2'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -149,6 +149,18 @@
|
||||
</foreach>
|
||||
)
|
||||
</update>
|
||||
<select id="getMaterialListByCategoryIds" resultMap="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap">
|
||||
select
|
||||
<include refid="com.jsh.erp.datasource.mappers.MaterialMapper.Base_Column_List" />
|
||||
from jsh_material
|
||||
where 1=1
|
||||
and categoryId in (
|
||||
<foreach collection="categoryIds" item="categoryId" separator=",">
|
||||
#{categoryId}
|
||||
</foreach>
|
||||
)
|
||||
and ifnull(delete_Flag,'0') !='1'
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user