Lihong@123456 5 years ago
parent
commit
d0f27669b0
  1. 22
      mt/src/main/java/com/ccsens/mt/api/ExcelController.java
  2. 7
      mt/src/main/java/com/ccsens/mt/bean/vo/CompeteVo.java
  3. 16
      mt/src/main/java/com/ccsens/mt/persist/dao/CompeteCompanyDao.java
  4. 1
      mt/src/main/java/com/ccsens/mt/persist/dao/CompetePlayerDao.java
  5. 1
      mt/src/main/java/com/ccsens/mt/persist/mapper/CompeteCompanyMapper.java
  6. 266
      mt/src/main/java/com/ccsens/mt/service/ExcelService.java
  7. 19
      mt/src/main/java/com/ccsens/mt/service/IExcelService.java
  8. 32
      mt/src/main/resources/mapper_dao/CompeteCompanyDao.xml
  9. 4
      mt/src/main/resources/mapper_dao/CompetePlayerDao.xml

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

@ -59,4 +59,26 @@ public class ExcelController {
String path = excelService.competeAllCount(params.getParam());
return JsonResponse.newInstance().ok(path);
}
@MustLogin
@ApiOperation(value = "大赛参赛队伍信息表", notes = "")
@RequestMapping(value = "/competitionTeamInformationTable", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<String> dasaiduiwuxinxiWPS(@ApiParam @Validated @RequestBody QueryDto<CompeteDto.CompeteTime> params) throws IOException {
log.info("导出大赛参赛队伍信息表:{}",params);
String path = excelService.dasaiduiwuxinxiWPS(params);
return JsonResponse.newInstance().ok(path);
}
@MustLogin
@ApiOperation(value = "代表队名单", notes = "")
@RequestMapping(value = "/teamList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<String> teamList(@ApiParam @Validated @RequestBody QueryDto<CompeteDto.CompeteTime> params) throws IOException {
log.info("导出代表队名单表:{}",params);
String path = excelService.iTeamListService(params);
return JsonResponse.newInstance().ok(path);
}
}

7
mt/src/main/java/com/ccsens/mt/bean/vo/CompeteVo.java

@ -44,6 +44,13 @@ public class CompeteVo {
@ApiModelProperty("描述")
private String groupDescription;
}
@Data
@ApiModel
public static class CompeteC{
@ApiModelProperty("参赛队伍")
private String cansaiduiName;
}
@Data
@ApiModel("模糊查询参赛单位")

16
mt/src/main/java/com/ccsens/mt/persist/dao/CompeteCompanyDao.java

@ -1,6 +1,8 @@
package com.ccsens.mt.persist.dao;
import com.ccsens.mt.bean.dto.ProvinceCompeteDto;
import com.ccsens.mt.bean.po.CompeteCoach;
import com.ccsens.mt.bean.po.CompeteCompany;
import com.ccsens.mt.bean.vo.CompeteVo;
import com.ccsens.mt.bean.vo.ProvinceCompeteVo;
import com.ccsens.mt.persist.mapper.CompeteCompanyMapper;
@ -93,4 +95,18 @@ public interface CompeteCompanyDao extends CompeteCompanyMapper {
* @return 返回详细信息
*/
ProvinceCompeteVo.GetCoach getCoachInfo(@Param("coachId")Long coachId);
/**
* 根据大赛id查看当前大赛所有队伍信息,以及联系人的信息
* @param CompeteTimeId 大赛CompeteTimeId
* @return 返回参赛队伍详细信息
*/
List<CompeteCompany> selectByCompeteTimeId(Long CompeteTimeId);
/**
* 根据查出来得大赛得单位的id查询教练和领队得信息
* @param companyId 单位id
* @return
*/
List<CompeteCoach> selectByCompanyId(@Param("companyId")Long companyId);
}

1
mt/src/main/java/com/ccsens/mt/persist/dao/CompetePlayerDao.java

