|
@@ -5,22 +5,31 @@ import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.EmployeeDao;
|
|
|
import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
|
|
|
import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentInstrumentExportDto;
|
|
|
import com.ym.mec.biz.dal.entity.Employee;
|
|
|
import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentRegistration;
|
|
|
import com.ym.mec.biz.dal.page.ReplacementInstrumentActivityQueryInfo;
|
|
|
import com.ym.mec.biz.service.ReplacementInstrumentActivityService;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
+import com.ym.mec.util.excel.POIUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -42,7 +51,7 @@ public class ReplacementInstrumentActivityController extends BaseController {
|
|
|
@ApiOperation(value = "分页查询列表")
|
|
|
@GetMapping("/queryPage")
|
|
|
@PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/queryPage')")
|
|
|
- public Object queryPage(ReplacementInstrumentActivityQueryInfo queryInfo) {
|
|
|
+ public HttpResponseResult<PageInfo<ReplacementInstrumentActivityStatDto>> queryPage(ReplacementInstrumentActivityQueryInfo queryInfo) {
|
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
if (sysUser == null) {
|
|
|
return failed("用户信息获取失败");
|
|
@@ -58,7 +67,8 @@ public class ReplacementInstrumentActivityController extends BaseController {
|
|
|
return failed("非法请求");
|
|
|
}
|
|
|
}
|
|
|
- return succeed(replacementInstrumentActivityService.queryPage(queryInfo));
|
|
|
+ queryInfo.setHasInstruments(true);
|
|
|
+ return succeed(replacementInstrumentActivityService.getPageList(queryInfo));
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "统计信息查询")
|
|
@@ -80,4 +90,58 @@ public class ReplacementInstrumentActivityController extends BaseController {
|
|
|
replacementInstrumentActivityService.update(replacementInstrumentActivity);
|
|
|
return succeed(replacementInstrumentActivity);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "导出")
|
|
|
+ @GetMapping("/export")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/export')")
|
|
|
+ public void export(ReplacementInstrumentActivityQueryInfo queryInfo, HttpServletResponse response) throws Exception {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ throw new BizException("用户信息获取失败");
|
|
|
+ }
|
|
|
+ Employee employee = employeeDao.get(sysUser.getId());
|
|
|
+ if (StringUtils.isEmpty(queryInfo.getOrganId())) {
|
|
|
+ queryInfo.setOrganId(employee.getOrganIdList());
|
|
|
+ } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
|
|
|
+ throw new BizException("用户所在分部异常");
|
|
|
+ } else {
|
|
|
+ List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
|
|
|
+ if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
|
|
|
+ throw new BizException("非法请求");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ queryInfo.setHasInstruments(true);
|
|
|
+ queryInfo.setRows(99999);
|
|
|
+ PageInfo<ReplacementInstrumentActivityStatDto> pageList = replacementInstrumentActivityService.getPageList(queryInfo);
|
|
|
+
|
|
|
+ if (pageList.getTotal() <=0) {
|
|
|
+ throw new BizException("没有可导出的记录");
|
|
|
+ }
|
|
|
+
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
+ HSSFWorkbook workbook = null;
|
|
|
+ try {
|
|
|
+ String[] header = {"合作单位编号", "合作单位", "学员编号", "学员姓名", "联系电话", "声部", "品牌", "型号"};
|
|
|
+ String[] body = {"cooperationOrganId", "cooperationOrganName","userId", "userName", "mobileNo", "subjectName", "brand", "specification"};
|
|
|
+ workbook = POIUtil.exportExcel(header, body, pageList.getRows());
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=replacement-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
+ response.flushBuffer();
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
+ workbook.write(outputStream);
|
|
|
+ outputStream.flush();
|
|
|
+ workbook.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (outputStream != null) {
|
|
|
+ try {
|
|
|
+ workbook.close();
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|