Browse Source

11-9

tiaosheng
wang0018 5 years ago
parent
commit
47bea2efd3
  1. 2
      mt/src/main/java/com/ccsens/mt/api/CompeteController.java
  2. 32
      mt/src/main/java/com/ccsens/mt/api/ExcelController.java
  3. 1
      mt/src/main/java/com/ccsens/mt/bean/vo/ProvinceCompeteVo.java
  4. 95
      mt/src/main/java/com/ccsens/mt/bean/vo/TableVo.java
  5. 8
      mt/src/main/java/com/ccsens/mt/persist/dao/CompeteEnrollDao.java
  6. 12
      mt/src/main/java/com/ccsens/mt/service/CompeteService.java
  7. 942
      mt/src/main/java/com/ccsens/mt/service/ExcelService.java
  8. 2
      mt/src/main/java/com/ccsens/mt/service/ICompeteService.java
  9. 69
      mt/src/main/java/com/ccsens/mt/service/IExcelService.java
  10. 7
      mt/src/main/resources/mapper_dao/CompeteEnrollDao.xml
  11. 3
      util/src/main/java/com/ccsens/util/PoiUtil.java

2
mt/src/main/java/com/ccsens/mt/api/CompeteController.java

@ -221,4 +221,6 @@ public class CompeteController {
// return JsonResponse.newInstance().ok(playerList); // return JsonResponse.newInstance().ok(playerList);
// } // }
} }

32
mt/src/main/java/com/ccsens/mt/api/ExcelController.java

@ -3,6 +3,7 @@ package com.ccsens.mt.api;
import com.ccsens.cloudutil.annotation.MustLogin; import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.mt.bean.dto.CompeteDto; import com.ccsens.mt.bean.dto.CompeteDto;
import com.ccsens.mt.service.ICompeteService;
import com.ccsens.mt.service.IExcelService; import com.ccsens.mt.service.IExcelService;
import com.ccsens.util.JsonResponse; import com.ccsens.util.JsonResponse;
import com.ccsens.util.bean.dto.QueryDto; import com.ccsens.util.bean.dto.QueryDto;
@ -31,12 +32,31 @@ public class ExcelController {
private IExcelService excelService; private IExcelService excelService;
@MustLogin @MustLogin
@ApiOperation(value = "报名表详情表(关联wps)", notes = "") @ApiOperation(value = "xxx大赛报名表", notes = "")
@RequestMapping(value = "/enrollWPS", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "/competeJoin", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse enrollPlayInfoWps(@ApiParam @Validated @RequestBody QueryDto<CompeteDto.CompeteType> params) throws IOException { public JsonResponse competeJoin(@ApiParam @Validated @RequestBody QueryDto<CompeteDto.CompeteTime> params) throws IOException {
log.info("查询各个项目报名人员信息:{}",params); log.info("xxx大赛报名表:{}",params);
// String enrollPlayInfoList= competeService.enrollPlayInfoWps(params); String path = excelService.competeJoin(params);
return JsonResponse.newInstance().ok(); return JsonResponse.newInstance().ok(path);
}
@MustLogin
@ApiOperation(value = "参赛人数统计表", notes = "")
@RequestMapping(value = "/competeJoinCount", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse competeJoinCount(@ApiParam @Validated @RequestBody QueryDto<CompeteDto.CompeteTime> params) throws IOException {
log.info("参赛人数统计表:{}",params);
String path = excelService.competeJoinCount(params.getParam());
return JsonResponse.newInstance().ok(path);
}
@MustLogin
@ApiOperation(value = "XXX比赛报名汇总表", notes = "")
@RequestMapping(value = "/competeAllCount", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse competeAllCount(@ApiParam @Validated @RequestBody QueryDto<CompeteDto.CompeteTime> params) throws IOException {
log.info("XXX比赛报名汇总表:{}",params);
String path = excelService.competeAllCount(params.getParam());
return JsonResponse.newInstance().ok(path);
} }

1
mt/src/main/java/com/ccsens/mt/bean/vo/ProvinceCompeteVo.java

@ -29,6 +29,7 @@ public class ProvinceCompeteVo {
private int projectNum; private int projectNum;
} }
@Data @Data
@ApiModel("查找单位内的参赛选手列表") @ApiModel("查找单位内的参赛选手列表")
public static class PlayerByCompanyId{ public static class PlayerByCompanyId{

95
mt/src/main/java/com/ccsens/mt/bean/vo/TableVo.java

@ -0,0 +1,95 @@
package com.ccsens.mt.bean.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author li
*/
@Data
public class TableVo {
@Data
@ApiModel("XXXX大赛报名表")
public static class CompeteJoin{
@ApiModelProperty("参赛项目")
private String competeProject;
@ApiModelProperty("组别")
private String competeGroup;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("性别")
private String gender;
@ApiModelProperty("年龄")
private int age;
@ApiModelProperty("身份证号")
private String idCard;
@ApiModelProperty("身份证明")
private String idCardPromise;
@ApiModelProperty("一寸证件照")
private String picture;
@ApiModelProperty("学籍证明/俱乐部证明")
private String StudentPromise;
@ApiModelProperty("体检证明")
private String bodyTest;
@ApiModelProperty("人身意外伤害保险证明")
private String bodyProtect;
@ApiModelProperty("参赛队伍")
private String joinTeam;
}
@Data
@ApiModel("参赛人数统计表")
public static class CompeteOverview{
@ApiModelProperty("参赛队伍名称")
private String companyName;
@ApiModelProperty("当前添加的教练的人数")
private int coachNum;
@ApiModelProperty("当前添加的领队的人数")
private int guideNum;
@ApiModelProperty("当前添加的参赛人员的人数")
private int playerNum;
@ApiModelProperty("队伍总人数")
private int sum;
}
@Data
@ApiModel("XXX比赛报名汇总表")
public static class CompeteAllCount{
@ApiModelProperty("参赛项目")
private String projectName;
@ApiModelProperty("小学男子组")
private int primaryMale;
@ApiModelProperty("小学女子组")
private int primaryFemale;
@ApiModelProperty("小学混合组")
private int primary;
@ApiModelProperty("中学男子组")
private int middleMale;
@ApiModelProperty("中学女子组")
private int middleFemale;
@ApiModelProperty("中学混合组")
private int middle;
@ApiModelProperty("高职院校男子组")
private int highMale;
@ApiModelProperty("高职院校女子组")
private int highFemale;
@ApiModelProperty("高职院校混合组")
private int high;
@ApiModelProperty("本科院校男子组")
private int collegeMale;
@ApiModelProperty("本科院校女子组")
private int collegeFemale;
@ApiModelProperty("本科院校混合组")
private int college;
@ApiModelProperty("俱乐部男子组(14岁及以下)")
private int clubMale;
@ApiModelProperty("俱乐部女子组(14岁及以下)")
private int clubFemale;
@ApiModelProperty("俱乐部混合组(14岁及以下)")
private int club;
}
}

8
mt/src/main/java/com/ccsens/mt/persist/dao/CompeteEnrollDao.java

@ -1,5 +1,6 @@
package com.ccsens.mt.persist.dao; package com.ccsens.mt.persist.dao;
import com.ccsens.mt.bean.po.CompeteProjectPlayer;
import com.ccsens.mt.bean.vo.CompeteVo; import com.ccsens.mt.bean.vo.CompeteVo;
import com.ccsens.mt.persist.mapper.CompetePlayerMapper; import com.ccsens.mt.persist.mapper.CompetePlayerMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -108,4 +109,11 @@ public interface CompeteEnrollDao extends CompetePlayerMapper {
*/ */
List<CompeteVo.Count> getGroupIdNameFromGroup(@Param("type")long type); List<CompeteVo.Count> getGroupIdNameFromGroup(@Param("type")long type);
/**
* 查询项目信息
* @param projectId 团队id
* @return 单人项目选手信息
*/
CompeteProjectPlayer getPlayerInfoSingle(@Param("project_id")long projectId);
} }

12
mt/src/main/java/com/ccsens/mt/service/CompeteService.java

@ -13,6 +13,7 @@ import com.ccsens.mt.bean.dto.CompeteDto;
import com.ccsens.mt.bean.dto.LevelDto; import com.ccsens.mt.bean.dto.LevelDto;
import com.ccsens.mt.bean.po.*; import com.ccsens.mt.bean.po.*;
import com.ccsens.mt.bean.vo.CompeteVo; import com.ccsens.mt.bean.vo.CompeteVo;
import com.ccsens.mt.bean.vo.TableVo;
import com.ccsens.mt.persist.dao.CompeteEnrollDao; import com.ccsens.mt.persist.dao.CompeteEnrollDao;
import com.ccsens.mt.persist.dao.CompetePlayerDao; import com.ccsens.mt.persist.dao.CompetePlayerDao;
import com.ccsens.mt.persist.dao.CompeteTeamDao; import com.ccsens.mt.persist.dao.CompeteTeamDao;
@ -79,6 +80,8 @@ public class CompeteService implements ICompeteService {
private CompeteEnrollDao competeEnrollDao; private CompeteEnrollDao competeEnrollDao;
@Resource @Resource
private TallFeignClient tallFeignClient; private TallFeignClient tallFeignClient;
@Resource
private CommonFileMapper commonFileMapper;
/** /**
* 查看第几届 * 查看第几届
@ -109,7 +112,7 @@ public class CompeteService implements ICompeteService {
// competeGroups.forEach(competeGroup -> { // competeGroups.forEach(competeGroup -> {
// CompeteProjectGroupExample competeProjectGroupExample = new CompeteProjectGroupExample(); // CompeteProjectGroupExample competeProjectGroupExample = new CompeteProjectGroupExample();
// competeProjectGroupExample.createCriteria().andGroupIdEqualTo(competeGroup.getGroupId()).andProjectIdEqualTo(competeType.getProjectId()); // competeProjectGroupExample.createCriteria().andGroupIdEqualTo(competeGroup.getGroupId()).andProjectIdEqualTo(competeType.getProjectId());
// if(competeProjectGroupMapper.countByExample(competeProjectGroupExample) == 0){ // if(competeProjectGroupMapper.1ByExample(competeProjectGroupExample) == 0){
// competeGroups.remove(competeGroup); // competeGroups.remove(competeGroup);
// } // }
// }); // });
@ -892,6 +895,7 @@ public class CompeteService implements ICompeteService {
return failPlayerInfoList; return failPlayerInfoList;
} }
/** /**
* 验证数据的正确性存入数据库 * 验证数据的正确性存入数据库
*/ */
@ -1002,4 +1006,10 @@ public class CompeteService implements ICompeteService {
} }
return true; return true;
} }
} }

