From 6395a5cec66fa1ac111280b80d5878eb2128a7bf Mon Sep 17 00:00:00 2001 From: erzhongxmu Date: Mon, 27 Jul 2020 07:09:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=B6=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zzjee/md/controller/MdBinController.java | 79 +++++++++++-------- .../zzjee/md/controller/MdCusController.java | 71 ++++++++++------- .../md/controller/MdGoodsController.java | 12 +++ src/main/java/com/zzjee/wmutil/wmUtil.java | 28 +++++++ 4 files changed, 128 insertions(+), 62 deletions(-) diff --git a/src/main/java/com/zzjee/md/controller/MdBinController.java b/src/main/java/com/zzjee/md/controller/MdBinController.java index 9fc25c06..f570eef5 100644 --- a/src/main/java/com/zzjee/md/controller/MdBinController.java +++ b/src/main/java/com/zzjee/md/controller/MdBinController.java @@ -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 attrs = new HashMap(); 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 fileMap = multipartRequest.getFileMap(); for (Map.Entry entity : fileMap.entrySet()) { @@ -408,14 +421,14 @@ public class MdBinController extends BaseController { } return j; } - + @RequestMapping(method = RequestMethod.GET) @ResponseBody public List list() { List listMdBins=mdBinService.getList(MdBinEntity.class); return listMdBins; } - + @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public ResponseEntity get(@PathVariable("id") String id) { diff --git a/src/main/java/com/zzjee/md/controller/MdCusController.java b/src/main/java/com/zzjee/md/controller/MdCusController.java index 1635415b..c07ec584 100644 --- a/src/main/java/com/zzjee/md/controller/MdCusController.java +++ b/src/main/java/com/zzjee/md/controller/MdCusController.java @@ -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 map1 = new HashMap(); - map1.put("zhuJiMa", "desc"); - cq.setOrder(map1); + Map map1 = new HashMap(); + 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 fileMap = multipartRequest.getFileMap(); for (Map.Entry entity : fileMap.entrySet()) { @@ -342,14 +355,14 @@ public class MdCusController extends BaseController { } return j; } - + @RequestMapping(method = RequestMethod.GET) @ResponseBody public List list() { List listMdCuss=mdCusService.getList(MdCusEntity.class); return listMdCuss; } - + @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public ResponseEntity get(@PathVariable("id") String id) { diff --git a/src/main/java/com/zzjee/md/controller/MdGoodsController.java b/src/main/java/com/zzjee/md/controller/MdGoodsController.java index 6e87b913..d8c3eca8 100644 --- a/src/main/java/com/zzjee/md/controller/MdGoodsController.java +++ b/src/main/java/com/zzjee/md/controller/MdGoodsController.java @@ -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); diff --git a/src/main/java/com/zzjee/wmutil/wmUtil.java b/src/main/java/com/zzjee/wmutil/wmUtil.java index a87d42c8..d2b357c9 100644 --- a/src/main/java/com/zzjee/wmutil/wmUtil.java +++ b/src/main/java/com/zzjee/wmutil/wmUtil.java @@ -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 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 {