@ -1,5 +1,6 @@
package com.ccsens.mt.persist.dao;
import com.ccsens.mt.bean.po.CompetePlayer;
import com.ccsens.mt.bean.vo.CompeteVo;
import com.ccsens.mt.bean.vo.ProvinceCompeteVo;
import com.ccsens.mt.bean.vo.TableVo;

1
mt/src/main/java/com/ccsens/mt/persist/mapper/CompeteCompanyMapper.java

@ -27,4 +27,5 @@ public interface CompeteCompanyMapper {
int updateByPrimaryKeySelective(CompeteCompany record);
int updateByPrimaryKey(CompeteCompany record);
}

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

@ -1,5 +1,4 @@
package com.ccsens.mt.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.ObjectUtil;
@ -11,6 +10,9 @@ import com.ccsens.mt.persist.mapper.*;
import com.ccsens.util.CodeEnum;
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 com.ccsens.util.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
@ -19,7 +21,6 @@ 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;
@ -28,11 +29,12 @@ 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
@ -54,10 +56,244 @@ public class ExcelService implements IExcelService {
@Resource
private IProvinceService provinceService;
@Resource
private CompeteCompanyDao competeCompanyDao;
@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 {
@ -525,23 +761,3 @@ public class ExcelService implements IExcelService {
}

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

@ -1,13 +1,28 @@
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 {
/**
* @author li
* 导出大赛队伍信息表
* @param params
* @return
*/
public interface IExcelService {
String dasaiduiwuxinxiWPS(QueryDto<CompeteDto.CompeteTime> params);
/**
*导出代表队名单
* @param params
* @return
*/
String iTeamListService(QueryDto<CompeteDto.CompeteTime> params);
/**
* XXXX大赛报名表
* @param params 大赛id

32
mt/src/main/resources/mapper_dao/CompeteCompanyDao.xml

@ -41,7 +41,6 @@
and cc.rec_status = 0
limit 1
</select>
<select id="queryPlayerByGroupId" resultMap="group_player">
SELECT
cg.id as groupId,
@ -232,6 +231,35 @@
WHERE
id = #{coachId}
</select>
<select id="selectByCompeteTimeId" resultType="com.ccsens.mt.bean.po.CompeteCompany">
SELECT
tcc.`id` as id,
tcc.`name` as name,
tcc.`contacts_name` as contactsName,
tcc.`contacts_phone` as contactsPhone
from
t_compete_company tcc
where
tcc.compete_time_id=#{CompeteTimeId}
</select>
<select id="selectByCompanyId" resultType="com.ccsens.mt.bean.po.CompeteCoach">
select
tcc.`id` as id,
tcc.`identity` as identity,
tcc.`name` as `name`,
tcc.`gender` as `gender`,
tcc.`phone` as `phone`,
tcc.`id_card` as `idCard`,
tcc.`id_photo` as `idPhoto`,
tcc.`coach_certificate` as `coachCertificate`,
tcc.`company_id` as `companyId`,
tcc.`created_at` as `createdAt`,
tcc.`updated_at` as `updatedAt`,
tcc.`rec_status` as `recStatus`
FROM
t_compete_coach tcc
where
tcc.`company_id`= #{companyId}
</select>
</mapper>

4
mt/src/main/resources/mapper_dao/CompetePlayerDao.xml

@ -196,6 +196,9 @@
id = #{playerId}
and rec_status = 0
</select>
<<<<<<< HEAD
=======
<select id="getTeamGroupRemark" resultType="com.ccsens.mt.bean.vo.ProvinceCompeteVo$TeamGroupRemark">
SELECT
g.group_name as groupRemark,
@ -262,4 +265,5 @@
and g.rec_status in (0,1)
ORDER BY g.sequence
</select>
>>>>>>> c32326aa81c6ae6a4ce3e0a067a7617201458f50
</mapper>
Loading…
Cancel
Save