|
@ -10,10 +10,21 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import jxl.Workbook;
|
|
|
import jxl.write.Label;
|
|
|
import jxl.write.WritableSheet;
|
|
|
import jxl.write.WritableWorkbook;
|
|
|
import jxl.write.WriteException;
|
|
|
import org.apache.http.client.utils.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.OutputStream;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created with IntelliJ IDEA.
|
|
@ -42,7 +53,7 @@ public class VoluntaryRecruitmentCompanyEndpoint extends EnvelopRestEndpoint {
|
|
|
|
|
|
@PostMapping(value = "update")
|
|
|
@ApiOperation(value = "更新")
|
|
|
public ObjEnvelop<VoluntaryRecruitmentCompanyDO> update (
|
|
|
public ObjEnvelop<VoluntaryRecruitmentCompanyDO> update(
|
|
|
@ApiParam(name = "jsonData", value = "Json数据", required = true)
|
|
|
@RequestParam String jsonData) throws Exception {
|
|
|
VoluntaryRecruitmentCompanyDO appVersion = toEntity(jsonData, VoluntaryRecruitmentCompanyDO.class);
|
|
@ -55,7 +66,7 @@ public class VoluntaryRecruitmentCompanyEndpoint extends EnvelopRestEndpoint {
|
|
|
|
|
|
@GetMapping(value = "page")
|
|
|
@ApiOperation(value = "获取分页")
|
|
|
public PageEnvelop<VoluntaryRecruitmentCompanyDO> page (
|
|
|
public PageEnvelop<VoluntaryRecruitmentCompanyDO> page(
|
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|
|
@ -67,13 +78,13 @@ public class VoluntaryRecruitmentCompanyEndpoint extends EnvelopRestEndpoint {
|
|
|
@ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
|
|
|
@RequestParam(value = "size") int size) throws Exception {
|
|
|
List<VoluntaryRecruitmentCompanyDO> appVersions = companyService.search(fields, filters, sorts, page, size);
|
|
|
int count = (int)companyService.getCount(filters);
|
|
|
int count = (int) companyService.getCount(filters);
|
|
|
return success(appVersions, count, page, size, VoluntaryRecruitmentCompanyDO.class);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "list")
|
|
|
@ApiOperation(value = "获取列表")
|
|
|
public ListEnvelop<VoluntaryRecruitmentCompanyDO> list (
|
|
|
public ListEnvelop<VoluntaryRecruitmentCompanyDO> list(
|
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|
|
@ -85,4 +96,62 @@ public class VoluntaryRecruitmentCompanyEndpoint extends EnvelopRestEndpoint {
|
|
|
}
|
|
|
|
|
|
|
|
|
@GetMapping(value = "exportExcel")
|
|
|
@ApiOperation("导出列表")
|
|
|
@ResponseBody
|
|
|
public void searchList(
|
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|
|
|
@RequestParam(value = "filters", required = false) String filters,
|
|
|
@ApiParam(name = "sorts", value = "排序,规则参见说明文档")
|
|
|
@RequestParam(value = "sorts", required = false) String sorts,
|
|
|
HttpServletResponse response) {
|
|
|
try {
|
|
|
List<VoluntaryRecruitmentCompanyDO> appVersions = companyService.search(fields, filters, sorts);
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + new String("volunteerInfo.xls"));
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
this.write(os, appVersions);
|
|
|
} catch (Exception ex) {
|
|
|
Envelop.getError("导出失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void write(OutputStream os, List<VoluntaryRecruitmentCompanyDO> list) throws Exception {
|
|
|
WritableWorkbook wwb = Workbook.createWorkbook(os);
|
|
|
try {
|
|
|
WritableSheet sheet = wwb.createSheet("sheet", 1);
|
|
|
String header[] = {"序号", "所在单位", "单位联系人", " 联系人手机号", "报名志愿者人数", "意向服务时间段", "意向服务的核酸采集点"};
|
|
|
int i = 0;
|
|
|
for (String h : header) {
|
|
|
addCell(sheet, 0, i, h);
|
|
|
i++;
|
|
|
}
|
|
|
int j = 1;
|
|
|
for (VoluntaryRecruitmentCompanyDO tmp : list) {
|
|
|
int ii=1;
|
|
|
addCell(sheet, j, 0, ii + "");
|
|
|
addCell(sheet, j, 1, tmp.getName());
|
|
|
addCell(sheet, j, 2, tmp.getContacts());
|
|
|
addCell(sheet, j, 3, tmp.getPhone() + "");
|
|
|
addCell(sheet, j, 4, tmp.getNum()+"");
|
|
|
addCell(sheet, j, 5, tmp.getTimes() + "");
|
|
|
addCell(sheet, j, 6, tmp.getServiceStation() + "");
|
|
|
j++;
|
|
|
ii++;
|
|
|
}
|
|
|
wwb.write();
|
|
|
wwb.close();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
if (wwb != null) wwb.close();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
|
|
|
Label label = new Label(column, row, data);
|
|
|
ws.addCell(label);
|
|
|
}
|
|
|
|
|
|
}
|