代码优化

master
e 2019-05-20 23:23:55 +08:00
parent 4e14482d14
commit 558e0916d6
1 changed files with 105 additions and 160 deletions

View File

@ -1,78 +1,36 @@
package com.zzjee.bireport.controller;
import com.zzjee.bireport.entity.RpPeriodInOutEntity;
import com.zzjee.bireport.service.RpPeriodInOutServiceI;
import java.util.ArrayList;
import java.util.List;
import java.text.SimpleDateFormat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.zzjee.wmutil.wmUtil;
import org.apache.log4j.Logger;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.exception.BusinessException;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.util.ResourceUtil;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.web.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.exception.BusinessException;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.common.TreeChildCount;
import org.jeecgframework.core.common.model.json.AjaxJson;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.constant.Globals;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.web.system.pojo.base.TSDepart;
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;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.entity.TemplateExportParams;
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;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
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.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Validator;
import java.net.URI;
import org.springframework.http.MediaType;
import org.springframework.web.util.UriComponentsBuilder;
import java.util.List;
/**
* @author onlineGenerator
* @version V1.0
* @Title: Controller
* @Description:
* @author onlineGenerator
* @date 2019-01-17 12:55:46
* @version V1.0
*
*/
@Controller
@RequestMapping("/rpPeriodInOutController")
@ -90,7 +48,6 @@ public class RpPeriodInOutController extends BaseController {
private Validator validator;
/**
*
*
@ -111,36 +68,30 @@ public class RpPeriodInOutController extends BaseController {
*/
@RequestMapping(params = "datagrid")
public void datagrid(RpPeriodInOutEntity rpPeriodInOut,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
public void datagrid(RpPeriodInOutEntity rpPeriodInOut, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
rpPeriodInOut.setCreateDate(null);
CriteriaQuery cq = new CriteriaQuery(RpPeriodInOutEntity.class, dataGrid);
//查询条件组装器
try{
try {
//自定义追加查询条件
String query_datePeriod_begin = request.getParameter("createDate1_begin");
String query_datePeriod_end = request.getParameter("createDate1_end");
try{
if(!StringUtil.isNotEmpty(query_datePeriod_begin)){
try {
if (!StringUtil.isNotEmpty(query_datePeriod_begin)) {
query_datePeriod_begin = "2018-01-01";
}
if(!StringUtil.isNotEmpty(query_datePeriod_end)){
if (!StringUtil.isNotEmpty(query_datePeriod_end)) {
query_datePeriod_end = "2099-01-01";
}
wmUtil.genrp(query_datePeriod_begin,query_datePeriod_end,ResourceUtil.getSessionUserName().getUserName());
}catch (Exception e){
wmUtil.genrp(query_datePeriod_begin, query_datePeriod_end, ResourceUtil.getSessionUserName().getUserName());
} catch (Exception e) {
}
// if(StringUtil.isNotEmpty(query_datePeriod_begin)){
// cq.ge("datePeriod", Integer.parseInt(query_datePeriod_begin));
// }
// if(StringUtil.isNotEmpty(query_datePeriod_end)){
// cq.le("datePeriod", Integer.parseInt(query_datePeriod_end));
// }
rpPeriodInOut.setCreateDate(null);
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, rpPeriodInOut, request.getParameterMap());
cq.eq("username",ResourceUtil.getSessionUserName().getUserName());
}catch (Exception e) {
cq.eq("username", ResourceUtil.getSessionUserName().getUserName());
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
cq.add();
@ -149,8 +100,6 @@ public class RpPeriodInOutController extends BaseController {
}
/**
* excel
*
@ -158,38 +107,34 @@ public class RpPeriodInOutController extends BaseController {
* @param response
*/
@RequestMapping(params = "exportXls")
public String exportXls(RpPeriodInOutEntity rpPeriodInOut,HttpServletRequest request,HttpServletResponse response
, DataGrid dataGrid,ModelMap modelMap) {
public String exportXls(RpPeriodInOutEntity rpPeriodInOut, HttpServletRequest request, HttpServletResponse response
, DataGrid dataGrid, ModelMap modelMap) {
//自定义追加查询条件
String query_datePeriod_begin = request.getParameter("createDate1_begin");
String query_datePeriod_end = request.getParameter("createDate1_end");
try{
if(!StringUtil.isNotEmpty(query_datePeriod_begin)){
try {
if (!StringUtil.isNotEmpty(query_datePeriod_begin)) {
query_datePeriod_begin = "2018-01-01";
}
if(!StringUtil.isNotEmpty(query_datePeriod_end)){
if (!StringUtil.isNotEmpty(query_datePeriod_end)) {
query_datePeriod_end = "2099-01-01";
}
wmUtil.genrp(query_datePeriod_begin,query_datePeriod_end,ResourceUtil.getSessionUserName().getUserName());
}catch (Exception e){
wmUtil.genrp(query_datePeriod_begin, query_datePeriod_end, ResourceUtil.getSessionUserName().getUserName());
} catch (Exception e) {
}
rpPeriodInOut.setCreateDate(null);
rpPeriodInOut.setUsername(ResourceUtil.getSessionUserName().getUserName());
CriteriaQuery cq = new CriteriaQuery(RpPeriodInOutEntity.class, dataGrid);
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, rpPeriodInOut, request.getParameterMap());
List<RpPeriodInOutEntity> rpPeriodInOuts = this.rpPeriodInOutService.getListByCriteriaQuery(cq,false);
modelMap.put(NormalExcelConstants.FILE_NAME,"期间出货统计");
modelMap.put(NormalExcelConstants.CLASS,RpPeriodInOutEntity.class);
modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("期间出货统计列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(),
List<RpPeriodInOutEntity> rpPeriodInOuts = this.rpPeriodInOutService.getListByCriteriaQuery(cq, false);
modelMap.put(NormalExcelConstants.FILE_NAME, "期间出货统计");
modelMap.put(NormalExcelConstants.CLASS, RpPeriodInOutEntity.class);
modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("期间出货统计列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(),
"导出信息"));
modelMap.put(NormalExcelConstants.DATA_LIST,rpPeriodInOuts);
modelMap.put(NormalExcelConstants.DATA_LIST, rpPeriodInOuts);
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
}