删除时检查是否存在库存

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;
@ -54,12 +55,12 @@ import com.zzjee.md.service.MdBinServiceI;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
* @Title: Controller
/**
* @Title: Controller
* @Description:
* @author erzhongxmu
* @date 2017-08-15 23:17:02
* @version V1.0
* @version V1.0
*
*/
@Controller
@ -76,12 +77,12 @@ public class MdBinController extends BaseController {
private SystemService systemService;
@Autowired
private Validator validator;
/**
*
*
*
* @return
*/
@RequestMapping(params = "list")
@ -94,7 +95,7 @@ public class MdBinController extends BaseController {
}
/**
* easyui AJAX
*
*
* @param request
* @param response
* @param dataGrid
@ -114,10 +115,10 @@ public class MdBinController extends BaseController {
this.mdBinService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "doDel")
@ -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);
@ -141,9 +148,9 @@ public class MdBinController extends BaseController {
j.setMsg(message);
return j;
}
@RequestMapping(params = "getbinall")
@ResponseBody
public AjaxJson getNoticeList(HttpServletRequest req) {
@ -174,11 +181,11 @@ public class MdBinController extends BaseController {
jsonParts.put("binid", resultt.get(i).get("binid"));
jsonParts.put("des", resultt.get(i).get("des"));
jsonParts.put("tincount", resultt.get(i).get("tincount"));
result.add(jsonParts);
result.add(jsonParts);
}
j.setObj(resultt.size());
Map<String,Object> attrs = new HashMap<String, Object>();
attrs.put("messageList", result);
// String tip = MutiLangUtil.getMutiLangInstance().getLang("message.tip");
@ -192,11 +199,11 @@ public class MdBinController extends BaseController {
}
return j;
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "doBatchDel")
@ -207,10 +214,16 @@ public class MdBinController extends BaseController {
message = "仓位停用成功";
try{
for(String id:ids.split(",")){
MdBinEntity mdBin = systemService.getEntity(MdBinEntity.class,
MdBinEntity mdBin = systemService.getEntity(MdBinEntity.class,
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);
}
@ -226,7 +239,7 @@ public class MdBinController extends BaseController {
/**
*
*
*
* @return
*/
@RequestMapping(params = "doAdd")
@ -261,10 +274,10 @@ public class MdBinController extends BaseController {
j.setMsg(message);
return j;
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "doUpdate")
@ -286,11 +299,11 @@ public class MdBinController extends BaseController {
j.setMsg(message);
return j;
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "goAdd")
@ -303,7 +316,7 @@ public class MdBinController extends BaseController {
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "goUpdate")
@ -314,10 +327,10 @@ public class MdBinController extends BaseController {
}
return new ModelAndView("com/zzjee/md/mdBin-update");
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "upload")
@ -325,10 +338,10 @@ public class MdBinController extends BaseController {
req.setAttribute("controller_name","mdBinController");
return new ModelAndView("common/upload/pub_excel_upload");
}
/**
* excel
*
*
* @param request
* @param response
*/
@ -347,7 +360,7 @@ public class MdBinController extends BaseController {
}
/**
* excel 使
*
*
* @param request
* @param response
*/
@ -361,13 +374,13 @@ public class MdBinController extends BaseController {
modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
@SuppressWarnings("unchecked")
@RequestMapping(params = "importExcel", method = RequestMethod.POST)
@ResponseBody
public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
@ -408,14 +421,14 @@ public class MdBinController extends BaseController {
}
return j;
}
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public List<MdBinEntity> list() {
List<MdBinEntity> listMdBins=mdBinService.getList(MdBinEntity.class);
return listMdBins;
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<?> get(@PathVariable("id") String id) {

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;
@ -51,12 +52,12 @@ import org.springframework.web.util.UriComponentsBuilder;
import com.zzjee.md.entity.MdCusEntity;
import com.zzjee.md.service.MdCusServiceI;
/**
* @Title: Controller
/**
* @Title: Controller
* @Description:
* @author erzhongxmu
* @date 2017-08-15 23:17:09
* @version V1.0
* @version V1.0
*
*/
@Controller
@ -73,12 +74,12 @@ public class MdCusController extends BaseController {
private SystemService systemService;
@Autowired
private Validator validator;
/**
*
*
*
* @return
*/
@RequestMapping(params = "list")
@ -93,7 +94,7 @@ public class MdCusController extends BaseController {
}
/**
* easyui AJAX
*
*
* @param request
* @param response
* @param dataGrid
@ -110,17 +111,17 @@ public class MdCusController extends BaseController {
}catch (Exception e) {
throw new BusinessException(e.getMessage());
}
Map<String,Object> map1 = new HashMap<String,Object>();
map1.put("zhuJiMa", "desc");
cq.setOrder(map1);
Map<String,Object> map1 = new HashMap<String,Object>();
map1.put("zhuJiMa", "desc");
cq.setOrder(map1);
cq.add();
this.mdCusService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "doDel")
@ -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){
@ -141,10 +148,10 @@ public class MdCusController extends BaseController {
j.setMsg(message);
return j;
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "doBatchDel")
@ -155,9 +162,15 @@ public class MdCusController extends BaseController {
message = "客户删除成功";
try{
for(String id:ids.split(",")){
MdCusEntity mdCus = systemService.getEntity(MdCusEntity.class,
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);
}
@ -173,7 +186,7 @@ public class MdCusController extends BaseController {
/**
*
*
*
* @param ids
* @return
*/
@ -201,10 +214,10 @@ public class MdCusController extends BaseController {
j.setMsg(message);
return j;
}
/**
*
*
*
* @param ids
* @return
*/
@ -227,11 +240,11 @@ public class MdCusController extends BaseController {
j.setMsg(message);
return j;
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "goAdd")
@ -244,7 +257,7 @@ public class MdCusController extends BaseController {
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "goUpdate")
@ -255,10 +268,10 @@ public class MdCusController extends BaseController {
}
return new ModelAndView("com/zzjee/md/mdCus-update");
}
/**
*
*
*
* @return
*/
@RequestMapping(params = "upload")
@ -266,10 +279,10 @@ public class MdCusController extends BaseController {
req.setAttribute("controller_name","mdCusController");
return new ModelAndView("common/upload/pub_excel_upload");
}
/**
* excel
*
*
* @param request
* @param response
*/
@ -288,7 +301,7 @@ public class MdCusController extends BaseController {
}
/**
* excel 使
*
*
* @param request
* @param response
*/
@ -302,13 +315,13 @@ public class MdCusController extends BaseController {
modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
@SuppressWarnings("unchecked")
@RequestMapping(params = "importExcel", method = RequestMethod.POST)
@ResponseBody
public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
@ -342,14 +355,14 @@ public class MdCusController extends BaseController {
}
return j;
}
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public List<MdCusEntity> list() {
List<MdCusEntity> listMdCuss=mdCusService.getList(MdCusEntity.class);
return listMdCuss;
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<?> get(@PathVariable("id") String id) {

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 {