You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
4.8 KiB
112 lines
4.8 KiB
package com.stone.service.impl;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.stone.base.BaseMapper;
|
|
import com.stone.conf.enums.EquipmentCodeEnum;
|
|
import com.stone.conf.exception.BusinessException;
|
|
import com.stone.mapper.intermediate.RenwuIntermediateMapper;
|
|
import com.stone.mapper.intermediate.ReportIntermediateMapper;
|
|
import com.stone.mapper.senior.TemplateMapper;
|
|
import com.stone.mapper.senior.YsjlSeniorMapper;
|
|
import com.stone.model.po.renwu.RenwuIntermediate;
|
|
import com.stone.model.po.report.Report;
|
|
import com.stone.model.po.ysjl.YsjlSenior;
|
|
import com.stone.model.vo.PageVO;
|
|
import com.stone.service.DownloadService;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
/**
|
|
* @author zichen
|
|
*/
|
|
@Service
|
|
public class DownloadServiceImpl implements DownloadService {
|
|
|
|
@Resource
|
|
private YsjlSeniorMapper ysjlSeniorMapper;
|
|
|
|
@Resource
|
|
private TemplateMapper templateMapper;
|
|
|
|
@Resource
|
|
private ReportIntermediateMapper reportIntermediateMapper;
|
|
|
|
@Resource
|
|
private RenwuIntermediateMapper renwuIntermediateMapper;
|
|
|
|
@Resource
|
|
private HttpServletRequest request;
|
|
|
|
@Value("${server.servlet.context-path}")
|
|
private String contextPath;
|
|
|
|
@Override
|
|
public BaseMapper getRepository() {
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 获取18版下载地址
|
|
* 报告打印路径示例:http://192.168.1.130:9093/DYBGManager/JNJY18/pdf/JYBG/2000/2020/3/RD(2020)-0153(6459)压力容器定期检验报告.pdf
|
|
* 合格证打印路径示例:http://192.168.1.130:9093/DYBGManager/JNJY18/pdf/HGZ/2000/2020/3/RD(2020)-0114(6370)压力容器打印合格证.pdf
|
|
* @param id 原始记录主键
|
|
* @param type 类型:JYBG:报告、HGZ:合格证
|
|
* @return
|
|
*/
|
|
@Override
|
|
public PageVO pullSeniorPath(String id, String type) {
|
|
YsjlSenior ysjlSenior = ysjlSeniorMapper.selectByPrimaryKey(id);
|
|
// 0. 判断是否已办结
|
|
if (ObjectUtil.isNotNull(ysjlSenior.getFlowstatus()) && ysjlSenior.getFlowstatus() > 3) {
|
|
throw new BusinessException("报告流程在检验结束时才可以进行打印!");
|
|
}
|
|
// 1. 判断是否交费
|
|
// 需要判断补交状态吗?任务里有个补交状态
|
|
if (!ysjlSenior.getJfState()) {
|
|
throw new BusinessException("交费后才能打印!");
|
|
}
|
|
// 2. 获取打印路径
|
|
String tempName = "";
|
|
if (StrUtil.equals(type, "JYBG")) {
|
|
tempName = templateMapper.selectByPrimaryKey(ysjlSenior.getModelId()).getTempName().replace("记录", "报告");
|
|
} else {
|
|
tempName = EquipmentCodeEnum.valueOf(ysjlSenior.getShebeizhongleidaima()).getName() + "打印合格证";
|
|
}
|
|
return PageVO.builder().data(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + contextPath + "/JNJY18/pdf/" + type + "/"
|
|
+ ysjlSenior.getShebeizhongleidaima() + "/" + ysjlSenior.getCreateTime().getYear() + "/" + ysjlSenior.getCreateTime().getMonthValue()
|
|
+ "/" + ysjlSenior.getBaogaobianhao() + "(" + ysjlSenior.getId() + ")" + tempName + ".pdf").build();
|
|
}
|
|
|
|
/**
|
|
* 获取16版下载地址
|
|
*
|
|
* @param id 检验报告主键
|
|
* @param type 类型:JYBG:报告、HGZ:合格证
|
|
* @return
|
|
*/
|
|
@Override
|
|
public PageVO pullIntermediatePath(String id, String type) {
|
|
Report report = reportIntermediateMapper.selectByPrimaryKey(id);
|
|
if (ObjectUtil.isNotNull(report.getFlowstatus()) && report.getFlowstatus() > 3) {
|
|
throw new BusinessException("报告流程在检验结束时才可以进行打印!");
|
|
}
|
|
RenwuIntermediate renwuIntermediate = RenwuIntermediate.builder().renwuId(report.getRenwuId()).build();
|
|
renwuIntermediate = renwuIntermediateMapper.selectOne(renwuIntermediate);
|
|
// 1. 判断是否交费
|
|
// 需要判断补交状态吗?
|
|
/*if (!renwuIntermediate.getJfstate()) {
|
|
throw new BusinessException("交费后才能打印!");
|
|
}*/
|
|
// 2. 获取打印路径
|
|
String path = "";
|
|
return PageVO.builder().data(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + contextPath + "/JNJY16/pdf/"
|
|
+ report.getShenpiriqi().getYear() + "/" + report.getShebeizhongleidaima() + "/" + type + "/" + (StrUtil.equals(report.getJianyanleibie(), "定期检验") ?
|
|
"dqjy" : "jdjy") + "/" + (StrUtil.equals(type, "HGZ") ? "hgz" : report.getShenpiriqi().getMonthValue()) + "/" + report.getBaogaobianhao() + "-"
|
|
+ report.getAnnalid() + (StrUtil.equals(type, "HGZ") ? "-hgz" : "") + ".pdf").build();
|
|
}
|
|
|
|
}
|
|
|