diff --git a/src/main/java/com/zzjee/wm/controller/WmPrintModelController.java b/src/main/java/com/zzjee/wm/controller/WmPrintModelController.java index 05a9f06b..7a196cf4 100644 --- a/src/main/java/com/zzjee/wm/controller/WmPrintModelController.java +++ b/src/main/java/com/zzjee/wm/controller/WmPrintModelController.java @@ -1,6 +1,8 @@ package com.zzjee.wm.controller; + import com.zzjee.wm.entity.WmPrintModelEntity; import com.zzjee.wm.service.WmPrintModelServiceI; + import java.util.ArrayList; import java.util.List; import java.text.SimpleDateFormat; @@ -29,6 +31,7 @@ import org.jeecgframework.web.system.service.SystemService; import org.jeecgframework.core.util.MyBeanUtils; import java.io.OutputStream; + import org.jeecgframework.core.util.BrowserUtils; import org.jeecgframework.poi.excel.ExcelExportUtil; import org.jeecgframework.poi.excel.ExcelImportUtil; @@ -39,12 +42,16 @@ import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.vo.TemplateExcelConstants; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.jeecgframework.core.util.ResourceUtil; + import java.io.IOException; + import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; + import java.util.Map; import java.util.HashMap; + import org.jeecgframework.core.util.ExceptionUtil; import org.springframework.http.ResponseEntity; @@ -58,349 +65,351 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.jeecgframework.core.beanvalidator.BeanValidators; + import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.Validator; import java.net.URI; + import org.springframework.http.MediaType; import org.springframework.web.util.UriComponentsBuilder; -/** - * @Title: Controller - * @Description: 打印模板 +/** * @author onlineGenerator + * @version V1.0 + * @Title: Controller + * @Description: 打印模板 * @date 2021-08-02 14:51:38 - * @version V1.0 - * */ @Controller @RequestMapping("/wmPrintModelController") public class WmPrintModelController extends BaseController { - /** - * Logger for this class - */ - private static final Logger logger = Logger.getLogger(WmPrintModelController.class); + /** + * Logger for this class + */ + private static final Logger logger = Logger.getLogger(WmPrintModelController.class); - @Autowired - private WmPrintModelServiceI wmPrintModelService; - @Autowired - private SystemService systemService; - @Autowired - private Validator validator; - + @Autowired + private WmPrintModelServiceI wmPrintModelService; + @Autowired + private SystemService systemService; + @Autowired + private Validator validator; - /** - * 打印模板列表 页面跳转 - * - * @return - */ - @RequestMapping(params = "list") - public ModelAndView list(HttpServletRequest request) { - return new ModelAndView("com/zzjee/wm/wmPrintModelList"); - } + /** + * 打印模板列表 页面跳转 + * + * @return + */ + @RequestMapping(params = "list") + public ModelAndView list(HttpServletRequest request) { + return new ModelAndView("com/zzjee/wm/wmPrintModelList"); + } - /** - * easyui AJAX请求数据 - * - * @param request - * @param response - * @param dataGrid - * @param user - */ + /** + * easyui AJAX请求数据 + * + * @param request + * @param response + * @param dataGrid + * @param user + */ - @RequestMapping(params = "datagrid") - public void datagrid(WmPrintModelEntity wmPrintModel,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { - CriteriaQuery cq = new CriteriaQuery(WmPrintModelEntity.class, dataGrid); - //查询条件组装器 - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmPrintModel, request.getParameterMap()); - try{ - //自定义追加查询条件 - }catch (Exception e) { - throw new BusinessException(e.getMessage()); - } - cq.add(); - this.wmPrintModelService.getDataGridReturn(cq, true); - TagUtil.datagrid(response, dataGrid); - } - - /** - * 删除打印模板 - * - * @return - */ - @RequestMapping(params = "doDel") - @ResponseBody - public AjaxJson doDel(WmPrintModelEntity wmPrintModel, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - wmPrintModel = systemService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId()); - message = "打印模板删除成功"; - try{ - wmPrintModelService.delete(wmPrintModel); - systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); - }catch(Exception e){ - e.printStackTrace(); - message = "打印模板删除失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } - - /** - * 批量删除打印模板 - * - * @return - */ - @RequestMapping(params = "doBatchDel") - @ResponseBody - public AjaxJson doBatchDel(String ids,HttpServletRequest request){ - String message = null; - AjaxJson j = new AjaxJson(); - message = "打印模板删除成功"; - try{ - for(String id:ids.split(",")){ - WmPrintModelEntity wmPrintModel = systemService.getEntity(WmPrintModelEntity.class, - id - ); - wmPrintModelService.delete(wmPrintModel); - systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); - } - }catch(Exception e){ - e.printStackTrace(); - message = "打印模板删除失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + @RequestMapping(params = "datagrid") + public void datagrid(WmPrintModelEntity wmPrintModel, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { + CriteriaQuery cq = new CriteriaQuery(WmPrintModelEntity.class, dataGrid); + //查询条件组装器 + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmPrintModel, request.getParameterMap()); + try { + //自定义追加查询条件 + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + cq.add(); + this.wmPrintModelService.getDataGridReturn(cq, true); + TagUtil.datagrid(response, dataGrid); + } + + /** + * 删除打印模板 + * + * @return + */ + @RequestMapping(params = "doDel") + @ResponseBody + public AjaxJson doDel(WmPrintModelEntity wmPrintModel, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + wmPrintModel = systemService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId()); + message = "打印模板删除成功"; + try { + wmPrintModelService.delete(wmPrintModel); + systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "打印模板删除失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } + + /** + * 批量删除打印模板 + * + * @return + */ + @RequestMapping(params = "doBatchDel") + @ResponseBody + public AjaxJson doBatchDel(String ids, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "打印模板删除成功"; + try { + for (String id : ids.split(",")) { + WmPrintModelEntity wmPrintModel = systemService.getEntity(WmPrintModelEntity.class, + id + ); + wmPrintModelService.delete(wmPrintModel); + systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); + } + } catch (Exception e) { + e.printStackTrace(); + message = "打印模板删除失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - /** - * 添加打印模板 - * - * @param ids - * @return - */ - @RequestMapping(params = "doAdd") - @ResponseBody - public AjaxJson doAdd(WmPrintModelEntity wmPrintModel, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - message = "打印模板添加成功"; - try{ - wmPrintModelService.save(wmPrintModel); - systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); - }catch(Exception e){ - e.printStackTrace(); - message = "打印模板添加失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } - - /** - * 更新打印模板 - * - * @param ids - * @return - */ - @RequestMapping(params = "doUpdate") - @ResponseBody - public AjaxJson doUpdate(WmPrintModelEntity wmPrintModel, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - message = "打印模板更新成功"; - WmPrintModelEntity t = wmPrintModelService.get(WmPrintModelEntity.class, wmPrintModel.getId()); - try { - MyBeanUtils.copyBeanNotNull2Bean(wmPrintModel, t); - wmPrintModelService.saveOrUpdate(t); - systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); - } catch (Exception e) { - e.printStackTrace(); - message = "打印模板更新失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } - + /** + * 添加打印模板 + * + * @param ids + * @return + */ + @RequestMapping(params = "doAdd") + @ResponseBody + public AjaxJson doAdd(WmPrintModelEntity wmPrintModel, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "打印模板添加成功"; + try { + wmPrintModelService.save(wmPrintModel); + systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "打印模板添加失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - /** - * 打印模板新增页面跳转 - * - * @return - */ - @RequestMapping(params = "goAdd") - public ModelAndView goAdd(WmPrintModelEntity wmPrintModel, HttpServletRequest req) { - if (StringUtil.isNotEmpty(wmPrintModel.getId())) { - wmPrintModel = wmPrintModelService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId()); - req.setAttribute("wmPrintModelPage", wmPrintModel); - } - return new ModelAndView("com/zzjee/wm/wmPrintModel-add"); - } - /** - * 打印模板编辑页面跳转 - * - * @return - */ - @RequestMapping(params = "goUpdate") - public ModelAndView goUpdate(WmPrintModelEntity wmPrintModel, HttpServletRequest req) { - if (StringUtil.isNotEmpty(wmPrintModel.getId())) { - wmPrintModel = wmPrintModelService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId()); - req.setAttribute("wmPrintModelPage", wmPrintModel); - } - return new ModelAndView("com/zzjee/wm/wmPrintModel-update"); - } - - /** - * 导入功能跳转 - * - * @return - */ - @RequestMapping(params = "upload") - public ModelAndView upload(HttpServletRequest req) { - req.setAttribute("controller_name","wmPrintModelController"); - return new ModelAndView("common/upload/pub_excel_upload"); - } - - /** - * 导出excel - * - * @param request - * @param response - */ - @RequestMapping(params = "exportXls") - public String exportXls(WmPrintModelEntity wmPrintModel,HttpServletRequest request,HttpServletResponse response - , DataGrid dataGrid,ModelMap modelMap) { - CriteriaQuery cq = new CriteriaQuery(WmPrintModelEntity.class, dataGrid); - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmPrintModel, request.getParameterMap()); - List wmPrintModels = this.wmPrintModelService.getListByCriteriaQuery(cq,false); - modelMap.put(NormalExcelConstants.FILE_NAME,"打印模板"); - modelMap.put(NormalExcelConstants.CLASS,WmPrintModelEntity.class); - modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("打印模板列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(), - "导出信息")); - modelMap.put(NormalExcelConstants.DATA_LIST,wmPrintModels); - return NormalExcelConstants.JEECG_EXCEL_VIEW; - } - /** - * 导出excel 使模板 - * - * @param request - * @param response - */ - @RequestMapping(params = "exportXlsByT") - public String exportXlsByT(WmPrintModelEntity wmPrintModel,HttpServletRequest request,HttpServletResponse response - , DataGrid dataGrid,ModelMap modelMap) { - modelMap.put(NormalExcelConstants.FILE_NAME,"打印模板"); - modelMap.put(NormalExcelConstants.CLASS,WmPrintModelEntity.class); - modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("打印模板列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(), - "导出信息")); - 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()) { - MultipartFile file = entity.getValue();// 获取上传文件对象 - ImportParams params = new ImportParams(); - params.setTitleRows(2); - params.setHeadRows(1); - params.setNeedSave(true); - try { - List listWmPrintModelEntitys = ExcelImportUtil.importExcel(file.getInputStream(),WmPrintModelEntity.class,params); - for (WmPrintModelEntity wmPrintModel : listWmPrintModelEntitys) { - wmPrintModelService.save(wmPrintModel); - } - j.setMsg("文件导入成功!"); - } catch (Exception e) { - j.setMsg("文件导入失败!"); - logger.error(ExceptionUtil.getExceptionMessage(e)); - }finally{ - try { - file.getInputStream().close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return j; - } - - @RequestMapping(method = RequestMethod.GET) - @ResponseBody - public List list() { - List listWmPrintModels=wmPrintModelService.getList(WmPrintModelEntity.class); - return listWmPrintModels; - } - - @RequestMapping(value = "/{id}", method = RequestMethod.GET) - @ResponseBody - public ResponseEntity get(@PathVariable("id") String id) { - WmPrintModelEntity task = wmPrintModelService.get(WmPrintModelEntity.class, id); - if (task == null) { - return new ResponseEntity(HttpStatus.NOT_FOUND); - } - return new ResponseEntity(task, HttpStatus.OK); - } + /** + * 更新打印模板 + * + * @param ids + * @return + */ + @RequestMapping(params = "doUpdate") + @ResponseBody + public AjaxJson doUpdate(WmPrintModelEntity wmPrintModel, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "打印模板更新成功"; + WmPrintModelEntity t = wmPrintModelService.get(WmPrintModelEntity.class, wmPrintModel.getId()); + try { + MyBeanUtils.copyBeanNotNull2Bean(wmPrintModel, t); + wmPrintModelService.saveOrUpdate(t); + systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "打印模板更新失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public ResponseEntity create(@RequestBody WmPrintModelEntity wmPrintModel, UriComponentsBuilder uriBuilder) { - //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. - Set> failures = validator.validate(wmPrintModel); - if (!failures.isEmpty()) { - return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); - } - //保存 - try{ - wmPrintModelService.save(wmPrintModel); - } catch (Exception e) { - e.printStackTrace(); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } - //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象. - String id = wmPrintModel.getId(); - URI uri = uriBuilder.path("/rest/wmPrintModelController/" + id).build().toUri(); - HttpHeaders headers = new HttpHeaders(); - headers.setLocation(uri); + /** + * 打印模板新增页面跳转 + * + * @return + */ + @RequestMapping(params = "goAdd") + public ModelAndView goAdd(WmPrintModelEntity wmPrintModel, HttpServletRequest req) { + if (StringUtil.isNotEmpty(wmPrintModel.getId())) { + wmPrintModel = wmPrintModelService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId()); + req.setAttribute("wmPrintModelPage", wmPrintModel); + } + return new ModelAndView("com/zzjee/wm/wmPrintModel-add"); + } - return new ResponseEntity(headers, HttpStatus.CREATED); - } + /** + * 打印模板编辑页面跳转 + * + * @return + */ + @RequestMapping(params = "goUpdate") + public ModelAndView goUpdate(WmPrintModelEntity wmPrintModel, HttpServletRequest req) { + if (StringUtil.isNotEmpty(wmPrintModel.getId())) { + wmPrintModel = wmPrintModelService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId()); + req.setAttribute("wmPrintModelPage", wmPrintModel); + } + return new ModelAndView("com/zzjee/wm/wmPrintModel-update"); + } - @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity update(@RequestBody WmPrintModelEntity wmPrintModel) { - //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. - Set> failures = validator.validate(wmPrintModel); - if (!failures.isEmpty()) { - return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); - } + /** + * 导入功能跳转 + * + * @return + */ + @RequestMapping(params = "upload") + public ModelAndView upload(HttpServletRequest req) { + req.setAttribute("controller_name", "wmPrintModelController"); + return new ModelAndView("common/upload/pub_excel_upload"); + } - //保存 - try{ - wmPrintModelService.saveOrUpdate(wmPrintModel); - } catch (Exception e) { - e.printStackTrace(); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + /** + * 导出excel + * + * @param request + * @param response + */ + @RequestMapping(params = "exportXls") + public String exportXls(WmPrintModelEntity wmPrintModel, HttpServletRequest request, HttpServletResponse response + , DataGrid dataGrid, ModelMap modelMap) { + CriteriaQuery cq = new CriteriaQuery(WmPrintModelEntity.class, dataGrid); + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmPrintModel, request.getParameterMap()); + List wmPrintModels = this.wmPrintModelService.getListByCriteriaQuery(cq, false); + modelMap.put(NormalExcelConstants.FILE_NAME, "打印模板"); + modelMap.put(NormalExcelConstants.CLASS, WmPrintModelEntity.class); + modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("打印模板列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(), + "导出信息")); + modelMap.put(NormalExcelConstants.DATA_LIST, wmPrintModels); + return NormalExcelConstants.JEECG_EXCEL_VIEW; + } - //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码. - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + /** + * 导出excel 使模板 + * + * @param request + * @param response + */ + @RequestMapping(params = "exportXlsByT") + public String exportXlsByT(WmPrintModelEntity wmPrintModel, HttpServletRequest request, HttpServletResponse response + , DataGrid dataGrid, ModelMap modelMap) { + modelMap.put(NormalExcelConstants.FILE_NAME, "打印模板"); + modelMap.put(NormalExcelConstants.CLASS, WmPrintModelEntity.class); + modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("打印模板列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(), + "导出信息")); + modelMap.put(NormalExcelConstants.DATA_LIST, new ArrayList()); + return NormalExcelConstants.JEECG_EXCEL_VIEW; + } - @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) - @ResponseStatus(HttpStatus.NO_CONTENT) - public void delete(@PathVariable("id") String id) { - wmPrintModelService.deleteEntityById(WmPrintModelEntity.class, id); - } + @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()) { + MultipartFile file = entity.getValue();// 获取上传文件对象 + ImportParams params = new ImportParams(); + params.setTitleRows(2); + params.setHeadRows(1); + params.setNeedSave(true); + try { + List listWmPrintModelEntitys = ExcelImportUtil.importExcel(file.getInputStream(), WmPrintModelEntity.class, params); + for (WmPrintModelEntity wmPrintModel : listWmPrintModelEntitys) { + wmPrintModelService.save(wmPrintModel); + } + j.setMsg("文件导入成功!"); + } catch (Exception e) { + j.setMsg("文件导入失败!"); + logger.error(ExceptionUtil.getExceptionMessage(e)); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return j; + } + + @RequestMapping(method = RequestMethod.GET) + @ResponseBody + public List list() { + List listWmPrintModels = wmPrintModelService.getList(WmPrintModelEntity.class); + return listWmPrintModels; + } + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public ResponseEntity get(@PathVariable("id") String id) { + WmPrintModelEntity task = wmPrintModelService.get(WmPrintModelEntity.class, id); + if (task == null) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + return new ResponseEntity(task, HttpStatus.OK); + } + + @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public ResponseEntity create(@RequestBody WmPrintModelEntity wmPrintModel, UriComponentsBuilder uriBuilder) { + //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. + Set> failures = validator.validate(wmPrintModel); + if (!failures.isEmpty()) { + return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); + } + + //保存 + try { + wmPrintModelService.save(wmPrintModel); + } catch (Exception e) { + e.printStackTrace(); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象. + String id = wmPrintModel.getId(); + URI uri = uriBuilder.path("/rest/wmPrintModelController/" + id).build().toUri(); + HttpHeaders headers = new HttpHeaders(); + headers.setLocation(uri); + + return new ResponseEntity(headers, HttpStatus.CREATED); + } + + @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity update(@RequestBody WmPrintModelEntity wmPrintModel) { + //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. + Set> failures = validator.validate(wmPrintModel); + if (!failures.isEmpty()) { + return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); + } + + //保存 + try { + wmPrintModelService.saveOrUpdate(wmPrintModel); + } catch (Exception e) { + e.printStackTrace(); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码. + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) + @ResponseStatus(HttpStatus.NO_CONTENT) + public void delete(@PathVariable("id") String id) { + wmPrintModelService.deleteEntityById(WmPrintModelEntity.class, id); + } } diff --git a/src/main/java/com/zzjee/wm/controller/WmSttInGoodsController.java b/src/main/java/com/zzjee/wm/controller/WmSttInGoodsController.java index f65107da..714e94fc 100644 --- a/src/main/java/com/zzjee/wm/controller/WmSttInGoodsController.java +++ b/src/main/java/com/zzjee/wm/controller/WmSttInGoodsController.java @@ -1,4 +1,5 @@ package com.zzjee.wm.controller; + import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -57,583 +58,585 @@ import com.zzjee.wm.service.WmSttInGoodsServiceI; import com.zzjee.wmutil.wmUtil; /** + * @author erzhongxmu + * @version V1.0 * @Title: Controller * @Description: 库存盘点 - * @author erzhongxmu * @date 2017-09-08 21:03:33 - * @version V1.0 - * */ @Controller @RequestMapping("/wmSttInGoodsController") public class WmSttInGoodsController extends BaseController { - /** - * Logger for this class - */ - private static final Logger logger = Logger.getLogger(WmSttInGoodsController.class); + /** + * Logger for this class + */ + private static final Logger logger = Logger.getLogger(WmSttInGoodsController.class); - @Autowired - private WmSttInGoodsServiceI wmSttInGoodsService; - @Autowired - private SystemService systemService; - @Autowired - private Validator validator; + @Autowired + private WmSttInGoodsServiceI wmSttInGoodsService; + @Autowired + private SystemService systemService; + @Autowired + private Validator validator; + /** + * 库存盘点列表 页面跳转 + * + * @return + */ + @RequestMapping(params = "list") + public ModelAndView list(HttpServletRequest request) { + return new ModelAndView("com/zzjee/wm/wmSttInGoodsList"); + } - /** - * 库存盘点列表 页面跳转 - * - * @return - */ - @RequestMapping(params = "list") - public ModelAndView list(HttpServletRequest request) { - return new ModelAndView("com/zzjee/wm/wmSttInGoodsList"); - } - @RequestMapping(params = "listfp") - public ModelAndView listfp(HttpServletRequest request) { - return new ModelAndView("com/zzjee/wm/wmSttInGoodsfpList"); - } - @RequestMapping(params = "listcygz") - public ModelAndView listcygz(HttpServletRequest request) { - return new ModelAndView("com/zzjee/wm/wmSttInGoodscygzList"); - } - /** - * easyui AJAX请求数据 - * - * @param request - * @param response - * @param dataGrid - */ + @RequestMapping(params = "listfp") + public ModelAndView listfp(HttpServletRequest request) { + return new ModelAndView("com/zzjee/wm/wmSttInGoodsfpList"); + } - @RequestMapping(params = "datagrid") - public void datagrid(WmSttInGoodsEntity wmSttInGoods,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { - CriteriaQuery cq = new CriteriaQuery(WmSttInGoodsEntity.class, dataGrid); - //查询条件组装器 - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmSttInGoods, request.getParameterMap()); - try{ - //自定义追加查询条件 + @RequestMapping(params = "listcygz") + public ModelAndView listcygz(HttpServletRequest request) { + return new ModelAndView("com/zzjee/wm/wmSttInGoodscygzList"); + } + + /** + * easyui AJAX请求数据 + * + * @param request + * @param response + * @param dataGrid + */ + + @RequestMapping(params = "datagrid") + public void datagrid(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { + CriteriaQuery cq = new CriteriaQuery(WmSttInGoodsEntity.class, dataGrid); + //查询条件组装器 + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmSttInGoods, request.getParameterMap()); + try { + //自定义追加查询条件 - // 自定义追加查询条件 - String query_createDate_begin = request.getParameter("createDate_begin1"); - String query_createDate_end = request.getParameter("createDate_end2"); + // 自定义追加查询条件 + String query_createDate_begin = request.getParameter("createDate_begin1"); + String query_createDate_end = request.getParameter("createDate_end2"); - if (StringUtil.isNotEmpty(query_createDate_begin)) { - cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd hh:mm:ss") - .parse(query_createDate_begin)); - } - if (StringUtil.isNotEmpty(query_createDate_end)) { - cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd hh:mm:ss") - .parse(query_createDate_end)); - } + if (StringUtil.isNotEmpty(query_createDate_begin)) { + cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd hh:mm:ss") + .parse(query_createDate_begin)); + } + if (StringUtil.isNotEmpty(query_createDate_end)) { + cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd hh:mm:ss") + .parse(query_createDate_end)); + } - }catch (Exception e) { - throw new BusinessException(e.getMessage()); - } - Map map1 = new HashMap(); - map1.put("createDate", "desc"); - cq.setOrder(map1); - cq.notEq("sttSta", "已删除"); - cq.add(); - this.wmSttInGoodsService.getDataGridReturn(cq, true); - TagUtil.datagrid(response, dataGrid); - } + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + Map map1 = new HashMap(); + map1.put("createDate", "desc"); + cq.setOrder(map1); + cq.notEq("sttSta", "已删除"); + cq.add(); + this.wmSttInGoodsService.getDataGridReturn(cq, true); + TagUtil.datagrid(response, dataGrid); + } - @RequestMapping(params = "datagridcygz") - public void datagridcygz(WmSttInGoodsEntity wmSttInGoods,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { - CriteriaQuery cq = new CriteriaQuery(WmSttInGoodsEntity.class, dataGrid); - //查询条件组装器 - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmSttInGoods, request.getParameterMap()); - try{ - //自定义追加查询条件 - }catch (Exception e) { - throw new BusinessException(e.getMessage()); - } - Map map1 = new HashMap(); - map1.put("createDate", "desc"); - cq.setOrder(map1); - cq.eq("sttSta", "已完成"); - cq.add(); - this.wmSttInGoodsService.getDataGridReturn(cq, true); - List resultnew = new ArrayList(); - List resultold = dataGrid.getResults(); - for (WmSttInGoodsEntity wmSttInGoodsold : resultold) { - if(!wmSttInGoodsold.getGoodsQua().equals(wmSttInGoodsold.getSttQua())){ - resultnew.add(wmSttInGoodsold); - } - } - dataGrid.setResults(resultnew); - dataGrid.setTotal(resultnew.size()); - TagUtil.datagrid(response, dataGrid); + @RequestMapping(params = "datagridcygz") + public void datagridcygz(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { + CriteriaQuery cq = new CriteriaQuery(WmSttInGoodsEntity.class, dataGrid); + //查询条件组装器 + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmSttInGoods, request.getParameterMap()); + try { + //自定义追加查询条件 + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + Map map1 = new HashMap(); + map1.put("createDate", "desc"); + cq.setOrder(map1); + cq.eq("sttSta", "已完成"); + cq.add(); + this.wmSttInGoodsService.getDataGridReturn(cq, true); + List resultnew = new ArrayList(); + List resultold = dataGrid.getResults(); + for (WmSttInGoodsEntity wmSttInGoodsold : resultold) { + if (!wmSttInGoodsold.getGoodsQua().equals(wmSttInGoodsold.getSttQua())) { + resultnew.add(wmSttInGoodsold); + } + } + dataGrid.setResults(resultnew); + dataGrid.setTotal(resultnew.size()); + TagUtil.datagrid(response, dataGrid); - } + } + @RequestMapping(params = "datagridfp") + public void datagridfp(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { + CriteriaQuery cq = new CriteriaQuery(WmSttInGoodsEntity.class, dataGrid); + //查询条件组装器 + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmSttInGoods, request.getParameterMap()); + try { + //自定义追加查询条件 + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + Map map1 = new HashMap(); + map1.put("createDate", "desc"); + cq.setOrder(map1); + cq.eq("sttSta", "已完成"); + cq.add(); + this.wmSttInGoodsService.getDataGridReturn(cq, true); + List resultnew = new ArrayList(); + List resultold = dataGrid.getResults(); + for (WmSttInGoodsEntity wmSttInGoodsold : resultold) { + if (!wmSttInGoodsold.getGoodsQua().equals(wmSttInGoodsold.getSttQua())) { + resultnew.add(wmSttInGoodsold); + } + } + dataGrid.setResults(resultnew); + dataGrid.setTotal(resultnew.size()); + TagUtil.datagrid(response, dataGrid); + + } + + /** + * 删除库存盘点 + * + * @return + */ + @RequestMapping(params = "doDel") + @ResponseBody + public AjaxJson doDel(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + wmSttInGoods = systemService.getEntity(WmSttInGoodsEntity.class, wmSttInGoods.getId()); + message = "库存盘点删除成功"; + try { + wmSttInGoods.setSttSta("已删除"); + wmSttInGoodsService.saveOrUpdate(wmSttInGoods); + systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "库存盘点删除失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - @RequestMapping(params = "datagridfp") - public void datagridfp(WmSttInGoodsEntity wmSttInGoods,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { - CriteriaQuery cq = new CriteriaQuery(WmSttInGoodsEntity.class, dataGrid); - //查询条件组装器 - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmSttInGoods, request.getParameterMap()); - try{ - //自定义追加查询条件 - }catch (Exception e) { - throw new BusinessException(e.getMessage()); - } - Map map1 = new HashMap(); - map1.put("createDate", "desc"); - cq.setOrder(map1); - cq.eq("sttSta", "已完成"); - cq.add(); - this.wmSttInGoodsService.getDataGridReturn(cq, true); - List resultnew = new ArrayList(); - List resultold = dataGrid.getResults(); - for (WmSttInGoodsEntity wmSttInGoodsold : resultold) { - if(!wmSttInGoodsold.getGoodsQua().equals(wmSttInGoodsold.getSttQua())){ - resultnew.add(wmSttInGoodsold); - } - } - dataGrid.setResults(resultnew); - dataGrid.setTotal(resultnew.size()); - TagUtil.datagrid(response, dataGrid); + @RequestMapping(params = "dorun") + @ResponseBody + public AjaxJson dorun(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + wmSttInGoods = systemService.getEntity(WmSttInGoodsEntity.class, request + .getParameter("id").toString()); + message = "库存盘点差异过账成功"; + if (wmSttInGoods.getSttSta().equals("已完成")) { - } - - /** - * 删除库存盘点 - * - * @return - */ - @RequestMapping(params = "doDel") - @ResponseBody - public AjaxJson doDel(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - wmSttInGoods = systemService.getEntity(WmSttInGoodsEntity.class, wmSttInGoods.getId()); - message = "库存盘点删除成功"; - try{ - wmSttInGoods.setSttSta("已删除"); - wmSttInGoodsService.saveOrUpdate(wmSttInGoods); - systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); - }catch(Exception e){ - e.printStackTrace(); - message = "库存盘点删除失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } - - - - @RequestMapping(params = "dorun") - @ResponseBody - public AjaxJson dorun(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - wmSttInGoods = systemService.getEntity(WmSttInGoodsEntity.class, request - .getParameter("id").toString()); - message = "库存盘点差异过账成功"; - if(wmSttInGoods.getSttSta().equals("已完成")){ - - if(!wmSttInGoods.getGoodsQua().equals(wmSttInGoods.getSttQua())){ - try{ + if (!wmSttInGoods.getGoodsQua().equals(wmSttInGoods.getSttQua())) { + try { // wmSttInGoods.setSttQua("0"); - if(Double.parseDouble(wmSttInGoods.getGoodsQua()) > Double.parseDouble(wmSttInGoods.getSttQua())){ - //下架 - String goodsqua = Double.toString((Double.parseDouble(wmSttInGoods.getGoodsQua()) - Double.parseDouble(wmSttInGoods.getSttQua()))); - WmToDownGoodsEntity wmToDownGoods = new WmToDownGoodsEntity(); + if (Double.parseDouble(wmSttInGoods.getGoodsQua()) > Double.parseDouble(wmSttInGoods.getSttQua())) { + //下架 + String goodsqua = Double.toString((Double.parseDouble(wmSttInGoods.getGoodsQua()) - Double.parseDouble(wmSttInGoods.getSttQua()))); + WmToDownGoodsEntity wmToDownGoods = new WmToDownGoodsEntity(); - wmToDownGoods.setOrderId("ZY"); - wmToDownGoods.setBinIdTo("PK"); - wmToDownGoods.setDownSta("已复核"); - wmToDownGoods.setGoodsQua(goodsqua); - wmToDownGoods.setGoodsQuaok(goodsqua); - MvGoodsEntity mvgoods = new MvGoodsEntity(); - mvgoods = systemService.findUniqueByProperty( - MvGoodsEntity.class, "goodsCode", - wmSttInGoods.getGoodsId()); - if(mvgoods!=null){ - wmToDownGoods.setGoodsId(wmSttInGoods.getGoodsId()); - wmToDownGoods.setBinIdFrom(wmSttInGoods.getTinId()); - wmToDownGoods.setKuWeiBianMa(wmSttInGoods.getBinId()); - wmToDownGoods.setGoodsProData(wmSttInGoods.getGoodsProData()); - wmToDownGoods.setBaseUnit(mvgoods.getBaseunit()); - wmToDownGoods.setGoodsUnit(mvgoods.getBaseunit()); - wmToDownGoods.setBaseGoodscount(wmToDownGoods - .getGoodsQuaok()); - wmToDownGoods.setCusCode(wmSttInGoods.getCusCode()); + wmToDownGoods.setOrderId("ZY"); + wmToDownGoods.setBinIdTo("PK"); + wmToDownGoods.setDownSta("已复核"); + wmToDownGoods.setGoodsQua(goodsqua); + wmToDownGoods.setGoodsQuaok(goodsqua); + MvGoodsEntity mvgoods = new MvGoodsEntity(); + mvgoods = systemService.findUniqueByProperty( + MvGoodsEntity.class, "goodsCode", + wmSttInGoods.getGoodsId()); + if (mvgoods != null) { + wmToDownGoods.setGoodsId(wmSttInGoods.getGoodsId()); + wmToDownGoods.setBinIdFrom(wmSttInGoods.getTinId()); + wmToDownGoods.setKuWeiBianMa(wmSttInGoods.getBinId()); + wmToDownGoods.setGoodsProData(wmSttInGoods.getGoodsProData()); + wmToDownGoods.setBaseUnit(mvgoods.getBaseunit()); + wmToDownGoods.setGoodsUnit(mvgoods.getBaseunit()); + wmToDownGoods.setBaseGoodscount(wmToDownGoods + .getGoodsQuaok()); + wmToDownGoods.setCusCode(wmSttInGoods.getCusCode()); - if(!wmUtil.checkstcok(wmToDownGoods.getKuWeiBianMa(),wmToDownGoods.getBinIdFrom(),wmToDownGoods.getGoodsId(),wmToDownGoods.getGoodsProData(),wmToDownGoods.getGoodsQua())){ - message = "库存不足"; - j.setMsg(message); - return j; + if (!wmUtil.checkstcok(wmToDownGoods.getKuWeiBianMa(), wmToDownGoods.getBinIdFrom(), wmToDownGoods.getGoodsId(), wmToDownGoods.getGoodsProData(), wmToDownGoods.getGoodsQua())) { + message = "库存不足"; + j.setMsg(message); + return j; - }; - systemService.save(wmToDownGoods); - wmSttInGoods.setSttSta("已过帐"); - wmSttInGoodsService.saveOrUpdate(wmSttInGoods); - systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); - } - }else{ - //上架 - String goodsqua = Double.toString(( Double.parseDouble(wmSttInGoods.getSttQua()) - Double.parseDouble(wmSttInGoods.getGoodsQua()))); + } + ; + systemService.save(wmToDownGoods); + wmSttInGoods.setSttSta("已过帐"); + wmSttInGoodsService.saveOrUpdate(wmSttInGoods); + systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); + } + } else { + //上架 + String goodsqua = Double.toString((Double.parseDouble(wmSttInGoods.getSttQua()) - Double.parseDouble(wmSttInGoods.getGoodsQua()))); - WmToUpGoodsEntity wmToUpGoods = new WmToUpGoodsEntity(); - wmToUpGoods.setOrderId("ZY"); - MvGoodsEntity mvgoods = new MvGoodsEntity(); - mvgoods = systemService.findUniqueByProperty( - MvGoodsEntity.class, "goodsCode", - wmSttInGoods.getGoodsId()); - if(mvgoods!=null){ - wmToUpGoods.setBaseUnit(mvgoods.getBaseunit()); - wmToUpGoods.setGoodsUnit(mvgoods.getBaseunit()); - wmToUpGoods.setBaseGoodscount(goodsqua); - wmToUpGoods.setGoodsQua(goodsqua); - wmToUpGoods.setGoodsId(wmSttInGoods.getGoodsId()); - wmToUpGoods.setBinId(wmSttInGoods.getTinId()); - wmToUpGoods.setKuWeiBianMa(wmSttInGoods.getBinId()); - wmToUpGoods.setCusCode(wmSttInGoods.getCusCode()); - wmToUpGoods.setGoodsProData(wmSttInGoods.getGoodsProData()); - systemService.save(wmToUpGoods); - wmSttInGoods.setSttSta("已过帐"); - wmSttInGoodsService.saveOrUpdate(wmSttInGoods); - systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); - } - } + WmToUpGoodsEntity wmToUpGoods = new WmToUpGoodsEntity(); + wmToUpGoods.setOrderId("ZY"); + MvGoodsEntity mvgoods = new MvGoodsEntity(); + mvgoods = systemService.findUniqueByProperty( + MvGoodsEntity.class, "goodsCode", + wmSttInGoods.getGoodsId()); + if (mvgoods != null) { + wmToUpGoods.setBaseUnit(mvgoods.getBaseunit()); + wmToUpGoods.setGoodsUnit(mvgoods.getBaseunit()); + wmToUpGoods.setBaseGoodscount(goodsqua); + wmToUpGoods.setGoodsQua(goodsqua); + wmToUpGoods.setGoodsId(wmSttInGoods.getGoodsId()); + wmToUpGoods.setBinId(wmSttInGoods.getTinId()); + wmToUpGoods.setKuWeiBianMa(wmSttInGoods.getBinId()); + wmToUpGoods.setCusCode(wmSttInGoods.getCusCode()); + wmToUpGoods.setGoodsProData(wmSttInGoods.getGoodsProData()); + systemService.save(wmToUpGoods); + wmSttInGoods.setSttSta("已过帐"); + wmSttInGoodsService.saveOrUpdate(wmSttInGoods); + systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); + } + } - }catch(Exception e){ - e.printStackTrace(); - message = "库存盘点差异过账失败"; - throw new BusinessException(e.getMessage()); - } - }else{ - message = "库存盘点差异无需过账"; - } - } - j.setMsg(message); - return j; - } + } catch (Exception e) { + e.printStackTrace(); + message = "库存盘点差异过账失败"; + throw new BusinessException(e.getMessage()); + } + } else { + message = "库存盘点差异无需过账"; + } + } + j.setMsg(message); + return j; + } - @RequestMapping(params = "dostt") - @ResponseBody - public AjaxJson dostt(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - wmSttInGoods = systemService.getEntity(WmSttInGoodsEntity.class, request - .getParameter("id").toString()); - message = "库存盘点添加成功"; - try{ - wmSttInGoods.setSttQua("0"); - wmSttInGoods.setSttSta("计划中"); - wmSttInGoodsService.save(wmSttInGoods); - systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); - }catch(Exception e){ - e.printStackTrace(); - message = "库存盘点添加失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + @RequestMapping(params = "dostt") + @ResponseBody + public AjaxJson dostt(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + wmSttInGoods = systemService.getEntity(WmSttInGoodsEntity.class, request + .getParameter("id").toString()); + message = "库存盘点添加成功"; + try { + wmSttInGoods.setSttQua("0"); + wmSttInGoods.setSttSta("计划中"); + wmSttInGoodsService.save(wmSttInGoods); + systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "库存盘点添加失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - /** - * 批量删除库存盘点 - * - * @return - */ - @RequestMapping(params = "doBatchDel") - @ResponseBody - public AjaxJson doBatchDel(String ids,HttpServletRequest request){ - String message = null; - AjaxJson j = new AjaxJson(); - message = "库存盘点删除成功"; - try{ - for(String id:ids.split(",")){ - WmSttInGoodsEntity wmSttInGoods = systemService.getEntity(WmSttInGoodsEntity.class, - id - ); - wmSttInGoodsService.delete(wmSttInGoods); - systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); - } - }catch(Exception e){ - e.printStackTrace(); - message = "库存盘点删除失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + /** + * 批量删除库存盘点 + * + * @return + */ + @RequestMapping(params = "doBatchDel") + @ResponseBody + public AjaxJson doBatchDel(String ids, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "库存盘点删除成功"; + try { + for (String id : ids.split(",")) { + WmSttInGoodsEntity wmSttInGoods = systemService.getEntity(WmSttInGoodsEntity.class, + id + ); + wmSttInGoodsService.delete(wmSttInGoods); + systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); + } + } catch (Exception e) { + e.printStackTrace(); + message = "库存盘点删除失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - /** - * 添加库存盘点 - * - * @return - */ - @RequestMapping(params = "doAdd") - @ResponseBody - public AjaxJson doAdd(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - message = "库存盘点添加成功"; - try{ - wmSttInGoods.setSttSta("计划中"); - wmSttInGoodsService.save(wmSttInGoods); - systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); - }catch(Exception e){ - e.printStackTrace(); - message = "库存盘点添加失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + /** + * 添加库存盘点 + * + * @return + */ + @RequestMapping(params = "doAdd") + @ResponseBody + public AjaxJson doAdd(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "库存盘点添加成功"; + try { + wmSttInGoods.setSttSta("计划中"); + wmSttInGoodsService.save(wmSttInGoods); + systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "库存盘点添加失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - /** - * 更新库存盘点 - * - * @return - */ - @RequestMapping(params = "doUpdate") - @ResponseBody - public AjaxJson doUpdate(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - message = "库存盘点更新成功"; - WmSttInGoodsEntity t = wmSttInGoodsService.get(WmSttInGoodsEntity.class, wmSttInGoods.getId()); - try { - MyBeanUtils.copyBeanNotNull2Bean(wmSttInGoods, t); - wmSttInGoodsService.saveOrUpdate(t); - systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); - } catch (Exception e) { - e.printStackTrace(); - message = "库存盘点更新失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + /** + * 更新库存盘点 + * + * @return + */ + @RequestMapping(params = "doUpdate") + @ResponseBody + public AjaxJson doUpdate(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "库存盘点更新成功"; + WmSttInGoodsEntity t = wmSttInGoodsService.get(WmSttInGoodsEntity.class, wmSttInGoods.getId()); + try { + MyBeanUtils.copyBeanNotNull2Bean(wmSttInGoods, t); + wmSttInGoodsService.saveOrUpdate(t); + systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "库存盘点更新失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - /** - * 库存盘点新增页面跳转 - * - * @return - */ - @RequestMapping(params = "goAdd") - public ModelAndView goAdd(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest req) { - if (StringUtil.isNotEmpty(wmSttInGoods.getId())) { - wmSttInGoods = wmSttInGoodsService.getEntity(WmSttInGoodsEntity.class, wmSttInGoods.getId()); - req.setAttribute("wmSttInGoodsPage", wmSttInGoods); - } - return new ModelAndView("com/zzjee/wm/wmSttInGoods-add"); - } - /** - * 库存盘点编辑页面跳转 - * - * @return - */ - @RequestMapping(params = "goUpdate") - public ModelAndView goUpdate(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest req) { - if (StringUtil.isNotEmpty(wmSttInGoods.getId())) { - wmSttInGoods = wmSttInGoodsService.getEntity(WmSttInGoodsEntity.class, wmSttInGoods.getId()); - req.setAttribute("wmSttInGoodsPage", wmSttInGoods); - } - return new ModelAndView("com/zzjee/wm/wmSttInGoods-update"); - } + /** + * 库存盘点新增页面跳转 + * + * @return + */ + @RequestMapping(params = "goAdd") + public ModelAndView goAdd(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest req) { + if (StringUtil.isNotEmpty(wmSttInGoods.getId())) { + wmSttInGoods = wmSttInGoodsService.getEntity(WmSttInGoodsEntity.class, wmSttInGoods.getId()); + req.setAttribute("wmSttInGoodsPage", wmSttInGoods); + } + return new ModelAndView("com/zzjee/wm/wmSttInGoods-add"); + } - /** - * 导入功能跳转 - * - * @return - */ - @RequestMapping(params = "upload") - public ModelAndView upload(HttpServletRequest req) { - req.setAttribute("controller_name","wmSttInGoodsController"); - return new ModelAndView("common/upload/pub_excel_upload"); - } + /** + * 库存盘点编辑页面跳转 + * + * @return + */ + @RequestMapping(params = "goUpdate") + public ModelAndView goUpdate(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest req) { + if (StringUtil.isNotEmpty(wmSttInGoods.getId())) { + wmSttInGoods = wmSttInGoodsService.getEntity(WmSttInGoodsEntity.class, wmSttInGoods.getId()); + req.setAttribute("wmSttInGoodsPage", wmSttInGoods); + } + return new ModelAndView("com/zzjee/wm/wmSttInGoods-update"); + } - /** - * 导出excel - * - * @param request - * @param response - */ - @RequestMapping(params = "exportXls") - public String exportXls(WmSttInGoodsEntity wmSttInGoods,HttpServletRequest request,HttpServletResponse response - , DataGrid dataGrid,ModelMap modelMap) { - CriteriaQuery cq = new CriteriaQuery(WmSttInGoodsEntity.class, dataGrid); - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmSttInGoods, request.getParameterMap()); - List wmSttInGoodss = this.wmSttInGoodsService.getListByCriteriaQuery(cq,false); - modelMap.put(NormalExcelConstants.FILE_NAME,"库存盘点"); - modelMap.put(NormalExcelConstants.CLASS,WmSttInGoodsEntity.class); - modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("库存盘点列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(), - "导出信息")); - modelMap.put(NormalExcelConstants.DATA_LIST,wmSttInGoodss); - return NormalExcelConstants.JEECG_EXCEL_VIEW; - } - /** - * 导出excel 使模板 - * - * @param request - * @param response - */ - @RequestMapping(params = "exportXlsByT") - public String exportXlsByT(WmSttInGoodsEntity wmSttInGoods,HttpServletRequest request,HttpServletResponse response - , DataGrid dataGrid,ModelMap modelMap) { - modelMap.put(NormalExcelConstants.FILE_NAME,"库存盘点"); - modelMap.put(NormalExcelConstants.CLASS,WmSttInGoodsEntity.class); - modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("库存盘点列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(), - "导出信息")); - modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList()); - return NormalExcelConstants.JEECG_EXCEL_VIEW; - } + /** + * 导入功能跳转 + * + * @return + */ + @RequestMapping(params = "upload") + public ModelAndView upload(HttpServletRequest req) { + req.setAttribute("controller_name", "wmSttInGoodsController"); + return new ModelAndView("common/upload/pub_excel_upload"); + } - @SuppressWarnings("unchecked") - @RequestMapping(params = "importExcel", method = RequestMethod.POST) - @ResponseBody - public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) { - AjaxJson j = new AjaxJson(); + /** + * 导出excel + * + * @param request + * @param response + */ + @RequestMapping(params = "exportXls") + public String exportXls(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request, HttpServletResponse response + , DataGrid dataGrid, ModelMap modelMap) { + CriteriaQuery cq = new CriteriaQuery(WmSttInGoodsEntity.class, dataGrid); + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmSttInGoods, request.getParameterMap()); + List wmSttInGoodss = this.wmSttInGoodsService.getListByCriteriaQuery(cq, false); + modelMap.put(NormalExcelConstants.FILE_NAME, "库存盘点"); + modelMap.put(NormalExcelConstants.CLASS, WmSttInGoodsEntity.class); + modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("库存盘点列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(), + "导出信息")); + modelMap.put(NormalExcelConstants.DATA_LIST, wmSttInGoodss); + return NormalExcelConstants.JEECG_EXCEL_VIEW; + } - MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; - Map fileMap = multipartRequest.getFileMap(); - for (Map.Entry entity : fileMap.entrySet()) { - MultipartFile file = entity.getValue();// 获取上传文件对象 - ImportParams params = new ImportParams(); - params.setTitleRows(2); - params.setHeadRows(1); - params.setNeedSave(true); - try { - List listWmSttInGoodsEntitys = ExcelImportUtil.importExcel(file.getInputStream(),WmSttInGoodsEntity.class,params); - for (WmSttInGoodsEntity wmSttInGoods : listWmSttInGoodsEntitys) { - wmSttInGoodsService.save(wmSttInGoods); - } - j.setMsg("文件导入成功!"); - } catch (Exception e) { - j.setMsg("文件导入失败!"); - logger.error(ExceptionUtil.getExceptionMessage(e)); - }finally{ - try { - file.getInputStream().close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return j; - } - //PDA接口 - @RequestMapping(method = RequestMethod.GET) - @ResponseBody - public ResponseEntity list( @RequestParam(value="username", required=false) String username, - @RequestParam(value="searchstr", required=false)String searchstr, - @RequestParam(value="searchstr2", required=false)String searchstr2) { + /** + * 导出excel 使模板 + * + * @param request + * @param response + */ + @RequestMapping(params = "exportXlsByT") + public String exportXlsByT(WmSttInGoodsEntity wmSttInGoods, HttpServletRequest request, HttpServletResponse response + , DataGrid dataGrid, ModelMap modelMap) { + modelMap.put(NormalExcelConstants.FILE_NAME, "库存盘点"); + modelMap.put(NormalExcelConstants.CLASS, WmSttInGoodsEntity.class); + modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("库存盘点列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(), + "导出信息")); + 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()) { + MultipartFile file = entity.getValue();// 获取上传文件对象 + ImportParams params = new ImportParams(); + params.setTitleRows(2); + params.setHeadRows(1); + params.setNeedSave(true); + try { + List listWmSttInGoodsEntitys = ExcelImportUtil.importExcel(file.getInputStream(), WmSttInGoodsEntity.class, params); + for (WmSttInGoodsEntity wmSttInGoods : listWmSttInGoodsEntitys) { + wmSttInGoodsService.save(wmSttInGoods); + } + j.setMsg("文件导入成功!"); + } catch (Exception e) { + j.setMsg("文件导入失败!"); + logger.error(ExceptionUtil.getExceptionMessage(e)); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return j; + } + + //PDA接口 + @RequestMapping(method = RequestMethod.GET) + @ResponseBody + public ResponseEntity list(@RequestParam(value = "username", required = false) String username, + @RequestParam(value = "searchstr", required = false) String searchstr, + @RequestParam(value = "searchstr2", required = false) String searchstr2) { // return listWvGis; - ResultDO D0 = new ResultDO(); - String hql = " from WmSttInGoodsEntity where 1 = 1 and sttSta = '计划中' "; - D0.setOK(true); - if(!StringUtil.isEmpty(searchstr)) { - hql=hql+" and binId like '%" + searchstr + "%'"; - } - if(!StringUtil.isEmpty(searchstr2)) { - try{ + ResultDO D0 = new ResultDO(); + String hql = " from WmSttInGoodsEntity where 1 = 1 and sttSta = '计划中' "; + D0.setOK(true); + if (!StringUtil.isEmpty(searchstr)) { + hql = hql + " and binId like '%" + searchstr + "%'"; + } + if (!StringUtil.isEmpty(searchstr2)) { + try { String shpbianma = wmUtil.getmdgoodsbytiaoma(searchstr2); - if(StringUtil.isNotEmpty(shpbianma)){ - searchstr2=shpbianma; + if (StringUtil.isNotEmpty(shpbianma)) { + searchstr2 = shpbianma; } - }catch (Exception e){ + } catch (Exception e) { } - hql=hql+" and goodsId like '%" + searchstr2 + "%'"; - } + hql = hql + " and goodsId like '%" + searchstr2 + "%'"; + } - List listWmSttInGoodss=wmSttInGoodsService.findHql(hql); - D0.setOK(true); - List result = new ArrayList(); - int i = 0; - for (WmSttInGoodsEntity t :listWmSttInGoodss){ + List listWmSttInGoodss = wmSttInGoodsService.findHql(hql); + D0.setOK(true); + List result = new ArrayList(); + int i = 0; + for (WmSttInGoodsEntity t : listWmSttInGoodss) { - i++; - if(i>100){ - break; - } - result.add(t); - } - if(result.size()<=0){ - D0.setOK(false); - } - D0.setObj(result); - return new ResponseEntity(D0, HttpStatus.OK); + i++; + if (i > 100) { + break; + } + result.add(t); + } + if (result.size() <= 0) { + D0.setOK(false); + } + D0.setObj(result); + return new ResponseEntity(D0, HttpStatus.OK); - } + } - @RequestMapping(value = "/{id}", method = RequestMethod.GET) - @ResponseBody - public ResponseEntity get(@PathVariable("id") String id) { - WmSttInGoodsEntity task = wmSttInGoodsService.get(WmSttInGoodsEntity.class, id); - if (task == null) { - return new ResponseEntity(HttpStatus.NOT_FOUND); - } - return new ResponseEntity(task, HttpStatus.OK); - } + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public ResponseEntity get(@PathVariable("id") String id) { + WmSttInGoodsEntity task = wmSttInGoodsService.get(WmSttInGoodsEntity.class, id); + if (task == null) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + return new ResponseEntity(task, HttpStatus.OK); + } - @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public ResponseEntity create(@RequestBody String wmSttInGoodsstr, UriComponentsBuilder uriBuilder) { - //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. - ResultDO D0 = new ResultDO(); - WmSttInGoodsEntity wmSttInGoods = (WmSttInGoodsEntity)JSONHelper.json2Object(wmSttInGoodsstr,WmToDownGoodsEntity.class); - //保存 - try{ - wmSttInGoodsService.save(wmSttInGoods); - D0.setOK(true); - } catch (Exception e) { - e.printStackTrace(); - D0.setOK(false); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public ResponseEntity create(@RequestBody String wmSttInGoodsstr, UriComponentsBuilder uriBuilder) { + //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. + ResultDO D0 = new ResultDO(); + WmSttInGoodsEntity wmSttInGoods = (WmSttInGoodsEntity) JSONHelper.json2Object(wmSttInGoodsstr, WmToDownGoodsEntity.class); + //保存 + try { + wmSttInGoodsService.save(wmSttInGoods); + D0.setOK(true); + } catch (Exception e) { + e.printStackTrace(); + D0.setOK(false); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } - return new ResponseEntity(D0, HttpStatus.OK); - } + return new ResponseEntity(D0, HttpStatus.OK); + } - @RequestMapping(value = "/change", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public ResponseEntity update(@RequestParam String wmSttInGoodsstr, - UriComponentsBuilder uriBuilder) { - //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. - ResultDO D0 = new ResultDO(); - WmSttInGoodsEntity wmSttInGoods = (WmSttInGoodsEntity)JSONHelper.json2Object(wmSttInGoodsstr,WmSttInGoodsEntity.class); - //保存 - try{ - WmSttInGoodsEntity t = systemService.get(WmSttInGoodsEntity.class,wmSttInGoods.getId()); + @RequestMapping(value = "/change", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public ResponseEntity update(@RequestParam String wmSttInGoodsstr, + UriComponentsBuilder uriBuilder) { + //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. + ResultDO D0 = new ResultDO(); + WmSttInGoodsEntity wmSttInGoods = (WmSttInGoodsEntity) JSONHelper.json2Object(wmSttInGoodsstr, WmSttInGoodsEntity.class); + //保存 + try { + WmSttInGoodsEntity t = systemService.get(WmSttInGoodsEntity.class, wmSttInGoods.getId()); - MyBeanUtils.copyBeanNotNull2Bean(wmSttInGoods,t); - t.setSttSta(Constants.wm_sta4); - t.setUpdateDate(new Date()); - wmSttInGoodsService.saveOrUpdate(t); - D0.setOK(true); - } catch (Exception e) { - e.printStackTrace(); - D0.setOK(false); - } + MyBeanUtils.copyBeanNotNull2Bean(wmSttInGoods, t); + t.setSttSta(Constants.wm_sta4); + t.setUpdateDate(new Date()); + wmSttInGoodsService.saveOrUpdate(t); + D0.setOK(true); + } catch (Exception e) { + e.printStackTrace(); + D0.setOK(false); + } - //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码. + //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码. - return new ResponseEntity(D0, HttpStatus.OK); - } + return new ResponseEntity(D0, HttpStatus.OK); + } - @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) - @ResponseStatus(HttpStatus.NO_CONTENT) - public void delete(@PathVariable("id") String id) { - wmSttInGoodsService.deleteEntityById(WmSttInGoodsEntity.class, id); - } + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) + @ResponseStatus(HttpStatus.NO_CONTENT) + public void delete(@PathVariable("id") String id) { + wmSttInGoodsService.deleteEntityById(WmSttInGoodsEntity.class, id); + } } diff --git a/src/main/java/com/zzjee/wm/controller/WmToDownGoodsController.java b/src/main/java/com/zzjee/wm/controller/WmToDownGoodsController.java index fd0d739d..2dc49e56 100644 --- a/src/main/java/com/zzjee/wm/controller/WmToDownGoodsController.java +++ b/src/main/java/com/zzjee/wm/controller/WmToDownGoodsController.java @@ -65,809 +65,815 @@ import static com.xiaoleilu.hutool.date.DateTime.now; import static org.jeecgframework.web.system.sms.util.Constants.wm_sta6; /** + * @author erzhongxmu + * @version V1.0 * @Title: Controller * @Description: 下架商品明细 - * @author erzhongxmu * @date 2017-08-25 10:40:39 - * @version V1.0 - * */ @Controller @RequestMapping("/wmToDownGoodsController") public class WmToDownGoodsController extends BaseController { - /** - * Logger for this class - */ - private static final Logger logger = Logger - .getLogger(WmToDownGoodsController.class); + /** + * Logger for this class + */ + private static final Logger logger = Logger + .getLogger(WmToDownGoodsController.class); - @Autowired - private WmToDownGoodsServiceI wmToDownGoodsService; - @Autowired - private SystemService systemService; - @Autowired - private Validator validator; + @Autowired + private WmToDownGoodsServiceI wmToDownGoodsService; + @Autowired + private SystemService systemService; + @Autowired + private Validator validator; - /** - * 下架商品明细列表 页面跳转 - * - * @return - */ - @RequestMapping(params = "list") - public ModelAndView list(HttpServletRequest request) { - return new ModelAndView("com/zzjee/wm/wmToDownGoodsList"); - } + /** + * 下架商品明细列表 页面跳转 + * + * @return + */ + @RequestMapping(params = "list") + public ModelAndView list(HttpServletRequest request) { + return new ModelAndView("com/zzjee/wm/wmToDownGoodsList"); + } - /** - * easyui AJAX请求数据 - * - * @param request - * @param response - * @param dataGrid - */ + /** + * easyui AJAX请求数据 + * + * @param request + * @param response + * @param dataGrid + */ - @RequestMapping(params = "datagrid") - public void datagrid(WmToDownGoodsEntity wmToDownGoods, - HttpServletRequest request, HttpServletResponse response, - DataGrid dataGrid) { - CriteriaQuery cq = new CriteriaQuery(WmToDownGoodsEntity.class, - dataGrid); - // 查询条件组装器 - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, - wmToDownGoods, request.getParameterMap()); - try { - // 自定义追加查询条件 - } catch (Exception e) { - throw new BusinessException(e.getMessage()); - } - Map map1 = new HashMap(); - map1.put("createDate", "desc"); - cq.setOrder(map1); - cq.add(); - this.wmToDownGoodsService.getDataGridReturn(cq, true); - List resultold = dataGrid.getResults(); - List resultnew = new ArrayList<>(); - for(WmToDownGoodsEntity t:resultold){ - if (StringUtil.isEmpty(t.getGoodsName())){ - try{ - MvGoodsEntity goods = systemService.findUniqueByProperty(MvGoodsEntity.class, "goodsCode", t.getGoodsId()); - if(goods!=null){ - t.setGoodsName(goods.getGoodsName()); - } - }catch (Exception e){ + @RequestMapping(params = "datagrid") + public void datagrid(WmToDownGoodsEntity wmToDownGoods, + HttpServletRequest request, HttpServletResponse response, + DataGrid dataGrid) { + CriteriaQuery cq = new CriteriaQuery(WmToDownGoodsEntity.class, + dataGrid); + // 查询条件组装器 + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, + wmToDownGoods, request.getParameterMap()); + try { + // 自定义追加查询条件 + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + Map map1 = new HashMap(); + map1.put("createDate", "desc"); + cq.setOrder(map1); + cq.add(); + this.wmToDownGoodsService.getDataGridReturn(cq, true); + List resultold = dataGrid.getResults(); + List resultnew = new ArrayList<>(); + for (WmToDownGoodsEntity t : resultold) { + if (StringUtil.isEmpty(t.getGoodsName())) { + try { + MvGoodsEntity goods = systemService.findUniqueByProperty(MvGoodsEntity.class, "goodsCode", t.getGoodsId()); + if (goods != null) { + t.setGoodsName(goods.getGoodsName()); + } + } catch (Exception e) { - } + } - } + } - resultnew.add(t); - } - dataGrid.setResults(resultnew); + resultnew.add(t); + } + dataGrid.setResults(resultnew); - TagUtil.datagrid(response, dataGrid); - } + TagUtil.datagrid(response, dataGrid); + } - @RequestMapping(params = "datagridwave") - public void wavedatagridzzfh(WmToDownGoodsEntity wmToDownGoods, - HttpServletRequest request, HttpServletResponse response, - DataGrid dataGrid) { - CriteriaQuery cq = new CriteriaQuery(WmToDownGoodsEntity.class, - dataGrid); - // 查询条件组装器 - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, - wmToDownGoods, request.getParameterMap()); - try { - // 自定义追加查询条件 - } catch (Exception e) { - throw new BusinessException(e.getMessage()); - } - Map map1 = new HashMap(); - map1.put("createDate", "desc"); - cq.setOrder(map1); - cq.isNull("downSta"); - cq.add(); - this.wmToDownGoodsService.getDataGridReturn(cq, true); - List resultnew = new ArrayList(); - List resultold = dataGrid.getResults(); - for (WmToDownGoodsEntity wmToDownGoodsEntity : resultold) { - wmToDownGoodsEntity.setGoodsQua(wmToDownGoodsEntity.getGoodsQuaok()); - wmToDownGoodsEntity.setGoodsQuaok(""); - resultnew.add(wmToDownGoodsEntity); + @RequestMapping(params = "datagridwave") + public void wavedatagridzzfh(WmToDownGoodsEntity wmToDownGoods, + HttpServletRequest request, HttpServletResponse response, + DataGrid dataGrid) { + CriteriaQuery cq = new CriteriaQuery(WmToDownGoodsEntity.class, + dataGrid); + // 查询条件组装器 + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, + wmToDownGoods, request.getParameterMap()); + try { + // 自定义追加查询条件 + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + Map map1 = new HashMap(); + map1.put("createDate", "desc"); + cq.setOrder(map1); + cq.isNull("downSta"); + cq.add(); + this.wmToDownGoodsService.getDataGridReturn(cq, true); + List resultnew = new ArrayList(); + List resultold = dataGrid.getResults(); + for (WmToDownGoodsEntity wmToDownGoodsEntity : resultold) { + wmToDownGoodsEntity.setGoodsQua(wmToDownGoodsEntity.getGoodsQuaok()); + wmToDownGoodsEntity.setGoodsQuaok(""); + resultnew.add(wmToDownGoodsEntity); - } - dataGrid.setResults(resultnew); - TagUtil.datagrid(response, dataGrid); - } + } + dataGrid.setResults(resultnew); + TagUtil.datagrid(response, dataGrid); + } - @RequestMapping(params = "datagridzzfh") - public void datagridzzfh(WmToDownGoodsEntity wmToDownGoods, - HttpServletRequest request, HttpServletResponse response, - DataGrid dataGrid) { - CriteriaQuery cq = new CriteriaQuery(WmToDownGoodsEntity.class, - dataGrid); - // 查询条件组装器 - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, - wmToDownGoods, request.getParameterMap()); - try { - // 自定义追加查询条件 - } catch (Exception e) { - throw new BusinessException(e.getMessage()); - } - Map map1 = new HashMap(); - map1.put("createDate", "desc"); - cq.setOrder(map1); - cq.isNull("downSta"); - cq.add(); - this.wmToDownGoodsService.getDataGridReturn(cq, true); - List resultnew = new ArrayList(); - List resultold = dataGrid.getResults(); - for (WmToDownGoodsEntity wmToDownGoodsEntity : resultold) { - wmToDownGoodsEntity.setGoodsQua(wmToDownGoodsEntity.getGoodsQuaok()); - wmToDownGoodsEntity.setGoodsQuaok(""); - resultnew.add(wmToDownGoodsEntity); + @RequestMapping(params = "datagridzzfh") + public void datagridzzfh(WmToDownGoodsEntity wmToDownGoods, + HttpServletRequest request, HttpServletResponse response, + DataGrid dataGrid) { + CriteriaQuery cq = new CriteriaQuery(WmToDownGoodsEntity.class, + dataGrid); + // 查询条件组装器 + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, + wmToDownGoods, request.getParameterMap()); + try { + // 自定义追加查询条件 + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + Map map1 = new HashMap(); + map1.put("createDate", "desc"); + cq.setOrder(map1); + cq.isNull("downSta"); + cq.add(); + this.wmToDownGoodsService.getDataGridReturn(cq, true); + List resultnew = new ArrayList(); + List resultold = dataGrid.getResults(); + for (WmToDownGoodsEntity wmToDownGoodsEntity : resultold) { + wmToDownGoodsEntity.setGoodsQua(wmToDownGoodsEntity.getGoodsQuaok()); + wmToDownGoodsEntity.setGoodsQuaok(""); + resultnew.add(wmToDownGoodsEntity); - } - dataGrid.setResults(resultnew); - TagUtil.datagrid(response, dataGrid); - } - /** - * 删除下架商品明细 - * - * @return - */ - @RequestMapping(params = "doDel") - @ResponseBody - public AjaxJson doDel(WmToDownGoodsEntity wmToDownGoods, - HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - wmToDownGoods = systemService.getEntity(WmToDownGoodsEntity.class, - wmToDownGoods.getId()); - message = "下架商品明细删除成功"; - try { - wmToDownGoodsService.delete(wmToDownGoods); - systemService.addLog(message, Globals.Log_Type_DEL, - Globals.Log_Leavel_INFO); - } catch (Exception e) { - e.printStackTrace(); - message = "下架商品明细删除失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + } + dataGrid.setResults(resultnew); + TagUtil.datagrid(response, dataGrid); + } - /** - * 批量删除下架商品明细 - * - * @return - */ - @RequestMapping(params = "doBatchDel") - @ResponseBody - public AjaxJson doBatchDel(String ids, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - message = "下架商品明细删除成功"; - try { - for (String id : ids.split(",")) { - WmToDownGoodsEntity wmToDownGoods = systemService.getEntity( - WmToDownGoodsEntity.class, id); - wmToDownGoodsService.delete(wmToDownGoods); - systemService.addLog(message, Globals.Log_Type_DEL, - Globals.Log_Leavel_INFO); - } - } catch (Exception e) { - e.printStackTrace(); - message = "下架商品明细删除失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } - /** - * 行编辑列表 - */ - //JeecgListDemoController.do?rowListDemo - @RequestMapping(params = "delList") - public ModelAndView delListDemo(HttpServletRequest request) { - return new ModelAndView("com/zzjee/wm/omconf"); - } - @RequestMapping(params = "wavedelList") - public ModelAndView wavedelListDemo(HttpServletRequest request) { - return new ModelAndView("com/zzjee/wm/wavedel_rowedtior"); - } + /** + * 删除下架商品明细 + * + * @return + */ + @RequestMapping(params = "doDel") + @ResponseBody + public AjaxJson doDel(WmToDownGoodsEntity wmToDownGoods, + HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + wmToDownGoods = systemService.getEntity(WmToDownGoodsEntity.class, + wmToDownGoods.getId()); + message = "下架商品明细删除成功"; + try { + wmToDownGoodsService.delete(wmToDownGoods); + systemService.addLog(message, Globals.Log_Type_DEL, + Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "下架商品明细删除失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } + + /** + * 批量删除下架商品明细 + * + * @return + */ + @RequestMapping(params = "doBatchDel") + @ResponseBody + public AjaxJson doBatchDel(String ids, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "下架商品明细删除成功"; + try { + for (String id : ids.split(",")) { + WmToDownGoodsEntity wmToDownGoods = systemService.getEntity( + WmToDownGoodsEntity.class, id); + wmToDownGoodsService.delete(wmToDownGoods); + systemService.addLog(message, Globals.Log_Type_DEL, + Globals.Log_Leavel_INFO); + } + } catch (Exception e) { + e.printStackTrace(); + message = "下架商品明细删除失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } + + /** + * 行编辑列表 + */ + //JeecgListDemoController.do?rowListDemo + @RequestMapping(params = "delList") + public ModelAndView delListDemo(HttpServletRequest request) { + return new ModelAndView("com/zzjee/wm/omconf"); + } + + @RequestMapping(params = "wavedelList") + public ModelAndView wavedelListDemo(HttpServletRequest request) { + return new ModelAndView("com/zzjee/wm/wavedel_rowedtior"); + } - /** - * 更新下架商品明细 - * - * @return - */ - @RequestMapping(params = "dofubatch") - @ResponseBody - public AjaxJson dofubatch(String id, - HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - message = "批量复核成功"; - WmToDownGoodsEntity t = wmToDownGoodsService.get( - WmToDownGoodsEntity.class, id); - try { - t.setDownSta(Constants.wm_sta5);//直接修改状态 - wmToDownGoodsService.saveOrUpdate(t); - try{ - String orderId = t.getOrderId(); - String type = "fh"; - String username = ResourceUtil.getSessionUserName().getRealName(); - updateUser(orderId,type,username); - }catch (Exception e){ - } - systemService.addLog(message, Globals.Log_Type_UPDATE, - Globals.Log_Leavel_INFO); - } catch (Exception e) { - e.printStackTrace(); - message = "批量复核失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + /** + * 更新下架商品明细 + * + * @return + */ + @RequestMapping(params = "dofubatch") + @ResponseBody + public AjaxJson dofubatch(String id, + HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "批量复核成功"; + WmToDownGoodsEntity t = wmToDownGoodsService.get( + WmToDownGoodsEntity.class, id); + try { + t.setDownSta(Constants.wm_sta5);//直接修改状态 + wmToDownGoodsService.saveOrUpdate(t); + try { + String orderId = t.getOrderId(); + String type = "fh"; + String username = ResourceUtil.getSessionUserName().getRealName(); + updateUser(orderId, type, username); + } catch (Exception e) { + } + systemService.addLog(message, Globals.Log_Type_UPDATE, + Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "批量复核失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } + /** + * gengxin + * + * @param page + * @return + */ + @RequestMapping(params = "updateRows") + @ResponseBody + public AjaxJson updateRows(Delrowpage page) { + String message = null; + List demos = page.getDownrows(); + AjaxJson j = new AjaxJson(); + if (CollectionUtils.isNotEmpty(demos)) { + for (WmToDownGoodsEntity jeecgDemo : demos) { + if (StringUtil.isNotEmpty(jeecgDemo.getId())) { + WmToDownGoodsEntity t = systemService.get(WmToDownGoodsEntity.class, jeecgDemo.getId()); + try { + MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t); + systemService.saveOrUpdate(t); + try { + String orderId = t.getOrderId(); + String type = "fh"; + String username = ResourceUtil.getSessionUserName().getRealName(); + updateUser(orderId, type, username); + } catch (Exception e) { + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + return j; + } - /** - * gengxin - * @param page - * @return - */ - @RequestMapping(params = "updateRows") - @ResponseBody - public AjaxJson updateRows(Delrowpage page){ - String message = null; - List demos=page.getDownrows(); - AjaxJson j = new AjaxJson(); - if(CollectionUtils.isNotEmpty(demos)){ - for(WmToDownGoodsEntity jeecgDemo:demos){ - if (StringUtil.isNotEmpty(jeecgDemo.getId())) { - WmToDownGoodsEntity t =systemService.get(WmToDownGoodsEntity.class, jeecgDemo.getId()); - try { - MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t); - systemService.saveOrUpdate(t); - try{ - String orderId = t.getOrderId(); - String type = "fh"; - String username = ResourceUtil.getSessionUserName().getRealName(); - updateUser(orderId,type,username); - }catch (Exception e){ - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - return j; - } + /** + * 装车复核 + * + * @param page + * @return + */ + @RequestMapping(params = "saveRows") + @ResponseBody + public AjaxJson saveRows(Delrowpage page) { + String message = null; + List demos = page.getDownrows(); + AjaxJson j = new AjaxJson(); + if (CollectionUtils.isNotEmpty(demos)) { + for (WmToDownGoodsEntity jeecgDemo : demos) { + if (StringUtil.isNotEmpty(jeecgDemo.getId())) { + WmToDownGoodsEntity t = systemService.get(WmToDownGoodsEntity.class, jeecgDemo.getId()); + try { + message = "装车复核成功"; + MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t); + t.setDownSta(Constants.wm_sta5); + systemService.saveOrUpdate(t); - /** - * 装车复核 - * @param page - * @return - */ - @RequestMapping(params = "saveRows") - @ResponseBody - public AjaxJson saveRows(Delrowpage page){ - String message = null; - List demos=page.getDownrows(); - AjaxJson j = new AjaxJson(); - if(CollectionUtils.isNotEmpty(demos)){ - for(WmToDownGoodsEntity jeecgDemo:demos){ - if (StringUtil.isNotEmpty(jeecgDemo.getId())) { - WmToDownGoodsEntity t =systemService.get(WmToDownGoodsEntity.class, jeecgDemo.getId()); - try { - message = "装车复核成功"; - MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t); - t.setDownSta(Constants.wm_sta5); - systemService.saveOrUpdate(t); + try { + String orderId = t.getOrderId(); + String type = "fh"; + String username = ResourceUtil.getSessionUserName().getRealName(); + updateUser(orderId, type, username); + } catch (Exception e) { + } - try{ - String orderId = t.getOrderId(); - String type = "fh"; - String username = ResourceUtil.getSessionUserName().getRealName(); - updateUser(orderId,type,username); - }catch (Exception e){ - } - - systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - return j; - } + systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + return j; + } - @RequestMapping(params = "doGetcusname",method ={RequestMethod.GET, RequestMethod.POST}) - @ResponseBody - public AjaxJson doGetcusname(HttpServletRequest request) { - AjaxJson j = new AjaxJson(); - MvCusEntity mvcus = systemService.findUniqueByProperty(MvCusEntity.class, "cusCode", oConvertUtils.getString(request.getParameter("cusCode"))) ; - if(mvcus==null){ - j.setSuccess(false); - j.setMsg("不存在货主"); - } - j.setObj(mvcus); - return j; - } + @RequestMapping(params = "doGetcusname", method = {RequestMethod.GET, RequestMethod.POST}) + @ResponseBody + public AjaxJson doGetcusname(HttpServletRequest request) { + AjaxJson j = new AjaxJson(); + MvCusEntity mvcus = systemService.findUniqueByProperty(MvCusEntity.class, "cusCode", oConvertUtils.getString(request.getParameter("cusCode"))); + if (mvcus == null) { + j.setSuccess(false); + j.setMsg("不存在货主"); + } + j.setObj(mvcus); + return j; + } - @RequestMapping(params = "doGettextzy",method ={RequestMethod.GET, RequestMethod.POST}) - @ResponseBody - public AjaxJson doGettextzy(HttpServletRequest request) { - AjaxJson j = new AjaxJson(); - MvGoodsEntity mvgoods = systemService.findUniqueByProperty(MvGoodsEntity.class, "goodsCode", oConvertUtils.getString(request.getParameter("goodsid"))) ; - if(mvgoods==null){ - j.setSuccess(false); - j.setMsg("不存在此商品"); - }else{ - String sql = "select ws.ku_wei_bian_ma,ws.bin_id,ws.shp_ming_cheng,cast(sum(ws.base_goodscount) as signed) as goods_qua, mb.qu_huo_ci_xu, ws.goods_pro_data" - +" from wv_stock ws, md_bin mb where " - +" ws.ku_wei_bian_ma = mb.ku_wei_bian_ma and mb.ting_yong <> 'Y' and ws.kuctype = '库存'" - +" and ws.goods_id = ? " - +" group by ws.ku_wei_bian_ma,ws.bin_id,ws.shp_ming_cheng,mb.qu_huo_ci_xu, ws.goods_pro_data order by ws.goods_pro_data , ws.goods_qua, mb.qu_huo_ci_xu"; - Object objs = null; - List> result = systemService.findForJdbc(sql, request.getParameter("goodsid")); + @RequestMapping(params = "doGettextzy", method = {RequestMethod.GET, RequestMethod.POST}) + @ResponseBody + public AjaxJson doGettextzy(HttpServletRequest request) { + AjaxJson j = new AjaxJson(); + MvGoodsEntity mvgoods = systemService.findUniqueByProperty(MvGoodsEntity.class, "goodsCode", oConvertUtils.getString(request.getParameter("goodsid"))); + if (mvgoods == null) { + j.setSuccess(false); + j.setMsg("不存在此商品"); + } else { + String sql = "select ws.ku_wei_bian_ma,ws.bin_id,ws.shp_ming_cheng,cast(sum(ws.base_goodscount) as signed) as goods_qua, mb.qu_huo_ci_xu, ws.goods_pro_data" + + " from wv_stock ws, md_bin mb where " + + " ws.ku_wei_bian_ma = mb.ku_wei_bian_ma and mb.ting_yong <> 'Y' and ws.kuctype = '库存'" + + " and ws.goods_id = ? " + + " group by ws.ku_wei_bian_ma,ws.bin_id,ws.shp_ming_cheng,mb.qu_huo_ci_xu, ws.goods_pro_data order by ws.goods_pro_data , ws.goods_qua, mb.qu_huo_ci_xu"; + Object objs = null; + List> result = systemService.findForJdbc(sql, request.getParameter("goodsid")); - if(result!=null){ + if (result != null) { - }else{ - j.setSuccess(false); - j.setMsg("商品没有库存"); - } - } - j.setObj(mvgoods); - return j; - } + } else { + j.setSuccess(false); + j.setMsg("商品没有库存"); + } + } + j.setObj(mvgoods); + return j; + } - @RequestMapping(params = "doGettext",method ={RequestMethod.GET, RequestMethod.POST}) - @ResponseBody - public AjaxJson doGettext(HttpServletRequest request) { - AjaxJson j = new AjaxJson(); - MvGoodsEntity mvgoods = systemService.findUniqueByProperty(MvGoodsEntity.class, "goodsCode", oConvertUtils.getString(request.getParameter("goodsid"))) ; - if(mvgoods==null){ - j.setSuccess(false); - j.setMsg("不存在此商品"); - }else{ - double goodsno = 0; - WmOmNoticeHEntity wmOmNoticeHEntity = systemService.findUniqueByProperty(WmOmNoticeHEntity.class, "omNoticeId", oConvertUtils.getString(request.getParameter("noticeid"))); - String hql0 = "from WmOmNoticeIEntity where 1 = 1 AND omNoticeId = ? and goodsId = ? "; - List wmOmNoticeIEntityList = systemService - .findHql(hql0, wmOmNoticeHEntity.getOmNoticeId(),oConvertUtils.getString(request.getParameter("goodsid")));//获取行项目 - for (WmOmNoticeIEntity wmOmNoticeIEntity : wmOmNoticeIEntityList) { - goodsno = (Double.valueOf(wmOmNoticeIEntity.getGoodsQua()) - Double.valueOf(wmOmNoticeIEntity.getGoodsQuaok())) * Double.valueOf(mvgoods.getChlShl()); - if(goodsno > 0 ){ - String sql = "select ws.ku_wei_bian_ma,ws.bin_id,ws.shp_ming_cheng,cast(sum(ws.base_goodscount) as signed) as goods_qua, mb.qu_huo_ci_xu, ws.goods_pro_data" - +" from wv_stock ws, md_bin mb where " - +" ws.ku_wei_bian_ma = mb.ku_wei_bian_ma and mb.ting_yong <> 'Y' and ws.kuctype = '库存'" - +" and ws.goods_id = ? " - +" and ws.cus_code = ? " - +" group by ws.ku_wei_bian_ma,ws.bin_id,ws.shp_ming_cheng,mb.qu_huo_ci_xu, ws.goods_pro_data order by ws.goods_pro_data , ws.goods_qua, mb.qu_huo_ci_xu"; - Object objs = null; - List> result = systemService.findForJdbc(sql, wmOmNoticeIEntity.getGoodsId(),wmOmNoticeHEntity.getCusCode()); - mvgoods.setChlShl(String.valueOf(goodsno)); - if(result!=null){ - for(int i = 0;i0){ - if(Double.valueOf(result.get(i).get("goods_qua").toString())>=goodsno){ - mvgoods.setTiJiCm(String.valueOf(goodsno));//数量 - mvgoods.setZhlKg("本次可发完");//还需数量 - }else{ - double wq = goodsno - Double.valueOf(result.get(i).get("goods_qua").toString()); - mvgoods.setTiJiCm(result.get(i).get("goods_qua").toString());//数量setChcDanWei - mvgoods.setZhlKg("还需要发"+Double.toString(wq));//还需数量 setChlKongZhi + @RequestMapping(params = "doGettext", method = {RequestMethod.GET, RequestMethod.POST}) + @ResponseBody + public AjaxJson doGettext(HttpServletRequest request) { + AjaxJson j = new AjaxJson(); + MvGoodsEntity mvgoods = systemService.findUniqueByProperty(MvGoodsEntity.class, "goodsCode", oConvertUtils.getString(request.getParameter("goodsid"))); + if (mvgoods == null) { + j.setSuccess(false); + j.setMsg("不存在此商品"); + } else { + double goodsno = 0; + WmOmNoticeHEntity wmOmNoticeHEntity = systemService.findUniqueByProperty(WmOmNoticeHEntity.class, "omNoticeId", oConvertUtils.getString(request.getParameter("noticeid"))); + String hql0 = "from WmOmNoticeIEntity where 1 = 1 AND omNoticeId = ? and goodsId = ? "; + List wmOmNoticeIEntityList = systemService + .findHql(hql0, wmOmNoticeHEntity.getOmNoticeId(), oConvertUtils.getString(request.getParameter("goodsid")));//获取行项目 + for (WmOmNoticeIEntity wmOmNoticeIEntity : wmOmNoticeIEntityList) { + goodsno = (Double.valueOf(wmOmNoticeIEntity.getGoodsQua()) - Double.valueOf(wmOmNoticeIEntity.getGoodsQuaok())) * Double.valueOf(mvgoods.getChlShl()); + if (goodsno > 0) { + String sql = "select ws.ku_wei_bian_ma,ws.bin_id,ws.shp_ming_cheng,cast(sum(ws.base_goodscount) as signed) as goods_qua, mb.qu_huo_ci_xu, ws.goods_pro_data" + + " from wv_stock ws, md_bin mb where " + + " ws.ku_wei_bian_ma = mb.ku_wei_bian_ma and mb.ting_yong <> 'Y' and ws.kuctype = '库存'" + + " and ws.goods_id = ? " + + " and ws.cus_code = ? " + + " group by ws.ku_wei_bian_ma,ws.bin_id,ws.shp_ming_cheng,mb.qu_huo_ci_xu, ws.goods_pro_data order by ws.goods_pro_data , ws.goods_qua, mb.qu_huo_ci_xu"; + Object objs = null; + List> result = systemService.findForJdbc(sql, wmOmNoticeIEntity.getGoodsId(), wmOmNoticeHEntity.getCusCode()); + mvgoods.setChlShl(String.valueOf(goodsno)); + if (result != null) { + for (int i = 0; i < result.size(); i++) { + if (Double.valueOf(result.get(i).get("goods_qua").toString()) > 0) { + if (Double.valueOf(result.get(i).get("goods_qua").toString()) >= goodsno) { + mvgoods.setTiJiCm(String.valueOf(goodsno));//数量 + mvgoods.setZhlKg("本次可发完");//还需数量 + } else { + double wq = goodsno - Double.valueOf(result.get(i).get("goods_qua").toString()); + mvgoods.setTiJiCm(result.get(i).get("goods_qua").toString());//数量setChcDanWei + mvgoods.setZhlKg("还需要发" + Double.toString(wq));//还需数量 setChlKongZhi - } - mvgoods.setGoodsName(result.get(i).get("shp_ming_cheng").toString());//名称 - mvgoods.setBzhiQi(result.get(i).get("ku_wei_bian_ma").toString());//库位 - mvgoods.setCfWenCeng(result.get(i).get("bin_id").toString());//托盘 + } + mvgoods.setGoodsName(result.get(i).get("shp_ming_cheng").toString());//名称 + mvgoods.setBzhiQi(result.get(i).get("ku_wei_bian_ma").toString());//库位 + mvgoods.setCfWenCeng(result.get(i).get("bin_id").toString());//托盘 - mvgoods.setChlShl(result.get(i).get("goods_pro_data").toString());//生成日期 setChDanPin - break; - } + mvgoods.setChlShl(result.get(i).get("goods_pro_data").toString());//生成日期 setChDanPin + break; + } - } - }else{ - j.setSuccess(false); - j.setMsg("商品没有库存"); - } + } + } else { + j.setSuccess(false); + j.setMsg("商品没有库存"); + } - break; - } - } - if(goodsno <=0){ - j.setSuccess(false); - j.setMsg("已经发货完毕"); - } - } - j.setObj(mvgoods); - return j; - } + break; + } + } + if (goodsno <= 0) { + j.setSuccess(false); + j.setMsg("已经发货完毕"); + } + } + j.setObj(mvgoods); + return j; + } - /** - * 添加下架商品明细 - * - * @return - */ - @RequestMapping(params = "doAdd") - @ResponseBody - public AjaxJson doAdd(WmToDownGoodsEntity wmToDownGoods, - HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - message = "下架商品明细添加成功"; - try { - wmToDownGoods.setOrderId("ZY"); - wmToDownGoods.setBinIdTo("PK"); - wmToDownGoods.setDownSta("已复核"); - wmToDownGoods.setGoodsQuaok(wmToDownGoods.getGoodsQua()); + /** + * 添加下架商品明细 + * + * @return + */ + @RequestMapping(params = "doAdd") + @ResponseBody + public AjaxJson doAdd(WmToDownGoodsEntity wmToDownGoods, + HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "下架商品明细添加成功"; + try { + wmToDownGoods.setOrderId("ZY"); + wmToDownGoods.setBinIdTo("PK"); + wmToDownGoods.setDownSta("已复核"); + wmToDownGoods.setGoodsQuaok(wmToDownGoods.getGoodsQua()); // MvGoodsEntity mvgoods = new MvGoodsEntity(); - MvGoodsEntity mvgoods = systemService.findUniqueByProperty( - MvGoodsEntity.class, "goodsCode", - wmToDownGoods.getGoodsId()); - if(mvgoods!=null){ - wmToDownGoods.setGoodsName(mvgoods.getGoodsName()); - wmToDownGoods.setBaseUnit(mvgoods.getBaseunit()); - wmToDownGoods.setGoodsUnit(mvgoods.getShlDanWei()); - if (!mvgoods.getBaseunit().equals(mvgoods.getShlDanWei())) { - try { - wmToDownGoods.setBaseGoodscount(String.valueOf(Double - .parseDouble(mvgoods.getChlShl()) - * Double.parseDouble(wmToDownGoods.getGoodsQua()))); - } catch (Exception e) { - // TODO: handle exception - } + MvGoodsEntity mvgoods = systemService.findUniqueByProperty( + MvGoodsEntity.class, "goodsCode", + wmToDownGoods.getGoodsId()); + if (mvgoods != null) { + wmToDownGoods.setGoodsName(mvgoods.getGoodsName()); + wmToDownGoods.setBaseUnit(mvgoods.getBaseunit()); + wmToDownGoods.setGoodsUnit(mvgoods.getShlDanWei()); + if (!mvgoods.getBaseunit().equals(mvgoods.getShlDanWei())) { + try { + wmToDownGoods.setBaseGoodscount(String.valueOf(Double + .parseDouble(mvgoods.getChlShl()) + * Double.parseDouble(wmToDownGoods.getGoodsQua()))); + } catch (Exception e) { + // TODO: handle exception + } - } else { - wmToDownGoods.setBaseGoodscount(wmToDownGoods - .getGoodsQua()); - } + } else { + wmToDownGoods.setBaseGoodscount(wmToDownGoods + .getGoodsQua()); + } - if(!wmUtil.checkstcok(wmToDownGoods.getKuWeiBianMa(),wmToDownGoods.getBinIdFrom(),wmToDownGoods.getGoodsId(),wmToDownGoods.getGoodsProData(),wmToDownGoods.getGoodsQua())){ - message = "库存不足"; - j.setMsg(message); - return j; + if (!wmUtil.checkstcok(wmToDownGoods.getKuWeiBianMa(), wmToDownGoods.getBinIdFrom(), wmToDownGoods.getGoodsId(), wmToDownGoods.getGoodsProData(), wmToDownGoods.getGoodsQua())) { + message = "库存不足"; + j.setMsg(message); + return j; - }; - wmToDownGoodsService.save(wmToDownGoods); - systemService.addLog(message, Globals.Log_Type_INSERT, - Globals.Log_Leavel_INFO); - } - } catch (Exception e) { - e.printStackTrace(); - message = "下架商品明细添加失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + } + ; + wmToDownGoodsService.save(wmToDownGoods); + systemService.addLog(message, Globals.Log_Type_INSERT, + Globals.Log_Leavel_INFO); + } + } catch (Exception e) { + e.printStackTrace(); + message = "下架商品明细添加失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - /** - * 更新下架商品明细 - * - * @return - */ - @RequestMapping(params = "doUpdate") - @ResponseBody - public AjaxJson doUpdate(WmToDownGoodsEntity wmToDownGoods, - HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - message = "下架商品明细更新成功"; - WmToDownGoodsEntity t = wmToDownGoodsService.get( - WmToDownGoodsEntity.class, wmToDownGoods.getId()); - try { - MyBeanUtils.copyBeanNotNull2Bean(wmToDownGoods, t); - wmToDownGoodsService.saveOrUpdate(t); - systemService.addLog(message, Globals.Log_Type_UPDATE, - Globals.Log_Leavel_INFO); - } catch (Exception e) { - e.printStackTrace(); - message = "下架商品明细更新失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + /** + * 更新下架商品明细 + * + * @return + */ + @RequestMapping(params = "doUpdate") + @ResponseBody + public AjaxJson doUpdate(WmToDownGoodsEntity wmToDownGoods, + HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "下架商品明细更新成功"; + WmToDownGoodsEntity t = wmToDownGoodsService.get( + WmToDownGoodsEntity.class, wmToDownGoods.getId()); + try { + MyBeanUtils.copyBeanNotNull2Bean(wmToDownGoods, t); + wmToDownGoodsService.saveOrUpdate(t); + systemService.addLog(message, Globals.Log_Type_UPDATE, + Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "下架商品明细更新失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - /** - * 下架商品明细新增页面跳转 - * - * @return - */ - @RequestMapping(params = "goAdd") - public ModelAndView goAdd(WmToDownGoodsEntity wmToDownGoods, - HttpServletRequest req) { - if (StringUtil.isNotEmpty(wmToDownGoods.getId())) { - wmToDownGoods = wmToDownGoodsService.getEntity( - WmToDownGoodsEntity.class, wmToDownGoods.getId()); - req.setAttribute("wmToDownGoodsPage", wmToDownGoods); - } - return new ModelAndView("com/zzjee/wm/wmToDownGoods-add"); - } + /** + * 下架商品明细新增页面跳转 + * + * @return + */ + @RequestMapping(params = "goAdd") + public ModelAndView goAdd(WmToDownGoodsEntity wmToDownGoods, + HttpServletRequest req) { + if (StringUtil.isNotEmpty(wmToDownGoods.getId())) { + wmToDownGoods = wmToDownGoodsService.getEntity( + WmToDownGoodsEntity.class, wmToDownGoods.getId()); + req.setAttribute("wmToDownGoodsPage", wmToDownGoods); + } + return new ModelAndView("com/zzjee/wm/wmToDownGoods-add"); + } - /** - * 下架商品明细编辑页面跳转 - * - * @return - */ - @RequestMapping(params = "goUpdate") - public ModelAndView goUpdate(WmToDownGoodsEntity wmToDownGoods, - HttpServletRequest req) { - if (StringUtil.isNotEmpty(wmToDownGoods.getId())) { - wmToDownGoods = wmToDownGoodsService.getEntity( - WmToDownGoodsEntity.class, wmToDownGoods.getId()); - req.setAttribute("wmToDownGoodsPage", wmToDownGoods); - } - return new ModelAndView("com/zzjee/wm/wmToDownGoods-update"); - } + /** + * 下架商品明细编辑页面跳转 + * + * @return + */ + @RequestMapping(params = "goUpdate") + public ModelAndView goUpdate(WmToDownGoodsEntity wmToDownGoods, + HttpServletRequest req) { + if (StringUtil.isNotEmpty(wmToDownGoods.getId())) { + wmToDownGoods = wmToDownGoodsService.getEntity( + WmToDownGoodsEntity.class, wmToDownGoods.getId()); + req.setAttribute("wmToDownGoodsPage", wmToDownGoods); + } + return new ModelAndView("com/zzjee/wm/wmToDownGoods-update"); + } - /** - * 导入功能跳转 - * - * @return - */ - @RequestMapping(params = "upload") - public ModelAndView upload(HttpServletRequest req) { - req.setAttribute("controller_name", "wmToDownGoodsController"); - return new ModelAndView("common/upload/pub_excel_upload"); - } + /** + * 导入功能跳转 + * + * @return + */ + @RequestMapping(params = "upload") + public ModelAndView upload(HttpServletRequest req) { + req.setAttribute("controller_name", "wmToDownGoodsController"); + return new ModelAndView("common/upload/pub_excel_upload"); + } - /** - * 导出excel - * - * @param request - * @param response - */ - @RequestMapping(params = "exportXls") - public String exportXls(WmToDownGoodsEntity wmToDownGoods, - HttpServletRequest request, HttpServletResponse response, - DataGrid dataGrid, ModelMap modelMap) { - CriteriaQuery cq = new CriteriaQuery(WmToDownGoodsEntity.class, - dataGrid); - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, - wmToDownGoods, request.getParameterMap()); - List wmToDownGoodss = this.wmToDownGoodsService - .getListByCriteriaQuery(cq, false); - modelMap.put(NormalExcelConstants.FILE_NAME, "下架商品明细"); - modelMap.put(NormalExcelConstants.CLASS, WmToDownGoodsEntity.class); - modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("下架商品明细列表", - "导出人:" + ResourceUtil.getSessionUserName().getRealName(), - "导出信息")); - modelMap.put(NormalExcelConstants.DATA_LIST, wmToDownGoodss); - return NormalExcelConstants.JEECG_EXCEL_VIEW; - } + /** + * 导出excel + * + * @param request + * @param response + */ + @RequestMapping(params = "exportXls") + public String exportXls(WmToDownGoodsEntity wmToDownGoods, + HttpServletRequest request, HttpServletResponse response, + DataGrid dataGrid, ModelMap modelMap) { + CriteriaQuery cq = new CriteriaQuery(WmToDownGoodsEntity.class, + dataGrid); + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, + wmToDownGoods, request.getParameterMap()); + List wmToDownGoodss = this.wmToDownGoodsService + .getListByCriteriaQuery(cq, false); + modelMap.put(NormalExcelConstants.FILE_NAME, "下架商品明细"); + modelMap.put(NormalExcelConstants.CLASS, WmToDownGoodsEntity.class); + modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("下架商品明细列表", + "导出人:" + ResourceUtil.getSessionUserName().getRealName(), + "导出信息")); + modelMap.put(NormalExcelConstants.DATA_LIST, wmToDownGoodss); + return NormalExcelConstants.JEECG_EXCEL_VIEW; + } - /** - * 导出excel 使模板 - * - * @param request - * @param response - */ - @RequestMapping(params = "exportXlsByT") - public String exportXlsByT(WmToDownGoodsEntity wmToDownGoods, - HttpServletRequest request, HttpServletResponse response, - DataGrid dataGrid, ModelMap modelMap) { - modelMap.put(NormalExcelConstants.FILE_NAME, "下架商品明细"); - modelMap.put(NormalExcelConstants.CLASS, WmToDownGoodsEntity.class); - modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("下架商品明细列表", - "导出人:" + ResourceUtil.getSessionUserName().getRealName(), - "导出信息")); - modelMap.put(NormalExcelConstants.DATA_LIST, new ArrayList()); - return NormalExcelConstants.JEECG_EXCEL_VIEW; - } + /** + * 导出excel 使模板 + * + * @param request + * @param response + */ + @RequestMapping(params = "exportXlsByT") + public String exportXlsByT(WmToDownGoodsEntity wmToDownGoods, + HttpServletRequest request, HttpServletResponse response, + DataGrid dataGrid, ModelMap modelMap) { + modelMap.put(NormalExcelConstants.FILE_NAME, "下架商品明细"); + modelMap.put(NormalExcelConstants.CLASS, WmToDownGoodsEntity.class); + modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("下架商品明细列表", + "导出人:" + ResourceUtil.getSessionUserName().getRealName(), + "导出信息")); + 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(); + @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()) { - MultipartFile file = entity.getValue();// 获取上传文件对象 - ImportParams params = new ImportParams(); - params.setTitleRows(2); - params.setHeadRows(1); - params.setNeedSave(true); - try { - List listWmToDownGoodsEntitys = ExcelImportUtil - .importExcel(file.getInputStream(), - WmToDownGoodsEntity.class, params); - for (WmToDownGoodsEntity wmToDownGoods : listWmToDownGoodsEntitys) { - wmToDownGoodsService.save(wmToDownGoods); - } - j.setMsg("文件导入成功!"); - } catch (Exception e) { - j.setMsg("文件导入失败!"); - logger.error(ExceptionUtil.getExceptionMessage(e)); - } finally { - try { - file.getInputStream().close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return j; - } + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + for (Map.Entry entity : fileMap.entrySet()) { + MultipartFile file = entity.getValue();// 获取上传文件对象 + ImportParams params = new ImportParams(); + params.setTitleRows(2); + params.setHeadRows(1); + params.setNeedSave(true); + try { + List listWmToDownGoodsEntitys = ExcelImportUtil + .importExcel(file.getInputStream(), + WmToDownGoodsEntity.class, params); + for (WmToDownGoodsEntity wmToDownGoods : listWmToDownGoodsEntitys) { + wmToDownGoodsService.save(wmToDownGoods); + } + j.setMsg("文件导入成功!"); + } catch (Exception e) { + j.setMsg("文件导入失败!"); + logger.error(ExceptionUtil.getExceptionMessage(e)); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return j; + } - @RequestMapping(method = RequestMethod.GET) - @ResponseBody - public List list() { - List listWmToDownGoodss = wmToDownGoodsService - .getList(WmToDownGoodsEntity.class); - return listWmToDownGoodss; - } + @RequestMapping(method = RequestMethod.GET) + @ResponseBody + public List list() { + List listWmToDownGoodss = wmToDownGoodsService + .getList(WmToDownGoodsEntity.class); + return listWmToDownGoodss; + } - @RequestMapping(value = "/{id}", method = RequestMethod.GET) - @ResponseBody - public ResponseEntity get(@PathVariable("id") String id) { - WmToDownGoodsEntity task = wmToDownGoodsService.get( - WmToDownGoodsEntity.class, id); - if (task == null) { - return new ResponseEntity(HttpStatus.NOT_FOUND); - } - return new ResponseEntity(task, HttpStatus.OK); - } - //下架 - @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public synchronized ResponseEntity create(@RequestParam String wmToDownGoodsstr, - UriComponentsBuilder uriBuilder) { - ResultDO D0 = new ResultDO(); - WmToDownGoodsEntity wmToDownGoods = (WmToDownGoodsEntity)JSONHelper.json2Object(wmToDownGoodsstr,WmToDownGoodsEntity.class); - // 调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. - WvGiNoticeEntity t = new WvGiNoticeEntity(); - Set> failures = validator - .validate(wmToDownGoods); - if (!failures.isEmpty()) { - D0.setOK(false); + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public ResponseEntity get(@PathVariable("id") String id) { + WmToDownGoodsEntity task = wmToDownGoodsService.get( + WmToDownGoodsEntity.class, id); + if (task == null) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + return new ResponseEntity(task, HttpStatus.OK); + } - } - try{ - WmToDownGoodsEntity wmToDownGoods1 = systemService.findUniqueByProperty(WmToDownGoodsEntity.class,"orderIdI",wmToDownGoods.getOrderIdI()); - if (wmToDownGoods1!=null){ - D0.setOK(false); - D0.setErrorMsg("重复保存"); + //下架 + @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public synchronized ResponseEntity create(@RequestParam String wmToDownGoodsstr, + UriComponentsBuilder uriBuilder) { + ResultDO D0 = new ResultDO(); + WmToDownGoodsEntity wmToDownGoods = (WmToDownGoodsEntity) JSONHelper.json2Object(wmToDownGoodsstr, WmToDownGoodsEntity.class); + // 调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. + WvGiNoticeEntity t = new WvGiNoticeEntity(); + Set> failures = validator + .validate(wmToDownGoods); + if (!failures.isEmpty()) { + D0.setOK(false); - return new ResponseEntity(D0,HttpStatus.OK); - } - }catch (Exception e){ + } + try { + WmToDownGoodsEntity wmToDownGoods1 = systemService.findUniqueByProperty(WmToDownGoodsEntity.class, "orderIdI", wmToDownGoods.getOrderIdI()); + if (wmToDownGoods1 != null) { + D0.setOK(false); + D0.setErrorMsg("重复保存"); - } + return new ResponseEntity(D0, HttpStatus.OK); + } + } catch (Exception e) { + + } + // 保存 + try { + //查询create_name + TSBaseUser user = systemService.findUniqueByProperty(TSBaseUser.class, "userName", wmToDownGoods.getCreateBy()); + if (user != null) { + wmToDownGoods.setCreateName(user.getRealName()); + } + todown(wmToDownGoods.getOrderIdI(), wmToDownGoods.getCreateBy(), wmToDownGoods.getCreateName()); + } catch (Exception e) { + e.printStackTrace(); + D0.setOK(false); + return new ResponseEntity(D0, HttpStatus.OK); + } - // 保存 - try { - //查询create_name - TSBaseUser user = systemService.findUniqueByProperty(TSBaseUser.class, "userName", wmToDownGoods.getCreateBy()); - if (user != null) { - wmToDownGoods.setCreateName(user.getRealName()); - } - todown(wmToDownGoods.getOrderIdI(),wmToDownGoods.getCreateBy(),wmToDownGoods.getCreateName()); - } catch (Exception e) { - e.printStackTrace(); - D0.setOK(false); - return new ResponseEntity(D0,HttpStatus.OK); - } - - return new ResponseEntity(D0, HttpStatus.OK); + return new ResponseEntity(D0, HttpStatus.OK); // return new ResponseEntity(headers, HttpStatus.CREATED); - } + } - public boolean todown(String id,String username,String realname){ - try { - WmOmQmIEntity wmOmQmI = systemService.getEntity( - WmOmQmIEntity.class, id); - if (wmOmQmI != null&&wmOmQmI.getBinSta().equals("N")) { - WmToDownGoodsEntity wmToDownGoods = new WmToDownGoodsEntity(); - wmToDownGoods.setCreateBy(username); - wmToDownGoods.setCreateName(realname); - wmToDownGoods.setCreateDate(now()); - wmToDownGoods.setBinIdFrom(wmOmQmI.getTinId());//下架托盘 - wmToDownGoods.setKuWeiBianMa(wmOmQmI.getBinId());//储位 - wmToDownGoods.setBinIdTo(wmOmQmI.getOmNoticeId());//到托盘 - wmToDownGoods.setCusCode(wmOmQmI.getCusCode());//货主 - wmToDownGoods.setGoodsId(wmOmQmI.getGoodsId());// - wmToDownGoods.setGoodsProData(wmOmQmI.getProData());//生产日期 - wmToDownGoods.setOrderId(wmOmQmI.getOmNoticeId());//出货通知单 - wmToDownGoods.setOrderIdI(wmOmQmI.getId());//出货通知项目 - wmToDownGoods.setBaseUnit(wmOmQmI.getBaseUnit());//基本单位 - wmToDownGoods.setBaseGoodscount(wmOmQmI.getBaseGoodscount());//基本单位数量 - wmToDownGoods.setGoodsUnit(wmOmQmI.getGoodsUnit());//出货单位 - wmToDownGoods.setGoodsQua(wmOmQmI.getQmOkQuat());//出货数量 - wmToDownGoods.setGoodsQuaok(wmOmQmI.getQmOkQuat());//出货数量 - wmToDownGoods.setGoodsName(wmOmQmI.getGoodsName());//商品名称 - wmToDownGoods.setOmBeizhu(wmOmQmI.getOmBeizhu());//备注 - wmToDownGoods.setImCusCode(wmOmQmI.getImCusCode());//客户单号 - wmToDownGoods.setOrderType("01");//默认为01 - systemService.save(wmToDownGoods); - wmOmQmI.setBinSta("Y"); - systemService.saveOrUpdate(wmOmQmI); - try{ - String orderId = wmOmQmI.getOmNoticeId(); - String type = "jh"; - updateUser(orderId,type,username); - }catch (Exception e){ - } - return true; - } else { - return false; - } - } catch (Exception e) { - return false; - } - } + public boolean todown(String id, String username, String realname) { + try { + WmOmQmIEntity wmOmQmI = systemService.getEntity( + WmOmQmIEntity.class, id); + if (wmOmQmI != null && wmOmQmI.getBinSta().equals("N")) { + WmToDownGoodsEntity wmToDownGoods = new WmToDownGoodsEntity(); + wmToDownGoods.setCreateBy(username); + wmToDownGoods.setCreateName(realname); + wmToDownGoods.setCreateDate(now()); + wmToDownGoods.setBinIdFrom(wmOmQmI.getTinId());//下架托盘 + wmToDownGoods.setKuWeiBianMa(wmOmQmI.getBinId());//储位 + wmToDownGoods.setBinIdTo(wmOmQmI.getOmNoticeId());//到托盘 + wmToDownGoods.setCusCode(wmOmQmI.getCusCode());//货主 + wmToDownGoods.setGoodsId(wmOmQmI.getGoodsId());// + wmToDownGoods.setGoodsProData(wmOmQmI.getProData());//生产日期 + wmToDownGoods.setOrderId(wmOmQmI.getOmNoticeId());//出货通知单 + wmToDownGoods.setOrderIdI(wmOmQmI.getId());//出货通知项目 + wmToDownGoods.setBaseUnit(wmOmQmI.getBaseUnit());//基本单位 + wmToDownGoods.setBaseGoodscount(wmOmQmI.getBaseGoodscount());//基本单位数量 + wmToDownGoods.setGoodsUnit(wmOmQmI.getGoodsUnit());//出货单位 + wmToDownGoods.setGoodsQua(wmOmQmI.getQmOkQuat());//出货数量 + wmToDownGoods.setGoodsQuaok(wmOmQmI.getQmOkQuat());//出货数量 + wmToDownGoods.setGoodsName(wmOmQmI.getGoodsName());//商品名称 + wmToDownGoods.setOmBeizhu(wmOmQmI.getOmBeizhu());//备注 + wmToDownGoods.setImCusCode(wmOmQmI.getImCusCode());//客户单号 + wmToDownGoods.setOrderType("01");//默认为01 + systemService.save(wmToDownGoods); + wmOmQmI.setBinSta("Y"); + systemService.saveOrUpdate(wmOmQmI); + try { + String orderId = wmOmQmI.getOmNoticeId(); + String type = "jh"; + updateUser(orderId, type, username); + } catch (Exception e) { + } + return true; + } else { + return false; + } + } catch (Exception e) { + return false; + } + } - //装车复核 - @RequestMapping(value = "/change", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public ResponseEntity update(@RequestParam String wmToDownGoodsstr, - UriComponentsBuilder uriBuilder) { - // 调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. - ResultDO D0 = new ResultDO(); - WmToDownGoodsEntity wmToDownGoods = (WmToDownGoodsEntity)JSONHelper.json2Object(wmToDownGoodsstr,WmToDownGoodsEntity.class); - WmToDownGoodsEntity t = wmToDownGoodsService.get(WmToDownGoodsEntity.class,wmToDownGoods.getId()); - // 保存 - try { - MyBeanUtils.copyBeanNotNull2Bean(wmToDownGoods, t); - t.setDownSta(Constants.wm_sta5); - t.setUpdateDate(now()); - wmToDownGoodsService.saveOrUpdate(t); - try{ - String orderId = t.getOrderId(); - String type = "fh"; - String username = wmToDownGoods.getUpdateBy(); - updateUser(orderId,type,username); - }catch (Exception e){ - } + //装车复核 + @RequestMapping(value = "/change", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public ResponseEntity update(@RequestParam String wmToDownGoodsstr, + UriComponentsBuilder uriBuilder) { + // 调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. + ResultDO D0 = new ResultDO(); + WmToDownGoodsEntity wmToDownGoods = (WmToDownGoodsEntity) JSONHelper.json2Object(wmToDownGoodsstr, WmToDownGoodsEntity.class); + WmToDownGoodsEntity t = wmToDownGoodsService.get(WmToDownGoodsEntity.class, wmToDownGoods.getId()); + // 保存 + try { + MyBeanUtils.copyBeanNotNull2Bean(wmToDownGoods, t); + t.setDownSta(Constants.wm_sta5); + t.setUpdateDate(now()); + wmToDownGoodsService.saveOrUpdate(t); + try { + String orderId = t.getOrderId(); + String type = "fh"; + String username = wmToDownGoods.getUpdateBy(); + updateUser(orderId, type, username); + } catch (Exception e) { + } - D0.setOK(true); - } catch (Exception e) { - e.printStackTrace(); - D0.setOK(false); - } - // 按Restful约定,返回204状态码, 无内容. 也可以返回200状态码. - return new ResponseEntity(D0, HttpStatus.OK); - } - void updateUser(String orderId,String type,String userName){ - try{ - WmOmNoticeHEntity wmOmNoticeHEntity = systemService.findUniqueByProperty(WmOmNoticeHEntity.class,"omNoticeId",orderId); - if ("jh".equals(type)){ - wmOmNoticeHEntity.setJhUser(userName); - } - if ("fh".equals(type)){ - wmOmNoticeHEntity.setFhUser(userName); - wmOmNoticeHEntity.setOmSta(wm_sta6); - } - systemService.updateEntitie(wmOmNoticeHEntity); - }catch (Exception e){ + D0.setOK(true); + } catch (Exception e) { + e.printStackTrace(); + D0.setOK(false); + } + // 按Restful约定,返回204状态码, 无内容. 也可以返回200状态码. + return new ResponseEntity(D0, HttpStatus.OK); + } - } + void updateUser(String orderId, String type, String userName) { + try { + WmOmNoticeHEntity wmOmNoticeHEntity = systemService.findUniqueByProperty(WmOmNoticeHEntity.class, "omNoticeId", orderId); + if ("jh".equals(type)) { + wmOmNoticeHEntity.setJhUser(userName); + } + if ("fh".equals(type)) { + wmOmNoticeHEntity.setFhUser(userName); + wmOmNoticeHEntity.setOmSta(wm_sta6); + } + systemService.updateEntitie(wmOmNoticeHEntity); + } catch (Exception e) { - } - @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) - @ResponseStatus(HttpStatus.NO_CONTENT) - public void delete(@PathVariable("id") String id) { - wmToDownGoodsService.deleteEntityById(WmToDownGoodsEntity.class, id); - } + } + + } + + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) + @ResponseStatus(HttpStatus.NO_CONTENT) + public void delete(@PathVariable("id") String id) { + wmToDownGoodsService.deleteEntityById(WmToDownGoodsEntity.class, id); + } } diff --git a/src/main/java/com/zzjee/wm/controller/WmToMoveGoodsController.java b/src/main/java/com/zzjee/wm/controller/WmToMoveGoodsController.java index 482a6211..eaf3b17e 100644 --- a/src/main/java/com/zzjee/wm/controller/WmToMoveGoodsController.java +++ b/src/main/java/com/zzjee/wm/controller/WmToMoveGoodsController.java @@ -1,4 +1,5 @@ package com.zzjee.wm.controller; + import java.io.IOException; import java.net.URI; import java.util.ArrayList; @@ -59,526 +60,519 @@ import com.zzjee.wmutil.wmUtil; import static com.xiaoleilu.hutool.date.DateTime.now; /** + * @author erzhongxmu + * @version V1.0 * @Title: Controller * @Description: 库存转移 - * @author erzhongxmu * @date 2017-09-08 21:03:22 - * @version V1.0 - * */ @Controller @RequestMapping("/wmToMoveGoodsController") public class WmToMoveGoodsController extends BaseController { - /** - * Logger for this class - */ - private static final Logger logger = Logger.getLogger(WmToMoveGoodsController.class); + /** + * Logger for this class + */ + private static final Logger logger = Logger.getLogger(WmToMoveGoodsController.class); - @Autowired - private WmToMoveGoodsServiceI wmToMoveGoodsService; - @Autowired - private SystemService systemService; - @Autowired - private Validator validator; + @Autowired + private WmToMoveGoodsServiceI wmToMoveGoodsService; + @Autowired + private SystemService systemService; + @Autowired + private Validator validator; + /** + * 库存转移列表 页面跳转 + * + * @return + */ + @RequestMapping(params = "list") + public ModelAndView list(HttpServletRequest request) { + return new ModelAndView("com/zzjee/wm/wmToMoveGoodsList"); + } - /** - * 库存转移列表 页面跳转 - * - * @return - */ - @RequestMapping(params = "list") - public ModelAndView list(HttpServletRequest request) { - return new ModelAndView("com/zzjee/wm/wmToMoveGoodsList"); - } + /** + * easyui AJAX请求数据 + * + * @param request + * @param response + * @param dataGrid + */ - /** - * easyui AJAX请求数据 - * - * @param request - * @param response - * @param dataGrid - */ + @RequestMapping(params = "datagrid") + public void datagrid(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { + CriteriaQuery cq = new CriteriaQuery(WmToMoveGoodsEntity.class, dataGrid); + //查询条件组装器 + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmToMoveGoods, request.getParameterMap()); + try { + //自定义追加查询条件 + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + Map map1 = new HashMap(); + map1.put("createDate", "desc"); + cq.setOrder(map1); + cq.add(); + this.wmToMoveGoodsService.getDataGridReturn(cq, true); + TagUtil.datagrid(response, dataGrid); + } - @RequestMapping(params = "datagrid") - public void datagrid(WmToMoveGoodsEntity wmToMoveGoods,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { - CriteriaQuery cq = new CriteriaQuery(WmToMoveGoodsEntity.class, dataGrid); - //查询条件组装器 - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmToMoveGoods, request.getParameterMap()); - try{ - //自定义追加查询条件 - }catch (Exception e) { - throw new BusinessException(e.getMessage()); - } - Map map1 = new HashMap(); - map1.put("createDate", "desc"); - cq.setOrder(map1); - cq.add(); - this.wmToMoveGoodsService.getDataGridReturn(cq, true); - TagUtil.datagrid(response, dataGrid); - } + /** + * 删除库存转移 + * + * @return + */ + @RequestMapping(params = "doDel") + @ResponseBody + public AjaxJson doDel(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); + message = "库存转移删除成功"; + try { + wmToMoveGoods.setMoveSta("已删除"); + wmToMoveGoodsService.saveOrUpdate(wmToMoveGoods); + systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "库存转移删除失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - /** - * 删除库存转移 - * - * @return - */ - @RequestMapping(params = "doDel") - @ResponseBody - public AjaxJson doDel(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); - message = "库存转移删除成功"; - try{ - wmToMoveGoods.setMoveSta("已删除"); - wmToMoveGoodsService.saveOrUpdate(wmToMoveGoods); - systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); - }catch(Exception e){ - e.printStackTrace(); - message = "库存转移删除失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + /** + * 批量删除库存转移 + * + * @return + */ + @RequestMapping(params = "doBatchUpdate") + @ResponseBody + public AjaxJson doBatchUpdate(String ids, String moveSta, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "批量设置状态成功"; + try { + for (String id : ids.split(",")) { + WmToMoveGoodsEntity wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class, + id + ); + message = "批量保存成功"; + String movesta = "已完成"; + try { + movesta = ResourceUtil.getConfigByName("wm.movesta"); - /** - * 批量删除库存转移 - * - * @return - */ - @RequestMapping(params = "doBatchUpdate") - @ResponseBody - public AjaxJson doBatchUpdate(String ids,String moveSta,HttpServletRequest request){ - String message = null; - AjaxJson j = new AjaxJson(); - message = "批量设置状态成功"; - try{ - for(String id:ids.split(",")){ - WmToMoveGoodsEntity wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class, - id - ); - message = "批量保存成功"; - String movesta = "已完成"; - try{ - movesta = ResourceUtil.getConfigByName("wm.movesta"); + } catch (Exception e) { - }catch (Exception e){ + } - } + wmToMoveGoods.setMoveSta(movesta); + wmToMoveGoodsService.updateEntitie(wmToMoveGoods); + systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); + } + } catch (Exception e) { + e.printStackTrace(); + message = "批量设置状态失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } - wmToMoveGoods.setMoveSta(movesta); - wmToMoveGoodsService.updateEntitie(wmToMoveGoods); - systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); - } - }catch(Exception e){ - e.printStackTrace(); - message = "批量设置状态失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } - - /** - * 批量删除库存转移 - * - * @return - */ - @RequestMapping(params = "doBatchDel") - @ResponseBody - public AjaxJson doBatchDel(String ids,HttpServletRequest request){ - String message = null; - AjaxJson j = new AjaxJson(); - message = "库存转移删除成功"; - try{ - for(String id:ids.split(",")){ - WmToMoveGoodsEntity wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class, - id - ); - wmToMoveGoods.setMoveSta("已删除"); - wmToMoveGoodsService.updateEntitie(wmToMoveGoods); - systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); - } - }catch(Exception e){ - e.printStackTrace(); - message = "库存转移删除失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + /** + * 批量删除库存转移 + * + * @return + */ + @RequestMapping(params = "doBatchDel") + @ResponseBody + public AjaxJson doBatchDel(String ids, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "库存转移删除成功"; + try { + for (String id : ids.split(",")) { + WmToMoveGoodsEntity wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class, + id + ); + wmToMoveGoods.setMoveSta("已删除"); + wmToMoveGoodsService.updateEntitie(wmToMoveGoods); + systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); + } + } catch (Exception e) { + e.printStackTrace(); + message = "库存转移删除失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } + @RequestMapping(params = "doGetstock", method = {RequestMethod.GET, + RequestMethod.POST}) + @ResponseBody + public AjaxJson doGetstock(HttpServletRequest request) { + AjaxJson j = new AjaxJson(); + WmToMoveGoodsEntity wmToMoveGoods = new WmToMoveGoodsEntity(); - @RequestMapping(params = "doGetstock", method = { RequestMethod.GET, - RequestMethod.POST }) - @ResponseBody - public AjaxJson doGetstock(HttpServletRequest request) { - AjaxJson j = new AjaxJson(); - WmToMoveGoodsEntity wmToMoveGoods = new WmToMoveGoodsEntity(); + j.setObj(wmToMoveGoods); + return j; + } + + /** + * 添加库存转移 + * + * @return + */ + @RequestMapping(params = "doAdd") + @ResponseBody + public AjaxJson doAdd(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "库存转移添加成功"; + try { + wmToMoveGoods.setMoveSta("计划中"); + wmToMoveGoodsService.save(wmToMoveGoods); + systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "库存转移添加失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } + + /** + * 更新库存转移 + * + * @return + */ + @RequestMapping(params = "doUpdate") + @ResponseBody + public AjaxJson doUpdate(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request) { + String message = null; + AjaxJson j = new AjaxJson(); + message = "库存转移更新成功"; + WmToMoveGoodsEntity t = wmToMoveGoodsService.get(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); + try { + MyBeanUtils.copyBeanNotNull2Bean(wmToMoveGoods, t); + try { + MvCusEntity mvcus = systemService.findUniqueByProperty(MvCusEntity.class, "cusCode", wmToMoveGoods.getToCusCode()); + t.setToCusName(mvcus.getCusName()); + } catch (Exception e) { + + } + + wmToMoveGoodsService.saveOrUpdate(t); + systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); + } catch (Exception e) { + e.printStackTrace(); + message = "库存转移更新失败"; + throw new BusinessException(e.getMessage()); + } + j.setMsg(message); + return j; + } + /** + * @param page + * @return + */ + @RequestMapping(params = "saveRows") + @ResponseBody + public AjaxJson saveRows(wmtomovepage page) { + String message = null; + List demos = page.getWmtomoverows(); + AjaxJson j = new AjaxJson(); + if (CollectionUtils.isNotEmpty(demos)) { + for (WmToMoveGoodsEntity jeecgDemo : demos) { + if (StringUtil.isNotEmpty(jeecgDemo.getId())) { + WmToMoveGoodsEntity t = systemService.get(WmToMoveGoodsEntity.class, jeecgDemo.getId()); + try { + if (!wmUtil.checkstcok(jeecgDemo.getBinFrom(), jeecgDemo.getTinFrom(), jeecgDemo.getGoodsId(), jeecgDemo.getGoodsProData(), jeecgDemo.getBaseGoodscount())) { + } else { + message = "批量保存成功"; + String movesta = "已完成"; + try { + movesta = ResourceUtil.getConfigByName("wm.movesta"); - j.setObj(wmToMoveGoods); - return j; - } + } catch (Exception e) { - /** - * 添加库存转移 - * - * @return - */ - @RequestMapping(params = "doAdd") - @ResponseBody - public AjaxJson doAdd(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - message = "库存转移添加成功"; - try{ - wmToMoveGoods.setMoveSta("计划中"); - wmToMoveGoodsService.save(wmToMoveGoods); - systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); - }catch(Exception e){ - e.printStackTrace(); - message = "库存转移添加失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } - - /** - * 更新库存转移 - * - * @return - */ - @RequestMapping(params = "doUpdate") - @ResponseBody - public AjaxJson doUpdate(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request) { - String message = null; - AjaxJson j = new AjaxJson(); - message = "库存转移更新成功"; - WmToMoveGoodsEntity t = wmToMoveGoodsService.get(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); - try { - MyBeanUtils.copyBeanNotNull2Bean(wmToMoveGoods, t); - try{ - MvCusEntity mvcus = systemService.findUniqueByProperty(MvCusEntity.class, "cusCode",wmToMoveGoods.getToCusCode() ) ; - t.setToCusName(mvcus.getCusName()); - }catch (Exception e){ - - } - - wmToMoveGoodsService.saveOrUpdate(t); - systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); - } catch (Exception e) { - e.printStackTrace(); - message = "库存转移更新失败"; - throw new BusinessException(e.getMessage()); - } - j.setMsg(message); - return j; - } + } + t.setMoveSta(movesta); + MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t); + systemService.saveOrUpdate(t); + systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + return j; + } + /** + * 库存转移新增页面跳转 + * + * @return + */ + @RequestMapping(params = "goAdd") + public ModelAndView goAdd(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest req) { + if (StringUtil.isNotEmpty(wmToMoveGoods.getId())) { + wmToMoveGoods = wmToMoveGoodsService.getEntity(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); + req.setAttribute("wmToMoveGoodsPage", wmToMoveGoods); + } + return new ModelAndView("com/zzjee/wm/wmToMoveGoods-add"); + } - /** - * - * @param page - * @return - */ - @RequestMapping(params = "saveRows") - @ResponseBody - public AjaxJson saveRows(wmtomovepage page){ - String message = null; - List demos=page.getWmtomoverows(); - AjaxJson j = new AjaxJson(); - if(CollectionUtils.isNotEmpty(demos)){ - for(WmToMoveGoodsEntity jeecgDemo:demos){ - if (StringUtil.isNotEmpty(jeecgDemo.getId())) { - WmToMoveGoodsEntity t =systemService.get(WmToMoveGoodsEntity.class, jeecgDemo.getId()); - try { - if(!wmUtil.checkstcok( jeecgDemo.getBinFrom(),jeecgDemo.getTinFrom(),jeecgDemo.getGoodsId(),jeecgDemo.getGoodsProData(),jeecgDemo.getBaseGoodscount())) { - }else{ - message = "批量保存成功"; - String movesta = "已完成"; - try{ - movesta = ResourceUtil.getConfigByName("wm.movesta"); + /** + * 库存转移编辑页面跳转 + * + * @return + */ + @RequestMapping(params = "goUpdate") + public ModelAndView goUpdate(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest req) { + if (StringUtil.isNotEmpty(wmToMoveGoods.getId())) { + wmToMoveGoods = wmToMoveGoodsService.getEntity(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); + req.setAttribute("wmToMoveGoodsPage", wmToMoveGoods); + } + return new ModelAndView("com/zzjee/wm/wmToMoveGoods-update"); + } - }catch (Exception e){ + /** + * 导入功能跳转 + * + * @return + */ + @RequestMapping(params = "upload") + public ModelAndView upload(HttpServletRequest req) { + req.setAttribute("controller_name", "wmToMoveGoodsController"); + return new ModelAndView("common/upload/pub_excel_upload"); + } - } - t.setMoveSta(movesta); - MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t); - systemService.saveOrUpdate(t); - systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - return j; - } + /** + * 导出excel + * + * @param request + * @param response + */ + @RequestMapping(params = "exportXls") + public String exportXls(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request, HttpServletResponse response + , DataGrid dataGrid, ModelMap modelMap) { + CriteriaQuery cq = new CriteriaQuery(WmToMoveGoodsEntity.class, dataGrid); + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmToMoveGoods, request.getParameterMap()); + List wmToMoveGoodss = this.wmToMoveGoodsService.getListByCriteriaQuery(cq, false); + modelMap.put(NormalExcelConstants.FILE_NAME, "库存转移"); + modelMap.put(NormalExcelConstants.CLASS, WmToMoveGoodsEntity.class); + modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("库存转移列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(), + "导出信息")); + modelMap.put(NormalExcelConstants.DATA_LIST, wmToMoveGoodss); + return NormalExcelConstants.JEECG_EXCEL_VIEW; + } + /** + * 导出excel 使模板 + * + * @param request + * @param response + */ + @RequestMapping(params = "exportXlsByT") + public String exportXlsByT(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request, HttpServletResponse response + , DataGrid dataGrid, ModelMap modelMap) { + modelMap.put(NormalExcelConstants.FILE_NAME, "库存转移"); + modelMap.put(NormalExcelConstants.CLASS, WmToMoveGoodsEntity.class); + modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("库存转移列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(), + "导出信息")); + 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()) { + MultipartFile file = entity.getValue();// 获取上传文件对象 + ImportParams params = new ImportParams(); + params.setTitleRows(2); + params.setHeadRows(1); + params.setNeedSave(true); + try { + List listWmToMoveGoodsEntitys = ExcelImportUtil.importExcel(file.getInputStream(), WmToMoveGoodsEntity.class, params); + for (WmToMoveGoodsEntity wmToMoveGoods : listWmToMoveGoodsEntitys) { + if (StringUtil.isNotEmpty(wmToMoveGoods.getOrderIdI())) { + try { + WmToMoveGoodsEntity t = systemService.findByProperty(WmToMoveGoodsEntity.class, "orderIdI", wmToMoveGoods.getOrderIdI()).get(0); + if (t != null) { + continue; + } + } catch (Exception e) { - /** - * 库存转移新增页面跳转 - * - * @return - */ - @RequestMapping(params = "goAdd") - public ModelAndView goAdd(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest req) { - if (StringUtil.isNotEmpty(wmToMoveGoods.getId())) { - wmToMoveGoods = wmToMoveGoodsService.getEntity(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); - req.setAttribute("wmToMoveGoodsPage", wmToMoveGoods); - } - return new ModelAndView("com/zzjee/wm/wmToMoveGoods-add"); - } - /** - * 库存转移编辑页面跳转 - * - * @return - */ - @RequestMapping(params = "goUpdate") - public ModelAndView goUpdate(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest req) { - if (StringUtil.isNotEmpty(wmToMoveGoods.getId())) { - wmToMoveGoods = wmToMoveGoodsService.getEntity(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); - req.setAttribute("wmToMoveGoodsPage", wmToMoveGoods); - } - return new ModelAndView("com/zzjee/wm/wmToMoveGoods-update"); - } + } + } + wmToMoveGoods.setRunSta("计划中"); + wmToMoveGoodsService.save(wmToMoveGoods); + } + j.setMsg("文件导入成功!"); + } catch (Exception e) { + j.setMsg("文件导入失败!"); + logger.error(ExceptionUtil.getExceptionMessage(e)); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return j; + } - /** - * 导入功能跳转 - * - * @return - */ - @RequestMapping(params = "upload") - public ModelAndView upload(HttpServletRequest req) { - req.setAttribute("controller_name","wmToMoveGoodsController"); - return new ModelAndView("common/upload/pub_excel_upload"); - } - - /** - * 导出excel - * - * @param request - * @param response - */ - @RequestMapping(params = "exportXls") - public String exportXls(WmToMoveGoodsEntity wmToMoveGoods,HttpServletRequest request,HttpServletResponse response - , DataGrid dataGrid,ModelMap modelMap) { - CriteriaQuery cq = new CriteriaQuery(WmToMoveGoodsEntity.class, dataGrid); - org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmToMoveGoods, request.getParameterMap()); - List wmToMoveGoodss = this.wmToMoveGoodsService.getListByCriteriaQuery(cq,false); - modelMap.put(NormalExcelConstants.FILE_NAME,"库存转移"); - modelMap.put(NormalExcelConstants.CLASS,WmToMoveGoodsEntity.class); - modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("库存转移列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(), - "导出信息")); - modelMap.put(NormalExcelConstants.DATA_LIST,wmToMoveGoodss); - return NormalExcelConstants.JEECG_EXCEL_VIEW; - } - /** - * 导出excel 使模板 - * - * @param request - * @param response - */ - @RequestMapping(params = "exportXlsByT") - public String exportXlsByT(WmToMoveGoodsEntity wmToMoveGoods,HttpServletRequest request,HttpServletResponse response - , DataGrid dataGrid,ModelMap modelMap) { - modelMap.put(NormalExcelConstants.FILE_NAME,"库存转移"); - modelMap.put(NormalExcelConstants.CLASS,WmToMoveGoodsEntity.class); - modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("库存转移列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(), - "导出信息")); - 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()) { - MultipartFile file = entity.getValue();// 获取上传文件对象 - ImportParams params = new ImportParams(); - params.setTitleRows(2); - params.setHeadRows(1); - params.setNeedSave(true); - try { - List listWmToMoveGoodsEntitys = ExcelImportUtil.importExcel(file.getInputStream(),WmToMoveGoodsEntity.class,params); - for (WmToMoveGoodsEntity wmToMoveGoods : listWmToMoveGoodsEntitys) { - if(StringUtil.isNotEmpty(wmToMoveGoods.getOrderIdI())){ - try{ - WmToMoveGoodsEntity t = systemService.findByProperty(WmToMoveGoodsEntity.class,"orderIdI",wmToMoveGoods.getOrderIdI()).get(0); - if(t!=null){ - continue; - } - }catch (Exception e){ - - } - } - wmToMoveGoods.setRunSta("计划中"); - wmToMoveGoodsService.save(wmToMoveGoods); - } - j.setMsg("文件导入成功!"); - } catch (Exception e) { - j.setMsg("文件导入失败!"); - logger.error(ExceptionUtil.getExceptionMessage(e)); - }finally{ - try { - file.getInputStream().close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return j; - } - - @RequestMapping(method = RequestMethod.GET) - @ResponseBody - public ResponseEntity list( @RequestParam(value="username", required=false) String username, - @RequestParam(value="searchstr", required=false)String searchstr, - @RequestParam(value="searchstr2", required=false)String searchstr2) { + @RequestMapping(method = RequestMethod.GET) + @ResponseBody + public ResponseEntity list(@RequestParam(value = "username", required = false) String username, + @RequestParam(value = "searchstr", required = false) String searchstr, + @RequestParam(value = "searchstr2", required = false) String searchstr2) { // return listWvGis; - ResultDO D0 = new ResultDO(); - String hql = " from WmToMoveGoodsEntity where 1 = 1 and moveSta = '计划中' "; - D0.setOK(true); - if(!StringUtil.isEmpty(searchstr)) { - hql=hql+" and binFrom like '%" + searchstr + "%'"; - } - if(!StringUtil.isEmpty(searchstr2)) { - try{ - String shpbianma = wmUtil.getmdgoodsbytiaoma(searchstr2); - if(StringUtil.isNotEmpty(shpbianma)){ - searchstr2=shpbianma; - } - }catch (Exception e){ + ResultDO D0 = new ResultDO(); + String hql = " from WmToMoveGoodsEntity where 1 = 1 and moveSta = '计划中' "; + D0.setOK(true); + if (!StringUtil.isEmpty(searchstr)) { + hql = hql + " and binFrom like '%" + searchstr + "%'"; + } + if (!StringUtil.isEmpty(searchstr2)) { + try { + String shpbianma = wmUtil.getmdgoodsbytiaoma(searchstr2); + if (StringUtil.isNotEmpty(shpbianma)) { + searchstr2 = shpbianma; + } + } catch (Exception e) { - } - hql=hql+" and goodsId like '%" + searchstr2 + "%'"; - } + } + hql = hql + " and goodsId like '%" + searchstr2 + "%'"; + } - List listWmToMoveGoodss=wmToMoveGoodsService.findHql(hql); + List listWmToMoveGoodss = wmToMoveGoodsService.findHql(hql); - List result = new ArrayList(); - int i = 0; - for (WmToMoveGoodsEntity t :listWmToMoveGoodss){ + List result = new ArrayList(); + int i = 0; + for (WmToMoveGoodsEntity t : listWmToMoveGoodss) { - i++; - if(i>100){ - break; - } - result.add(t); - } - if(result.size()<=0){ - D0.setOK(false); - } - D0.setObj(result); - return new ResponseEntity(D0, HttpStatus.OK); - } + i++; + if (i > 100) { + break; + } + result.add(t); + } + if (result.size() <= 0) { + D0.setOK(false); + } + D0.setObj(result); + return new ResponseEntity(D0, HttpStatus.OK); + } - @RequestMapping(value = "/{id}", method = RequestMethod.GET) - @ResponseBody - public ResponseEntity get(@PathVariable("id") String id) { - WmToMoveGoodsEntity task = wmToMoveGoodsService.get(WmToMoveGoodsEntity.class, id); - if (task == null) { - return new ResponseEntity(HttpStatus.NOT_FOUND); - } - return new ResponseEntity(task, HttpStatus.OK); - } + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public ResponseEntity get(@PathVariable("id") String id) { + WmToMoveGoodsEntity task = wmToMoveGoodsService.get(WmToMoveGoodsEntity.class, id); + if (task == null) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + return new ResponseEntity(task, HttpStatus.OK); + } - @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public ResponseEntity create(@RequestBody WmToMoveGoodsEntity wmToMoveGoods, UriComponentsBuilder uriBuilder) { - //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. - Set> failures = validator.validate(wmToMoveGoods); - if (!failures.isEmpty()) { - return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); - } + @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public ResponseEntity create(@RequestBody WmToMoveGoodsEntity wmToMoveGoods, UriComponentsBuilder uriBuilder) { + //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. + Set> failures = validator.validate(wmToMoveGoods); + if (!failures.isEmpty()) { + return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); + } - //保存 - try{ - wmToMoveGoodsService.save(wmToMoveGoods); - } catch (Exception e) { - e.printStackTrace(); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } - //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象. - String id = wmToMoveGoods.getId(); - URI uri = uriBuilder.path("/rest/wmToMoveGoodsController/" + id).build().toUri(); - HttpHeaders headers = new HttpHeaders(); - headers.setLocation(uri); + //保存 + try { + wmToMoveGoodsService.save(wmToMoveGoods); + } catch (Exception e) { + e.printStackTrace(); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象. + String id = wmToMoveGoods.getId(); + URI uri = uriBuilder.path("/rest/wmToMoveGoodsController/" + id).build().toUri(); + HttpHeaders headers = new HttpHeaders(); + headers.setLocation(uri); - return new ResponseEntity(headers, HttpStatus.CREATED); - } + return new ResponseEntity(headers, HttpStatus.CREATED); + } - @RequestMapping(value = "/change", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public ResponseEntity update(@RequestParam String wmToMoveGoodsstr, - UriComponentsBuilder uriBuilder) { - //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. - ResultDO D0 = new ResultDO(); - WmToMoveGoodsEntity wmToMoveGoods = (WmToMoveGoodsEntity)JSONHelper.json2Object(wmToMoveGoodsstr,WmToMoveGoodsEntity.class); - //保存 - try{ - WmToMoveGoodsEntity t = systemService.get(WmToMoveGoodsEntity.class,wmToMoveGoods.getId()); - MyBeanUtils.copyBeanNotNull2Bean(wmToMoveGoods,t); - try{ - if(StringUtil.isNotEmpty(wmToMoveGoods.getUpdateBy())){ - TSUser tsuser = systemService.findUniqueByProperty(TSUser.class,"",wmToMoveGoods.getUpdateBy()); - t.setUpdateName(tsuser.getRealName()); - } - }catch (Exception e){ + @RequestMapping(value = "/change", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public ResponseEntity update(@RequestParam String wmToMoveGoodsstr, + UriComponentsBuilder uriBuilder) { + //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. + ResultDO D0 = new ResultDO(); + WmToMoveGoodsEntity wmToMoveGoods = (WmToMoveGoodsEntity) JSONHelper.json2Object(wmToMoveGoodsstr, WmToMoveGoodsEntity.class); + //保存 + try { + WmToMoveGoodsEntity t = systemService.get(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); + MyBeanUtils.copyBeanNotNull2Bean(wmToMoveGoods, t); + try { + if (StringUtil.isNotEmpty(wmToMoveGoods.getUpdateBy())) { + TSUser tsuser = systemService.findUniqueByProperty(TSUser.class, "", wmToMoveGoods.getUpdateBy()); + t.setUpdateName(tsuser.getRealName()); + } + } catch (Exception e) { - } - t.setUpdateDate(now()); + } + t.setUpdateDate(now()); // if(!wmUtil.checkstcok( t.getBinFrom(),t.getTinFrom(),t.getGoodsId(),t.getGoodsProData(),t.getBaseGoodscount())) { // D0.setOK(false); // D0.setErrorMsg("库存不足"); // }else{ - String movesta = "已完成"; - try{ - movesta = ResourceUtil.getConfigByName("wm.movesta"); + String movesta = "已完成"; + try { + movesta = ResourceUtil.getConfigByName("wm.movesta"); - }catch (Exception e){ + } catch (Exception e) { - } - t.setMoveSta(movesta); - wmToMoveGoodsService.saveOrUpdate(t); - D0.setOK(true); + } + t.setMoveSta(movesta); + wmToMoveGoodsService.saveOrUpdate(t); + D0.setOK(true); // } - } catch (Exception e) { - e.printStackTrace(); - D0.setOK(false); + } catch (Exception e) { + e.printStackTrace(); + D0.setOK(false); - } + } - //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码. - return new ResponseEntity(D0, HttpStatus.OK); - } + //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码. + return new ResponseEntity(D0, HttpStatus.OK); + } - @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) - @ResponseStatus(HttpStatus.NO_CONTENT) - public void delete(@PathVariable("id") String id) { - wmToMoveGoodsService.deleteEntityById(WmToMoveGoodsEntity.class, id); - } + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) + @ResponseStatus(HttpStatus.NO_CONTENT) + public void delete(@PathVariable("id") String id) { + wmToMoveGoodsService.deleteEntityById(WmToMoveGoodsEntity.class, id); + } }