|
@@ -1,12 +1,14 @@
|
|
|
package com.jpsoft.railroad.modules.form.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.railroad.config.OSSConfig;
|
|
|
import com.jpsoft.railroad.modules.base.entity.Organization;
|
|
|
import com.jpsoft.railroad.modules.base.entity.RegUser;
|
|
|
import com.jpsoft.railroad.modules.base.service.OrganizationService;
|
|
|
import com.jpsoft.railroad.modules.base.service.RegUserService;
|
|
|
import com.jpsoft.railroad.modules.common.dto.Sort;
|
|
|
import com.jpsoft.railroad.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.railroad.modules.common.utils.OSSUtil;
|
|
|
import com.jpsoft.railroad.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.railroad.modules.form.entity.VehicleApplicationInfo;
|
|
|
import com.jpsoft.railroad.modules.form.service.VehicleApplicationInfoService;
|
|
@@ -17,12 +19,19 @@ import net.sf.json.JSONArray;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+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.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -42,11 +51,14 @@ public class VehicleApplicationInfoController {
|
|
|
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value="创建空记录")
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OSSConfig ossConfig;
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "创建空记录")
|
|
|
@GetMapping("create")
|
|
|
- public MessageResult<VehicleApplicationInfo> create(){
|
|
|
+ public MessageResult<VehicleApplicationInfo> create() {
|
|
|
MessageResult<VehicleApplicationInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
VehicleApplicationInfo vehicleApplicationInfo = new VehicleApplicationInfo();
|
|
@@ -57,21 +69,21 @@ public class VehicleApplicationInfoController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="添加信息")
|
|
|
+ @ApiOperation(value = "添加信息")
|
|
|
@PostMapping("add")
|
|
|
- public MessageResult<VehicleApplicationInfo> add(@RequestBody VehicleApplicationInfo vehicleApplicationInfo,@RequestAttribute String subject){
|
|
|
+ public MessageResult<VehicleApplicationInfo> add(@RequestBody VehicleApplicationInfo vehicleApplicationInfo, @RequestAttribute String subject) {
|
|
|
MessageResult<VehicleApplicationInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
Date now = new Date();
|
|
|
vehicleApplicationInfo.setId(UUID.randomUUID().toString());
|
|
|
- vehicleApplicationInfo.setDelFlag(false);
|
|
|
+ vehicleApplicationInfo.setDelFlag(false);
|
|
|
vehicleApplicationInfo.setCreateBy(subject);
|
|
|
vehicleApplicationInfo.setCreateTime(new Date());
|
|
|
|
|
|
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
- if(vehicleApplicationInfo.getRangeDateTime()!=null){
|
|
|
+ if (vehicleApplicationInfo.getRangeDateTime() != null) {
|
|
|
String startDateTime = vehicleApplicationInfo.getRangeDateTime()[0];
|
|
|
String endDateTime = vehicleApplicationInfo.getRangeDateTime()[1];
|
|
|
vehicleApplicationInfo.setStartTime(sdf.parse(startDateTime));
|
|
@@ -84,7 +96,7 @@ public class VehicleApplicationInfoController {
|
|
|
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
|
|
|
- if(vehicleApplicationInfo.getAnnexFileList()!=null) {
|
|
|
+ if (vehicleApplicationInfo.getAnnexFileList() != null) {
|
|
|
for (Map<String, String> map : vehicleApplicationInfo.getAnnexFileList()) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("name", map.get("name"));
|
|
@@ -93,7 +105,7 @@ public class VehicleApplicationInfoController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(jsonArray.size()>0){
|
|
|
+ if (jsonArray.size() > 0) {
|
|
|
vehicleApplicationInfo.setAnnexFile(jsonArray.toString());
|
|
|
}
|
|
|
|
|
@@ -102,22 +114,20 @@ public class VehicleApplicationInfoController {
|
|
|
if (regUser != null) {
|
|
|
vehicleApplicationInfo.setApplyPersonId(regUser.getId());
|
|
|
vehicleApplicationInfo.setApplyDate(now);
|
|
|
- if(StringUtils.isNotEmpty(regUser.getOrgId())){
|
|
|
+ if (StringUtils.isNotEmpty(regUser.getOrgId())) {
|
|
|
vehicleApplicationInfo.setDepartmentId(regUser.getOrgId());
|
|
|
}
|
|
|
|
|
|
//是否为保存草稿
|
|
|
- if(vehicleApplicationInfo.getIsDraft()!=null){
|
|
|
- if(!vehicleApplicationInfo.getIsDraft()){
|
|
|
- affectCount = vehicleApplicationInfoService.insertAndProc(vehicleApplicationInfo,regUser);
|
|
|
- }
|
|
|
- else{
|
|
|
+ if (vehicleApplicationInfo.getIsDraft() != null) {
|
|
|
+ if (!vehicleApplicationInfo.getIsDraft()) {
|
|
|
+ affectCount = vehicleApplicationInfoService.insertAndProc(vehicleApplicationInfo, regUser);
|
|
|
+ } else {
|
|
|
vehicleApplicationInfo.setStatus("-1");//为保存草稿
|
|
|
affectCount = vehicleApplicationInfoService.insert(vehicleApplicationInfo);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("账号未关联人员账号无法提交申请!");
|
|
|
}
|
|
@@ -129,9 +139,8 @@ public class VehicleApplicationInfoController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库添加失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -140,9 +149,9 @@ public class VehicleApplicationInfoController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="获取信息")
|
|
|
+ @ApiOperation(value = "获取信息")
|
|
|
@GetMapping("edit/{id}")
|
|
|
- public MessageResult<VehicleApplicationInfo> edit(@PathVariable("id") String id){
|
|
|
+ public MessageResult<VehicleApplicationInfo> edit(@PathVariable("id") String id) {
|
|
|
MessageResult<VehicleApplicationInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
@@ -150,11 +159,11 @@ public class VehicleApplicationInfoController {
|
|
|
|
|
|
if (vehicleApplicationInfo != null) {
|
|
|
RegUser regUser = regUserService.get(vehicleApplicationInfo.getApplyPersonId());
|
|
|
- if(regUser!=null){
|
|
|
+ if (regUser != null) {
|
|
|
vehicleApplicationInfo.setApplyPersonName(regUser.getName());
|
|
|
|
|
|
Organization organization = organizationService.get(regUser.getOrgId());
|
|
|
- if(organization!=null){
|
|
|
+ if (organization != null) {
|
|
|
vehicleApplicationInfo.setOrgName(organization.getName());
|
|
|
}
|
|
|
}
|
|
@@ -163,7 +172,7 @@ public class VehicleApplicationInfoController {
|
|
|
|
|
|
List<Map> annexFileList = new ArrayList<>();
|
|
|
|
|
|
- if(StringUtils.isNotEmpty(annexFile)) {
|
|
|
+ if (StringUtils.isNotEmpty(annexFile)) {
|
|
|
|
|
|
JSONArray jsonArray = JSONArray.fromObject(annexFile);
|
|
|
|
|
@@ -181,11 +190,11 @@ public class VehicleApplicationInfoController {
|
|
|
|
|
|
vehicleApplicationInfo.setAnnexFileList(annexFileList);
|
|
|
|
|
|
- if(vehicleApplicationInfo.getStartTime()!=null&&vehicleApplicationInfo.getEndTime()!=null){
|
|
|
+ if (vehicleApplicationInfo.getStartTime() != null && vehicleApplicationInfo.getEndTime() != null) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String[] rangeDateTimeArr = new String[2];
|
|
|
- rangeDateTimeArr[0]=sdf.format(vehicleApplicationInfo.getStartTime());
|
|
|
- rangeDateTimeArr[1]=sdf.format(vehicleApplicationInfo.getEndTime());
|
|
|
+ rangeDateTimeArr[0] = sdf.format(vehicleApplicationInfo.getStartTime());
|
|
|
+ rangeDateTimeArr[1] = sdf.format(vehicleApplicationInfo.getEndTime());
|
|
|
vehicleApplicationInfo.setRangeDateTime(rangeDateTimeArr);
|
|
|
}
|
|
|
|
|
@@ -195,9 +204,8 @@ public class VehicleApplicationInfoController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库不存在该记录!");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -206,19 +214,19 @@ public class VehicleApplicationInfoController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="更新用户")
|
|
|
+ @ApiOperation(value = "更新用户")
|
|
|
@PostMapping("update")
|
|
|
- public MessageResult<VehicleApplicationInfo> update(@RequestBody VehicleApplicationInfo vehicleApplicationInfo,@RequestAttribute String subject){
|
|
|
+ public MessageResult<VehicleApplicationInfo> update(@RequestBody VehicleApplicationInfo vehicleApplicationInfo, @RequestAttribute String subject) {
|
|
|
MessageResult<VehicleApplicationInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
Date now = new Date();
|
|
|
- vehicleApplicationInfo.setUpdateBy(subject);
|
|
|
+ vehicleApplicationInfo.setUpdateBy(subject);
|
|
|
vehicleApplicationInfo.setUpdateTime(new Date());
|
|
|
|
|
|
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
- if(vehicleApplicationInfo.getRangeDateTime()!=null){
|
|
|
+ if (vehicleApplicationInfo.getRangeDateTime() != null) {
|
|
|
String startDateTime = vehicleApplicationInfo.getRangeDateTime()[0];
|
|
|
String endDateTime = vehicleApplicationInfo.getRangeDateTime()[1];
|
|
|
vehicleApplicationInfo.setStartTime(sdf.parse(startDateTime));
|
|
@@ -233,7 +241,7 @@ public class VehicleApplicationInfoController {
|
|
|
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
|
|
|
- if(vehicleApplicationInfo.getAnnexFileList()!=null) {
|
|
|
+ if (vehicleApplicationInfo.getAnnexFileList() != null) {
|
|
|
for (Map<String, String> map : vehicleApplicationInfo.getAnnexFileList()) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("name", map.get("name"));
|
|
@@ -242,7 +250,7 @@ public class VehicleApplicationInfoController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(jsonArray.size()>0){
|
|
|
+ if (jsonArray.size() > 0) {
|
|
|
vehicleApplicationInfo.setAnnexFile(jsonArray.toString());
|
|
|
}
|
|
|
|
|
@@ -250,17 +258,15 @@ public class VehicleApplicationInfoController {
|
|
|
vehicleApplicationInfo.setApplyDate(now);
|
|
|
|
|
|
//是否为保存草稿
|
|
|
- if(vehicleApplicationInfo.getIsDraft()!=null){
|
|
|
- if(!vehicleApplicationInfo.getIsDraft()){
|
|
|
- affectCount = vehicleApplicationInfoService.updateAndProc(vehicleApplicationInfo,regUser);
|
|
|
- }
|
|
|
- else{
|
|
|
+ if (vehicleApplicationInfo.getIsDraft() != null) {
|
|
|
+ if (!vehicleApplicationInfo.getIsDraft()) {
|
|
|
+ affectCount = vehicleApplicationInfoService.updateAndProc(vehicleApplicationInfo, regUser);
|
|
|
+ } else {
|
|
|
vehicleApplicationInfo.setStatus("-1");//为保存草稿
|
|
|
affectCount = vehicleApplicationInfoService.update(vehicleApplicationInfo);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("账号未关联人员账号无法提交申请!");
|
|
|
}
|
|
@@ -272,9 +278,8 @@ public class VehicleApplicationInfoController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库更新失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -283,19 +288,19 @@ public class VehicleApplicationInfoController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="删除用户")
|
|
|
+ @ApiOperation(value = "删除用户")
|
|
|
@PostMapping("delete/{id}")
|
|
|
- public MessageResult<VehicleApplicationInfo> delete(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
+ public MessageResult<VehicleApplicationInfo> delete(@PathVariable("id") String id, @RequestAttribute String subject) {
|
|
|
MessageResult<VehicleApplicationInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
-
|
|
|
- VehicleApplicationInfo vehicleApplicationInfo = vehicleApplicationInfoService.get(id);
|
|
|
+
|
|
|
+ VehicleApplicationInfo vehicleApplicationInfo = vehicleApplicationInfoService.get(id);
|
|
|
vehicleApplicationInfo.setDelFlag(true);
|
|
|
vehicleApplicationInfo.setUpdateBy(subject);
|
|
|
vehicleApplicationInfo.setUpdateTime(new Date());
|
|
|
-
|
|
|
- int affectCount = vehicleApplicationInfoService.updateAndProcinst(vehicleApplicationInfo);
|
|
|
+
|
|
|
+ int affectCount = vehicleApplicationInfoService.updateAndProcinst(vehicleApplicationInfo);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
@@ -303,9 +308,8 @@ public class VehicleApplicationInfoController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库删除失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -315,9 +319,9 @@ public class VehicleApplicationInfoController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @ApiOperation(value="批量删除")
|
|
|
+ @ApiOperation(value = "批量删除")
|
|
|
@PostMapping("batchDelete")
|
|
|
- public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject) {
|
|
|
MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
@@ -339,9 +343,8 @@ public class VehicleApplicationInfoController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("删除失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -350,56 +353,191 @@ public class VehicleApplicationInfoController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="列表")
|
|
|
- @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
- public MessageResult<Map> pageList(
|
|
|
- String id,
|
|
|
- @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
- @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
- HttpServletRequest request){
|
|
|
- String subject = (String)request.getAttribute("subject");
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
+ @RequestMapping(value = "pageList", method = RequestMethod.POST)
|
|
|
+ public MessageResult<Object> pageList(
|
|
|
+ String applyDateRange,
|
|
|
+ @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
|
|
|
+ @RequestParam(value = "exportFlag", defaultValue = "false") Boolean exportFlag,
|
|
|
+ HttpServletRequest request) {
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
|
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|
|
|
|
|
|
User user = userService.get(subject);
|
|
|
|
|
|
- MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
+ MessageResult<Object> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
|
|
|
- Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
|
|
|
- List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("create_time","desc"));
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
|
|
|
- if (!userService.hasRole(subject, "SYSADMIN")) {
|
|
|
- RegUser curRegUser = regUserService.findByPhone(user.getPhone());
|
|
|
- if(curRegUser!=null){
|
|
|
- searchParams.put("applyPersonId", curRegUser.getId());
|
|
|
+ if (!userService.hasRole(subject, "SYSADMIN")) {
|
|
|
+ RegUser curRegUser = regUserService.findByPhone(user.getPhone());
|
|
|
+ if (curRegUser != null) {
|
|
|
+ searchParams.put("applyPersonId", curRegUser.getId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ searchParams.put("status", "-1");
|
|
|
}
|
|
|
- }
|
|
|
- else{
|
|
|
- searchParams.put("status", "-1");
|
|
|
- }
|
|
|
|
|
|
- Page<VehicleApplicationInfo> page = vehicleApplicationInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+ if (StringUtils.isNotEmpty(applyDateRange)) {
|
|
|
+ String[] timeRangeArray = applyDateRange.split(",");
|
|
|
+ String startTime = "";
|
|
|
+ String endTime = "";
|
|
|
+ if (timeRangeArray.length == 1) {
|
|
|
+ startTime = timeRangeArray[0];
|
|
|
+ startTime += " 00:00:00";
|
|
|
+ } else if (timeRangeArray.length == 2) {
|
|
|
+ startTime = timeRangeArray[0];
|
|
|
+ endTime = timeRangeArray[1];
|
|
|
+ startTime += " 00:00:00";
|
|
|
+ endTime += " 23:59:59";
|
|
|
+ }
|
|
|
+ searchParams.put("startTime", startTime);
|
|
|
+ searchParams.put("endTime", endTime);
|
|
|
+ }
|
|
|
|
|
|
- for (VehicleApplicationInfo vehicleApplicationInfo:page) {
|
|
|
+ Page<VehicleApplicationInfo> page = vehicleApplicationInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
|
|
|
- RegUser regUser = regUserService.get(vehicleApplicationInfo.getApplyPersonId());
|
|
|
- if(regUser!=null){
|
|
|
- vehicleApplicationInfo.setApplyPersonName(regUser.getName());
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
|
|
|
- Organization organization = organizationService.get(regUser.getOrgId());
|
|
|
- if(organization!=null){
|
|
|
- vehicleApplicationInfo.setOrgName(organization.getName());
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+
|
|
|
+ for (VehicleApplicationInfo vehicleApplicationInfo : page) {
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("id", vehicleApplicationInfo.getId());
|
|
|
+ String applyDateStr = "";
|
|
|
+ if (vehicleApplicationInfo.getApplyDate() != null) {
|
|
|
+ applyDateStr = sdf.format(vehicleApplicationInfo.getApplyDate());
|
|
|
+ }
|
|
|
+ map.put("applyDate", applyDateStr);
|
|
|
+ map.put("reason", vehicleApplicationInfo.getReason());
|
|
|
+
|
|
|
+ String startTimeStr = "";
|
|
|
+ if (vehicleApplicationInfo.getStartTime() != null) {
|
|
|
+ startTimeStr = sdf1.format(vehicleApplicationInfo.getStartTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("startTime", startTimeStr);
|
|
|
+
|
|
|
+ String endTimeStr = "";
|
|
|
+ if (vehicleApplicationInfo.getEndTime() != null) {
|
|
|
+ endTimeStr = sdf1.format(vehicleApplicationInfo.getEndTime());
|
|
|
}
|
|
|
+ map.put("endTime", endTimeStr);
|
|
|
+ map.put("startAddress", vehicleApplicationInfo.getStartAddress());
|
|
|
+ map.put("endAddress", vehicleApplicationInfo.getEndAddress());
|
|
|
+ map.put("kilometers", vehicleApplicationInfo.getKilometers());
|
|
|
+ map.put("amount", vehicleApplicationInfo.getAmount());
|
|
|
+ map.put("bak", vehicleApplicationInfo.getBak());
|
|
|
+
|
|
|
+ String createTimeStr = "";
|
|
|
+ if (vehicleApplicationInfo.getCreateTime() != null) {
|
|
|
+ createTimeStr = sdf1.format(vehicleApplicationInfo.getCreateTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("createTime", createTimeStr);
|
|
|
+ map.put("status", vehicleApplicationInfo.getStatus());
|
|
|
+
|
|
|
+ map.put("statusN", vehicleApplicationInfo.getStatusN());
|
|
|
+
|
|
|
+ String applyPersonName = "";
|
|
|
+ String orgName = "";
|
|
|
+
|
|
|
+ RegUser regUser = regUserService.get(vehicleApplicationInfo.getApplyPersonId());
|
|
|
+ if (regUser != null) {
|
|
|
+ applyPersonName = regUser.getName();
|
|
|
+ vehicleApplicationInfo.setApplyPersonName(regUser.getName());
|
|
|
+
|
|
|
+ Organization organization = organizationService.get(regUser.getOrgId());
|
|
|
+ if (organization != null) {
|
|
|
+ orgName = organization.getName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("applyPersonName", applyPersonName);
|
|
|
+ map.put("orgName", orgName);
|
|
|
+
|
|
|
+ mapList.add(map);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ if (exportFlag) {
|
|
|
+ String filePath = exportXls(mapList);
|
|
|
+ msgResult.setData(filePath);
|
|
|
+ } else {
|
|
|
+ Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
|
|
|
+ dataMap.put("data", mapList);
|
|
|
+ msgResult.setData(dataMap);
|
|
|
+ }
|
|
|
|
|
|
- msgResult.setResult(true);
|
|
|
- msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+ msgResult.setResult(true);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
+ msgResult.setResult(false);
|
|
|
+ }
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private String exportXls(List<Map> mapList) {
|
|
|
+ String downloadUrl = "";
|
|
|
+
|
|
|
+ Workbook workbook = new HSSFWorkbook();
|
|
|
+ Sheet sheet = workbook.createSheet();
|
|
|
+
|
|
|
+ //表头
|
|
|
+ Row rowTitle = sheet.createRow(0);
|
|
|
+
|
|
|
+ String[] titles = new String[]{"序号", "日期", "姓名", "事由","用车开始时间","用车结束时间",
|
|
|
+ "起始地","目的地", "公里数", "金额", "备注","申请时间","状态"};
|
|
|
+
|
|
|
+ for (int i = 0; i < titles.length; i++) {
|
|
|
+ Cell cell = rowTitle.createCell(i);
|
|
|
+ cell.setCellValue(titles[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < mapList.size(); i++) {
|
|
|
+ Map<String, Object> map = mapList.get(i);
|
|
|
+
|
|
|
+ Row row = sheet.createRow(i + 1);
|
|
|
+
|
|
|
+ int colIndex = 0;
|
|
|
+ row.createCell(colIndex++).setCellValue(i + 1);
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("applyDate"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("applyPersonName"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("reason"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("startTime"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("endTime"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("startAddress"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("endAddress"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("kilometers"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("amount"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("bak"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("createTime"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.railroad.utils.StringUtils.strValue(map.get("statusN"), ""));
|
|
|
+ }
|
|
|
+
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+
|
|
|
+ try {
|
|
|
+ workbook.write(output);
|
|
|
+
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+
|
|
|
+ downloadUrl = OSSUtil.upload(ossConfig, "vehicleApplicationList", "用车申请记录.xls", input);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
+ }
|
|
|
+
|
|
|
+ return downloadUrl;
|
|
|
+ }
|
|
|
}
|