格式化

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;
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<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);
}
/**
*
*
* @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<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
*/
@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<ConstraintViolation<WmPrintModelEntity>> 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<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)
@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<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;
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<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);
//查询条件组装器
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmToMoveGoods, request.getParameterMap());
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);
}
/**
*
*
* @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<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);
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<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");
/**
*
*
* @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<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) {
/**
*
*
* @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<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) {
@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<WmToMoveGoodsEntity> listWmToMoveGoodss=wmToMoveGoodsService.findHql(hql);
List<WmToMoveGoodsEntity> listWmToMoveGoodss = wmToMoveGoodsService.findHql(hql);
List<WmToMoveGoodsEntity> result = new ArrayList<WmToMoveGoodsEntity>();
int i = 0;
for (WmToMoveGoodsEntity t :listWmToMoveGoodss){
List<WmToMoveGoodsEntity> result = new ArrayList<WmToMoveGoodsEntity>();
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<ConstraintViolation<WmToMoveGoodsEntity>> 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<ConstraintViolation<WmToMoveGoodsEntity>> 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);
}
}