格式化

master
erzhongxmu 2024-01-26 14:06:19 +08:00
parent b326ad568f
commit d5619c9523
4 changed files with 2041 additions and 2029 deletions

View File

@ -1,6 +1,8 @@
package com.zzjee.wm.controller; package com.zzjee.wm.controller;
import com.zzjee.wm.entity.WmPrintModelEntity; import com.zzjee.wm.entity.WmPrintModelEntity;
import com.zzjee.wm.service.WmPrintModelServiceI; import com.zzjee.wm.service.WmPrintModelServiceI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -29,6 +31,7 @@ import org.jeecgframework.web.system.service.SystemService;
import org.jeecgframework.core.util.MyBeanUtils; import org.jeecgframework.core.util.MyBeanUtils;
import java.io.OutputStream; import java.io.OutputStream;
import org.jeecgframework.core.util.BrowserUtils; import org.jeecgframework.core.util.BrowserUtils;
import org.jeecgframework.poi.excel.ExcelExportUtil; import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.ExcelImportUtil; 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.jeecgframework.poi.excel.entity.vo.TemplateExcelConstants;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.jeecgframework.core.util.ResourceUtil; import org.jeecgframework.core.util.ResourceUtil;
import java.io.IOException; import java.io.IOException;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import org.jeecgframework.core.util.ExceptionUtil; import org.jeecgframework.core.util.ExceptionUtil;
import org.springframework.http.ResponseEntity; 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.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.jeecgframework.core.beanvalidator.BeanValidators; import org.jeecgframework.core.beanvalidator.BeanValidators;
import java.util.Set; import java.util.Set;
import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolation;
import javax.validation.Validator; import javax.validation.Validator;
import java.net.URI; import java.net.URI;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
/** /**
* @Title: Controller
* @Description:
* @author onlineGenerator * @author onlineGenerator
* @version V1.0
* @Title: Controller
* @Description:
* @date 2021-08-02 14:51:38 * @date 2021-08-02 14:51:38
* @version V1.0
*
*/ */
@Controller @Controller
@RequestMapping("/wmPrintModelController") @RequestMapping("/wmPrintModelController")
public class WmPrintModelController extends BaseController { public class WmPrintModelController extends BaseController {
/** /**
* Logger for this class * Logger for this class
*/ */
private static final Logger logger = Logger.getLogger(WmPrintModelController.class); private static final Logger logger = Logger.getLogger(WmPrintModelController.class);
@Autowired @Autowired
private WmPrintModelServiceI wmPrintModelService; private WmPrintModelServiceI wmPrintModelService;
@Autowired @Autowired
private SystemService systemService; private SystemService systemService;
@Autowired @Autowired
private Validator validator; private Validator validator;
/** /**
* *
* *
* @return * @return
*/ */
@RequestMapping(params = "list") @RequestMapping(params = "list")
public ModelAndView list(HttpServletRequest request) { public ModelAndView list(HttpServletRequest request) {
return new ModelAndView("com/zzjee/wm/wmPrintModelList"); return new ModelAndView("com/zzjee/wm/wmPrintModelList");
} }
/** /**
* easyui AJAX * easyui AJAX
* *
* @param request * @param request
* @param response * @param response
* @param dataGrid * @param dataGrid
* @param user * @param user
*/ */
@RequestMapping(params = "datagrid") @RequestMapping(params = "datagrid")
public void datagrid(WmPrintModelEntity wmPrintModel,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { public void datagrid(WmPrintModelEntity wmPrintModel, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(WmPrintModelEntity.class, dataGrid); CriteriaQuery cq = new CriteriaQuery(WmPrintModelEntity.class, dataGrid);
//查询条件组装器 //查询条件组装器
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmPrintModel, request.getParameterMap()); org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmPrintModel, request.getParameterMap());
try{ try {
//自定义追加查询条件 //自定义追加查询条件
}catch (Exception e) { } catch (Exception e) {
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
cq.add(); cq.add();
this.wmPrintModelService.getDataGridReturn(cq, true); this.wmPrintModelService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid); TagUtil.datagrid(response, dataGrid);
} }
/** /**
* *
* *
* @return * @return
*/ */
@RequestMapping(params = "doDel") @RequestMapping(params = "doDel")
@ResponseBody @ResponseBody
public AjaxJson doDel(WmPrintModelEntity wmPrintModel, HttpServletRequest request) { public AjaxJson doDel(WmPrintModelEntity wmPrintModel, HttpServletRequest request) {
String message = null; String message = null;
AjaxJson j = new AjaxJson(); AjaxJson j = new AjaxJson();
wmPrintModel = systemService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId()); wmPrintModel = systemService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId());
message = "打印模板删除成功"; message = "打印模板删除成功";
try{ try {
wmPrintModelService.delete(wmPrintModel); wmPrintModelService.delete(wmPrintModel);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}catch(Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "打印模板删除失败"; message = "打印模板删除失败";
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
j.setMsg(message); j.setMsg(message);
return j; return j;
} }
/** /**
* *
* *
* @return * @return
*/ */
@RequestMapping(params = "doBatchDel") @RequestMapping(params = "doBatchDel")
@ResponseBody @ResponseBody
public AjaxJson doBatchDel(String ids,HttpServletRequest request){ public AjaxJson doBatchDel(String ids, HttpServletRequest request) {
String message = null; String message = null;
AjaxJson j = new AjaxJson(); AjaxJson j = new AjaxJson();
message = "打印模板删除成功"; message = "打印模板删除成功";
try{ try {
for(String id:ids.split(",")){ for (String id : ids.split(",")) {
WmPrintModelEntity wmPrintModel = systemService.getEntity(WmPrintModelEntity.class, WmPrintModelEntity wmPrintModel = systemService.getEntity(WmPrintModelEntity.class,
id id
); );
wmPrintModelService.delete(wmPrintModel); wmPrintModelService.delete(wmPrintModel);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
} }
}catch(Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "打印模板删除失败"; message = "打印模板删除失败";
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
j.setMsg(message); j.setMsg(message);
return j; return j;
} }
/** /**
* *
* *
* @param ids * @param ids
* @return * @return
*/ */
@RequestMapping(params = "doAdd") @RequestMapping(params = "doAdd")
@ResponseBody @ResponseBody
public AjaxJson doAdd(WmPrintModelEntity wmPrintModel, HttpServletRequest request) { public AjaxJson doAdd(WmPrintModelEntity wmPrintModel, HttpServletRequest request) {
String message = null; String message = null;
AjaxJson j = new AjaxJson(); AjaxJson j = new AjaxJson();
message = "打印模板添加成功"; message = "打印模板添加成功";
try{ try {
wmPrintModelService.save(wmPrintModel); wmPrintModelService.save(wmPrintModel);
systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
}catch(Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "打印模板添加失败"; message = "打印模板添加失败";
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
j.setMsg(message); j.setMsg(message);
return j; 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;
}
/** /**
* *
* *
* @return * @param ids
*/ * @return
@RequestMapping(params = "goAdd") */
public ModelAndView goAdd(WmPrintModelEntity wmPrintModel, HttpServletRequest req) { @RequestMapping(params = "doUpdate")
if (StringUtil.isNotEmpty(wmPrintModel.getId())) { @ResponseBody
wmPrintModel = wmPrintModelService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId()); public AjaxJson doUpdate(WmPrintModelEntity wmPrintModel, HttpServletRequest request) {
req.setAttribute("wmPrintModelPage", wmPrintModel); String message = null;
} AjaxJson j = new AjaxJson();
return new ModelAndView("com/zzjee/wm/wmPrintModel-add"); message = "打印模板更新成功";
} WmPrintModelEntity t = wmPrintModelService.get(WmPrintModelEntity.class, wmPrintModel.getId());
/** try {
* MyBeanUtils.copyBeanNotNull2Bean(wmPrintModel, t);
* wmPrintModelService.saveOrUpdate(t);
* @return systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
*/ } catch (Exception e) {
@RequestMapping(params = "goUpdate") e.printStackTrace();
public ModelAndView goUpdate(WmPrintModelEntity wmPrintModel, HttpServletRequest req) { message = "打印模板更新失败";
if (StringUtil.isNotEmpty(wmPrintModel.getId())) { throw new BusinessException(e.getMessage());
wmPrintModel = wmPrintModelService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId()); }
req.setAttribute("wmPrintModelPage", wmPrintModel); j.setMsg(message);
} return j;
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<WmPrintModelEntity> 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<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<WmPrintModelEntity> 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<WmPrintModelEntity> list() {
List<WmPrintModelEntity> 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<ConstraintViolation<WmPrintModelEntity>> failures = validator.validate(wmPrintModel);
if (!failures.isEmpty()) {
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
}
//保存 /**
try{ *
wmPrintModelService.save(wmPrintModel); *
} catch (Exception e) { * @return
e.printStackTrace(); */
return new ResponseEntity(HttpStatus.NO_CONTENT); @RequestMapping(params = "goAdd")
} public ModelAndView goAdd(WmPrintModelEntity wmPrintModel, HttpServletRequest req) {
//按照Restful风格约定创建指向新任务的url, 也可以直接返回id或对象. if (StringUtil.isNotEmpty(wmPrintModel.getId())) {
String id = wmPrintModel.getId(); wmPrintModel = wmPrintModelService.getEntity(WmPrintModelEntity.class, wmPrintModel.getId());
URI uri = uriBuilder.path("/rest/wmPrintModelController/" + id).build().toUri(); req.setAttribute("wmPrintModelPage", wmPrintModel);
HttpHeaders headers = new HttpHeaders(); }
headers.setLocation(uri); 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<ConstraintViolation<WmPrintModelEntity>> failures = validator.validate(wmPrintModel); * @return
if (!failures.isEmpty()) { */
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); @RequestMapping(params = "upload")
} public ModelAndView upload(HttpServletRequest req) {
req.setAttribute("controller_name", "wmPrintModelController");
return new ModelAndView("common/upload/pub_excel_upload");
}
//保存 /**
try{ * excel
wmPrintModelService.saveOrUpdate(wmPrintModel); *
} catch (Exception e) { * @param request
e.printStackTrace(); * @param response
return new ResponseEntity(HttpStatus.NO_CONTENT); */
} @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<WmPrintModelEntity> 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) @SuppressWarnings("unchecked")
@ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(params = "importExcel", method = RequestMethod.POST)
public void delete(@PathVariable("id") String id) { @ResponseBody
wmPrintModelService.deleteEntityById(WmPrintModelEntity.class, id); public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
} AjaxJson j = new AjaxJson();
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<WmPrintModelEntity> 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<WmPrintModelEntity> list() {
List<WmPrintModelEntity> 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<ConstraintViolation<WmPrintModelEntity>> 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<ConstraintViolation<WmPrintModelEntity>> 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);
}
} }

View File

@ -1,4 +1,5 @@
package com.zzjee.wm.controller; package com.zzjee.wm.controller;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
@ -59,526 +60,519 @@ import com.zzjee.wmutil.wmUtil;
import static com.xiaoleilu.hutool.date.DateTime.now; import static com.xiaoleilu.hutool.date.DateTime.now;
/** /**
* @author erzhongxmu
* @version V1.0
* @Title: Controller * @Title: Controller
* @Description: * @Description:
* @author erzhongxmu
* @date 2017-09-08 21:03:22 * @date 2017-09-08 21:03:22
* @version V1.0
*
*/ */
@Controller @Controller
@RequestMapping("/wmToMoveGoodsController") @RequestMapping("/wmToMoveGoodsController")
public class WmToMoveGoodsController extends BaseController { public class WmToMoveGoodsController extends BaseController {
/** /**
* Logger for this class * Logger for this class
*/ */
private static final Logger logger = Logger.getLogger(WmToMoveGoodsController.class); private static final Logger logger = Logger.getLogger(WmToMoveGoodsController.class);
@Autowired @Autowired
private WmToMoveGoodsServiceI wmToMoveGoodsService; private WmToMoveGoodsServiceI wmToMoveGoodsService;
@Autowired @Autowired
private SystemService systemService; private SystemService systemService;
@Autowired @Autowired
private Validator validator; private Validator validator;
/**
*
*
* @return
*/
@RequestMapping(params = "list")
public ModelAndView list(HttpServletRequest request) {
return new ModelAndView("com/zzjee/wm/wmToMoveGoodsList");
}
/** /**
* * easyui AJAX
* *
* @return * @param request
*/ * @param response
@RequestMapping(params = "list") * @param dataGrid
public ModelAndView list(HttpServletRequest request) { */
return new ModelAndView("com/zzjee/wm/wmToMoveGoodsList");
}
/** @RequestMapping(params = "datagrid")
* easyui AJAX public void datagrid(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
* CriteriaQuery cq = new CriteriaQuery(WmToMoveGoodsEntity.class, dataGrid);
* @param request //查询条件组装器
* @param response org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmToMoveGoods, request.getParameterMap());
* @param dataGrid try {
*/ //自定义追加查询条件
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
Map<String, Object> map1 = new HashMap<String, Object>();
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); *
//查询条件组装器 * @return
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmToMoveGoods, request.getParameterMap()); */
try{ @RequestMapping(params = "doDel")
//自定义追加查询条件 @ResponseBody
}catch (Exception e) { public AjaxJson doDel(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request) {
throw new BusinessException(e.getMessage()); String message = null;
} AjaxJson j = new AjaxJson();
Map<String,Object> map1 = new HashMap<String,Object>(); wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class, wmToMoveGoods.getId());
map1.put("createDate", "desc"); message = "库存转移删除成功";
cq.setOrder(map1); try {
cq.add(); wmToMoveGoods.setMoveSta("已删除");
this.wmToMoveGoodsService.getDataGridReturn(cq, true); wmToMoveGoodsService.saveOrUpdate(wmToMoveGoods);
TagUtil.datagrid(response, dataGrid); 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 * @return
*/ */
@RequestMapping(params = "doDel") @RequestMapping(params = "doBatchUpdate")
@ResponseBody @ResponseBody
public AjaxJson doDel(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request) { public AjaxJson doBatchUpdate(String ids, String moveSta, HttpServletRequest request) {
String message = null; String message = null;
AjaxJson j = new AjaxJson(); AjaxJson j = new AjaxJson();
wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); message = "批量设置状态成功";
message = "库存转移删除成功"; try {
try{ for (String id : ids.split(",")) {
wmToMoveGoods.setMoveSta("已删除"); WmToMoveGoodsEntity wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class,
wmToMoveGoodsService.saveOrUpdate(wmToMoveGoods); id
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); );
}catch(Exception e){ message = "批量保存成功";
e.printStackTrace(); String movesta = "已完成";
message = "库存转移删除失败"; try {
throw new BusinessException(e.getMessage()); movesta = ResourceUtil.getConfigByName("wm.movesta");
}
j.setMsg(message);
return j;
}
/** } catch (Exception e) {
*
*
* @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){ }
} 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); *
} * @return
}catch(Exception e){ */
e.printStackTrace(); @RequestMapping(params = "doBatchDel")
message = "批量设置状态失败"; @ResponseBody
throw new BusinessException(e.getMessage()); public AjaxJson doBatchDel(String ids, HttpServletRequest request) {
} String message = null;
j.setMsg(message); AjaxJson j = new AjaxJson();
return j; message = "库存转移删除成功";
} try {
for (String id : ids.split(",")) {
/** WmToMoveGoodsEntity wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class,
* id
* );
* @return wmToMoveGoods.setMoveSta("已删除");
*/ wmToMoveGoodsService.updateEntitie(wmToMoveGoods);
@RequestMapping(params = "doBatchDel") systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
@ResponseBody }
public AjaxJson doBatchDel(String ids,HttpServletRequest request){ } catch (Exception e) {
String message = null; e.printStackTrace();
AjaxJson j = new AjaxJson(); message = "库存转移删除失败";
message = "库存转移删除成功"; throw new BusinessException(e.getMessage());
try{ }
for(String id:ids.split(",")){ j.setMsg(message);
WmToMoveGoodsEntity wmToMoveGoods = systemService.getEntity(WmToMoveGoodsEntity.class, return j;
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, j.setObj(wmToMoveGoods);
RequestMethod.POST }) return j;
@ResponseBody }
public AjaxJson doGetstock(HttpServletRequest request) {
AjaxJson j = new AjaxJson(); /**
WmToMoveGoodsEntity wmToMoveGoods = new WmToMoveGoodsEntity(); *
*
* @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<WmToMoveGoodsEntity> 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); } catch (Exception e) {
return j;
}
/** }
* t.setMoveSta(movesta);
* MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t);
* @return systemService.saveOrUpdate(t);
*/ systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
@RequestMapping(params = "doAdd") }
@ResponseBody } catch (Exception e) {
public AjaxJson doAdd(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest request) { e.printStackTrace();
String message = null; }
AjaxJson j = new AjaxJson(); }
message = "库存转移添加成功"; }
try{ }
wmToMoveGoods.setMoveSta("计划中"); return j;
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;
}
/**
*
*
* @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 * @return
*/ */
@RequestMapping(params = "saveRows") @RequestMapping(params = "goUpdate")
@ResponseBody public ModelAndView goUpdate(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest req) {
public AjaxJson saveRows(wmtomovepage page){ if (StringUtil.isNotEmpty(wmToMoveGoods.getId())) {
String message = null; wmToMoveGoods = wmToMoveGoodsService.getEntity(WmToMoveGoodsEntity.class, wmToMoveGoods.getId());
List<WmToMoveGoodsEntity> demos=page.getWmtomoverows(); req.setAttribute("wmToMoveGoodsPage", wmToMoveGoods);
AjaxJson j = new AjaxJson(); }
if(CollectionUtils.isNotEmpty(demos)){ return new ModelAndView("com/zzjee/wm/wmToMoveGoods-update");
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");
}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); * excel
MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t); *
systemService.saveOrUpdate(t); * @param request
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); * @param response
} */
} catch (Exception e) { @RequestMapping(params = "exportXls")
e.printStackTrace(); 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<WmToMoveGoodsEntity> wmToMoveGoodss = this.wmToMoveGoodsService.getListByCriteriaQuery(cq, false);
return j; 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<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<WmToMoveGoodsEntity> 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("计划中");
* @return wmToMoveGoodsService.save(wmToMoveGoods);
*/ }
@RequestMapping(params = "goAdd") j.setMsg("文件导入成功!");
public ModelAndView goAdd(WmToMoveGoodsEntity wmToMoveGoods, HttpServletRequest req) { } catch (Exception e) {
if (StringUtil.isNotEmpty(wmToMoveGoods.getId())) { j.setMsg("文件导入失败!");
wmToMoveGoods = wmToMoveGoodsService.getEntity(WmToMoveGoodsEntity.class, wmToMoveGoods.getId()); logger.error(ExceptionUtil.getExceptionMessage(e));
req.setAttribute("wmToMoveGoodsPage", wmToMoveGoods); } finally {
} try {
return new ModelAndView("com/zzjee/wm/wmToMoveGoods-add"); file.getInputStream().close();
} } catch (IOException e) {
/** e.printStackTrace();
* }
* }
* @return }
*/ return j;
@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");
}
/** @RequestMapping(method = RequestMethod.GET)
* @ResponseBody
* public ResponseEntity<?> list(@RequestParam(value = "username", required = false) String username,
* @return @RequestParam(value = "searchstr", required = false) String searchstr,
*/ @RequestParam(value = "searchstr2", required = false) String searchstr2) {
@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<WmToMoveGoodsEntity> 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<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<WmToMoveGoodsEntity> 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) {
// return listWvGis; // return listWvGis;
ResultDO D0 = new ResultDO(); ResultDO D0 = new ResultDO();
String hql = " from WmToMoveGoodsEntity where 1 = 1 and moveSta = '计划中' "; String hql = " from WmToMoveGoodsEntity where 1 = 1 and moveSta = '计划中' ";
D0.setOK(true); D0.setOK(true);
if(!StringUtil.isEmpty(searchstr)) { if (!StringUtil.isEmpty(searchstr)) {
hql=hql+" and binFrom like '%" + searchstr + "%'"; hql = hql + " and binFrom like '%" + searchstr + "%'";
} }
if(!StringUtil.isEmpty(searchstr2)) { if (!StringUtil.isEmpty(searchstr2)) {
try{ try {
String shpbianma = wmUtil.getmdgoodsbytiaoma(searchstr2); String shpbianma = wmUtil.getmdgoodsbytiaoma(searchstr2);
if(StringUtil.isNotEmpty(shpbianma)){ if (StringUtil.isNotEmpty(shpbianma)) {
searchstr2=shpbianma; searchstr2 = shpbianma;
} }
}catch (Exception e){ } catch (Exception e) {
} }
hql=hql+" and goodsId like '%" + searchstr2 + "%'"; hql = hql + " and goodsId like '%" + searchstr2 + "%'";
} }
List<WmToMoveGoodsEntity> listWmToMoveGoodss=wmToMoveGoodsService.findHql(hql); List<WmToMoveGoodsEntity> listWmToMoveGoodss = wmToMoveGoodsService.findHql(hql);
List<WmToMoveGoodsEntity> result = new ArrayList<WmToMoveGoodsEntity>(); List<WmToMoveGoodsEntity> result = new ArrayList<WmToMoveGoodsEntity>();
int i = 0; int i = 0;
for (WmToMoveGoodsEntity t :listWmToMoveGoodss){ for (WmToMoveGoodsEntity t : listWmToMoveGoodss) {
i++; i++;
if(i>100){ if (i > 100) {
break; break;
} }
result.add(t); result.add(t);
} }
if(result.size()<=0){ if (result.size() <= 0) {
D0.setOK(false); D0.setOK(false);
} }
D0.setObj(result); D0.setObj(result);
return new ResponseEntity(D0, HttpStatus.OK); return new ResponseEntity(D0, HttpStatus.OK);
} }
@RequestMapping(value = "/{id}", method = RequestMethod.GET) @RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public ResponseEntity<?> get(@PathVariable("id") String id) { public ResponseEntity<?> get(@PathVariable("id") String id) {
WmToMoveGoodsEntity task = wmToMoveGoodsService.get(WmToMoveGoodsEntity.class, id); WmToMoveGoodsEntity task = wmToMoveGoodsService.get(WmToMoveGoodsEntity.class, id);
if (task == null) { if (task == null) {
return new ResponseEntity(HttpStatus.NOT_FOUND); return new ResponseEntity(HttpStatus.NOT_FOUND);
} }
return new ResponseEntity(task, HttpStatus.OK); return new ResponseEntity(task, HttpStatus.OK);
} }
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
public ResponseEntity<?> create(@RequestBody WmToMoveGoodsEntity wmToMoveGoods, UriComponentsBuilder uriBuilder) { public ResponseEntity<?> create(@RequestBody WmToMoveGoodsEntity wmToMoveGoods, UriComponentsBuilder uriBuilder) {
//调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息. //调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息.
Set<ConstraintViolation<WmToMoveGoodsEntity>> failures = validator.validate(wmToMoveGoods); Set<ConstraintViolation<WmToMoveGoodsEntity>> failures = validator.validate(wmToMoveGoods);
if (!failures.isEmpty()) { if (!failures.isEmpty()) {
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
} }
//保存 //保存
try{ try {
wmToMoveGoodsService.save(wmToMoveGoods); wmToMoveGoodsService.save(wmToMoveGoods);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }
//按照Restful风格约定创建指向新任务的url, 也可以直接返回id或对象. //按照Restful风格约定创建指向新任务的url, 也可以直接返回id或对象.
String id = wmToMoveGoods.getId(); String id = wmToMoveGoods.getId();
URI uri = uriBuilder.path("/rest/wmToMoveGoodsController/" + id).build().toUri(); URI uri = uriBuilder.path("/rest/wmToMoveGoodsController/" + id).build().toUri();
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setLocation(uri); 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) @RequestMapping(value = "/change", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
public ResponseEntity<?> update(@RequestParam String wmToMoveGoodsstr, public ResponseEntity<?> update(@RequestParam String wmToMoveGoodsstr,
UriComponentsBuilder uriBuilder) { UriComponentsBuilder uriBuilder) {
//调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息. //调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息.
ResultDO D0 = new ResultDO(); ResultDO D0 = new ResultDO();
WmToMoveGoodsEntity wmToMoveGoods = (WmToMoveGoodsEntity)JSONHelper.json2Object(wmToMoveGoodsstr,WmToMoveGoodsEntity.class); WmToMoveGoodsEntity wmToMoveGoods = (WmToMoveGoodsEntity) JSONHelper.json2Object(wmToMoveGoodsstr, WmToMoveGoodsEntity.class);
//保存 //保存
try{ try {
WmToMoveGoodsEntity t = systemService.get(WmToMoveGoodsEntity.class,wmToMoveGoods.getId()); WmToMoveGoodsEntity t = systemService.get(WmToMoveGoodsEntity.class, wmToMoveGoods.getId());
MyBeanUtils.copyBeanNotNull2Bean(wmToMoveGoods,t); MyBeanUtils.copyBeanNotNull2Bean(wmToMoveGoods, t);
try{ try {
if(StringUtil.isNotEmpty(wmToMoveGoods.getUpdateBy())){ if (StringUtil.isNotEmpty(wmToMoveGoods.getUpdateBy())) {
TSUser tsuser = systemService.findUniqueByProperty(TSUser.class,"",wmToMoveGoods.getUpdateBy()); TSUser tsuser = systemService.findUniqueByProperty(TSUser.class, "", wmToMoveGoods.getUpdateBy());
t.setUpdateName(tsuser.getRealName()); t.setUpdateName(tsuser.getRealName());
} }
}catch (Exception e){ } catch (Exception e) {
} }
t.setUpdateDate(now()); t.setUpdateDate(now());
// if(!wmUtil.checkstcok( t.getBinFrom(),t.getTinFrom(),t.getGoodsId(),t.getGoodsProData(),t.getBaseGoodscount())) { // if(!wmUtil.checkstcok( t.getBinFrom(),t.getTinFrom(),t.getGoodsId(),t.getGoodsProData(),t.getBaseGoodscount())) {
// D0.setOK(false); // D0.setOK(false);
// D0.setErrorMsg("库存不足"); // D0.setErrorMsg("库存不足");
// }else{ // }else{
String movesta = "已完成"; String movesta = "已完成";
try{ try {
movesta = ResourceUtil.getConfigByName("wm.movesta"); movesta = ResourceUtil.getConfigByName("wm.movesta");
}catch (Exception e){ } catch (Exception e) {
} }
t.setMoveSta(movesta); t.setMoveSta(movesta);
wmToMoveGoodsService.saveOrUpdate(t); wmToMoveGoodsService.saveOrUpdate(t);
D0.setOK(true); D0.setOK(true);
// } // }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
D0.setOK(false); 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) @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT) @ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable("id") String id) { public void delete(@PathVariable("id") String id) {
wmToMoveGoodsService.deleteEntityById(WmToMoveGoodsEntity.class, id); wmToMoveGoodsService.deleteEntityById(WmToMoveGoodsEntity.class, id);
} }
} }