package com.forestry.controller.sys;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFHeader;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.support.RequestContext;
import com.forestry.core.ForestryBaseController;
import com.forestry.model.sys.Forestry;
import com.forestry.model.sys.ForestryType;
import com.forestry.service.sys.ForestryService;
import com.forestry.service.sys.ForestryTypeService;
import core.extjs.ExtJSBaseParameter;
import core.extjs.ListView;
import core.support.QueryResult;
import core.util.ForestryUtils;
/**
* @框架唯一的升级和技术支持地址:http://shop111863449.taobao.com
*/
@Controller
@RequestMapping("/sys/forestry")
public class ForestryController extends ForestryBaseController<Forestry> {
private static final Logger log = Logger.getLogger(ForestryController.class);
private static SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
@Resource
private ForestryService forestryService;
@Resource
private ForestryTypeService forestryTypeService;
@RequestMapping(value = "/getForestry", method = { RequestMethod.POST, RequestMethod.GET })
public void getForestry(HttpServletRequest request, HttpServletResponse response) throws Exception {
Integer firstResult = Integer.valueOf(request.getParameter("start"));
Integer maxResults = Integer.valueOf(request.getParameter("limit"));
String sortedObject = null;
String sortedValue = null;
List<LinkedHashMap<String, Object>> sortedList = mapper.readValue(request.getParameter("sort"), List.class);
for (int i = 0; i < sortedList.size(); i++) {
Map<String, Object> map = sortedList.get(i);
sortedObject = (String) map.get("property");
sortedValue = (String) map.get("direction");
}
Forestry forestry = new Forestry();
String epcId = request.getParameter("epcId");
if (StringUtils.isNotBlank(epcId)) {
forestry.set$like_epcId(epcId);
}
String name = request.getParameter("name");
if (StringUtils.isNotBlank(name)) {
forestry.set$like_name(name);
}
String forestryTypeId = request.getParameter("forestryTypeId");
if (StringUtils.isNotBlank(forestryTypeId)) {
forestry.set$eq_typeId(Long.valueOf(forestryTypeId));
}
forestry.setFirstResult(firstResult);
forestry.setMaxResults(maxResults);
Map<String, String> sortedCondition = new HashMap<String, String>();
sortedCondition.put(sortedObject, sortedValue);
forestry.setSortedConditions(sortedCondition);
QueryResult<Forestry> queryResult = forestryService.doPaginationQuery(forestry);
List<Forestry> forestryList = forestryService.getForestryList(queryResult.getResultList());
ListView<Forestry> forestryListView = new ListView<Forestry>();
forestryListView.setData(forestryList);
forestryListView.setTotalRecord(queryResult.getTotalCount());
writeJSON(response, forestryListView);
}
@RequestMapping("/deleteForestry")
public void deleteForestry(HttpServletRequest request, HttpServletResponse response, @RequestParam("ids") Long[] ids) throws IOException {
boolean flag = forestryService.deleteByPK(ids);
if (flag) {
writeJSON(response, "{success:true}");
} else {
writeJSON(response, "{success:false}");
}
}
@RequestMapping("/getForestryTypeName")
public void getForestryTypeName(HttpServletRequest request, HttpServletResponse response) throws Exception {
List<ForestryType> forestryTypeList = forestryTypeService.doQueryAll();
JSONArray jsonArray = new JSONArray();
for (int i = 0; i < forestryTypeList.size(); i++) {
JSONObject jsonObject = new JSONObject();
jsonObject.element("ItemText", forestryTypeList.get(i).getName());
jsonObject.element("ItemValue", forestryTypeList.get(i).getId());
jsonArray.add(jsonObject);
}
JSONObject resultJSONObject = new JSONObject();
resultJSONObject.element("list", jsonArray);
writeJSON(response, resultJSONObject);
}
@Override
@RequestMapping(value = "/saveForestry", method = { RequestMethod.POST, RequestMethod.GET })
public void doSave(Forestry entity, HttpServletRequest request, HttpServletResponse response) throws IOException {
ExtJSBaseParameter parameter = ((ExtJSBaseParameter) entity);
Forestry checkEpcId = forestryService.getByProerties("epcId", entity.getEpcId());
if (null != checkEpcId && null == entity.getId()) {
parameter.setSuccess(false);
} else {
ForestryType forestryType = forestryTypeService.get(entity.getForestryTypeId());
entity.setForestryType(forestryType);
if (CMD_EDIT.equals(parameter.getCmd())) {
forestryService.update(entity);
} else if (CMD_NEW.equals(parameter.getCmd())) {
forestryService.persist(entity);
}
parameter.setCmd(CMD_EDIT);
parameter.setSuccess(true);
}
writeJSON(response, parameter);
}
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
@RequestMapping(value = "/importForestryFile", method = RequestMethod.POST)
public void importForestryFile(@RequestParam(value = "importedFile", required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws Exception {
RequestContext requestContext = new RequestContext(request);
JSONObject json = new JSONObject();
if (!file.isEmpty()) {
if (file.getSize() > 2097152) {
json.put("msg", requestContext.getMessage("g_fileTooLarge"));
} else {
try {
String originalFilename = file.getOriginalFilename();
String fileName = sdf.format(new Date()) + ForestryUtils.getRandomString(3) + originalFilename.substring(originalFilename.lastIndexOf("."));
File filePath = new File(getClass().getClassLoader().getResource("/").getPath().replace("/WEB-INF/classes/", "/static/download/attachment/" + DateFormatUtils.format(new Date(), "yyyyMM")));
if (!filePath.exists()) {
filePath.mkdirs();
}
String serverFile = filePath.getAbsolutePath() + "\\" + fileName;
file.transferTo(new File(serverFile));
String fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
if (!fileType.equalsIgnoreCase("xls") && !fileType.equalsIgnoreCase("xlsx")) {
json.put("success", false);
json.put("msg", requestContext.getMessage("g_notValidExcel"));
writeJSON(response, j
没有合适的资源?快使用搜索试试~ 我知道了~
基于ExtJS的通用后台管理系统
共2000个文件
gif:1646个
png:426个
java:116个
1星 需积分: 33 65 下载量 94 浏览量
2017-12-08
15:20:57
上传
评论
收藏 42.17MB RAR 举报
温馨提示
基于ExtJS的通用后台管理系统。某宝购买,界面布局漂亮、里面有如何导入,以及中间遇到错误的解决办法的文档。可以快捷、方便的移入自己的项目中。
资源推荐
资源详情
资源评论
收起资源包目录
基于ExtJS的通用后台管理系统 (2000个子文件)
ForestryController.class 19KB
AuthorityController.class 13KB
SysUserController.class 11KB
ForestryTypeController.class 10KB
ConfigController.class 9KB
SensorController.class 9KB
BeanUtils.class 7KB
SystemInitListener.class 7KB
DepartmentController.class 6KB
SensorDaoImpl.class 5KB
Authority.class 4KB
ForestryServiceImpl.class 4KB
Service.class 4KB
Dao.class 4KB
HtmlUtils.class 4KB
SysUser.class 4KB
Forestry.class 4KB
AuthorityServiceImpl.class 3KB
ForestryType.class 3KB
Attachment.class 3KB
MonitorLog.class 3KB
Sensor.class 3KB
SensorLastData.class 3KB
SensorData.class 3KB
SysUserServiceImpl.class 3KB
LoginFilter.class 3KB
PageView.class 2KB
AttachmentController.class 2KB
ConfigServiceImpl.class 2KB
RoleAuthorityController.class 2KB
SensorDataServiceImpl.class 2KB
RoleAuthority.class 2KB
ForestryTypeServiceImpl.class 2KB
Config.class 2KB
Department.class 2KB
AuthorityDaoImpl.class 2KB
SensorServiceImpl.class 2KB
SensorDataController.class 2KB
AttachmentDaoImpl.class 2KB
ForestryDaoImpl.class 2KB
ForestryParameter.class 2KB
HighPreciseComputor.class 2KB
SpringBeanFactoryUtils.class 2KB
DESede.class 2KB
MD5.class 2KB
CustomDateEditor.class 2KB
MonitorLogController.class 1KB
SensorDataDaoImpl.class 1KB
ForestryUtils.class 1KB
IPChecker.class 1KB
MonitorLogDaoImpl.class 1KB
ServiceException.class 1KB
ForestryBaseController.class 1KB
AttachmentServiceImpl.class 1KB
DateTimeSerializer.class 1KB
SysUserParameter.class 1KB
DateSerializer.class 1KB
JavaUtilDateConverter.class 1KB
GetHttpServletRequestWrapper.class 1KB
SSHTest.class 1KB
Group.class 1KB
MonitorLogServiceImpl.class 1KB
QueryResult.class 1KB
ForestryTypeParameter.class 1KB
ListView.class 1KB
SensorDataParameter.class 1KB
SensorLastDataServiceImpl.class 953B
RoleAuthorityServiceImpl.class 943B
SessionThreadLocal.class 941B
DepartmentServiceImpl.class 913B
ExtJSBaseParameter.class 896B
CacheFactory.class 893B
AttachmentParameter.class 873B
AuthorityService.class 841B
SensorService.class 804B
SensorLastDataController.class 795B
SensorDao.class 776B
Item.class 695B
ConfigParameter.class 685B
SensorLastDataDaoImpl.class 666B
SensorParameter.class 664B
RoleAuthorityDaoImpl.class 659B
ForestryTypeDaoImpl.class 652B
DepartmentDaoImpl.class 638B
SysUserDaoImpl.class 617B
ConfigDaoImpl.class 610B
AuthorityDao.class 583B
ForestryService.class 577B
SensorDataService.class 576B
SystemCache.class 503B
AttachmentService.class 466B
ForestryTypeService.class 464B
AttachmentDao.class 438B
SysUserService.class 434B
SensorLastDataParameter.class 429B
ConfigService.class 428B
RoleAuthorityParameter.class 426B
DepartmentParameter.class 417B
AuthorityParameter.class 414B
MonitorLogService.class 387B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- qq_353674252018-01-15没用。具体操作文档也没有、完全是浪费积分
等待的萝卜
- 粉丝: 44
- 资源: 27
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功