@ -7,10 +7,7 @@ import com.ccsens.mt.bean.dto.CompeteDto;
import com.ccsens.mt.bean.dto.ProvinceCompeteDto ;
import com.ccsens.mt.bean.dto.ScoreDto ;
import com.ccsens.mt.bean.po.* ;
import com.ccsens.mt.bean.vo.CompeteExcelVo ;
import com.ccsens.mt.bean.vo.CompeteVo ;
import com.ccsens.mt.bean.vo.ScoreVo ;
import com.ccsens.mt.bean.vo.TableVo ;
import com.ccsens.mt.bean.vo.* ;
import com.ccsens.mt.persist.dao.* ;
import com.ccsens.mt.persist.mapper.* ;
import com.ccsens.mt.util.Constant ;
@ -25,6 +22,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.poi.ss.usermodel.Table ;
import org.apache.poi.ss.usermodel.Workbook ;
import org.apache.poi.xssf.usermodel.XSSFWorkbook ;
import org.eclipse.jetty.util.StringUtil ;
@ -40,7 +38,9 @@ import java.io.OutputStream;
import java.text.SimpleDateFormat ;
import java.util.ArrayList ;
import java.util.Comparator ;
import java.util.Date ;
import java.util.LinkedList ;
import java.util.List ;
@Slf4j
@ -718,38 +718,58 @@ public class ExcelService implements IExcelService {
}
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 ) ;
competeCoachMapper . selectByExample ( competeCoachExample ) ;
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 ;
List < TableVo . CompeteOverview > competeOverviewList = competeCompanyDao . selectCompeteJoinCountList ( params . getCompeteTimeId ( ) ) ;
List < TableVo . CompeteOverview > list = new LinkedList < > ( ) ;
for ( TableVo . CompeteOverview mes : competeOverviewList ) {
if ( mes . getCoachNum ( ) ! = 0 & & mes . getGuideNum ( ) ! = 0 & & mes . getPlayerNum ( ) ! = 0 ) {
int num = mes . getCoachNum ( ) + mes . getPlayerNum ( ) + mes . getGuideNum ( ) ;
mes . setSum ( num ) ;
list . add ( mes ) ;
}
}
return list ;
// 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);
// competeCoachMapper.selectByExample(competeCoachExample);
// 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);
// List<CompetePlayer> competePlayerList = competePlayerDao.selectByExample(competePlayerExample2);
// competePlayerList.forEach(mes->{
// CompeteProjectPlayerExample competeProjectPlayerExample = new CompeteProjectPlayerExample();
// competeProjectPlayerMapper.selectByExample(competeProjectPlayerExample);
//
// });
// //总人数
// 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;
}
@ -809,7 +829,8 @@ public class ExcelService implements IExcelService {
@Override
public String competeAllCount ( CompeteDto . CompeteTime params ) throws IOException {
List < TableVo . CompeteAllCount > competeAllCountList = competeAllCountList ( params ) ;
// List<TableVo.CompeteAllCount> competeAllCountList = competeAllCountList(params);
List < TableVo . CompeteAllCount1 > competeAllCountList = competeAllCountList1 ( params . getCompeteTimeId ( ) ) ;
String path = getExcelFilePathForCompeteAllCount ( competeAllCountList ) ;
return path ;
}
@ -1036,24 +1057,26 @@ public class ExcelService implements IExcelService {
}
@Override
public List < TableVo . CompeteAllCount1 > competeAllCountList1 ( int type ) {
// CompeteTime competeTime = competeTimeDao.selectByPrimaryKey(params.getCompeteTimeId());
public List < TableVo . CompeteAllCount1 > competeAllCountList1 ( Long competeTimeId ) {
CompeteTime competeTime = competeTimeDao . selectByPrimaryKey ( competeTimeId ) ;
List < TableVo . CompeteAllCount1 > competeAllCountList = new ArrayList < > ( ) ;
// if(ObjectUtil.isNotNull(competeTime)) {
if ( ObjectUtil . isNotNull ( competeTime ) ) {
//查询个人赛的数量统计
competeAllCountList = competePlayerDao . getJoinNumByType ( ( byte ) type ) ;
//查询团体赛的数量统计
// List<TableVo.CompeteAllCount1> groupNum = competePlayerDao.getJoinTeamNumByType((byte) type);
List < TableVo . CompeteAllCount1 > nums = competePlayerDao . getJoinNumByType ( competeTime . getType ( ) ) ;
competeAllCountList . addAll ( nums ) ;
//查询限制组别的团体赛的统计
//查询不限组别团体赛的统计
// }
List < TableVo . CompeteAllCount1 > groupRuleNum = competePlayerDao . getJoinRuleTeamNumByType ( competeTime . getType ( ) ) ;
competeAllCountList . addAll ( groupRuleNum ) ;
//查询团体赛的数量统计
List < TableVo . CompeteAllCount1 > groupNum = competePlayerDao . getJoinTeamNumByType ( competeTime . getType ( ) ) ;
competeAllCountList . addAll ( groupNum ) ;
}
CollectionUtil . sort ( competeAllCountList , ( t1 , t2 ) - > ( int ) ( t1 . getProjectId ( ) - t2 . getProjectId ( ) ) ) ;
return competeAllCountList ;
}
private String getExcelFilePathForCompeteAllCount ( List < TableVo . CompeteAllCount > arrayList ) throws IOException {
private String getExcelFilePathForCompeteAllCount ( List < TableVo . CompeteAllCount1 > arrayList ) throws IOException {
//创建excle表格对象
List < List < PoiUtil . PoiUtilCell > > list = new ArrayList < > ( ) ;
//创建行对象
@ -1081,43 +1104,52 @@ public class ExcelService implements IExcelService {
//创建整个excel表格对象
Workbook workbook = new XSSFWorkbook ( ) ;
int i = 1 ;
for ( TableVo . CompeteAllCount competeAllCount : arrayList ) {
for ( TableVo . CompeteAllCount1 competeAllCount : arrayList ) {
//行对象
List < PoiUtil . PoiUtilCell > cells = new ArrayList < > ( ) ;
cells . add ( new PoiUtil . PoiUtilCell ( i + "" , 1 , 1 , 300 , 18 ) ) ;
//单元格对象
PoiUtil . PoiUtilCell poiUtilCel15 = new PoiUtil . PoiUtilCell ( competeAllCount . getProjectName ( ) ) ;
cells . add ( poiUtilCel15 ) ;
PoiUtil . PoiUtilCell poiUtilCel = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 0 ) ) ) ;
for ( int j = 0 ; j < competeAllCount . getNums ( ) . size ( ) ; j + + ) {
if ( ( competeAllCount . getTeam ( ) = = 1 & & competeAllCount . getJoinRule ( ) = = 1 ) | | ( competeAllCount . getCertificate ( ) = = 1 ) ) {
PoiUtil . PoiUtilCell poiUtilCel = new PoiUtil . PoiUtilCell ( competeAllCount . getNums ( ) . get ( j ) , 15 , 1 ) ;
cells . add ( poiUtilCel ) ;
PoiUtil . PoiUtilCell poiUtilCell = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 1 ) ) ) ;
cells . add ( poiUtilCell ) ;
PoiUtil . PoiUtilCell poiUtilCel2 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 2 ) ) ) ;
cells . add ( poiUtilCel2 ) ;
PoiUtil . PoiUtilCell poiUtilCel3 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 3 ) ) ) ;
cells . add ( poiUtilCel3 ) ;
PoiUtil . PoiUtilCell poiUtilCel4 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 4 ) ) ) ;
cells . add ( poiUtilCel4 ) ;
PoiUtil . PoiUtilCell poiUtilCel5 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 5 ) ) ) ;
cells . add ( poiUtilCel5 ) ;
PoiUtil . PoiUtilCell poiUtilCel6 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 6 ) ) ) ;
cells . add ( poiUtilCel6 ) ;
PoiUtil . PoiUtilCell poiUtilCel7 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 7 ) ) ) ;
cells . add ( poiUtilCel7 ) ;
PoiUtil . PoiUtilCell poiUtilCel8 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 8 ) ) ) ;
cells . add ( poiUtilCel8 ) ;
PoiUtil . PoiUtilCell poiUtilCel9 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 9 ) ) ) ;
cells . add ( poiUtilCel9 ) ;
PoiUtil . PoiUtilCell poiUtilCel10 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 10 ) ) ) ;
cells . add ( poiUtilCel10 ) ;
PoiUtil . PoiUtilCell poiUtilCel11 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 11 ) ) ) ;
cells . add ( poiUtilCel11 ) ;
PoiUtil . PoiUtilCell poiUtilCel12 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 12 ) ) ) ;
cells . add ( poiUtilCel12 ) ;
PoiUtil . PoiUtilCell poiUtilCel13 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 13 ) ) ) ;
cells . add ( poiUtilCel13 ) ;
PoiUtil . PoiUtilCell poiUtilCel14 = new PoiUtil . PoiUtilCell ( String . valueOf ( competeAllCount . getNums ( ) . get ( 14 ) ) ) ;
cells . add ( poiUtilCel14 ) ;
} else {
PoiUtil . PoiUtilCell poiUtilCel = new PoiUtil . PoiUtilCell ( competeAllCount . getNums ( ) . get ( j ) ) ;
cells . add ( poiUtilCel ) ;
}
}
// PoiUtil.PoiUtilCell poiUtilCel = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(0)));
// cells.add(poiUtilCel);
// PoiUtil.PoiUtilCell poiUtilCell = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(1)));
// cells.add(poiUtilCell);
// PoiUtil.PoiUtilCell poiUtilCel2 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(2)));
// cells.add(poiUtilCel2);
// PoiUtil.PoiUtilCell poiUtilCel3 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(3)));
// cells.add(poiUtilCel3);
// PoiUtil.PoiUtilCell poiUtilCel4 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(4)));
// cells.add(poiUtilCel4);
// PoiUtil.PoiUtilCell poiUtilCel5 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(5)));
// cells.add(poiUtilCel5);
// PoiUtil.PoiUtilCell poiUtilCel6 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(6)));
// cells.add(poiUtilCel6);
// PoiUtil.PoiUtilCell poiUtilCel7 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(7)));
// cells.add(poiUtilCel7);
// PoiUtil.PoiUtilCell poiUtilCel8 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(8)));
// cells.add(poiUtilCel8);
// PoiUtil.PoiUtilCell poiUtilCel9 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(9)));
// cells.add(poiUtilCel9);
// PoiUtil.PoiUtilCell poiUtilCel10 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(10)));
// cells.add(poiUtilCel10);
// PoiUtil.PoiUtilCell poiUtilCel11 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(11)));
// cells.add(poiUtilCel11);
// PoiUtil.PoiUtilCell poiUtilCel12 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(12)));
// cells.add(poiUtilCel12);
// PoiUtil.PoiUtilCell poiUtilCel13 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(13)));
// cells.add(poiUtilCel13);
// PoiUtil.PoiUtilCell poiUtilCel14 = new PoiUtil.PoiUtilCell(String.valueOf(competeAllCount.getNums().get(14)));
// cells.add(poiUtilCel14);
list . add ( cells ) ;
i + + ;
}
@ -1802,7 +1834,7 @@ public class ExcelService implements IExcelService {
} else {
for ( int i = 0 ; i < eights . size ( ) ; i + + ) {
List < PoiUtil . PoiUtilCell > cells = new ArrayList < > ( ) ;
cells . add ( new PoiUtil . PoiUtilCell ( "第" + i + "名" ) ) ;
cells . add ( new PoiUtil . PoiUtilCell ( "第" + ( i + 1 ) + "名" ) ) ;
cells . add ( new PoiUtil . PoiUtilCell ( eights . get ( i ) . getEightNames ( ) , 8 , 1 ) ) ;
raws . add ( cells ) ;
}