|
@@ -1,23 +1,35 @@
|
|
package com.jpsoft.campus.modules.base.controller;
|
|
package com.jpsoft.campus.modules.base.controller;
|
|
|
|
|
|
|
|
+import com.alipay.api.domain.Person;
|
|
import com.github.pagehelper.Page;
|
|
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.ApportionDetailDTO;
|
|
import com.jpsoft.campus.modules.base.dto.ApportionDetailDTO;
|
|
-import com.jpsoft.campus.modules.base.entity.ApplicationPrimary;
|
|
|
|
-import com.jpsoft.campus.modules.base.entity.ApportionDetail;
|
|
|
|
-import com.jpsoft.campus.modules.base.service.ApplicationPrimaryService;
|
|
|
|
-import com.jpsoft.campus.modules.base.service.ApportionDetailService;
|
|
|
|
|
|
+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.Sort;
|
|
import com.jpsoft.campus.modules.common.dto.MessageResult;
|
|
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.common.utils.PojoUtils;
|
|
|
|
+import com.jpsoft.campus.modules.sys.entity.DataDictionary;
|
|
|
|
+import com.jpsoft.campus.modules.sys.entity.User;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
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.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@@ -31,6 +43,14 @@ public class ApportionDetailController {
|
|
private ApportionDetailService apportionDetailService;
|
|
private ApportionDetailService apportionDetailService;
|
|
@Autowired
|
|
@Autowired
|
|
private ApplicationPrimaryService applicationPrimaryService;
|
|
private ApplicationPrimaryService applicationPrimaryService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SchoolInfoService schoolInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private StudentInfoService studentInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private PersonInfoService personInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private OSSConfig ossConfig;
|
|
|
|
|
|
@ApiOperation(value="创建空记录")
|
|
@ApiOperation(value="创建空记录")
|
|
@GetMapping("create")
|
|
@GetMapping("create")
|
|
@@ -231,6 +251,42 @@ public class ApportionDetailController {
|
|
return msgResult;
|
|
return msgResult;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ApiOperation(value="列表")
|
|
|
|
+ @RequestMapping(value = "pageListTest",method = RequestMethod.POST)
|
|
|
|
+ public MessageResult<Map> pageListTest(
|
|
|
|
+ String id,
|
|
|
|
+ @RequestParam(value="apportionId",defaultValue="") String apportionId,
|
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
|
+ @RequestParam(value="winner",defaultValue="true") boolean winner,
|
|
|
|
+ @RequestAttribute String subject){
|
|
|
|
+
|
|
|
|
+ //当前用户ID
|
|
|
|
+ System.out.println(subject);
|
|
|
|
+
|
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
|
+ sortList.add(new Sort("t1.create_time","asc"));
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(apportionId)) {
|
|
|
|
+ searchParams.put("apportionId",apportionId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ searchParams.put("winner",winner);
|
|
|
|
+ searchParams.put("delFlag",true);
|
|
|
|
+ searchParams.put("createBy","测试派位系统");
|
|
|
|
+
|
|
|
|
+ Page<ApportionDetail> page = apportionDetailService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation(value="派位详情列表")
|
|
@ApiOperation(value="派位详情列表")
|
|
@RequestMapping(value = "pageListDTO",method = RequestMethod.POST)
|
|
@RequestMapping(value = "pageListDTO",method = RequestMethod.POST)
|
|
public MessageResult<Map> pageListDTO(
|
|
public MessageResult<Map> pageListDTO(
|
|
@@ -301,4 +357,123 @@ public class ApportionDetailController {
|
|
|
|
|
|
return msgResult;
|
|
return msgResult;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "导出派位结果")
|
|
|
|
+ @PostMapping("exportXlsPwjg")
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
+ @ApiImplicitParam(name = "apportionId", value = "派位ID", required = false, paramType = "form", dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "winner", value = "派位结果", required = false, paramType = "form", dataType = "boolean"),
|
|
|
|
+ })
|
|
|
|
+ public MessageResult<String> exportXlsPwjg(
|
|
|
|
+ @RequestParam(value="apportionId",defaultValue="") String apportionId,
|
|
|
|
+ @RequestParam(value="winner",defaultValue="true") boolean winner,
|
|
|
|
+ @RequestAttribute String subject) {
|
|
|
|
+ MessageResult<String> msgResult = new MessageResult<>();
|
|
|
|
+ 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("结果");
|
|
|
|
+
|
|
|
|
+ //预录取学校
|
|
|
|
+ sheet.setColumnWidth(1, 20 * 256);
|
|
|
|
+ //姓名
|
|
|
|
+ sheet.setColumnWidth(2, 20 * 256);
|
|
|
|
+ //证件号
|
|
|
|
+ sheet.setColumnWidth(3, 24 * 256);
|
|
|
|
+ //姓名
|
|
|
|
+ sheet.setColumnWidth(4, 20 * 256);
|
|
|
|
+ //手机号
|
|
|
|
+ sheet.setColumnWidth(5, 24 * 256);
|
|
|
|
+ //结果
|
|
|
|
+ sheet.setColumnWidth(6, 10 * 256);
|
|
|
|
+
|
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
|
+ sortList.add(new Sort("t1.create_time","asc"));
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(apportionId)) {
|
|
|
|
+ searchParams.put("apportionId",apportionId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ searchParams.put("winner",winner);
|
|
|
|
+ Page<ApportionDetail> page = apportionDetailService.pageSearch(searchParams,0,1000000,false,sortList);
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < page.size(); i++) {
|
|
|
|
+ ApportionDetail ad = page.get(i);
|
|
|
|
+ StudentInfo studentInfo = studentInfoService.get(ad.getStudentId());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ HSSFRow rowContent = sheet.createRow(i + 1);
|
|
|
|
+ //"序号"
|
|
|
|
+ HSSFCell cellContent1 = rowContent.createCell(0);
|
|
|
|
+ cellContent1.setCellValue(i + 1);
|
|
|
|
+// "预录取学校"
|
|
|
|
+ HSSFCell cellContent2 = rowContent.createCell(1);
|
|
|
|
+ cellContent2.setCellValue(ad.getSchoolName());
|
|
|
|
+// "学生姓名"
|
|
|
|
+ HSSFCell cellContent3 = rowContent.createCell(2);
|
|
|
|
+ cellContent3.setCellValue(ad.getStudentName());
|
|
|
|
+// "证件号码"
|
|
|
|
+ HSSFCell cellContent4 = rowContent.createCell(3);
|
|
|
|
+ cellContent4.setCellValue(studentInfo.getIdCard());
|
|
|
|
+ if(StringUtils.isNotEmpty(ad.getPersonId())){
|
|
|
|
+ //"登记人姓名"
|
|
|
|
+ HSSFCell cellContent5 = rowContent.createCell(4);
|
|
|
|
+ PersonInfo personInfo = personInfoService.get(ad.getPersonId());
|
|
|
|
+ cellContent5.setCellValue(personInfo.getName());
|
|
|
|
+
|
|
|
|
+ //"登记人手机号码"
|
|
|
|
+ HSSFCell cellContent6 = rowContent.createCell(5);
|
|
|
|
+ cellContent6.setCellValue(personInfo.getPhone());
|
|
|
|
+ }
|
|
|
|
+ //"结果"
|
|
|
|
+ HSSFCell cellContent7 = rowContent.createCell(6);
|
|
|
|
+ String winnerStr = "成功";
|
|
|
|
+ if(ad.getWinner()){
|
|
|
|
+ winnerStr = "成功";
|
|
|
|
+ }else{
|
|
|
|
+ winnerStr = "失败";
|
|
|
|
+ }
|
|
|
|
+ cellContent7.setCellValue(winnerStr);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //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;
|
|
|
|
+ }
|
|
}
|
|
}
|