11 changed files with 870 additions and 303 deletions
@ -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; |
|||
} |
|||
} |
@ -1,276 +1,666 @@ |
|||
package com.ccsens.mt.service; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import com.ccsens.mt.bean.dto.CompeteDto; |
|||
import com.ccsens.mt.bean.po.*; |
|||
import com.ccsens.mt.persist.dao.CompeteCompanyDao; |
|||
import com.ccsens.mt.persist.dao.CompeteTimeDao; |
|||
import com.ccsens.mt.persist.mapper.CompeteCompanyMapper; |
|||
import com.ccsens.mt.persist.mapper.CompetePlayerMapper; |
|||
import com.ccsens.util.PoiUtil; |
|||
import com.ccsens.util.PropUtil; |
|||
import com.ccsens.util.WebConstant; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.collections.map.HashedMap; |
|||
import org.apache.poi.ss.usermodel.Workbook; |
|||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|||
import org.aspectj.lang.annotation.Pointcut; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Propagation; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.io.File; |
|||
import java.io.FileOutputStream; |
|||
import java.io.IOException; |
|||
import java.io.OutputStream; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|||
public class ExcelService implements IExcelService { |
|||
@Resource |
|||
private CompeteCompanyDao competeCompanyDao; |
|||
@Resource |
|||
private CompeteTimeDao competeTimeDao; |
|||
|
|||
@Resource |
|||
private CompetePlayerMapper competePlayerMapper; |
|||
|
|||
@Override |
|||
public String dasaiduiwuxinxiWPS(QueryDto<CompeteDto.CompeteTime> params) { |
|||
//这个里面包含联系人得信息
|
|||
List<CompeteCompany> competeCompanyList= competeCompanyDao.selectByCompeteTimeId(params.getParam().getCompeteTimeId()); |
|||
List<CompeteCoach> competeCoachList =new ArrayList<CompeteCoach>(); |
|||
for (CompeteCompany com:competeCompanyList) { |
|||
//再根据单位id查询,领队和教练信息,返回list集合
|
|||
competeCoachList.addAll(competeCompanyDao.selectByCompanyId(com.getId())); |
|||
} |
|||
List<List<PoiUtil.PoiUtilCell>> biao = new ArrayList<>(); |
|||
//先把联系人的都添加进去
|
|||
List<PoiUtil.PoiUtilCell> biaotou=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell biaotouName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 8, 1, null, null); |
|||
biaotouName.setValue(competeTimeDao.selectByPrimaryKey(params.getParam().getCompeteTimeId()).getName()); |
|||
biaotou.add(biaotouName); |
|||
biao.add(biaotou); |
|||
List<PoiUtil.PoiUtilCell> hangTou=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell xuhaoTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
xuhaoTou.setValue("序号"); |
|||
hangTou.add(xuhaoTou); |
|||
PoiUtil.PoiUtilCell cansaiduiwuTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
cansaiduiwuTou.setValue("参赛队伍"); |
|||
hangTou.add(cansaiduiwuTou); |
|||
PoiUtil.PoiUtilCell lianxirenTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
lianxirenTou.setValue("联系人/领队/教练"); |
|||
hangTou.add(lianxirenTou); |
|||
PoiUtil.PoiUtilCell nameTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
nameTou.setValue("姓名"); |
|||
hangTou.add(nameTou); |
|||
PoiUtil.PoiUtilCell sexTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
sexTou.setValue("性别"); |
|||
hangTou.add(sexTou); |
|||
PoiUtil.PoiUtilCell lianxifangshiTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
lianxifangshiTou.setValue("联系方式"); |
|||
hangTou.add(lianxifangshiTou); |
|||
PoiUtil.PoiUtilCell shenfenzhengTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
shenfenzhengTou.setValue("身份证号"); |
|||
hangTou.add(shenfenzhengTou); |
|||
PoiUtil.PoiUtilCell beizhuTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
beizhuTou.setValue("备注"); |
|||
hangTou.add(beizhuTou); |
|||
biao.add(hangTou); |
|||
int i=1; |
|||
for(CompeteCompany competeCompany:competeCompanyList){ |
|||
List<PoiUtil.PoiUtilCell> hang=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell xuhao=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
xuhao.setValue(String.valueOf(i++)); |
|||
hang.add(xuhao); |
|||
PoiUtil.PoiUtilCell cansaiduiwu=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
cansaiduiwu.setValue(competeCompany.getName()); |
|||
hang.add(cansaiduiwu); |
|||
PoiUtil.PoiUtilCell renyuanleibei=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
renyuanleibei.setValue("联系人"); |
|||
hang.add(renyuanleibei); |
|||
PoiUtil.PoiUtilCell name=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
name.setValue(competeCompany.getContactsName()); |
|||
hang.add(name); |
|||
PoiUtil.PoiUtilCell sex=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
sex.setValue("/"); |
|||
hang.add(sex); |
|||
PoiUtil.PoiUtilCell pho=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
pho.setValue(String.valueOf(competeCompany.getContactsPhone())); |
|||
hang.add(pho); |
|||
PoiUtil.PoiUtilCell idCardNum=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
idCardNum.setValue("/"); |
|||
hang.add(idCardNum); |
|||
PoiUtil.PoiUtilCell beizhu=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
beizhu.setValue("无"); |
|||
hang.add(beizhu); |
|||
biao.add(hang); |
|||
for (CompeteCoach competeCoach:competeCoachList){ |
|||
if(competeCoach.getCompanyId().equals(competeCompany.getId())){ |
|||
List<PoiUtil.PoiUtilCell> hanghou=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell xuhaoCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
xuhaoCach.setValue(String.valueOf(i++)); |
|||
hanghou.add(xuhaoCach); |
|||
PoiUtil.PoiUtilCell cansaiduiwuCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
cansaiduiwuCach.setValue(competeCompany.getName()); |
|||
hanghou.add(cansaiduiwuCach); |
|||
PoiUtil.PoiUtilCell renyuanleibeiCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
if (competeCoach.getIdentity().equals((byte) 0)){ |
|||
renyuanleibeiCach.setValue("领队"); |
|||
}else { |
|||
renyuanleibeiCach.setValue("教练"); |
|||
} |
|||
hanghou.add(renyuanleibeiCach); |
|||
PoiUtil.PoiUtilCell nameCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
nameCach.setValue(competeCoach.getName()); |
|||
hanghou.add(nameCach); |
|||
PoiUtil.PoiUtilCell sexCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
sexCach.setValue(competeCoach.getGender().equals((byte) 0)?"女":"男"); |
|||
hanghou.add(sexCach); |
|||
PoiUtil.PoiUtilCell phoCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
phoCach.setValue(String.valueOf(competeCoach.getPhone())); |
|||
hanghou.add(phoCach); |
|||
PoiUtil.PoiUtilCell idCardNumCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
idCardNumCach.setValue(String.valueOf(competeCoach.getIdPhoto())); |
|||
hanghou.add(idCardNumCach); |
|||
PoiUtil.PoiUtilCell beizhuCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
beizhuCach.setValue("无"); |
|||
hanghou.add(beizhuCach); |
|||
biao.add(hanghou); |
|||
} |
|||
} |
|||
} |
|||
Workbook workbook = new XSSFWorkbook(); |
|||
PoiUtil.exportWB("参赛队伍信息表",biao,workbook); |
|||
//String name = "跳绳比赛报名人数统计表" + ".xlsx";
|
|||
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 iTeamListService(QueryDto<CompeteDto.CompeteTime> params) { |
|||
//查出所有的单位的id
|
|||
List<CompeteCompany> competeCompanyList= competeCompanyDao.selectByCompeteTimeId(params.getParam().getCompeteTimeId()); |
|||
List<List<PoiUtil.PoiUtilCell>> biao = new ArrayList<>(); |
|||
List<PoiUtil.PoiUtilCell> biaoti=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell biaotouName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1, null, null); |
|||
biaotouName.setValue("代表队名单"); |
|||
biaoti.add(biaotouName); |
|||
biao.add(biaoti); |
|||
for (CompeteCompany com:competeCompanyList) { |
|||
//查出教练和领队的list
|
|||
List<CompeteCoach> jLandLD=competeCompanyDao.selectByCompanyId(com.getId()); |
|||
CompetePlayerExample competePlayerExample=new CompetePlayerExample(); |
|||
competePlayerExample.createCriteria().andCompanyIdEqualTo(com.getId()); |
|||
//运动员list
|
|||
List<CompetePlayer> competePlayerList = competePlayerMapper.selectByExample(competePlayerExample); |
|||
|
|||
List<PoiUtil.PoiUtilCell> daibiaodui=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell daibiaoduiName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1, null, null); |
|||
daibiaoduiName.setValue(com.getName()); |
|||
daibiaodui.add(daibiaoduiName); |
|||
biao.add(daibiaodui); |
|||
//领队和教练
|
|||
List<PoiUtil.PoiUtilCell> lingduiList=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell lingdui=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
lingdui.setValue("领 队:"); |
|||
lingduiList.add(lingdui); |
|||
biao.add(lingduiList); |
|||
StringBuffer lingduiName=new StringBuffer(""); |
|||
StringBuffer jiaolianName=new StringBuffer(""); |
|||
jLandLD.forEach(jLD->{ |
|||
if (jLD.getIdentity().equals((byte) 0)) { |
|||
lingduiName.append(jLD.getName()+'、'); |
|||
} else { |
|||
jiaolianName.append(jLD.getName()+'、'); |
|||
} |
|||
}); |
|||
if(lingduiName.length()>0){ |
|||
lingduiName.deleteCharAt(lingduiName.length() - 1) ; |
|||
} |
|||
if(jiaolianName.length()>0){ |
|||
jiaolianName.deleteCharAt(jiaolianName.length() - 1) ; |
|||
} |
|||
PoiUtil.PoiUtilCell lingduiNameHang=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
lingduiNameHang.setValue(String.valueOf(lingduiName)); |
|||
lingduiList.add(lingduiNameHang); |
|||
|
|||
biao.add(lingduiList); |
|||
List<PoiUtil.PoiUtilCell> jiaolianList=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell jiaoling=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
jiaoling.setValue("教 练:"); |
|||
jiaolianList.add(jiaoling); |
|||
PoiUtil.PoiUtilCell jiaolianHang= new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
jiaolianHang.setValue(String.valueOf(jiaolianName)); |
|||
jiaolianList.add(jiaolianHang); |
|||
biao.add(jiaolianList); |
|||
|
|||
//再放运动员
|
|||
StringBuffer yDYLN=new StringBuffer(""); |
|||
competePlayerList.forEach(cpL->{ |
|||
yDYLN.append(cpL.getName()); |
|||
yDYLN.append("("); |
|||
yDYLN.append(cpL.getGender().equals((byte) 0)?"女":"男"); |
|||
yDYLN.append(")、"); |
|||
}); |
|||
if (yDYLN.length()>0){ |
|||
yDYLN.deleteCharAt(yDYLN.length()-1); |
|||
} |
|||
|
|||
List<PoiUtil.PoiUtilCell> yundongyuanList=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell yuandongyuan=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
yuandongyuan.setValue("运动员"); |
|||
yundongyuanList.add(yuandongyuan); |
|||
PoiUtil.PoiUtilCell yuandongyuanName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
yuandongyuanName.setValue(String.valueOf(yDYLN)); |
|||
yundongyuanList.add(yuandongyuanName); |
|||
biao.add(yundongyuanList); |
|||
biao.add(yundongyuanList); |
|||
List<PoiUtil.PoiUtilCell> entryList=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell enter= new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1); |
|||
entryList.add(enter); |
|||
biao.add(entryList); |
|||
} |
|||
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; |
|||
} |
|||
} |
|||
package com.ccsens.mt.service; |
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.lang.Snowflake; |
|||
import cn.hutool.core.util.IdcardUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.ccsens.cloudutil.feign.TallFeignClient; |
|||
import com.ccsens.mt.bean.dto.CompeteDto; |
|||
import com.ccsens.mt.bean.po.*; |
|||
import com.ccsens.mt.bean.vo.TableVo; |
|||
import com.ccsens.mt.persist.dao.*; |
|||
import com.ccsens.mt.persist.mapper.*; |
|||
import com.ccsens.util.PoiUtil; |
|||
import com.ccsens.util.PropUtil; |
|||
import com.ccsens.util.RedisUtil; |
|||
import com.ccsens.util.WebConstant; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.poi.ss.usermodel.Workbook; |
|||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Propagation; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import javax.annotation.Resource; |
|||
import java.io.File; |
|||
import java.io.FileOutputStream; |
|||
import java.io.IOException; |
|||
import java.io.OutputStream; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
@Slf4j |
|||
@Service |
|||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|||
public class ExcelService implements IExcelService { |
|||
@Resource |
|||
private CompeteCompanyDao competeCompanyDao; |
|||
@Resource |
|||
private CompeteTimeDao competeTimeDao; |
|||
|
|||
@Resource |
|||
private CompeteCompanyMapper competeCompanyMapper; |
|||
@Resource |
|||
private Snowflake snowflake; |
|||
@Resource |
|||
private CompeteTeamDao competeTeamDao; |
|||
@Resource |
|||
private CompetePlayerDao competePlayerDao; |
|||
@Resource |
|||
private CompeteTeamMemberMapper competeTeamMemberMapper; |
|||
@Resource |
|||
private CompeteProjectMapper competeProjectMapper; |
|||
@Resource |
|||
private CompeteProjectPlayerMapper competeProjectPlayerMapper; |
|||
@Resource |
|||
private CompeteGroupMapper competeGroupMapper; |
|||
|
|||
@Resource |
|||
CompeteCoachMapper competeCoachMapper; |
|||
|
|||
@Resource |
|||
private CompetePlayerMapper competePlayerMapper; |
|||
|
|||
@Override |
|||
public String dasaiduiwuxinxiWPS(QueryDto<CompeteDto.CompeteTime> params) { |
|||
//这个里面包含联系人得信息
|
|||
List<CompeteCompany> competeCompanyList= competeCompanyDao.selectByCompeteTimeId(params.getParam().getCompeteTimeId()); |
|||
List<CompeteCoach> competeCoachList =new ArrayList<CompeteCoach>(); |
|||
for (CompeteCompany com:competeCompanyList) { |
|||
//再根据单位id查询,领队和教练信息,返回list集合
|
|||
competeCoachList.addAll(competeCompanyDao.selectByCompanyId(com.getId())); |
|||
} |
|||
List<List<PoiUtil.PoiUtilCell>> biao = new ArrayList<>(); |
|||
//先把联系人的都添加进去
|
|||
List<PoiUtil.PoiUtilCell> biaotou=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell biaotouName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 8, 1, null, null); |
|||
biaotouName.setValue(competeTimeDao.selectByPrimaryKey(params.getParam().getCompeteTimeId()).getName()); |
|||
biaotou.add(biaotouName); |
|||
biao.add(biaotou); |
|||
List<PoiUtil.PoiUtilCell> hangTou=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell xuhaoTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
xuhaoTou.setValue("序号"); |
|||
hangTou.add(xuhaoTou); |
|||
PoiUtil.PoiUtilCell cansaiduiwuTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
cansaiduiwuTou.setValue("参赛队伍"); |
|||
hangTou.add(cansaiduiwuTou); |
|||
PoiUtil.PoiUtilCell lianxirenTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
lianxirenTou.setValue("联系人/领队/教练"); |
|||
hangTou.add(lianxirenTou); |
|||
PoiUtil.PoiUtilCell nameTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
nameTou.setValue("姓名"); |
|||
hangTou.add(nameTou); |
|||
PoiUtil.PoiUtilCell sexTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
sexTou.setValue("性别"); |
|||
hangTou.add(sexTou); |
|||
PoiUtil.PoiUtilCell lianxifangshiTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
lianxifangshiTou.setValue("联系方式"); |
|||
hangTou.add(lianxifangshiTou); |
|||
PoiUtil.PoiUtilCell shenfenzhengTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
shenfenzhengTou.setValue("身份证号"); |
|||
hangTou.add(shenfenzhengTou); |
|||
PoiUtil.PoiUtilCell beizhuTou=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
beizhuTou.setValue("备注"); |
|||
hangTou.add(beizhuTou); |
|||
biao.add(hangTou); |
|||
int i=1; |
|||
for(CompeteCompany competeCompany:competeCompanyList){ |
|||
List<PoiUtil.PoiUtilCell> hang=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell xuhao=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
xuhao.setValue(String.valueOf(i++)); |
|||
hang.add(xuhao); |
|||
PoiUtil.PoiUtilCell cansaiduiwu=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
cansaiduiwu.setValue(competeCompany.getName()); |
|||
hang.add(cansaiduiwu); |
|||
PoiUtil.PoiUtilCell renyuanleibei=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
renyuanleibei.setValue("联系人"); |
|||
hang.add(renyuanleibei); |
|||
PoiUtil.PoiUtilCell name=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
name.setValue(competeCompany.getContactsName()); |
|||
hang.add(name); |
|||
PoiUtil.PoiUtilCell sex=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
sex.setValue("/"); |
|||
hang.add(sex); |
|||
PoiUtil.PoiUtilCell pho=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
pho.setValue(String.valueOf(competeCompany.getContactsPhone())); |
|||
hang.add(pho); |
|||
PoiUtil.PoiUtilCell idCardNum=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
idCardNum.setValue("/"); |
|||
hang.add(idCardNum); |
|||
PoiUtil.PoiUtilCell beizhu=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
beizhu.setValue("无"); |
|||
hang.add(beizhu); |
|||
biao.add(hang); |
|||
for (CompeteCoach competeCoach:competeCoachList){ |
|||
if(competeCoach.getCompanyId().equals(competeCompany.getId())){ |
|||
List<PoiUtil.PoiUtilCell> hanghou=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell xuhaoCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
xuhaoCach.setValue(String.valueOf(i++)); |
|||
hanghou.add(xuhaoCach); |
|||
PoiUtil.PoiUtilCell cansaiduiwuCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
cansaiduiwuCach.setValue(competeCompany.getName()); |
|||
hanghou.add(cansaiduiwuCach); |
|||
PoiUtil.PoiUtilCell renyuanleibeiCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
if (competeCoach.getIdentity().equals((byte) 0)){ |
|||
renyuanleibeiCach.setValue("领队"); |
|||
}else { |
|||
renyuanleibeiCach.setValue("教练"); |
|||
} |
|||
hanghou.add(renyuanleibeiCach); |
|||
PoiUtil.PoiUtilCell nameCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
nameCach.setValue(competeCoach.getName()); |
|||
hanghou.add(nameCach); |
|||
PoiUtil.PoiUtilCell sexCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
sexCach.setValue(competeCoach.getGender().equals((byte) 0)?"女":"男"); |
|||
hanghou.add(sexCach); |
|||
PoiUtil.PoiUtilCell phoCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
phoCach.setValue(String.valueOf(competeCoach.getPhone())); |
|||
hanghou.add(phoCach); |
|||
PoiUtil.PoiUtilCell idCardNumCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
idCardNumCach.setValue(String.valueOf(competeCoach.getIdPhoto())); |
|||
hanghou.add(idCardNumCach); |
|||
PoiUtil.PoiUtilCell beizhuCach=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1, null, null); |
|||
beizhuCach.setValue("无"); |
|||
hanghou.add(beizhuCach); |
|||
biao.add(hanghou); |
|||
} |
|||
} |
|||
} |
|||
Workbook workbook = new XSSFWorkbook(); |
|||
PoiUtil.exportWB("参赛队伍信息表",biao,workbook); |
|||
//String name = "跳绳比赛报名人数统计表" + ".xlsx";
|
|||
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 iTeamListService(QueryDto<CompeteDto.CompeteTime> params) { |
|||
//查出所有的单位的id
|
|||
List<CompeteCompany> competeCompanyList= competeCompanyDao.selectByCompeteTimeId(params.getParam().getCompeteTimeId()); |
|||
List<List<PoiUtil.PoiUtilCell>> biao = new ArrayList<>(); |
|||
List<PoiUtil.PoiUtilCell> biaoti=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell biaotouName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1, null, null); |
|||
biaotouName.setValue("代表队名单"); |
|||
biaoti.add(biaotouName); |
|||
biao.add(biaoti); |
|||
for (CompeteCompany com:competeCompanyList) { |
|||
//查出教练和领队的list
|
|||
List<CompeteCoach> jLandLD=competeCompanyDao.selectByCompanyId(com.getId()); |
|||
CompetePlayerExample competePlayerExample=new CompetePlayerExample(); |
|||
competePlayerExample.createCriteria().andCompanyIdEqualTo(com.getId()); |
|||
//运动员list
|
|||
List<CompetePlayer> competePlayerList = competePlayerMapper.selectByExample(competePlayerExample); |
|||
|
|||
List<PoiUtil.PoiUtilCell> daibiaodui=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell daibiaoduiName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1, null, null); |
|||
daibiaoduiName.setValue(com.getName()); |
|||
daibiaodui.add(daibiaoduiName); |
|||
biao.add(daibiaodui); |
|||
//领队和教练
|
|||
List<PoiUtil.PoiUtilCell> lingduiList=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell lingdui=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
lingdui.setValue("领 队:"); |
|||
lingduiList.add(lingdui); |
|||
biao.add(lingduiList); |
|||
StringBuffer lingduiName=new StringBuffer(""); |
|||
StringBuffer jiaolianName=new StringBuffer(""); |
|||
jLandLD.forEach(jLD->{ |
|||
if (jLD.getIdentity().equals((byte) 0)) { |
|||
lingduiName.append(jLD.getName()+'、'); |
|||
} else { |
|||
jiaolianName.append(jLD.getName()+'、'); |
|||
} |
|||
}); |
|||
if(lingduiName.length()>0){ |
|||
lingduiName.deleteCharAt(lingduiName.length() - 1) ; |
|||
} |
|||
if(jiaolianName.length()>0){ |
|||
jiaolianName.deleteCharAt(jiaolianName.length() - 1) ; |
|||
} |
|||
PoiUtil.PoiUtilCell lingduiNameHang=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
lingduiNameHang.setValue(String.valueOf(lingduiName)); |
|||
lingduiList.add(lingduiNameHang); |
|||
|
|||
biao.add(lingduiList); |
|||
List<PoiUtil.PoiUtilCell> jiaolianList=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell jiaoling=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
jiaoling.setValue("教 练:"); |
|||
jiaolianList.add(jiaoling); |
|||
PoiUtil.PoiUtilCell jiaolianHang= new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
jiaolianHang.setValue(String.valueOf(jiaolianName)); |
|||
jiaolianList.add(jiaolianHang); |
|||
biao.add(jiaolianList); |
|||
|
|||
//再放运动员
|
|||
StringBuffer yDYLN=new StringBuffer(""); |
|||
competePlayerList.forEach(cpL->{ |
|||
yDYLN.append(cpL.getName()); |
|||
yDYLN.append("("); |
|||
yDYLN.append(cpL.getGender().equals((byte) 0)?"女":"男"); |
|||
yDYLN.append(")、"); |
|||
}); |
|||
if (yDYLN.length()>0){ |
|||
yDYLN.deleteCharAt(yDYLN.length()-1); |
|||
} |
|||
|
|||
List<PoiUtil.PoiUtilCell> yundongyuanList=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell yuandongyuan=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
yuandongyuan.setValue("运动员"); |
|||
yundongyuanList.add(yuandongyuan); |
|||
PoiUtil.PoiUtilCell yuandongyuanName=new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 1, 1); |
|||
yuandongyuanName.setValue(String.valueOf(yDYLN)); |
|||
yundongyuanList.add(yuandongyuanName); |
|||
biao.add(yundongyuanList); |
|||
biao.add(yundongyuanList); |
|||
List<PoiUtil.PoiUtilCell> entryList=new ArrayList<>(); |
|||
PoiUtil.PoiUtilCell enter= new PoiUtil.PoiUtilCell(WebConstant.CELL_NULL, 2, 1); |
|||
entryList.add(enter); |
|||
biao.add(entryList); |
|||
} |
|||
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; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
@ -1,20 +1,49 @@ |
|||
package com.ccsens.mt.service; |
|||
|
|||
import com.ccsens.mt.bean.dto.CompeteDto; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
|
|||
public interface IExcelService { |
|||
/** |
|||
* 导出大赛队伍信息表 |
|||
* @param params |
|||
* @return |
|||
*/ |
|||
String dasaiduiwuxinxiWPS(QueryDto<CompeteDto.CompeteTime> params); |
|||
|
|||
/** |
|||
*导出代表队名单 |
|||
* @param params |
|||
* @return |
|||
*/ |
|||
String iTeamListService(QueryDto<CompeteDto.CompeteTime> params); |
|||
} |
|||
package com.ccsens.mt.service; |
|||
|
|||
import com.ccsens.mt.bean.dto.CompeteDto; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
import com.ccsens.mt.bean.dto.CompeteDto; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
|
|||
import java.io.IOException; |
|||
|
|||
public interface IExcelService { |
|||
/** |
|||
* 导出大赛队伍信息表 |
|||
* @param params |
|||
* @return |
|||
*/ |
|||
String dasaiduiwuxinxiWPS(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; |
|||
} |
|||
|
Loading…
Reference in new issue