Commit a5264cae authored by 竹天卫's avatar 竹天卫

优化

parent 05500501
package cn.wise.sc.cement.business.controller; package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.enumation.FileExt;
import cn.wise.sc.cement.business.model.BaseResponse; import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery; import cn.wise.sc.cement.business.service.IDataStatisticsService;
import cn.wise.sc.cement.business.model.query.*;
import cn.wise.sc.cement.business.model.vo.EntrustVo;
import cn.wise.sc.cement.business.model.vo.SampleDistributionTeamVo;
import cn.wise.sc.cement.business.model.vo.SampleVo;
import cn.wise.sc.cement.business.service.IEntrustService;
import cn.wise.sc.cement.business.util.WordUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -18,10 +11,6 @@ import org.slf4j.LoggerFactory; ...@@ -18,10 +11,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -39,6 +28,58 @@ public class DataStatisticsController { ...@@ -39,6 +28,58 @@ public class DataStatisticsController {
private static final Logger log = LoggerFactory.getLogger("DataStatisticsController"); private static final Logger log = LoggerFactory.getLogger("DataStatisticsController");
@Autowired
private IDataStatisticsService dataStatisticsService;
@ApiOperation(value = "统计概览-重要数值统计")
@GetMapping("/countOverview")
public BaseResponse countOverview() {
try {
return dataStatisticsService.countOverview();
} catch (Exception e) {
log.debug("统计概览-重要数值统计{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "统计概览-检测项数量统计")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "type", value = "类型1:按时间 2:按地区", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "", value = "类型1:按时间 2:按地区", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String")
})
@GetMapping("/countTeamByTime")
public BaseResponse countTeamByTime(Integer type, String startDate, String endDate) {
try {
if(type == 1){
}else if(type == 2){
}else{
}
return dataStatisticsService.countTeamByTime(startDate,endDate);
} catch (Exception e) {
log.debug("统计概览-检测项数量统计{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......
...@@ -149,7 +149,7 @@ public class EntrustController { ...@@ -149,7 +149,7 @@ public class EntrustController {
List<SampleVo> sampleList = new ArrayList<>(entrustVo.getSampleList().size()); List<SampleVo> sampleList = new ArrayList<>(entrustVo.getSampleList().size());
entrustVo.getSampleList() entrustVo.getSampleList()
.stream() .stream()
.filter(arg -> arg.getIsParallel() == 0) .filter(arg -> arg.getCementCode().equals(arg.getParallelCode()) )
.forEach(arg -> { .forEach(arg -> {
List<SampleDistributionTeamVo> teamVoList = arg.getSampleDistributionTeamVoList(); List<SampleDistributionTeamVo> teamVoList = arg.getSampleDistributionTeamVoList();
arg.setTeamName(getTeamName(teamVoList)); arg.setTeamName(getTeamName(teamVoList));
...@@ -157,7 +157,7 @@ public class EntrustController { ...@@ -157,7 +157,7 @@ public class EntrustController {
}); });
beanParams.put("list", sampleList); beanParams.put("list", sampleList);
WordUtil.writeWordReport(entrustVo.getProjectName() + "(委托单)", "entrust2.ftl", WordUtil.writeWordReport(entrustVo.getEntrustCode() +"-"+ entrustVo.getProjectName() + "-委托单", "entrust2.ftl",
beanParams, response, FileExt.DOC); beanParams, response, FileExt.DOC);
} }
......
package cn.wise.sc.cement.business.mapper;
import cn.wise.sc.cement.business.entity.Client;
import cn.wise.sc.cement.business.model.vo.ClientVo;
import cn.wise.sc.cement.business.model.vo.DataStatisticsVo;
import cn.wise.sc.cement.business.model.vo.EntrustVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ztw
* @since 2020-08-07
*/
public interface DataStatisticsMapper {
List<DataStatisticsVo> countTeamByTime(@Param("params") Map<String, Object> params);
List<DataStatisticsVo> countTeamByOrigin(@Param("params") Map<String, Object> params);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wise.sc.cement.business.mapper.DataStatisticsMapper">
<select id="countTeamByTime" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT DATE_FORMAT(sd.create_time,'%Y-%m') as name, count(sd.id) as value
FROM sample_distribution sd
where sd.finish_time is not null
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate}
</if>
group by name
</select>
<select id="countTeamByOrigin" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT s.origin as name, count(sd.id) as value
FROM sample_distribution sd
left join sample s on s.id = sd.sample_id
where sd.finish_time is not null
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate}
</if>
group by s.origin
</select>
</mapper>
package cn.wise.sc.cement.business.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @description:
* @author: ztw
* @create: 2021-01-08
**/
@Data
@ApiModel("数据统计-展示类")
public class DataStatisticsVo {
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("值")
private String value;
}
...@@ -51,4 +51,7 @@ public class SampleTmpVo { ...@@ -51,4 +51,7 @@ public class SampleTmpVo {
@ApiModelProperty("产地") @ApiModelProperty("产地")
private String origin; private String origin;
@ApiModelProperty("平行样编号")
private String parallelCode;
} }
package cn.wise.sc.cement.business.service;
import cn.wise.sc.cement.business.entity.Entrust;
import cn.wise.sc.cement.business.entity.SampleDistribution;
import cn.wise.sc.cement.business.entity.SampleHandleEnclosure;
import cn.wise.sc.cement.business.model.*;
import cn.wise.sc.cement.business.model.query.*;
import cn.wise.sc.cement.business.model.vo.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import io.swagger.models.auth.In;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务类
* </p>
*
* @author ztw
* @since 2021-01-12
*/
public interface IDataStatisticsService {
BaseResponse<Map<String, String>> countOverview();
BaseResponse<List<DataStatisticsVo>> countTeamByTime(String startDate, String endDate);
BaseResponse<List<DataStatisticsVo>> countTeamByOrigin(String startDate, String endDate);
}
...@@ -24,6 +24,7 @@ import org.springframework.stereotype.Service; ...@@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
...@@ -438,10 +439,42 @@ public class CommonServiceImpl { ...@@ -438,10 +439,42 @@ public class CommonServiceImpl {
return countMap; return countMap;
} }
/**
* 根据开始日期和技术日期列出月份
* @param startDate
* @param endDate
* @return
* @throws Exception
*/
public List<String> getMonthBetween(String startDate, String endDate) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");//格式化为年月
Date minDate = null;
Date maxDate = null;
try {
minDate = sdf.parse(startDate);
maxDate = sdf.parse(endDate);
} catch (ParseException e) {
e.printStackTrace();
}
ArrayList<String> result = new ArrayList<String>();
Calendar min = Calendar.getInstance();
Calendar max = Calendar.getInstance();
min.setTime(minDate);
min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1);
max.setTime(maxDate);
max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2);
Calendar curr = min;
while (curr.before(max)) {
result.add(sdf.format(curr.getTime()));
curr.add(Calendar.MONTH, 1);
}
return result;
}
......
package cn.wise.sc.cement.business.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.entity.*;
import cn.wise.sc.cement.business.mapper.*;
import cn.wise.sc.cement.business.model.*;
import cn.wise.sc.cement.business.model.query.*;
import cn.wise.sc.cement.business.model.vo.*;
import cn.wise.sc.cement.business.service.*;
import cn.wise.sc.cement.business.util.CheckCountUtil;
import cn.wise.sc.cement.business.util.ExcelUtil;
import cn.wise.sc.cement.business.util.RedisUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 服务实现类
* </p>
*
* @author ztw
* @since 2021-01-12
*/
@Service
public class DataStatisticsServiceImpl implements IDataStatisticsService {
@Resource
private DataStatisticsMapper dataStatisticsMapper;
@Autowired
private IProjectService projectService;
@Autowired
private IEquipmentService equipmentService;
@Autowired
private ISampleService sampleService;
@Autowired
private IEntrustService entrustService;
@Autowired
private CommonServiceImpl commonService;
/**
* 统计概览-重要数值统计
* @return
*/
@Override
public BaseResponse<Map<String, String>> countOverview() {
Map<String, String> map = new HashMap<>();
//当前进行的项目
QueryWrapper<Project> projectWrapper = new QueryWrapper<>();
projectWrapper.eq("status", 1);
Integer projectCounts = projectService.count(projectWrapper);
map.put("projectCounts", projectCounts.toString());
//实验设备总量
QueryWrapper<Equipment> equipmentWrapper = new QueryWrapper<>();
Integer equipmentCounts = equipmentService.count(equipmentWrapper);
map.put("equipmentCounts", equipmentCounts.toString());
//样品库存总量
QueryWrapper<Sample> sampleWrapper = new QueryWrapper<>();
sampleWrapper.ne("status", 2);
Integer sampleCounts = sampleService.count(sampleWrapper);
map.put("sampleCounts", sampleCounts.toString());
//委托单数量
QueryWrapper<Entrust> entrustWrapper = new QueryWrapper<>();
Integer entrustCounts = entrustService.count(entrustWrapper);
map.put("entrustCounts", entrustCounts.toString());
return BaseResponse.okData(map);
}
/**
* 检测项数量统计-按时间
* @param startDate
* @param endDate
* @return
*/
@Override
public BaseResponse<List<DataStatisticsVo>> countTeamByTime(String startDate, String endDate){
Map<String, String> dateMap = new HashMap<>();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
if(startDate != null || endDate != null){
List<String> dateList = commonService.getMonthBetween(startDate, endDate);
if(dateList != null && dateList.size()>0){
for(int i=0; i<dateList.size(); i++ ){
dateMap.put(dateList.get(i),"0");
}
}
}else{
Date date = new Date();//获取当前时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
for(int i=0; i<12; i++){
date = calendar.getTime();
String dateTime = format.format(date);
dateMap.put(dateTime,"0");
calendar.add(Calendar.MONTH, -1);
}
}
Map<String, Object> params = new HashMap<>();
params.put("startDate", startDate);
params.put("endDate", endDate);
List<DataStatisticsVo> list = dataStatisticsMapper.countTeamByTime(params);
for(DataStatisticsVo vo:list){
if(dateMap.containsKey(vo.getName())){
dateMap.put(vo.getName(), vo.getValue());
}
}
List<DataStatisticsVo> listResult = new ArrayList<>();
for(String key:dateMap.keySet()){
DataStatisticsVo vo = new DataStatisticsVo();
vo.setName(key);
vo.setValue(dateMap.get(key));
listResult.add(vo);
}
return BaseResponse.okData(listResult);
}
/**
* 检测项数量统计-按地区
* @param startDate
* @param endDate
* @return
*/
public BaseResponse<List<DataStatisticsVo>> countTeamByOrigin(String startDate, String endDate){
Map<String, Object> params = new HashMap<>();
params.put("startDate", startDate);
params.put("endDate", endDate);
List<DataStatisticsVo> list = dataStatisticsMapper.countTeamByOrigin(params);
return BaseResponse.okData(list);
}
}
...@@ -283,6 +283,9 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -283,6 +283,9 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
if (query.getSampleTmpList() != null && query.getSampleTmpList().size() > 0) { if (query.getSampleTmpList() != null && query.getSampleTmpList().size() > 0) {
List<SampleTmp> sampleTmpList = new ArrayList<>(); List<SampleTmp> sampleTmpList = new ArrayList<>();
for (SampleTmpQuery sampleTmpQuery : query.getSampleTmpList()) { for (SampleTmpQuery sampleTmpQuery : query.getSampleTmpList()) {
if(StringUtils.isEmpty(sampleTmpQuery.getOrigin())){
return BaseResponse.errorMsg("请选择样品产地");
}
SampleTmp sampleTmp = new SampleTmp(); SampleTmp sampleTmp = new SampleTmp();
BeanUtils.copyProperties(sampleTmpQuery, sampleTmp); BeanUtils.copyProperties(sampleTmpQuery, sampleTmp);
String teamIds = sampleTmpQuery.getTeamIds(); //选择的检测项id集合 String teamIds = sampleTmpQuery.getTeamIds(); //选择的检测项id集合
...@@ -719,15 +722,14 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -719,15 +722,14 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
return BaseResponse.errorMsg("参数错误"); return BaseResponse.errorMsg("参数错误");
} }
EntrustVo entrustVo = entrustMapper.getDetail(id); EntrustVo entrustVo = entrustMapper.getDetail(id);
QueryWrapper<SampleTmp> queryWrapper = new QueryWrapper<>(); List<Sample> sampleList = sampleMapper.getSampleList(entrustVo.getId());
queryWrapper.eq("entrust_id", entrustVo.getId()); List<SampleTmpVo> sampleVoList = new ArrayList<>();
List<SampleTmp> sampleTmpList = sampleTmpService.list(queryWrapper); if (sampleList != null && sampleList.size() > 0) {
List<SampleTmpVo> sampleTmpVoList = new ArrayList<>(); for (Sample sample : sampleList) {
if (sampleTmpList != null && sampleTmpList.size() > 0) { SampleTmpVo sampleVo = new SampleTmpVo();
for (SampleTmp sampleTmp : sampleTmpList) { BeanUtils.copyProperties(sample, sampleVo);
SampleTmpVo sampleTmpVo = new SampleTmpVo(); sampleVo.setParallelCode(sample.getCementCode());
BeanUtils.copyProperties(sampleTmp, sampleTmpVo); String teamIds = sample.getTeamIds();
String teamIds = sampleTmp.getTeamIds();
String teamName = ""; String teamName = "";
if (teamIds != null) { if (teamIds != null) {
String[] teamIdS = teamIds.split("、"); String[] teamIdS = teamIds.split("、");
...@@ -739,11 +741,11 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -739,11 +741,11 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
} }
} }
} }
sampleTmpVo.setTeamName(teamName); sampleVo.setTeamName(teamName);
sampleTmpVoList.add(sampleTmpVo); sampleVoList.add(sampleVo);
} }
} }
entrustVo.setSampleTmpList(sampleTmpVoList); entrustVo.setSampleTmpList(sampleVoList);
//查询报告,如果有上传的委托报告,用户可已进行下载 //查询报告,如果有上传的委托报告,用户可已进行下载
QueryWrapper<EntityEnclosure> wrapper = new QueryWrapper<>(); QueryWrapper<EntityEnclosure> wrapper = new QueryWrapper<>();
wrapper.eq("entity_type", EntityEnclosure.EntityType.ENTRUST_REPORT); wrapper.eq("entity_type", EntityEnclosure.EntityType.ENTRUST_REPORT);
...@@ -996,11 +998,12 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -996,11 +998,12 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
if (StringUtils.isEmpty(query.getProjectType())) { if (StringUtils.isEmpty(query.getProjectType())) {
return BaseResponse.errorMsg("请选择项目类型"); return BaseResponse.errorMsg("请选择项目类型");
} }
//当前平行样编号最大值
String redisMaxCementCode = getMaxCementCode().getData();
if (query.getSampleList() != null && query.getSampleList().size() > 0) { if (query.getSampleList() != null && query.getSampleList().size() > 0) {
List<Sample> sampleList = new ArrayList<>(); List<Sample> sampleList = new ArrayList<>();
String maxCementCode = ""; //最大本所编号对应的平行样编号 String maxCementCode = ""; //最大本所编号对应的平行样编号
//当前平行样编号最大值 Integer integerMaxCode = commonService.getIntegerCode(redisMaxCementCode);
Integer integerMaxCode = commonService.getIntegerCode(getMaxCementCode().getData());
for (SampleQuery sampleQuery : query.getSampleList()) { for (SampleQuery sampleQuery : query.getSampleList()) {
if (StringUtils.isEmpty(sampleQuery.getCementCode())) { if (StringUtils.isEmpty(sampleQuery.getCementCode())) {
return BaseResponse.errorMsg("本所编号不能为空"); return BaseResponse.errorMsg("本所编号不能为空");
...@@ -1119,7 +1122,11 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -1119,7 +1122,11 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
queryWrapper.eq("status", 1); queryWrapper.eq("status", 1);
NormProduction normProduction = iNormProductionService.getOne(queryWrapper); NormProduction normProduction = iNormProductionService.getOne(queryWrapper);
if(normProduction == null){ if(normProduction == null){
return BaseResponse.errorMsg("联系管理员.配置产值信息!"); //评审未通过,删除评审后的样品
sampleMapper.deleteBatchIds(sampleList);
//还原本所编号最大值
redisUtil.setString("maxCementCode", redisMaxCementCode);
return BaseResponse.errorMsg("请配置处理项名称为"+handle.getName()+"的产值信息!");
} }
} }
//消息推送 //消息推送
......
...@@ -186,7 +186,7 @@ public class ExcelUtil { ...@@ -186,7 +186,7 @@ public class ExcelUtil {
if (datas != null && datas.size() > 0) {// 渲染数据 if (datas != null && datas.size() > 0) {// 渲染数据
CellStyle style = workbook.createCellStyle(); CellStyle style = workbook.createCellStyle();
XSSFFont xxsfFont = workbook.createFont(); XSSFFont xxsfFont = workbook.createFont();
xxsfFont.setTypeOffset(FontFormatting.SS_SUB);
for (int index = 0, size = datas.size(); index < size; index++) { for (int index = 0, size = datas.size(); index < size; index++) {
Object[] data = datas.get(index); Object[] data = datas.get(index);
if (data != null && data.length > 0) { if (data != null && data.length > 0) {
...@@ -203,10 +203,18 @@ public class ExcelUtil { ...@@ -203,10 +203,18 @@ public class ExcelUtil {
cell = row.createCell(i); cell = row.createCell(i);
//处理下标 //处理下标
if(value.contains("<sub>") || value.contains("</sub>") ){ if(value.contains("<sub>") || value.contains("</sub>") ){
xxsfFont.setTypeOffset(FontFormatting.SS_SUB);
cell.setCellStyle(style); cell.setCellStyle(style);
XSSFRichTextString richString = new XSSFRichTextString(value.replaceAll("</sub>","<sub>").replaceAll("<sub>","")); XSSFRichTextString richString = new XSSFRichTextString(value.replaceAll("</sub>","<sub>").replaceAll("<sub>",""));
//提取下标位置 //提取下标位置
applyRichStringFont(value, richString, xxsfFont); applyRichStringFontsub(value, richString, xxsfFont);
cell.setCellValue(richString);
}else if(value.contains("<sup>") || value.contains("</sup>")){
xxsfFont.setTypeOffset(FontFormatting.SS_SUPER);
cell.setCellStyle(style);
XSSFRichTextString richString = new XSSFRichTextString(value.replaceAll("</sup>","<sup>").replaceAll("<sup>",""));
//提取下标位置
applyRichStringFontsup(value, richString, xxsfFont);
cell.setCellValue(richString); cell.setCellValue(richString);
}else{ }else{
cell.setCellValue(value); cell.setCellValue(value);
...@@ -226,7 +234,7 @@ public class ExcelUtil { ...@@ -226,7 +234,7 @@ public class ExcelUtil {
return workbook; return workbook;
} }
private static void applyRichStringFont(String sub, XSSFRichTextString richString,XSSFFont xxsfFont) { private static void applyRichStringFontsub(String sub, XSSFRichTextString richString,XSSFFont xxsfFont) {
String[] split = sub.replaceAll("</sub>", "<sub>").split("<sub>"); String[] split = sub.replaceAll("</sub>", "<sub>").split("<sub>");
String it_str = ""; String it_str = "";
for (int i = 1; i < split.length + 1; i++) { for (int i = 1; i < split.length + 1; i++) {
...@@ -240,6 +248,21 @@ public class ExcelUtil { ...@@ -240,6 +248,21 @@ public class ExcelUtil {
} }
} }
private static void applyRichStringFontsup(String sup, XSSFRichTextString richString,XSSFFont xxsfFont) {
String[] split = sup.replaceAll("</sup>", "<sup>").split("<sup>");
String it_str = "";
for (int i = 1; i < split.length + 1; i++) {
if (i % 2 != 0) {
it_str = it_str + split[i - 1];
} else {
richString.applyFont(it_str.length(),(it_str+split[i-1]).length(),xxsfFont);
it_str = it_str + split[i - 1];
}
}
}
public static Workbook getWorkbookNew(String[] headers, List<Object[]> datas) { public static Workbook getWorkbookNew(String[] headers, List<Object[]> datas) {
Workbook workbook = new HSSFWorkbook(); Workbook workbook = new HSSFWorkbook();
......
package cn.wise.sc.cement.business.util; package cn.wise.sc.cement.business.util;
import cn.wise.sc.cement.business.enumation.FileExt; import cn.wise.sc.cement.business.enumation.FileExt;
import cn.wise.sc.cement.business.model.vo.SampleVo;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.Template; import freemarker.template.Template;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -14,6 +15,7 @@ import java.io.IOException; ...@@ -14,6 +15,7 @@ import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Writer; import java.io.Writer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -54,11 +56,9 @@ public class WordUtil { ...@@ -54,11 +56,9 @@ public class WordUtil {
try { try {
configuration.setClassForTemplateLoading(WordUtil.class, FTL_FP); configuration.setClassForTemplateLoading(WordUtil.class, FTL_FP);
Template template = configuration.getTemplate(templateFileName, "UTF-8"); Template template = configuration.getTemplate(templateFileName, "UTF-8");
if (template ==null){ if (template ==null){
System.out.println("==========================\n 报错-================\n"); System.out.println("==========================\n 报错-================\n");
} }
String filePath; String filePath;
filePath = ""; filePath = "";
file = new File(filePath + templeName); file = new File(filePath + templeName);
...@@ -66,7 +66,18 @@ public class WordUtil { ...@@ -66,7 +66,18 @@ public class WordUtil {
FileOutputStream fos = new FileOutputStream(file); FileOutputStream fos = new FileOutputStream(file);
out = new OutputStreamWriter(fos, StandardCharsets.UTF_8); out = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
//变量替换 //变量替换
List<SampleVo> list = (List<SampleVo>)beanParams.get("list");
if(list != null && list.size()>0){
for(SampleVo sampleVo : list){
if(sampleVo.getTeamName().contains("<sub>") || sampleVo.getTeamName().contains("</sub>") ){
String teamName = sampleVo.getTeamName().replaceAll("<sub>","")
.replaceAll("</sub>","");
sampleVo.setTeamName(teamName);
}
}
}
template.process(beanParams, out); template.process(beanParams, out);
FileInputStream in = new FileInputStream(file); FileInputStream in = new FileInputStream(file);
byte[] buffer = new byte[in.available()]; byte[] buffer = new byte[in.available()];
...@@ -80,6 +91,7 @@ public class WordUtil { ...@@ -80,6 +91,7 @@ public class WordUtil {
ServletOutputStream outputStream = response.getOutputStream(); ServletOutputStream outputStream = response.getOutputStream();
response.setCharacterEncoding(StandardCharsets.UTF_8.toString()); response.setCharacterEncoding(StandardCharsets.UTF_8.toString());
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("fileName",templeName+ fileExt.getName() );
templeName = new String((templeName).getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); templeName = new String((templeName).getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
response.setHeader("Content-Disposition", "attachment;filename=" + templeName + fileExt.getName()); response.setHeader("Content-Disposition", "attachment;filename=" + templeName + fileExt.getName());
outputStream.write(buffer); outputStream.write(buffer);
......
...@@ -15,6 +15,7 @@ cn\wise\sc\cement\business\entity\NormProductionStatistics.class ...@@ -15,6 +15,7 @@ cn\wise\sc\cement\business\entity\NormProductionStatistics.class
cn\wise\sc\cement\business\service\ISysPermissionService.class cn\wise\sc\cement\business\service\ISysPermissionService.class
cn\wise\sc\cement\business\mapper\SupplierEnclosureMapper.class cn\wise\sc\cement\business\mapper\SupplierEnclosureMapper.class
cn\wise\sc\cement\business\util\ExcelUtil.class cn\wise\sc\cement\business\util\ExcelUtil.class
cn\wise\sc\cement\business\mapper\DataStatisticsMapper.class
cn\wise\sc\cement\business\controller\PlanTrainingController.class cn\wise\sc\cement\business\controller\PlanTrainingController.class
cn\wise\sc\cement\business\model\WrapperQuery.class cn\wise\sc\cement\business\model\WrapperQuery.class
cn\wise\sc\cement\business\model\vo\SampleVo.class cn\wise\sc\cement\business\model\vo\SampleVo.class
...@@ -30,6 +31,7 @@ cn\wise\sc\cement\business\service\impl\SupplierEnclosureServiceImpl.class ...@@ -30,6 +31,7 @@ cn\wise\sc\cement\business\service\impl\SupplierEnclosureServiceImpl.class
cn\wise\sc\cement\business\config\DateConfig.class cn\wise\sc\cement\business\config\DateConfig.class
cn\wise\sc\cement\business\entity\ConsumablesOut.class cn\wise\sc\cement\business\entity\ConsumablesOut.class
cn\wise\sc\cement\business\service\IPrecipriceService.class cn\wise\sc\cement\business\service\IPrecipriceService.class
cn\wise\sc\cement\business\service\impl\DataStatisticsServiceImpl.class
cn\wise\sc\cement\business\controller\SysApprovalController.class cn\wise\sc\cement\business\controller\SysApprovalController.class
cn\wise\sc\cement\business\util\PageUtil.class cn\wise\sc\cement\business\util\PageUtil.class
cn\wise\sc\cement\business\controller\HistoryArchivesController.class cn\wise\sc\cement\business\controller\HistoryArchivesController.class
...@@ -85,6 +87,7 @@ cn\wise\sc\cement\business\exception\RedisHandleException.class ...@@ -85,6 +87,7 @@ cn\wise\sc\cement\business\exception\RedisHandleException.class
cn\wise\sc\cement\business\model\query\SupplierQuery.class cn\wise\sc\cement\business\model\query\SupplierQuery.class
cn\wise\sc\cement\business\model\query\ProjectQuery.class cn\wise\sc\cement\business\model\query\ProjectQuery.class
cn\wise\sc\cement\business\controller\ClientController.class cn\wise\sc\cement\business\controller\ClientController.class
cn\wise\sc\cement\business\service\IDataStatisticsService.class
cn\wise\sc\cement\business\model\Message.class cn\wise\sc\cement\business\model\Message.class
cn\wise\sc\cement\business\service\impl\NormProductionServiceImpl.class cn\wise\sc\cement\business\service\impl\NormProductionServiceImpl.class
cn\wise\sc\cement\business\mapper\TeamMapper.class cn\wise\sc\cement\business\mapper\TeamMapper.class
...@@ -234,6 +237,7 @@ cn\wise\sc\cement\business\enumation\ProjectRole.class ...@@ -234,6 +237,7 @@ cn\wise\sc\cement\business\enumation\ProjectRole.class
cn\wise\sc\cement\business\service\ISysPostService.class cn\wise\sc\cement\business\service\ISysPostService.class
cn\wise\sc\cement\business\service\impl\CabinetServiceImpl.class cn\wise\sc\cement\business\service\impl\CabinetServiceImpl.class
cn\wise\sc\cement\business\model\vo\EntrustVo.class cn\wise\sc\cement\business\model\vo\EntrustVo.class
cn\wise\sc\cement\business\model\vo\DataStatisticsVo.class
cn\wise\sc\cement\business\service\impl\StandardValueServiceImpl.class cn\wise\sc\cement\business\service\impl\StandardValueServiceImpl.class
cn\wise\sc\cement\business\entity\QualityApply.class cn\wise\sc\cement\business\entity\QualityApply.class
cn\wise\sc\cement\business\entity\Consumables.class cn\wise\sc\cement\business\entity\Consumables.class
......
...@@ -189,6 +189,7 @@ D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cemen ...@@ -189,6 +189,7 @@ D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cemen
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\mapper\SysApprovalMapper.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\mapper\SysApprovalMapper.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\service\IPlanStandardPurchaseService.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\service\IPlanStandardPurchaseService.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\service\ISampleHandleEnclosureService.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\service\ISampleHandleEnclosureService.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\model\vo\DataStatisticsVo.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\service\IEquipmentTestService.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\service\IEquipmentTestService.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\mapper\SysGroupMapper.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\mapper\SysGroupMapper.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\util\weixin\message\send\TextMessage.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\util\weixin\message\send\TextMessage.java
...@@ -237,6 +238,7 @@ D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cemen ...@@ -237,6 +238,7 @@ D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cemen
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\model\vo\InputResultVo.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\model\vo\InputResultVo.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\util\weixin\message\send\VoiceMessage.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\util\weixin\message\send\VoiceMessage.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\controller\PlanEquipmentPurchaseController.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\controller\PlanEquipmentPurchaseController.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\service\IDataStatisticsService.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\controller\MethodController.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\controller\MethodController.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\entity\Standard.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\entity\Standard.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\model\ReportDetailVo.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\model\ReportDetailVo.java
...@@ -317,6 +319,7 @@ D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cemen ...@@ -317,6 +319,7 @@ D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cemen
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\entity\Equipment.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\entity\Equipment.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\mapper\ConsumablesMapper.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\mapper\ConsumablesMapper.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\entity\StandardOut.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\entity\StandardOut.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\service\impl\DataStatisticsServiceImpl.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\util\SerializeUtil.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\util\SerializeUtil.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\service\impl\ConsumablesEnterServiceImpl.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\service\impl\ConsumablesEnterServiceImpl.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\controller\QualityController.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\controller\QualityController.java
...@@ -352,6 +355,7 @@ D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cemen ...@@ -352,6 +355,7 @@ D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cemen
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\entity\NormProductionStatistics.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\entity\NormProductionStatistics.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\model\query\ClientQuery.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\model\query\ClientQuery.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\controller\SysPostController.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\controller\SysPostController.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\mapper\DataStatisticsMapper.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\util\weixin\WeixinInterfaceUtil.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\util\weixin\WeixinInterfaceUtil.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\exception\BusinessExceptionEnum.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\exception\BusinessExceptionEnum.java
D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\entity\PlanEquipmentPurchase.java D:\idea_workspases\tianjin-cement\cement-business\src\main\java\cn\wise\sc\cement\business\entity\PlanEquipmentPurchase.java
......
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