Commit a6943c59 authored by qinhu's avatar qinhu

委托单导出

parent d089079d
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.FileExt;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.ReportDetailVo;
import cn.wise.sc.cement.business.model.SixElementKey;
......@@ -111,8 +112,8 @@ public class ReportController {
beanParams.put("list1", al2o3AndTio2List);
beanParams.put("list2", al2o3SplitTio2List);
WordUtil.writeWordReport(rts.getProjectName() + "(报告).xls", "report.ftl",
beanParams, response);
WordUtil.writeWordReport(rts.getProjectName() + "(报告)", "report.ftl",
beanParams, response, FileExt.EXCL);
}
......
package cn.wise.sc.cement.business.model;
/**
* @description: 文件扩展名
* @author: qh
* @create: 2020-10-16 13:40
**/
public enum FileExt {
//office后缀名
DOC(".doc"),
EXCL(".xls");
private String name;
FileExt(String name){
this.name = name;
}
public String getName() {
return name;
}
}
......@@ -3,7 +3,6 @@ package cn.wise.sc.cement.business.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @description:
* @author: ztw
......@@ -49,13 +48,4 @@ public class SampleDistributionTeamVo {
@ApiModelProperty("扩展名")
private String extName;
}
......@@ -35,6 +35,7 @@ public interface IEntrustService extends IService<Entrust> {
BaseResponse<Entrust> create(EntrustQuery query);
BaseResponse<EntrustVo> getDtail(Integer id);
BaseResponse<EntrustVo> getDetailCapacity(Integer id);
BaseResponse<String> getMaxCementCode();
......
......@@ -378,6 +378,98 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
return BaseResponse.okData(entrustVo);
}
@Override
public BaseResponse<EntrustVo> getDetailCapacity(Integer id) {
if (id == null) {
return BaseResponse.errorMsg("参数错误");
}
EntrustVo entrustVo = entrustMapper.getDetail(id);
if (entrustVo.getStatus() != 0) {
QueryWrapper<Sample> sampleWrapper = new QueryWrapper<>();
sampleWrapper.eq("entrust_id", entrustVo.getId());
sampleWrapper.orderByAsc("id");
List<Sample> sampleList = sampleService.list(sampleWrapper);
List<SampleVo> sampleVoList = new ArrayList<>();
List<SampleVo> sampleHandleVoList = new ArrayList<>();
if (sampleList != null && sampleList.size() > 0) {
for (Sample sample : sampleList) {
SampleVo sampleVo = new SampleVo();
BeanUtils.copyProperties(sample, sampleVo);
String teamIds = sample.getTeamIds();
String teamName = "";
List<SampleDistributionTeamVo> sampleNoDistributionTeamVoList = new ArrayList<>();
if (teamIds != null) {
String[] teamIdS = teamIds.split("、");
for (String teamId : teamIdS) {
TeamVo teamVo = teamMapper.getDetail(Integer.valueOf(teamId));
if (teamVo != null && "1".equals(teamVo.getQualifications())) {
teamName = teamName.equals("") ? teamVo.getName() : (teamName + "、" + teamVo.getName());
SampleDistributionTeamVo distributionTeamVo = new SampleDistributionTeamVo();
distributionTeamVo.setTeamGroupId(teamVo.getGroupId());
distributionTeamVo.setTeamGroupName(teamVo.getGroupName());
distributionTeamVo.setTeamId(teamVo.getId());
distributionTeamVo.setTeamName(teamVo.getName());
sampleNoDistributionTeamVoList.add(distributionTeamVo);
}
}
}
sampleVo.setTeamName(teamName);
//评审人员可以查看所有的检测项内容
List<SampleDistributionTeamVo> sampleDistributionTeamVoList =
distributionMapper.getDistributionTeamList(sample.getId(), null);
if (sampleDistributionTeamVoList != null && sampleDistributionTeamVoList.size() > 0) {
sampleVo.setSampleDistributionTeamVoList(sampleDistributionTeamVoList);
} else {
sampleVo.setSampleDistributionTeamVoList(sampleNoDistributionTeamVoList);
}
sampleVoList.add(sampleVo);
//样品处理列表只展示
if (sample.getIsParallel() == 1) {
if (sample.getCementCode().equals(sample.getParallelCode())) {
sampleHandleVoList.add(sampleVo);
}
} else {
sampleHandleVoList.add(sampleVo);
}
}
}
entrustVo.setSampleList(sampleVoList);//样品列表(展示平行样样品)
entrustVo.setSampleHandleList(sampleHandleVoList);//处理样品列表(不展示平行样样品)
} else {
QueryWrapper<SampleTmp> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("entrust_id", entrustVo.getId());
List<SampleTmp> sampleTmpList = sampleTmpService.list(queryWrapper);
List<SampleTmpVo> sampleTmpVoList = new ArrayList<>();
if (sampleTmpList != null && sampleTmpList.size() > 0) {
for (SampleTmp sampleTmp : sampleTmpList) {
SampleTmpVo sampleTmpVo = new SampleTmpVo();
BeanUtils.copyProperties(sampleTmp, sampleTmpVo);
String teamIds = sampleTmp.getTeamIds();
String teamName = "";
if (teamIds != null) {
String[] teamIdS = teamIds.split("、");
for (String teamId : teamIdS) {
Team team = teamMapper.selectById(Integer.valueOf(teamId));
if (team != null && "1".equals(team.getQualifications())) {
team.getName();
teamName = teamName.equals("") ? team.getName() : (teamName + "、" + team.getName());
}
}
}
sampleTmpVo.setTeamName(teamName);
sampleTmpVoList.add(sampleTmpVo);
}
}
entrustVo.setSampleTmpList(sampleTmpVoList);
}
LoginUser loginUser = userService.getLoginUser();
if (loginUser == null) {
return BaseResponse.errorMsg("请登录账号");
}
userMessageService.checkMessage(loginUser.getId(), id, SysUserMessage.MessageType.ENTRUST);
return BaseResponse.okData(entrustVo);
}
/**
* 详情-基本信息
*
......
package cn.wise.sc.cement.business.util;
import cn.wise.sc.cement.business.model.FileExt;
import freemarker.template.Configuration;
import freemarker.template.Template;
import lombok.extern.slf4j.Slf4j;
......@@ -45,7 +46,8 @@ public class WordUtil {
String templeName,
String templateFileName,
Map<String, Object> beanParams,
HttpServletResponse response) {
HttpServletResponse response,
FileExt fileExt) {
Writer out = null;
File file = null;
try {
......@@ -74,7 +76,7 @@ public class WordUtil {
response.setCharacterEncoding(StandardCharsets.UTF_8.toString());
response.setContentType("application/octet-stream");
templeName = new String((templeName).getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
response.setHeader("Content-Disposition", "attachment;filename=" + templeName + ".xls");
response.setHeader("Content-Disposition", "attachment;filename=" + templeName + fileExt.getName());
outputStream.write(buffer);
outputStream.flush();
outputStream.close();
......
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Version>16.00</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>12650</WindowHeight>
<WindowWidth>22260</WindowWidth>
<WindowTopX>32767</WindowTopX>
<WindowTopY>32767</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="等线" x:CharSet="134" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s63">
<Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
<Font ss:FontName="等线" x:CharSet="134" ss:Size="11" ss:Color="#000000"
ss:Bold="1"/>
</Style>
<Style ss:ID="s64">
<Font ss:FontName="等线" x:CharSet="134" ss:Size="11" ss:Color="#000000"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="8" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="52" ss:DefaultRowHeight="14">
<Column ss:AutoFitWidth="0" ss:Width="116.5"/>
<Column ss:AutoFitWidth="0" ss:Width="117"/>
<Row>
<Cell ss:MergeAcross="1" ss:StyleID="s63"><Data ss:Type="String">中国水泥发展中心物化检测所检测委托单</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">委托单位</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${clientName}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">委托编号</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${entrustCode}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">委托人</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${userName}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">电话</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${userPhone}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">传真</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${userFax}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">项目名称</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${projectName}</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">样品数量</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">${sampleNum}</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>9</ActiveRow>
<ActiveCol>4</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
This source diff could not be displayed because it is too large. You can view the blob instead.
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