942
mt/src/main/java/com/ccsens/mt/service/ExcelService.java

@ -1,276 +1,666 @@
package com.ccsens.mt.service; package com.ccsens.mt.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Snowflake;
import com.ccsens.mt.bean.dto.CompeteDto; import cn.hutool.core.util.IdcardUtil;
import com.ccsens.mt.bean.po.*; import cn.hutool.core.util.ObjectUtil;
import com.ccsens.mt.persist.dao.CompeteCompanyDao; import com.ccsens.cloudutil.feign.TallFeignClient;
import com.ccsens.mt.persist.dao.CompeteTimeDao; import com.ccsens.mt.bean.dto.CompeteDto;
import com.ccsens.mt.persist.mapper.CompeteCompanyMapper; import com.ccsens.mt.bean.po.*;
import com.ccsens.mt.persist.mapper.CompetePlayerMapper; import com.ccsens.mt.bean.vo.TableVo;
import com.ccsens.util.PoiUtil; import com.ccsens.mt.persist.dao.*;
import com.ccsens.util.PropUtil; import com.ccsens.mt.persist.mapper.*;
import com.ccsens.util.WebConstant; import com.ccsens.util.PoiUtil;
import com.ccsens.util.bean.dto.QueryDto; import com.ccsens.util.PropUtil;
import lombok.extern.slf4j.Slf4j; import com.ccsens.util.RedisUtil;
import org.apache.commons.collections.map.HashedMap; import com.ccsens.util.WebConstant;
import org.apache.poi.ss.usermodel.Workbook; import com.ccsens.util.bean.dto.QueryDto;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Pointcut; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Service; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.transaction.annotation.Propagation; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; @Slf4j
@Service
@Slf4j @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@Service public class ExcelService implements IExcelService {
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Resource
public class ExcelService implements IExcelService { private CompeteCompanyDao competeCompanyDao;
@Resource @Resource
private CompeteCompanyDao competeCompanyDao; private CompeteTimeDao competeTimeDao;
@Resource
private CompeteTimeDao competeTimeDao; @Resource
private CompeteCompanyMapper competeCompanyMapper;
@Resource @Resource
private CompetePlayerMapper competePlayerMapper; private Snowflake snowflake;
@Resource
@Override private CompeteTeamDao competeTeamDao;
public String dasaiduiwuxinxiWPS(QueryDto<CompeteDto.CompeteTime> params) { @Resource
//这个里面包含联系人得信息 private CompetePlayerDao competePlayerDao;
List<CompeteCompany> competeCompanyList= competeCompanyDao.selectByCompeteTimeId(params.getParam().getCompeteTimeId()); @Resource
List<CompeteCoach> competeCoachList =new ArrayList<CompeteCoach>(); private CompeteTeamMemberMapper competeTeamMemberMapper;
for (CompeteCompany com:competeCompanyList) { @Resource
//再根据单位id查询,领队和教练信息,返回list集合 private CompeteProjectMapper competeProjectMapper;
competeCoachList.addAll(competeCompanyDao.selectByCompanyId(com.getId())); @Resource
} private CompeteProjectPlayerMapper competeProjectPlayerMapper;
List<List<PoiUtil.PoiUtilCell>> biao = new ArrayList<>(); @Resource
//先把联系人的都添加进去 private CompeteGroupMapper competeGroupMapper;
List<PoiUtil.PoiUtilCell> biaotou=new ArrayList<>();
PoiUtil.PoiUtilCell biaotouName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 8, 1, null, null); @Resource
biaotouName.setValue(competeTimeDao.selectByPrimaryKey(params.getParam().getCompeteTimeId()).getName()); CompeteCoachMapper competeCoachMapper;
biaotou.add(biaotouName);
biao.add(biaotou); @Resource
List<PoiUtil.PoiUtilCell> hangTou=new ArrayList<>(); private CompetePlayerMapper competePlayerMapper;
PoiUtil.PoiUtilCell xuhaoTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
xuhaoTou.setValue("序号"); @Override
hangTou.add(xuhaoTou); public String dasaiduiwuxinxiWPS(QueryDto<CompeteDto.CompeteTime> params) {
PoiUtil.PoiUtilCell cansaiduiwuTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); //这个里面包含联系人得信息
cansaiduiwuTou.setValue("参赛队伍"); List<CompeteCompany> competeCompanyList= competeCompanyDao.selectByCompeteTimeId(params.getParam().getCompeteTimeId());
hangTou.add(cansaiduiwuTou); List<CompeteCoach> competeCoachList =new ArrayList<CompeteCoach>();
PoiUtil.PoiUtilCell lianxirenTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); for (CompeteCompany com:competeCompanyList) {
lianxirenTou.setValue("联系人/领队/教练"); //再根据单位id查询,领队和教练信息,返回list集合
hangTou.add(lianxirenTou); competeCoachList.addAll(competeCompanyDao.selectByCompanyId(com.getId()));
PoiUtil.PoiUtilCell nameTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); }
nameTou.setValue("姓名"); List<List<PoiUtil.PoiUtilCell>> biao = new ArrayList<>();
hangTou.add(nameTou); //先把联系人的都添加进去
PoiUtil.PoiUtilCell sexTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); List<PoiUtil.PoiUtilCell> biaotou=new ArrayList<>();
sexTou.setValue("性别"); PoiUtil.PoiUtilCell biaotouName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 8, 1, null, null);
hangTou.add(sexTou); biaotouName.setValue(competeTimeDao.selectByPrimaryKey(params.getParam().getCompeteTimeId()).getName());
PoiUtil.PoiUtilCell lianxifangshiTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); biaotou.add(biaotouName);
lianxifangshiTou.setValue("联系方式"); biao.add(biaotou);
hangTou.add(lianxifangshiTou); List<PoiUtil.PoiUtilCell> hangTou=new ArrayList<>();
PoiUtil.PoiUtilCell shenfenzhengTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); PoiUtil.PoiUtilCell xuhaoTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
shenfenzhengTou.setValue("身份证号"); xuhaoTou.setValue("序号");
hangTou.add(shenfenzhengTou); hangTou.add(xuhaoTou);
PoiUtil.PoiUtilCell beizhuTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); PoiUtil.PoiUtilCell cansaiduiwuTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
beizhuTou.setValue("备注"); cansaiduiwuTou.setValue("参赛队伍");
hangTou.add(beizhuTou); hangTou.add(cansaiduiwuTou);
biao.add(hangTou); PoiUtil.PoiUtilCell lianxirenTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
int i=1; lianxirenTou.setValue("联系人/领队/教练");
for(CompeteCompany competeCompany:competeCompanyList){ hangTou.add(lianxirenTou);
List<PoiUtil.PoiUtilCell> hang=new ArrayList<>(); PoiUtil.PoiUtilCell nameTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell xuhao=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); nameTou.setValue("姓名");
xuhao.setValue(String.valueOf(i++)); hangTou.add(nameTou);
hang.add(xuhao); PoiUtil.PoiUtilCell sexTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell cansaiduiwu=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); sexTou.setValue("性别");
cansaiduiwu.setValue(competeCompany.getName()); hangTou.add(sexTou);
hang.add(cansaiduiwu); PoiUtil.PoiUtilCell lianxifangshiTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell renyuanleibei=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); lianxifangshiTou.setValue("联系方式");
renyuanleibei.setValue("联系人"); hangTou.add(lianxifangshiTou);
hang.add(renyuanleibei); PoiUtil.PoiUtilCell shenfenzhengTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell name=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); shenfenzhengTou.setValue("身份证号");
name.setValue(competeCompany.getContactsName()); hangTou.add(shenfenzhengTou);
hang.add(name); PoiUtil.PoiUtilCell beizhuTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell sex=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); beizhuTou.setValue("备注");
sex.setValue("/"); hangTou.add(beizhuTou);
hang.add(sex); biao.add(hangTou);
PoiUtil.PoiUtilCell pho=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); int i=1;
pho.setValue(String.valueOf(competeCompany.getContactsPhone())); for(CompeteCompany competeCompany:competeCompanyList){
hang.add(pho); List<PoiUtil.PoiUtilCell> hang=new ArrayList<>();
PoiUtil.PoiUtilCell idCardNum=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); PoiUtil.PoiUtilCell xuhao=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
idCardNum.setValue("/"); xuhao.setValue(String.valueOf(i++));
hang.add(idCardNum); hang.add(xuhao);
PoiUtil.PoiUtilCell beizhu=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); PoiUtil.PoiUtilCell cansaiduiwu=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
beizhu.setValue("无"); cansaiduiwu.setValue(competeCompany.getName());
hang.add(beizhu); hang.add(cansaiduiwu);
biao.add(hang); PoiUtil.PoiUtilCell renyuanleibei=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
for (CompeteCoach competeCoach:competeCoachList){ renyuanleibei.setValue("联系人");
if(competeCoach.getCompanyId().equals(competeCompany.getId())){ hang.add(renyuanleibei);
List<PoiUtil.PoiUtilCell> hanghou=new ArrayList<>(); PoiUtil.PoiUtilCell name=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell xuhaoCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); name.setValue(competeCompany.getContactsName());
xuhaoCach.setValue(String.valueOf(i++)); hang.add(name);
hanghou.add(xuhaoCach); PoiUtil.PoiUtilCell sex=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell cansaiduiwuCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); sex.setValue("/");
cansaiduiwuCach.setValue(competeCompany.getName()); hang.add(sex);
hanghou.add(cansaiduiwuCach); PoiUtil.PoiUtilCell pho=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell renyuanleibeiCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); pho.setValue(String.valueOf(competeCompany.getContactsPhone()));
if (competeCoach.getIdentity().equals((byte) 0)){ hang.add(pho);
renyuanleibeiCach.setValue("领队"); PoiUtil.PoiUtilCell idCardNum=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
}else { idCardNum.setValue("/");
renyuanleibeiCach.setValue("教练"); hang.add(idCardNum);
} PoiUtil.PoiUtilCell beizhu=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
hanghou.add(renyuanleibeiCach); beizhu.setValue("无");
PoiUtil.PoiUtilCell nameCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); hang.add(beizhu);
nameCach.setValue(competeCoach.getName()); biao.add(hang);
hanghou.add(nameCach); for (CompeteCoach competeCoach:competeCoachList){
PoiUtil.PoiUtilCell sexCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); if(competeCoach.getCompanyId().equals(competeCompany.getId())){
sexCach.setValue(competeCoach.getGender().equals((byte) 0)?"女":"男"); List<PoiUtil.PoiUtilCell> hanghou=new ArrayList<>();
hanghou.add(sexCach); PoiUtil.PoiUtilCell xuhaoCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell phoCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); xuhaoCach.setValue(String.valueOf(i++));
phoCach.setValue(String.valueOf(competeCoach.getPhone())); hanghou.add(xuhaoCach);
hanghou.add(phoCach); PoiUtil.PoiUtilCell cansaiduiwuCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell idCardNumCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); cansaiduiwuCach.setValue(competeCompany.getName());
idCardNumCach.setValue(String.valueOf(competeCoach.getIdPhoto())); hanghou.add(cansaiduiwuCach);
hanghou.add(idCardNumCach); PoiUtil.PoiUtilCell renyuanleibeiCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
PoiUtil.PoiUtilCell beizhuCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); if (competeCoach.getIdentity().equals((byte) 0)){
beizhuCach.setValue("无"); renyuanleibeiCach.setValue("领队");
hanghou.add(beizhuCach); }else {
biao.add(hanghou); renyuanleibeiCach.setValue("教练");
} }
} hanghou.add(renyuanleibeiCach);
} PoiUtil.PoiUtilCell nameCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
Workbook workbook = new XSSFWorkbook(); nameCach.setValue(competeCoach.getName());
PoiUtil.exportWB("参赛队伍信息表",biao,workbook); hanghou.add(nameCach);
//String name = "跳绳比赛报名人数统计表" + ".xlsx"; PoiUtil.PoiUtilCell sexCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; sexCach.setValue(competeCoach.getGender().equals((byte) 0)?"女":"男");
String path = PropUtil.path + filepath; hanghou.add(sexCach);
PoiUtil.PoiUtilCell phoCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
String path1="C:/d/"+filepath;//本地的路径 phoCach.setValue(String.valueOf(competeCoach.getPhone()));
File tmpFile = new File(path); hanghou.add(phoCach);
if (!tmpFile.getParentFile().exists()) { PoiUtil.PoiUtilCell idCardNumCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
tmpFile.getParentFile().mkdirs(); idCardNumCach.setValue(String.valueOf(competeCoach.getIdPhoto()));
} hanghou.add(idCardNumCach);
File file = new File(path); PoiUtil.PoiUtilCell beizhuCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null);
try { beizhuCach.setValue("无");
OutputStream outputStream = new FileOutputStream(file); hanghou.add(beizhuCach);
workbook.write(outputStream); biao.add(hanghou);
outputStream.close(); }
} catch (IOException e) { }
e.printStackTrace(); }
} Workbook workbook = new XSSFWorkbook();
return PropUtil.domain + "file/download/know?path="+path; PoiUtil.exportWB("参赛队伍信息表",biao,workbook);
} //String name = "跳绳比赛报名人数统计表" + ".xlsx";
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx";
String path = PropUtil.path + filepath;
@Override
public String iTeamListService(QueryDto<CompeteDto.CompeteTime> params) { String path1="C:/d/"+filepath;//本地的路径
//查出所有的单位的id File tmpFile = new File(path);
List<CompeteCompany> competeCompanyList= competeCompanyDao.selectByCompeteTimeId(params.getParam().getCompeteTimeId()); if (!tmpFile.getParentFile().exists()) {
List<List<PoiUtil.PoiUtilCell>> biao = new ArrayList<>(); tmpFile.getParentFile().mkdirs();
List<PoiUtil.PoiUtilCell> biaoti=new ArrayList<>(); }
PoiUtil.PoiUtilCell biaotouName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1, null, null); File file = new File(path);
biaotouName.setValue("代表队名单"); try {
biaoti.add(biaotouName); OutputStream outputStream = new FileOutputStream(file);
biao.add(biaoti); workbook.write(outputStream);
for (CompeteCompany com:competeCompanyList) { outputStream.close();
//查出教练和领队的list } catch (IOException e) {
List<CompeteCoach> jLandLD=competeCompanyDao.selectByCompanyId(com.getId()); e.printStackTrace();
CompetePlayerExample competePlayerExample=new CompetePlayerExample(); }
competePlayerExample.createCriteria().andCompanyIdEqualTo(com.getId()); return PropUtil.domain + "file/download/know?path="+path;
//运动员list }
List<CompetePlayer> competePlayerList = competePlayerMapper.selectByExample(competePlayerExample);
List<PoiUtil.PoiUtilCell> daibiaodui=new ArrayList<>(); @Override
PoiUtil.PoiUtilCell daibiaoduiName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1, null, null); public String iTeamListService(QueryDto<CompeteDto.CompeteTime> params) {
daibiaoduiName.setValue(com.getName()); //查出所有的单位的id
daibiaodui.add(daibiaoduiName); List<CompeteCompany> competeCompanyList= competeCompanyDao.selectByCompeteTimeId(params.getParam().getCompeteTimeId());
biao.add(daibiaodui); List<List<PoiUtil.PoiUtilCell>> biao = new ArrayList<>();
//领队和教练 List<PoiUtil.PoiUtilCell> biaoti=new ArrayList<>();
List<PoiUtil.PoiUtilCell> lingduiList=new ArrayList<>(); PoiUtil.PoiUtilCell biaotouName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1, null, null);
PoiUtil.PoiUtilCell lingdui=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); biaotouName.setValue("代表队名单");
lingdui.setValue("领 队:"); biaoti.add(biaotouName);
lingduiList.add(lingdui); biao.add(biaoti);
biao.add(lingduiList); for (CompeteCompany com:competeCompanyList) {
StringBuffer lingduiName=new StringBuffer(""); //查出教练和领队的list
StringBuffer jiaolianName=new StringBuffer(""); List<CompeteCoach> jLandLD=competeCompanyDao.selectByCompanyId(com.getId());
jLandLD.forEach(jLD->{ CompetePlayerExample competePlayerExample=new CompetePlayerExample();
if (jLD.getIdentity().equals((byte) 0)) { competePlayerExample.createCriteria().andCompanyIdEqualTo(com.getId());
lingduiName.append(jLD.getName()+'、'); //运动员list
} else { List<CompetePlayer> competePlayerList = competePlayerMapper.selectByExample(competePlayerExample);
jiaolianName.append(jLD.getName()+'、');
} List<PoiUtil.PoiUtilCell> daibiaodui=new ArrayList<>();
}); PoiUtil.PoiUtilCell daibiaoduiName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1, null, null);
if(lingduiName.length()>0){ daibiaoduiName.setValue(com.getName());
lingduiName.deleteCharAt(lingduiName.length() - 1) ; daibiaodui.add(daibiaoduiName);
} biao.add(daibiaodui);
if(jiaolianName.length()>0){ //领队和教练
jiaolianName.deleteCharAt(jiaolianName.length() - 1) ; List<PoiUtil.PoiUtilCell> lingduiList=new ArrayList<>();
} PoiUtil.PoiUtilCell lingdui=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1);
PoiUtil.PoiUtilCell lingduiNameHang=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); lingdui.setValue("领 队:");
lingduiNameHang.setValue(String.valueOf(lingduiName)); lingduiList.add(lingdui);
lingduiList.add(lingduiNameHang); biao.add(lingduiList);
StringBuffer lingduiName=new StringBuffer("");
biao.add(lingduiList); StringBuffer jiaolianName=new StringBuffer("");
List<PoiUtil.PoiUtilCell> jiaolianList=new ArrayList<>(); jLandLD.forEach(jLD->{
PoiUtil.PoiUtilCell jiaoling=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); if (jLD.getIdentity().equals((byte) 0)) {
jiaoling.setValue("教 练:"); lingduiName.append(jLD.getName()+'、');
jiaolianList.add(jiaoling); } else {
PoiUtil.PoiUtilCell jiaolianHang= new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); jiaolianName.append(jLD.getName()+'、');
jiaolianHang.setValue(String.valueOf(jiaolianName)); }
jiaolianList.add(jiaolianHang); });
biao.add(jiaolianList); if(lingduiName.length()>0){
lingduiName.deleteCharAt(lingduiName.length() - 1) ;
//再放运动员 }
StringBuffer yDYLN=new StringBuffer(""); if(jiaolianName.length()>0){
competePlayerList.forEach(cpL->{ jiaolianName.deleteCharAt(jiaolianName.length() - 1) ;
yDYLN.append(cpL.getName()); }
yDYLN.append("("); PoiUtil.PoiUtilCell lingduiNameHang=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1);
yDYLN.append(cpL.getGender().equals((byte) 0)?"女":"男"); lingduiNameHang.setValue(String.valueOf(lingduiName));
yDYLN.append(")、"); lingduiList.add(lingduiNameHang);
});
if (yDYLN.length()>0){ biao.add(lingduiList);
yDYLN.deleteCharAt(yDYLN.length()-1); List<PoiUtil.PoiUtilCell> jiaolianList=new ArrayList<>();
} PoiUtil.PoiUtilCell jiaoling=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1);
jiaoling.setValue("教 练:");
List<PoiUtil.PoiUtilCell> yundongyuanList=new ArrayList<>(); jiaolianList.add(jiaoling);
PoiUtil.PoiUtilCell yuandongyuan=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); PoiUtil.PoiUtilCell jiaolianHang= new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1);
yuandongyuan.setValue("运动员"); jiaolianHang.setValue(String.valueOf(jiaolianName));
yundongyuanList.add(yuandongyuan); jiaolianList.add(jiaolianHang);
PoiUtil.PoiUtilCell yuandongyuanName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); biao.add(jiaolianList);
yuandongyuanName.setValue(String.valueOf(yDYLN));
yundongyuanList.add(yuandongyuanName); //再放运动员
biao.add(yundongyuanList); StringBuffer yDYLN=new StringBuffer("");
biao.add(yundongyuanList); competePlayerList.forEach(cpL->{
List<PoiUtil.PoiUtilCell> entryList=new ArrayList<>(); yDYLN.append(cpL.getName());
PoiUtil.PoiUtilCell enter= new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1); yDYLN.append("(");
entryList.add(enter); yDYLN.append(cpL.getGender().equals((byte) 0)?"女":"男");
biao.add(entryList); yDYLN.append(")、");
} });
biao.remove(biaoti.size()-1); if (yDYLN.length()>0){
Workbook workbook = new XSSFWorkbook(); yDYLN.deleteCharAt(yDYLN.length()-1);
PoiUtil.exportWB("代表队名单",biao,workbook); }
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx";
String path = PropUtil.path + filepath; List<PoiUtil.PoiUtilCell> yundongyuanList=new ArrayList<>();
String path1="C:/d/"+filepath;//本地的路径 PoiUtil.PoiUtilCell yuandongyuan=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1);
File tmpFile = new File(path); yuandongyuan.setValue("运动员");
if (!tmpFile.getParentFile().exists()) { yundongyuanList.add(yuandongyuan);
tmpFile.getParentFile().mkdirs(); PoiUtil.PoiUtilCell yuandongyuanName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1);
} yuandongyuanName.setValue(String.valueOf(yDYLN));
File file = new File(path); yundongyuanList.add(yuandongyuanName);
try { biao.add(yundongyuanList);
OutputStream outputStream = new FileOutputStream(file); biao.add(yundongyuanList);
workbook.write(outputStream); List<PoiUtil.PoiUtilCell> entryList=new ArrayList<>();
outputStream.close(); PoiUtil.PoiUtilCell enter= new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1);
} catch (IOException e) { entryList.add(enter);
e.printStackTrace(); biao.add(entryList);
} }
return PropUtil.domain + "file/download/know?path="+path; biao.remove(biaoti.size()-1);
} Workbook workbook = new XSSFWorkbook();
} PoiUtil.exportWB("代表队名单",biao,workbook);
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx";
String path = PropUtil.path + filepath;
String path1="C:/d/"+filepath;//本地的路径
File tmpFile = new File(path);
if (!tmpFile.getParentFile().exists()) {
tmpFile.getParentFile().mkdirs();
}
File file = new File(path);
try {
OutputStream outputStream = new FileOutputStream(file);
workbook.write(outputStream);
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
return PropUtil.domain + "file/download/know?path="+path;
}
@Override
public String competeJoin(QueryDto<CompeteDto.CompeteTime> params) throws IOException {
CompeteDto.CompeteTime competeTime = params.getParam();
List<TableVo.CompeteJoin> competeJoinList = getCompeteJoin(competeTime);
String path = getExcelFilePathForCompeteJoin(competeJoinList);
return path;
}
private List<TableVo.CompeteJoin> getCompeteJoin(CompeteDto.CompeteTime params) {
List<TableVo.CompeteJoin> competeJoinList = new ArrayList<>();
Long competeTimeId = params.getCompeteTimeId();
CompeteTime competeTime = competeTimeDao.selectByPrimaryKey(competeTimeId);
int type = competeTime.getType();
Byte level = 2;
CompeteProjectExample competeProjectExample = new CompeteProjectExample();
competeProjectExample.createCriteria().andTypeEqualTo((byte) type).andLevelEqualTo(level);
//获取参赛项目集合
List<CompeteProject> competeProjectList = competeProjectMapper.selectByExample(competeProjectExample);
for (CompeteProject competeProject : competeProjectList) {
String projectName = competeProject.getName();
if (competeProject.getTeam() == 0) {
//如果不是团队项目,查询该项目下报名人数集合
CompeteProjectPlayerExample competeProjectPlayerExample = new CompeteProjectPlayerExample();
competeProjectPlayerExample.createCriteria().andProjectIdEqualTo(competeProject.getId());
List<CompeteProjectPlayer> competeProjectPlayerList = competeProjectPlayerMapper.selectByExample(competeProjectPlayerExample);
for (CompeteProjectPlayer competeProjectPlayer : competeProjectPlayerList) {
//查询每个报名人的详细信息下
CompetePlayer competePlayer = competePlayerDao.selectByPrimaryKey(competeProjectPlayer.getPlayerId());
TableVo.CompeteJoin competeJoin = new TableVo.CompeteJoin();
//姓名
competeJoin.setName(competePlayer.getName());
//身份证号
competeJoin.setIdCard(competePlayer.getIdCard());
//根据身份证获取选手年龄并赋值
String idCard = competeJoin.getIdCard();
int ageByIdCard = IdcardUtil.getAgeByIdCard(idCard);
competeJoin.setAge(ageByIdCard);
Byte gender = competePlayer.getGender();
if (gender == 0) {
competeJoin.setGender("女");
} else {
competeJoin.setGender("男");
}
//查询单位,并赋值
CompeteCompany competeCompany = competeCompanyMapper.selectByPrimaryKey(competePlayer.getCompanyId());
if (ObjectUtil.isNotNull(competeCompany)) {
competeJoin.setJoinTeam(competeCompany.getName());
}
//查询组别,并赋值
CompeteGroup competeGroup = competeGroupMapper.selectByPrimaryKey(competePlayer.getCompeteGroupId());
if (ObjectUtil.isNotNull(competeGroup)) {
competeJoin.setCompeteGroup(competePlayer.getName());
}
// //身份证明查询,并赋值
// CommonFile commonFile = commonFileMapper.selectByPrimaryKey(competePlayer.getIdCardFrontFile());
// if (ObjectUtil.isNotNull(commonFile)) {
// competeJoin.setIdCardPromise(commonFile.getVisitLocation());
// }
// //一寸证件照查询赋值
// CommonFile commonFile1 = commonFileMapper.selectByPrimaryKey(competePlayer.getIdPhotoFile());
// if (ObjectUtil.isNotNull(commonFile1)) {
// competeJoin.setPicture(commonFile1.getVisitLocation());
// }
// //学籍证明/俱乐部证明
// CommonFile commonFile2 = commonFileMapper.selectByPrimaryKey(competePlayer.getStudentRecordFile());
// if (ObjectUtil.isNotNull(commonFile2)) {
// competeJoin.setStudentPromise(commonFile2.getVisitLocation());
// }
// //体检证明
// CommonFile commonFile3 = commonFileMapper.selectByPrimaryKey(competePlayer.getHealthRecordFile());
// if (ObjectUtil.isNotNull(commonFile3)) {
// competeJoin.setBodyTest(commonFile3.getVisitLocation());
// }
// //人身意外伤害保险证明
// CommonFile commonFile4 = commonFileMapper.selectByPrimaryKey(competePlayer.getInsuranceRecordFile());
// if (ObjectUtil.isNotNull(commonFile4)) {
// competeJoin.setBodyProtect(commonFile4.getVisitLocation());
// }
//参赛项目名赋值
competeJoin.setCompeteProject(projectName);
competeJoinList.add(competeJoin);
}
} else { //团队项目
//获取参赛队伍集合
CompeteTeamExample competeTeamExample = new CompeteTeamExample();
competeTeamExample.createCriteria().andProjectIdEqualTo(competeProject.getId());
List<CompeteTeam> competeTeamList = competeTeamDao.selectByExample(competeTeamExample);
for (CompeteTeam competeTeam : competeTeamList) {
//获取队伍下的成员集合
CompeteTeamMemberExample competeTeamMemberExample = new CompeteTeamMemberExample();
competeTeamMemberExample.createCriteria().andCompeteTeamIdEqualTo(competeTeam.getId());
List<CompeteTeamMember> competeTeamMemberList = competeTeamMemberMapper.selectByExample(competeTeamMemberExample);
for (CompeteTeamMember competeTeamMember : competeTeamMemberList) {
//查询成员详细信息
CompetePlayer competePlayer = competePlayerDao.selectByPrimaryKey(competeTeamMember.getPlayerId());
TableVo.CompeteJoin competeJoin = new TableVo.CompeteJoin();
//姓名
competeJoin.setName(competePlayer.getName());
//身份证号
competeJoin.setIdCard(competePlayer.getIdCard());
//根据身份证获取选手年龄并赋值
String idCard = competeJoin.getIdCard();
int ageByIdCard = IdcardUtil.getAgeByIdCard(idCard);
competeJoin.setAge(ageByIdCard);
//性别
Byte gender = competePlayer.getGender();
if (gender == 0) {
competeJoin.setGender("女");
} else {
competeJoin.setGender("男");
}
//查询单位,并赋值
CompeteCompany competeCompany = competeCompanyMapper.selectByPrimaryKey(competePlayer.getCompanyId());
if (ObjectUtil.isNotNull(competeCompany)) {
competeJoin.setJoinTeam(competeCompany.getName());
}
//查询组别,并赋值
CompeteGroup competeGroup = competeGroupMapper.selectByPrimaryKey(competePlayer.getCompeteGroupId());
if (ObjectUtil.isNotNull(competeGroup)) {
competeJoin.setCompeteGroup(competePlayer.getName());
}
// //身份证明查询,并赋值
// CommonFile commonFile = commonFileMapper.selectByPrimaryKey(competePlayer.getIdCardFrontFile());
// if (ObjectUtil.isNotNull(commonFile)){
// competeJoin.setIdCardPromise(commonFile.getVisitLocation());
// }
// //一寸证件照查询赋值
// CommonFile commonFile1 = commonFileMapper.selectByPrimaryKey(competePlayer.getIdPhotoFile());
// if (ObjectUtil.isNotNull(commonFile1)){
// competeJoin.setPicture(commonFile1.getVisitLocation());
// }
// //学籍证明/俱乐部证明
// CommonFile commonFile2 = commonFileMapper.selectByPrimaryKey(competePlayer.getStudentRecordFile());
// if (ObjectUtil.isNotNull(commonFile2)){
// competeJoin.setStudentPromise(commonFile2.getVisitLocation());
// }
// //体检证明
// CommonFile commonFile3 = commonFileMapper.selectByPrimaryKey(competePlayer.getHealthRecordFile());
// if (ObjectUtil.isNotNull(commonFile3)){
// competeJoin.setBodyTest(commonFile3.getVisitLocation());
// }
// //人身意外伤害保险证明
// CommonFile commonFile4 = commonFileMapper.selectByPrimaryKey(competePlayer.getInsuranceRecordFile());
// if (ObjectUtil.isNotNull(commonFile4)){
// competeJoin.setBodyProtect(commonFile4.getVisitLocation());
// }
//参赛项目名赋值
competeJoin.setCompeteProject(projectName);
competeJoinList.add(competeJoin);
}
}
}
}
return competeJoinList;
}
private String getExcelFilePathForCompeteJoin(List<TableVo.CompeteJoin> arrayList) throws IOException {
//创建excle表格对象
List<List<PoiUtil.PoiUtilCell>> list = new ArrayList<>();
//创建行对象
List<PoiUtil.PoiUtilCell> title = new ArrayList<>();
//给首行单元格赋值
title.add(new PoiUtil.PoiUtilCell("序号"));
title.add(new PoiUtil.PoiUtilCell("参赛项目"));
title.add(new PoiUtil.PoiUtilCell("组别"));
title.add(new PoiUtil.PoiUtilCell("参赛队伍"));
title.add(new PoiUtil.PoiUtilCell("姓名"));
title.add(new PoiUtil.PoiUtilCell("性别"));
title.add(new PoiUtil.PoiUtilCell("年龄"));
title.add(new PoiUtil.PoiUtilCell("身份证号"));
// title.add(new PoiUtil.PoiUtilCell("身份证明"));
// title.add(new PoiUtil.PoiUtilCell("一寸证件照"));
// title.add(new PoiUtil.PoiUtilCell("学籍证明/俱乐部证明"));
// title.add(new PoiUtil.PoiUtilCell("体检证明"));
// title.add(new PoiUtil.PoiUtilCell("人身意外伤害保险证明"));
title.add(new PoiUtil.PoiUtilCell("备注"));
list.add(title);
//创建整个excel表格对象
Workbook workbook = new XSSFWorkbook();
int i = 1;
for (TableVo.CompeteJoin competeJoin : arrayList) {
//行对象
List<PoiUtil.PoiUtilCell> cells = new ArrayList<>();
cells.add(new PoiUtil.PoiUtilCell(i + "", 1, 1, 300, 18));
//单元格对象
PoiUtil.PoiUtilCell poiUtilCel = new PoiUtil.PoiUtilCell(competeJoin.getCompeteProject());
cells.add(poiUtilCel);
PoiUtil.PoiUtilCell poiUtilCell = new PoiUtil.PoiUtilCell(competeJoin.getCompeteGroup());
cells.add(poiUtilCell);
PoiUtil.PoiUtilCell poiUtilCel2 = new PoiUtil.PoiUtilCell(competeJoin.getJoinTeam());
cells.add(poiUtilCel2);
PoiUtil.PoiUtilCell poiUtilCel3 = new PoiUtil.PoiUtilCell(competeJoin.getName());
cells.add(poiUtilCel3);
PoiUtil.PoiUtilCell poiUtilCel4 = new PoiUtil.PoiUtilCell(String.valueOf(competeJoin.getGender()));
cells.add(poiUtilCel4);
PoiUtil.PoiUtilCell poiUtilCel5 = new PoiUtil.PoiUtilCell(String.valueOf(competeJoin.getAge()));
cells.add(poiUtilCel5);
PoiUtil.PoiUtilCell poiUtilCel6 = new PoiUtil.PoiUtilCell(competeJoin.getIdCard());
cells.add(poiUtilCel6);
// PoiUtil.PoiUtilCell poiUtilCel7 = new PoiUtil.PoiUtilCell(competeJoin.getIdCardPromise());
// cells.add(poiUtilCel7);
// PoiUtil.PoiUtilCell poiUtilCel8 = new PoiUtil.PoiUtilCell(competeJoin.getPicture());
// cells.add(poiUtilCel8);
// PoiUtil.PoiUtilCell poiUtilCel9 = new PoiUtil.PoiUtilCell(competeJoin.getStudentPromise());
// cells.add(poiUtilCel9);
// PoiUtil.PoiUtilCell poiUtilCel10 = new PoiUtil.PoiUtilCell(competeJoin.getBodyTest());
// cells.add(poiUtilCel10);
// PoiUtil.PoiUtilCell poiUtilCel11 = new PoiUtil.PoiUtilCell(competeJoin.getBodyProtect());
// cells.add(poiUtilCel11);
list.add(cells);
i++;
}
//生成excel表格对象,并将数据放入
Workbook wbs = PoiUtil.exportWB("报名表", list, workbook);
//8:关联金山在线文档
String name = "XXXX大赛报名表" + ".xlsx";
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx";
String path = PropUtil.path + filepath;
// String path = filepath;
File tmpFile = new File(path);
if (!tmpFile.getParentFile().exists()) {
tmpFile.getParentFile().mkdirs();
}
//PropUtil.path获取配置文件中的path属性,拼接生成写入信息的文件名,
File file = new File(path);
OutputStream stream = new FileOutputStream(file);
wbs.write(stream);
stream.close();
return path;
}
@Override
public String competeJoinCount(CompeteDto.CompeteTime params) throws IOException {
List<TableVo.CompeteOverview> competeOverviewList = competeJoinCountList(params);
String path = getExcelFilePathForCompeteJoinCount(competeOverviewList);
return path;
}
private List<TableVo.CompeteOverview> competeJoinCountList(CompeteDto.CompeteTime params) {
CompeteCompanyExample competeCompanyExample = new CompeteCompanyExample();
competeCompanyExample.createCriteria().andCompeteTimeIdEqualTo(params.getCompeteTimeId());
//根据大赛id查公司集合
List<CompeteCompany> competeCompanyList = competeCompanyMapper.selectByExample(competeCompanyExample);
List<TableVo.CompeteOverview> competeOverview2List = new ArrayList<>();
for (CompeteCompany competeCompany : competeCompanyList) {
//每个公司的教练数量
int leader = 1;
int coach = 0;
CompeteCoachExample competeCoachExample = new CompeteCoachExample();
competeCoachExample.createCriteria().andCompanyIdEqualTo(competeCompany.getId()).andIdentityEqualTo((byte) coach);
long count = competeCoachMapper.countByExample(competeCoachExample);
//每个公司的领队数量
CompeteCoachExample competeCoachExample1 = new CompeteCoachExample();
competeCoachExample1.createCriteria().andCompanyIdEqualTo(competeCompany.getId()).andIdentityEqualTo((byte) leader);
long count1 = competeCoachMapper.countByExample(competeCoachExample1);
//每个公司运动员人数
CompetePlayerExample competePlayerExample2 = new CompetePlayerExample();
competePlayerExample2.createCriteria().andCompanyIdEqualTo(competeCompany.getId());
long count2 = competePlayerDao.countByExample(competePlayerExample2);
//总人数
long sum = count + count1 + count2;
TableVo.CompeteOverview CompeteOverview2 = new TableVo.CompeteOverview();
CompeteOverview2.setCompanyName(competeCompany.getName());
CompeteOverview2.setCoachNum((int) count);
CompeteOverview2.setGuideNum((int) count1);
CompeteOverview2.setPlayerNum((int) count2);
CompeteOverview2.setSum((int) sum);
competeOverview2List.add(CompeteOverview2);
}
return competeOverview2List;
}
private String getExcelFilePathForCompeteJoinCount(List<TableVo.CompeteOverview> arrayList) throws IOException {
//创建excle表格对象
List<List<PoiUtil.PoiUtilCell>> list = new ArrayList<>();
//创建行对象
List<PoiUtil.PoiUtilCell> title = new ArrayList<>();
//给首行单元格赋值
title.add(new PoiUtil.PoiUtilCell("序号"));
title.add(new PoiUtil.PoiUtilCell("单位"));
title.add(new PoiUtil.PoiUtilCell("领队"));
title.add(new PoiUtil.PoiUtilCell("教练"));
title.add(new PoiUtil.PoiUtilCell("运动员"));
title.add(new PoiUtil.PoiUtilCell("总人数"));
list.add(title);
//创建整个excel表格对象
Workbook workbook = new XSSFWorkbook();
int i = 1;
for (TableVo.CompeteOverview competeOverview : arrayList) {
//行对象
List<PoiUtil.PoiUtilCell> cells = new ArrayList<>();
cells.add(new PoiUtil.PoiUtilCell(i + "", 1, 1, 300, 18));
//单元格对象
PoiUtil.PoiUtilCell poiUtilCel = new PoiUtil.PoiUtilCell(competeOverview.getCompanyName());
cells.add(poiUtilCel);
PoiUtil.PoiUtilCell poiUtilCell = new PoiUtil.PoiUtilCell(String.valueOf(competeOverview.getGuideNum()));
cells.add(poiUtilCell);
PoiUtil.PoiUtilCell poiUtilCel2 = new PoiUtil.PoiUtilCell(String.valueOf(competeOverview.getCoachNum()));
cells.add(poiUtilCel2);
PoiUtil.PoiUtilCell poiUtilCel3 = new PoiUtil.PoiUtilCell(String.valueOf(competeOverview.getPlayerNum()));
cells.add(poiUtilCel3);
PoiUtil.PoiUtilCell poiUtilCel4 = new PoiUtil.PoiUtilCell(String.valueOf(competeOverview.getSum()));
cells.add(poiUtilCel4);
list.add(cells);
i++;
}
//生成excel表格对象,并将数据放入
Workbook wbs = PoiUtil.exportWB("参赛人数统计表", list, workbook);
//8:关联金山在线文档
String name = "参赛人数统计表" + ".xlsx";
String filepath = "mt/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx";
String path = PropUtil.path + filepath;
// String path = filepath;
File tmpFile = new File(path);
if (!tmpFile.getParentFile().exists()) {
tmpFile.getParentFile().mkdirs();
}
//PropUtil.path获取配置文件中的path属性,拼接生成写入信息的文件名,
File file = new File(path);
OutputStream stream = new FileOutputStream(file);
wbs.write(stream);
stream.close();
return path;
}
@Override
public String competeAllCount(CompeteDto.CompeteTime params) throws IOException {
return null;
}
private List<TableVo.CompeteAllCount> competeAllCountList(CompeteDto.CompeteTime params){
//根据大赛查类型
Long competeTimeId = params.getCompeteTimeId();
CompeteTime competeTime = competeTimeDao.selectByPrimaryKey(competeTimeId);
int type = competeTime.getType();
Byte level = 2;
CompeteProjectExample competeProjectExample = new CompeteProjectExample();
competeProjectExample.createCriteria().andTypeEqualTo((byte) type).andLevelEqualTo(level);
//获取参赛项目集合
List<CompeteProject> competeProjectList = competeProjectMapper.selectByExample(competeProjectExample);
CompeteGroupExample competeGroupExample = new CompeteGroupExample();
competeGroupExample.createCriteria().andTypeEqualTo((byte) type);
//获取组别集合
List<CompeteGroup> competeGroupList = competeGroupMapper.selectByExample(competeGroupExample);
for (CompeteProject competeProject : competeProjectList){
//若不是团队项目
if (competeProject.getTeam() == 0){
TableVo.CompeteAllCount competeAllCount = new TableVo.CompeteAllCount();
//项目名赋值
competeAllCount.setProjectName(competeProject.getName());
//遍历组别集合
int i = 0;
for(CompeteGroup competeGroup : competeGroupList){
CompetePlayerExample competePlayerExample = new CompetePlayerExample();
competePlayerExample.createCriteria().andCompeteGroupIdEqualTo(competeGroup.getId());
//计算每个组别人数
long count = competePlayerDao.countByExample(competePlayerExample);
}
}
}
return null;
}
}

