|
@@ -1,12 +1,15 @@
|
|
|
package com.jpsoft.campus.modules.base.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.campus.config.OSSConfig;
|
|
|
import com.jpsoft.campus.modules.base.dto.ApplicationMiddleDTO;
|
|
|
+import com.jpsoft.campus.modules.base.dto.ApplicationPrimaryDTO;
|
|
|
import com.jpsoft.campus.modules.base.dto.AttachmentDTO;
|
|
|
import com.jpsoft.campus.modules.base.entity.*;
|
|
|
import com.jpsoft.campus.modules.base.service.*;
|
|
|
import com.jpsoft.campus.modules.common.dto.Sort;
|
|
|
import com.jpsoft.campus.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.campus.modules.common.utils.OSSUtil;
|
|
|
import com.jpsoft.campus.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.campus.modules.sys.entity.DataDictionary;
|
|
|
import com.jpsoft.campus.modules.sys.entity.User;
|
|
@@ -14,14 +17,22 @@ import com.jpsoft.campus.modules.sys.service.DataDictionaryService;
|
|
|
import com.jpsoft.campus.modules.sys.service.UserRoleService;
|
|
|
import com.jpsoft.campus.modules.sys.service.UserService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
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.*;
|
|
|
|
|
@@ -51,6 +62,8 @@ public class ApplicationMiddleController {
|
|
|
private UserService userService;
|
|
|
@Autowired
|
|
|
private UserRoleService userRoleService;
|
|
|
+ @Autowired
|
|
|
+ private OSSConfig ossConfig;
|
|
|
|
|
|
@ApiOperation(value="创建空记录")
|
|
|
@GetMapping("create")
|
|
@@ -332,6 +345,8 @@ public class ApplicationMiddleController {
|
|
|
String type,
|
|
|
String nameOrIdCard,
|
|
|
String schoolId,
|
|
|
+ @RequestParam(value="startStatus",defaultValue="") String startStatus,
|
|
|
+ @RequestParam(value="endStatus",defaultValue="") String endStatus,
|
|
|
@RequestParam(value="delFlag",defaultValue="false") Boolean delFlag,
|
|
|
@RequestAttribute String subject){
|
|
|
//当前用户ID
|
|
@@ -363,6 +378,15 @@ public class ApplicationMiddleController {
|
|
|
searchParams.put("cardType",cardType);
|
|
|
}
|
|
|
|
|
|
+ //开始
|
|
|
+ if (StringUtils.isNotEmpty(startStatus)) {
|
|
|
+ searchParams.put("startStatus",startStatus);
|
|
|
+ }
|
|
|
+ //结束
|
|
|
+ if (StringUtils.isNotEmpty(endStatus)) {
|
|
|
+ searchParams.put("endStatus",endStatus);
|
|
|
+ }
|
|
|
+
|
|
|
searchParams.put("delFlag",delFlag);
|
|
|
|
|
|
if(StringUtils.isNotEmpty(schoolId)){
|
|
@@ -412,6 +436,8 @@ public class ApplicationMiddleController {
|
|
|
String type,
|
|
|
String nameOrIdCard,
|
|
|
String schoolId,
|
|
|
+ @RequestParam(value="startStatus",defaultValue="") String startStatus,
|
|
|
+ @RequestParam(value="endStatus",defaultValue="") String endStatus,
|
|
|
@RequestParam(value="delFlag",defaultValue="false") Boolean delFlag,
|
|
|
@RequestAttribute String subject){
|
|
|
//当前用户ID
|
|
@@ -455,6 +481,15 @@ public class ApplicationMiddleController {
|
|
|
searchParams.put("cardType",cardType);
|
|
|
}
|
|
|
|
|
|
+ //开始
|
|
|
+ if (StringUtils.isNotEmpty(startStatus)) {
|
|
|
+ searchParams.put("startStatus",startStatus);
|
|
|
+ }
|
|
|
+ //结束
|
|
|
+ if (StringUtils.isNotEmpty(endStatus)) {
|
|
|
+ searchParams.put("endStatus",endStatus);
|
|
|
+ }
|
|
|
+
|
|
|
searchParams.put("delFlag",delFlag);
|
|
|
|
|
|
if(StringUtils.isNotEmpty(schoolId)){
|
|
@@ -784,4 +819,235 @@ public class ApplicationMiddleController {
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "导出")
|
|
|
+ @PostMapping("exportXls")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "name", value = "姓名", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "idCard", value = "身份证", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "phone", value = "手机号", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "parentId", value = "企业编号", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "subordinate", value = "是否查询下级单位", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "position1", value = "一级位置", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "position2", value = "二级位置", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "position3", value = "三级位置", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "position4", value = "四级位置", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "position5", value = "五级位置", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "faceBound", value = "是否同步", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "isUploadPhoto", value = "是否上传照片", required = false, paramType = "form", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "popedom", value = "用户角色", required = false, paramType = "form", dataType = "String")
|
|
|
+ })
|
|
|
+ public MessageResult<String> exportXls(
|
|
|
+ String tabStatus,
|
|
|
+ String type,
|
|
|
+ String nameOrIdCard,
|
|
|
+ String status,
|
|
|
+ String cardType,
|
|
|
+ String schoolId,
|
|
|
+ @RequestParam(value="categoryId",defaultValue="") String categoryId,
|
|
|
+ @RequestParam(value="startStatus",defaultValue="") String startStatus,
|
|
|
+ @RequestParam(value="endStatus",defaultValue="") String endStatus,
|
|
|
+ @RequestParam(value="delFlag",defaultValue="false") Boolean delFlag,
|
|
|
+ @RequestAttribute String subject) {
|
|
|
+ MessageResult<String> msgResult = new MessageResult<>();
|
|
|
+ User user = userService.get(subject);
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
+ HSSFSheet sheet = workbook.createSheet();
|
|
|
+ //表头
|
|
|
+ HSSFRow rowTitle = sheet.createRow(0);
|
|
|
+ HSSFCell cellTitle1 = rowTitle.createCell(0);
|
|
|
+ cellTitle1.setCellValue("序号");
|
|
|
+ HSSFCell cellTitle2 = rowTitle.createCell(1);
|
|
|
+ cellTitle2.setCellValue("报名类型");
|
|
|
+ HSSFCell cellTitle3 = rowTitle.createCell(2);
|
|
|
+ cellTitle3.setCellValue("报名学校");
|
|
|
+ HSSFCell cellTitle4 = rowTitle.createCell(3);
|
|
|
+ cellTitle4.setCellValue("学生姓名");
|
|
|
+ HSSFCell cellTitle5 = rowTitle.createCell(4);
|
|
|
+ cellTitle5.setCellValue("证件类型");
|
|
|
+ HSSFCell cellTitle6 = rowTitle.createCell(5);
|
|
|
+ cellTitle6.setCellValue("证件号码");
|
|
|
+ HSSFCell cellTitle7 = rowTitle.createCell(6);
|
|
|
+ cellTitle7.setCellValue("审核状态");
|
|
|
+ HSSFCell cellTitle8 = rowTitle.createCell(7);
|
|
|
+ cellTitle8.setCellValue("申请时间");
|
|
|
+ HSSFCell cellTitle9 = rowTitle.createCell(8);
|
|
|
+ cellTitle9.setCellValue("登记人关系");
|
|
|
+ HSSFCell cellTitle10 = rowTitle.createCell(9);
|
|
|
+ cellTitle10.setCellValue("登记人姓名");
|
|
|
+ HSSFCell cellTitle11 = rowTitle.createCell(10);
|
|
|
+ cellTitle11.setCellValue("登记人手机号码");
|
|
|
+ HSSFCell cellTitle12 = rowTitle.createCell(11);
|
|
|
+ cellTitle12.setCellValue("学生地址");
|
|
|
+
|
|
|
+// int maxColumn = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
|
+// for(int i = 1; i < maxColumn; i++) {
|
|
|
+// //int columnWidth = sheet.getColumnWidth(i) / 256;
|
|
|
+// sheet.setColumnWidth(i, 12 * 256);
|
|
|
+// }
|
|
|
+ //学校
|
|
|
+ sheet.setColumnWidth(2, 20 * 256);
|
|
|
+ //身份证
|
|
|
+ sheet.setColumnWidth(5, 24 * 256);
|
|
|
+ //报名时间
|
|
|
+ sheet.setColumnWidth(7, 24 * 256);
|
|
|
+ //登记人手机号
|
|
|
+ sheet.setColumnWidth(10, 15 * 256);
|
|
|
+ //地址
|
|
|
+ sheet.setColumnWidth(11, 30 * 256);
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.create_time","desc"));
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(tabStatus)) {
|
|
|
+ searchParams.put("tabStatus",tabStatus);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(type)) {
|
|
|
+ searchParams.put("type",type);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(status)) {
|
|
|
+ searchParams.put("status",status);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(nameOrIdCard)) {
|
|
|
+ searchParams.put("nameOrIdCard","%" + nameOrIdCard + "%");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(cardType)) {
|
|
|
+ searchParams.put("cardType",cardType);
|
|
|
+ }
|
|
|
+
|
|
|
+ searchParams.put("delFlag",delFlag);
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(schoolId)){
|
|
|
+ searchParams.put("code", "%" + schoolId + "%");
|
|
|
+ }else{
|
|
|
+ if (!userService.hasRole(subject,"SYSADMIN")) {
|
|
|
+ searchParams.put("code", "%" + user.getSchoolId() + "%");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询范围
|
|
|
+ //开始
|
|
|
+ if (StringUtils.isNotEmpty(startStatus)) {
|
|
|
+ searchParams.put("startStatus",startStatus);
|
|
|
+ }
|
|
|
+ //结束
|
|
|
+ if (StringUtils.isNotEmpty(endStatus)) {
|
|
|
+ searchParams.put("endStatus",endStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(categoryId)) {
|
|
|
+ searchParams.put("categoryId",categoryId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据用户和角色查询
|
|
|
+ int count1 = userRoleService.findCountByAIdAndRName(subject,"SYSADMIN");
|
|
|
+ int count2 = userRoleService.findCountByAIdAndRName(subject,"XFLD");
|
|
|
+ int count3 = userRoleService.findCountByAIdAndRName(subject,"XFGZRY");
|
|
|
+
|
|
|
+ if(count1 > 0){
|
|
|
+ //管理员查全部
|
|
|
+ }else if(count2 > 0){
|
|
|
+ //领导查全部
|
|
|
+ }else if(count3 > 0){
|
|
|
+ //工作人员只能查网上初审10和现场初审20
|
|
|
+ List statusList = new ArrayList();
|
|
|
+ statusList.add("10");
|
|
|
+ statusList.add("20");
|
|
|
+ searchParams.put("orStatus",statusList);
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<ApplicationMiddleDTO> page = applicationMiddleService.pageSearchDTO(searchParams,0,100000,true,sortList);
|
|
|
+ List<DataDictionary> relationshipList = dataDictionaryService.findByCatalogName("学生关系");
|
|
|
+ List<DataDictionary> typeNameList = dataDictionaryService.findByCatalogName("报名类型");
|
|
|
+ List<DataDictionary> statusNameList = dataDictionaryService.findByCatalogName("小学招生审核流程");
|
|
|
+ List<DataDictionary> cardTypeList = dataDictionaryService.findByCatalogName("证件类型");
|
|
|
+ for (int i = 0; i < page.size(); i++) {
|
|
|
+ ApplicationMiddleDTO amDTO = page.get(i);
|
|
|
+ String relationship = relationshipList.stream()
|
|
|
+ .filter(e -> e.getId().equals(amDTO.getRelationship()))
|
|
|
+ .findFirst().get().getName();
|
|
|
+ String typeName = typeNameList.stream()
|
|
|
+ .filter(e -> e.getValue().equals(amDTO.getType()))
|
|
|
+ .findFirst().get().getName();
|
|
|
+ String statusName = statusNameList.stream()
|
|
|
+ .filter(e -> e.getValue().equals(amDTO.getStatus()))
|
|
|
+ .findFirst().get().getName();
|
|
|
+ String cardTypeName = cardTypeList.stream()
|
|
|
+ .filter(e -> e.getValue().equals(amDTO.getCardType()))
|
|
|
+ .findFirst().get().getName();
|
|
|
+
|
|
|
+ HSSFRow rowContent = sheet.createRow(i + 1);
|
|
|
+ //"序号"
|
|
|
+ HSSFCell cellContent1 = rowContent.createCell(0);
|
|
|
+ cellContent1.setCellValue(i + 1);
|
|
|
+// "报名类型"
|
|
|
+ HSSFCell cellContent2 = rowContent.createCell(1);
|
|
|
+ cellContent2.setCellValue(typeName);
|
|
|
+// "报名学校"
|
|
|
+ HSSFCell cellContent3 = rowContent.createCell(2);
|
|
|
+ cellContent3.setCellValue(amDTO.getSchoolName());
|
|
|
+// "学生姓名"
|
|
|
+ HSSFCell cellContent4 = rowContent.createCell(3);
|
|
|
+ cellContent4.setCellValue(amDTO.getName());
|
|
|
+// "证件类型"
|
|
|
+ HSSFCell cellContent5 = rowContent.createCell(4);
|
|
|
+ cellContent5.setCellValue(cardTypeName);
|
|
|
+// "证件号码"
|
|
|
+ HSSFCell cellContent6 = rowContent.createCell(5);
|
|
|
+ cellContent6.setCellValue(amDTO.getIdCard());
|
|
|
+// "审核状态"
|
|
|
+ HSSFCell cellContent7 = rowContent.createCell(6);
|
|
|
+ cellContent7.setCellValue(statusName);
|
|
|
+// "申请时间"
|
|
|
+ HSSFCell cellContent8 = rowContent.createCell(7);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+ cellContent8.setCellValue(sdf.format(amDTO.getCreateTime()));
|
|
|
+ //"登记人关系"
|
|
|
+ HSSFCell cellContent9 = rowContent.createCell(8);
|
|
|
+ cellContent9.setCellValue(relationship);
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(amDTO.getPersonId())){
|
|
|
+ //"登记人姓名"
|
|
|
+ HSSFCell cellContent10 = rowContent.createCell(9);
|
|
|
+ PersonInfo pi =personInfoService.get(amDTO.getPersonId());
|
|
|
+ cellContent10.setCellValue(pi.getName());
|
|
|
+
|
|
|
+ //"登记人手机号码"
|
|
|
+ HSSFCell cellContent11 = rowContent.createCell(10);
|
|
|
+ cellContent11.setCellValue(pi.getPhone());
|
|
|
+ }
|
|
|
+
|
|
|
+ //"学生地址"
|
|
|
+ HSSFCell cellContent12 = rowContent.createCell(11);
|
|
|
+ cellContent12.setCellValue(amDTO.getAddress());
|
|
|
+ }
|
|
|
+
|
|
|
+ //todo 将wb保存到oss
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+ workbook.write(output);
|
|
|
+
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+
|
|
|
+ String downloadUrl = OSSUtil.upload(ossConfig, "import", "error.xls", input);
|
|
|
+
|
|
|
+ //todo 返回导入失败报表下载链接
|
|
|
+
|
|
|
+ msgResult.setData(downloadUrl);
|
|
|
+ msgResult.setResult(true);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
}
|