Commit 464448a6 authored by 竹天卫's avatar 竹天卫

校核详情导出 & 标签导出

parent f40d98be
......@@ -855,51 +855,33 @@ public class EntrustController {
}
@ApiOperation(value = "查看样品标签")
@GetMapping("/getSampleLabelList")
public BaseResponse getSampleLabelList(Integer entrustId) {
try {
return entrustService.getSampleLabelList(entrustId);
} catch (Exception e) {
log.debug("查看样品标签{}", e);
}
return BaseResponse.errorMsg("失败!");
}
//todo 导出样品标签功能待完善
@PostMapping("/exportSampleLabel/{entrustId}")
@ApiOperation("导出样品标签")
@PostMapping("/exportSampleLabel/{entrustId}")
public void exportSampleLabel(@PathVariable("entrustId") Integer entrustId,
HttpServletResponse response) {
Map<String, Object> map = entrustService.getSampleLabelList(entrustId).getData();
if (map == null) {
return;
}
List<Sample> sampleList = (List<Sample>)map.get("list");
if (sampleList == null || sampleList.size()==0) {
return;
}
Entrust entrust = (Entrust)map.get("entrust");
Map<String, Object> beanParams = new HashMap<>(5);
String fileName, HttpServletResponse response) {
try {
entrustService.exportSampleLabel(entrustId, fileName, response);
//(不包含平行样)
List<SampleLabelVo> sampleLabelVoList = new ArrayList<>();
for(int i=0; i<sampleList.size(); i++){
SampleLabelVo sampleLabelVo = new SampleLabelVo();
i=i+4;
} catch (Exception e) {
log.debug("导出样品标签{}", e);
}
beanParams.put("list", sampleList);
WordUtil.writeWordReport(entrust.getEntrustCode() +"-"+ entrust.getProjectName() + "-样品标签",
"sampleFlow.ftl",
beanParams, response, FileExt.DOC);
}
@ApiOperation("导出-委托单校核详情")
@PostMapping("/exportCheckDetail/{entrustId}")
public void exportCheckDetail(@PathVariable("entrustId") Integer entrustId,
String fileName, HttpServletResponse response) {
try {
entrustService.exportCheckDetail(entrustId, fileName, response);
} catch (Exception e) {
log.debug("导出-委托单校核详情{}", e);
}
}
......
......@@ -57,7 +57,7 @@ public interface SampleMapper extends BaseMapper<Sample> {
@Select("select * from sample where entrust_id = #{entrustId} and cement_code= #{cementCode}")
List<Sample> getByCementCode(@Param("entrustId") Integer entrustId, @Param("cementCode") String cementCode);
@Select("select * from sample where entrust_id = #{entrustId} order by id asc")
@Select("select * from sample where entrust_id = #{entrustId} order by cement_code asc ")
List<Sample> getSampleCheckList(Integer entrustId);
List<SampleSaveDto> getSampleSaveList();
......
......@@ -45,7 +45,7 @@
<select id="exportList" resultType="java.util.HashMap">
SELECT
IF(ISNULL(na.id),'',na.id) as 序号,
(@i:=@i+1) as 序号,
IF(ISNULL(su.name),'',su.name) as 姓名,
IF(ISNULL(su.username),'',su.username) as 账户,
IF(ISNULL(na.statistical),'',na.statistical) as 统计日期,
......@@ -62,6 +62,7 @@
)as 状态
FROM nonstandard_apply na
left join sys_user su on na.user_id = su.id
,(select @i:=0)aa
<include refid="where"/>
order by na.start_time desc
</select>
......
......@@ -170,4 +170,7 @@
where sd.entrust_id = #{entrustId}
group by sd.sample_id,sd.user_id
</select>
</mapper>
......@@ -13,28 +13,18 @@ import lombok.Data;
@ApiModel("委托-样品标签打印Vo")
public class SampleLabelVo {
@ApiModelProperty("样品名")
private String sampleName1;
@ApiModelProperty("平行样编号")
private String parallelCode1;
@ApiModelProperty("样品名")
private String sampleName2;
@ApiModelProperty("平行样编号")
private String parallelCode2;
@ApiModelProperty("样品名")
private String sampleName3;
@ApiModelProperty("平行样编号")
private String parallelCode3;
@ApiModelProperty("样品名")
private String sampleName4;
@ApiModelProperty("平行样编号")
private String parallelCode4;
}
......@@ -180,15 +180,13 @@ public interface IEntrustService extends IService<Entrust> {
*/
BaseResponse<Map<String, Object>> getSampleFlowList(Integer entrustId);
/**
* 查看样品标签
* @param entrustId
* @return
*/
BaseResponse<Map<String, Object>> getSampleLabelList(Integer entrustId);
void exportSampleLabel(Integer entrustId,
String fileName, HttpServletResponse response);
void exportCheckDetail(Integer entrustId,
String fileName, HttpServletResponse response);
......
......@@ -380,6 +380,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
QueryWrapper<Team> teamQueryWrapper = new QueryWrapper<>();
teamQueryWrapper.eq("is_display", 1);
teamQueryWrapper.eq("status", 1);
teamQueryWrapper.orderByAsc("group_id","sort_no");
List<Team> teamList = teamService.list(teamQueryWrapper);
//转化成id为key的map
......
......@@ -5550,23 +5550,241 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
}
/**
* 查看样品标签
* 导出样品标签
* @param entrustId
* @return
*/
public BaseResponse<Map<String, Object>> getSampleLabelList(Integer entrustId) {
if(entrustId == null){
return BaseResponse.errorMsg("参数错误");
public void exportSampleLabel(Integer entrustId,
String fileName, HttpServletResponse response) {
EntrustVo entrustVo = entrustMapper.getDetail(entrustId);
List<Sample> list = sampleMapper.getSampleCheckList(entrustId);
Map<String, List<Sample>> groupByCementCode = list.stream().collect(Collectors.groupingBy(Sample::getCementCode, Collectors.toList()));
//开始填充数据。首先填充表头
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
sheet.setDefaultColumnWidth(20);
XSSFCellStyle style = wb.createCellStyle();
XSSFFont font = wb.createFont();
//水平居中
style.setAlignment(HorizontalAlignment.CENTER);
//垂直居中
style.setVerticalAlignment(VerticalAlignment.CENTER);
//字体加粗
font.setBold(true);
style.setFont(font);
int coloum = 0;
for(Map.Entry<String,List<Sample>> entry : groupByCementCode.entrySet()){
List<Sample> sampleList = entry.getValue();
int rownum = 0; //记录当前插入数据的行数
if(coloum == 0 ){
for(int i = 0; i < sampleList.size(); i++){
rownum = i*4;
XSSFRow row1 = sheet.createRow(rownum);
row1.setHeightInPoints(46.5f);
XSSFCell tempCell_1 = row1.createCell(coloum);
tempCell_1.setCellValue(entrustVo.getProjectName());
tempCell_1.setCellStyle(style);
XSSFRow row2 = sheet.createRow(rownum+1);
row2.setHeightInPoints(19.5f);
XSSFCell tempCell_2 = row2.createCell(coloum);
tempCell_2.setCellValue(entrustVo.getProjectCode());
tempCell_2.setCellStyle(style);
XSSFRow row3 = sheet.createRow(rownum+2);
row3.setHeightInPoints(19.5f);
XSSFCell tempCell_3 = row3.createCell(coloum);
tempCell_3.setCellValue(sampleList.get(i).getName());
tempCell_3.setCellStyle(style);
XSSFRow row4 = sheet.createRow(rownum+3);
row4.setHeightInPoints(19.5f);
XSSFCell tempCell_4 = row4.createCell(coloum);
tempCell_4.setCellValue(sampleList.get(i).getParallelCode());
tempCell_4.setCellStyle(style);
}
}else{
for(int i = 0; i < sampleList.size(); i++){
rownum = i*4;
XSSFRow row1 = sheet.getRow(rownum)==null ? sheet.createRow(rownum): sheet.getRow(rownum);
row1.setHeightInPoints(46.5f);
XSSFCell tempCell_1 = row1.createCell(coloum);
tempCell_1.setCellValue(entrustVo.getProjectName());
tempCell_1.setCellStyle(style);
XSSFRow row2 = sheet.getRow(rownum+1)==null ? sheet.createRow(rownum+1): sheet.getRow(rownum+1);
row2.setHeightInPoints(19.5f);
XSSFCell tempCell_2 = row2.createCell(coloum);
tempCell_2.setCellValue(entrustVo.getProjectCode());
tempCell_2.setCellStyle(style);
XSSFRow row3 = sheet.getRow(rownum+2)==null ? sheet.createRow(rownum+2): sheet.getRow(rownum+2);
row3.setHeightInPoints(19.5f);
XSSFCell tempCell_3 = row3.createCell(coloum);
tempCell_3.setCellValue(sampleList.get(i).getName());
tempCell_3.setCellStyle(style);
XSSFRow row4 = sheet.getRow(rownum+3)==null ? sheet.createRow(rownum+3): sheet.getRow(rownum+3);
row4.setHeightInPoints(19.5f);
XSSFCell tempCell_4 = row4.createCell(coloum);
tempCell_4.setCellValue(sampleList.get(i).getParallelCode());
tempCell_4.setCellStyle(style);
}
}
coloum = coloum+1;
}
Map<String, Object> map = new HashMap<>();
Entrust entrust = entrustMapper.selectById(entrustId);
if (entrust == null) {
return BaseResponse.errorMsg("信息错误");
ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "委托列表" : fileName, wb, response);
}
/**
* 导出-委托单校核详情
* @param entrustId
* @param fileName
* @param response
*/
@Override
public void exportCheckDetail(Integer entrustId,
String fileName, HttpServletResponse response) {
EntrustVo entrustVo = entrustMapper.getDetail(entrustId);
if(entrustVo == null){
return;
}
//1.首先查询所有可见的检测项
QueryWrapper<Team> teamQueryWrapper = new QueryWrapper<>();
teamQueryWrapper.eq("is_display", 1);
teamQueryWrapper.eq("status", 1);
teamQueryWrapper.orderByAsc("group_id","sort_no");
List<Team> teamList = teamService.list(teamQueryWrapper);
//2只看主样 对应的最终结果值
List<Sample> sampleList = sampleMapper.getCheckSampleList(entrustId);
//4.查询所有的派发检测项
QueryWrapper<SampleDistribution> sdqueryWrapper = new QueryWrapper<>();
sdqueryWrapper.eq("entrust_id", entrustId);
sdqueryWrapper.in("sample_id", sampleList.stream().map(Sample::getId).collect(Collectors.toList()));
List<SampleDistribution> sampleDistributions = sampleDistributionService.list(sdqueryWrapper);
//5.分组并统计 检测项id list
Map<Integer, List<SampleDistribution>> groupByTeamId = sampleDistributions.stream().collect(Collectors.groupingBy(SampleDistribution::getTeamId, Collectors.toList()));
//6.开始填充数据。首先填充表头
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
XSSFCellStyle style = wb.createCellStyle();
XSSFFont font = wb.createFont();
//水平居中
style.setAlignment(HorizontalAlignment.CENTER);
//垂直居中
style.setVerticalAlignment(VerticalAlignment.CENTER);
//生成表头
String[] in_fo = {
"委托单号",
"委托单位",
"项目编号",
"项目名称",
"委托人",
"样品名称",
"本所编号",
"是否加急",
};
List<String> infoHeader = Arrays.asList(in_fo);
generatoronsignationWorkbook2(font,style, sheet, infoHeader, teamList.stream().map(Team::getName).collect(Collectors.toList()));
//填充数据,从第二行开始
int rownum = 1;
if (sampleList != null && sampleList.size() > 0) {
for (Sample sample : sampleList) {
XSSFRow row0 = sheet.createRow(rownum++);
// Map<Integer, List<SampleDistribution>> sampleDistribuGroup = groupByEntrustId.get(sample.getId()).stream().collect(Collectors.groupingBy(SampleDistribution::getTeamId, Collectors.toList()));
//处理委托人信息表头
for (int i = 0; i < infoHeader.size(); i++) {
XSSFCell tempCell = row0.createCell(i);
if(infoHeader.get(i).equals("委托单号")){
tempCell.setCellValue(entrustVo.getEntrustCode() == null ? "" : entrustVo.getEntrustCode());
tempCell.setCellStyle(style);
}else if(infoHeader.get(i).equals("委托单位")){
tempCell.setCellValue(entrustVo.getClientName() == null ? "" : entrustVo.getClientName());
tempCell.setCellStyle(style);
}else if(infoHeader.get(i).equals("项目编号")){
tempCell.setCellValue(entrustVo.getProjectCode() == null ? "" : entrustVo.getProjectCode());
tempCell.setCellStyle(style);
}else if(infoHeader.get(i).equals("项目名称")){
tempCell.setCellValue(entrustVo.getProjectName() == null ? "" : entrustVo.getProjectName());
tempCell.setCellStyle(style);
}else if(infoHeader.get(i).equals("委托人")){
tempCell.setCellValue(entrustVo.getUserName() == null ? "" : entrustVo.getUserName());
tempCell.setCellStyle(style);
}else if(infoHeader.get(i).equals("样品名称")){
tempCell.setCellValue(sample.getName() == null ? "" : sample.getName());
tempCell.setCellStyle(style);
}else if(infoHeader.get(i).equals("本所编号")){
tempCell.setCellValue(sample.getParallelCode() == null ? "" : sample.getParallelCode());
tempCell.setCellStyle(style);
}else if(infoHeader.get(i).equals("是否加急")){
tempCell.setCellValue(entrustVo.getIsUrgent() == 1 ? "加急" : "不加急");
tempCell.setCellStyle(style);
}
}
//处理检测项总产值表头
for (int i = infoHeader.size(); i < teamList.size() + infoHeader.size(); i++) {
XSSFCell tempCell = row0.createCell(i);
Team team = teamList.get(i - infoHeader.size());
List<SampleDistribution> sdList = groupByTeamId.get(team.getId());
String lastResult = "";
if(sdList != null && sdList.size()>0){
if(sdList.get(0).getCheckId() != null){
SampleDistributionCheck disCheck = sampleDistributionCheckMapper.selectById(sdList.get(0).getCheckId());
lastResult = disCheck.getLastResult();
}else{
lastResult = sdList.get(0).getDistributionResult();
}
}
tempCell.setCellValue(sdList == null ? "" : lastResult);
tempCell.setCellStyle(style);
}
}
}
ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "委托列表" : fileName, wb, response);
}
private static void generatoronsignationWorkbook2(XSSFFont font ,XSSFCellStyle style, XSSFSheet sheet, List<String> infoHeader, List<String> teamsHeader) {
//委托项的表头
int rownum = 0;
//创建第一行
XSSFRow row0 = sheet.createRow(rownum++);
//处理委托人信息表头
for (int i = 0; i < infoHeader.size(); i++) {
XSSFCell tempCell = row0.createCell(i);
tempCell.setCellValue(infoHeader.get(i));
tempCell.setCellStyle(style);
}
//处理检测项总产值表头
for (int i = infoHeader.size(); i < teamsHeader.size() + infoHeader.size(); i++) {
XSSFCell tempCell = row0.createCell(i);
tempCell.setCellValue(ExcelUtil.applyFontsub(teamsHeader.get(i - infoHeader.size()),font));
tempCell.setCellStyle(style);
}
List<Sample> list = sampleMapper.getSampleCheckList(entrustId);
map.put("list", list);
map.put("entrust", entrust);
return BaseResponse.okData(map);
}
......@@ -5575,4 +5793,12 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
}
......@@ -326,6 +326,9 @@ public class ExcelUtil {
public static XSSFRichTextString applyFontsub(String sub, XSSFFont xxsfFont) {
XSSFRichTextString richString = new XSSFRichTextString();
if (sub.contains("<sup>") || sub.contains("</sup>")) {
sub = sub.replaceAll("<sup>-</sup>", "⁻");
}
if (sub.contains("<sub>") || sub.contains("</sub>")) {
xxsfFont.setTypeOffset(FontFormatting.SS_SUB);
richString.setString(sub.replaceAll("</sub>", "<sub>").replaceAll("<sub>", ""));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment