删除时检查是否存在库存

master
erzhongxmu 2020-07-27 07:09:53 +08:00
parent db515e2f05
commit 6395a5cec6
4 changed files with 128 additions and 62 deletions

View File

@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import com.zzjee.wmutil.wmUtil;
import org.apache.log4j.Logger;
import org.jeecgframework.core.beanvalidator.BeanValidators;
import org.jeecgframework.core.common.controller.BaseController;
@ -130,6 +131,12 @@ public class MdBinController extends BaseController {
try{
// mdBin.setTingYong("Y");
// mdBinService.saveOrUpdate(mdBin);
if(wmUtil.checkishavestock("bin",mdBin.getKuWeiBianMa())){
message = "仓位存在库存";
j.setSuccess(false);
j.setMsg(message);
return j;
}
mdBinService.delete(mdBin);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
@ -211,6 +218,12 @@ public class MdBinController extends BaseController {
id
);
// mdBin.setTingYong("Y");
if(wmUtil.checkishavestock("bin",mdBin.getKuWeiBianMa())){
message = "仓位存在库存";
j.setSuccess(false);
j.setMsg(message);
return j;
}
mdBinService.delete(mdBin);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}

View File

@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import com.zzjee.wmutil.wmUtil;
import org.apache.log4j.Logger;
import org.jeecgframework.core.beanvalidator.BeanValidators;
import org.jeecgframework.core.common.controller.BaseController;
@ -131,6 +132,12 @@ public class MdCusController extends BaseController {
mdCus = systemService.getEntity(MdCusEntity.class, mdCus.getId());
message = "客户删除成功";
try{
if(wmUtil.checkishavestock("cus",mdCus.getKeHuBianMa())){
message = "货主存在库存";
j.setSuccess(false);
j.setMsg(message);
return j;
}
mdCusService.delete(mdCus);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}catch(Exception e){
@ -158,6 +165,12 @@ public class MdCusController extends BaseController {
MdCusEntity mdCus = systemService.getEntity(MdCusEntity.class,
id
);
if(wmUtil.checkishavestock("cus",mdCus.getKeHuBianMa())){
message = "货主存在库存";
j.setSuccess(false);
j.setMsg(message);
return j;
}
mdCusService.delete(mdCus);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}

View File

@ -139,6 +139,12 @@ public class MdGoodsController extends BaseController {
message = "商品删除成功";
try {
// mdGoods.setZhuangTai("Y");
if(wmUtil.checkishavestock("goods",mdGoods.getShpBianMa())){
message = "商品存在库存";
j.setSuccess(false);
j.setMsg(message);
return j;
}
mdGoodsService.delete(mdGoods);;
systemService.addLog(message, Globals.Log_Type_DEL,
Globals.Log_Leavel_INFO);
@ -176,6 +182,12 @@ public class MdGoodsController extends BaseController {
for (String id : ids.split(",")) {
MdGoodsEntity mdGoods = systemService.getEntity(
MdGoodsEntity.class, id);
if(wmUtil.checkishavestock("goods",mdGoods.getShpBianMa())){
message = "商品存在库存";
j.setSuccess(false);
j.setMsg(message);
return j;
}
mdGoodsService.delete(mdGoods);
systemService.addLog(message, Globals.Log_Type_DEL,
Globals.Log_Leavel_INFO);

View File

@ -4,6 +4,7 @@ import com.zzjee.conf.entity.FxjOtherLoginEntity;
import com.zzjee.md.entity.MdBinEntity;
import com.zzjee.md.entity.MdGoodsEntity;
import com.zzjee.sys.entity.SysParaEntity;
import com.zzjee.wm.entity.WvStockEntity;
import org.antlr.stringtemplate.language.Cat;
import org.jeecgframework.core.common.exception.BusinessException;
import org.jeecgframework.core.util.DateUtils;
@ -372,6 +373,33 @@ public class wmUtil {
return flag;
}
public static boolean checkishavestock(String checktype,String checkvalue){
boolean ishavestock = false;
String hql = "from WvStockEntity where ";
if("bin".equals(checktype)){
hql = hql + " kuWeiBianMa = ?";
}
if("cus".equals(checktype)){
hql = hql + " cusCode = ?";
}
if("goods".equals(checktype)){
hql = hql + " goodsId = ?";
}
SystemService systemService =ApplicationContextUtil.getContext().getBean(SystemService.class);
List<WvStockEntity> list = systemService.findHql(hql,checkvalue);
if(list!=null&&list.size()>0){
ishavestock = true;
}
return ishavestock;
}
public static String getstock(String goodsid) {
String goodsqua = "0";
try {