2
mt/src/main/java/com/ccsens/mt/service/ICompeteService.java

@ -147,6 +147,8 @@ public interface ICompeteService {
* @return 返回失败的信息 * @return 返回失败的信息
*/ */
List<CompeteVo.FailPlayerInfo> signupImport(String path) throws FileNotFoundException, Exception; List<CompeteVo.FailPlayerInfo> signupImport(String path) throws FileNotFoundException, Exception;
} }

69
mt/src/main/java/com/ccsens/mt/service/IExcelService.java

@ -1,20 +1,49 @@
package com.ccsens.mt.service; package com.ccsens.mt.service;
import com.ccsens.mt.bean.dto.CompeteDto; import com.ccsens.mt.bean.dto.CompeteDto;
import com.ccsens.util.bean.dto.QueryDto; import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.mt.bean.dto.CompeteDto;
public interface IExcelService { import com.ccsens.util.bean.dto.QueryDto;
/**
* 导出大赛队伍信息表 import java.io.IOException;
* @param params
* @return public interface IExcelService {
*/ /**
String dasaiduiwuxinxiWPS(QueryDto<CompeteDto.CompeteTime> params); * 导出大赛队伍信息表
* @param params
/** * @return
*导出代表队名单 */
* @param params String dasaiduiwuxinxiWPS(QueryDto<CompeteDto.CompeteTime> params);
* @return
*/ /**
String iTeamListService(QueryDto<CompeteDto.CompeteTime> params); *导出代表队名单
} * @param params
* @return
*/
String iTeamListService(QueryDto<CompeteDto.CompeteTime> params);
/**
* XXXX大赛报名表
* @param params 大赛id
* @return 返回失败的信息
*/
String competeJoin(QueryDto<CompeteDto.CompeteTime> params) throws IOException;
/**
* XXXX大赛报名表
* @param params 大赛id
* @return 返回失败的信息
*/
String competeJoinCount(CompeteDto.CompeteTime params) throws IOException;
/**
* XXX比赛报名汇总表
* @param params 大赛id
* @return 返回失败的信息
*/
String competeAllCount(CompeteDto.CompeteTime params) throws IOException;
}

7
mt/src/main/resources/mapper_dao/CompeteEnrollDao.xml

@ -170,4 +170,11 @@
WHERE type = #{type} WHERE type = #{type}
ORDER BY id ORDER BY id
</select> </select>
<select id="getPlayerInfoSingle" parameterType="java.util.Map" resultType="com.ccsens.mt.bean.po.CompeteProjectPlayer">
SELECT
*
FROM
t_compete_project_player
WHERE project_id = #{projectId}
</select>
</mapper> </mapper>

3
util/src/main/java/com/ccsens/util/PoiUtil.java

@ -162,6 +162,9 @@ public class PoiUtil {
List<PoiUtilCell> cells = rows.get(i); List<PoiUtilCell> cells = rows.get(i);
for (int j = 0; j < cells.size(); j++) { for (int j = 0; j < cells.size(); j++) {
PoiUtilCell cell = cells.get(j); PoiUtilCell cell = cells.get(j);
if(ObjectUtil.isNull(cell)){
continue;
}
//查找当前单元格 //查找当前单元格
Cell newCell = row.getCell(j); Cell newCell = row.getCell(j);
if(ObjectUtil.isNull(newCell)){ if(ObjectUtil.isNull(newCell)){

Loading…
Cancel
Save