报告增加打印标志
This commit is contained in:
parent
d95446874f
commit
ca8d0b01b7
@ -62,4 +62,5 @@ public class RegPatMain {
|
||||
private String LisGroupName;
|
||||
private String DstHospCode;
|
||||
private String DstHospName;
|
||||
private String printFlag;
|
||||
}
|
||||
|
||||
@ -13,4 +13,5 @@ public interface RegResultMapper {
|
||||
void deleteRegResultMed(String reportNo);
|
||||
void insertRegReportFile(RegReportFile regReportFile);
|
||||
void deleteRegReportFile(String reportNo);
|
||||
void updateRegPatMain(RegPatMain regPatMain);
|
||||
}
|
||||
|
||||
@ -5,10 +5,12 @@ import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.transitPlatForm.common.core.domain.Result;
|
||||
import com.transitPlatForm.common.core.domain.entity.reg.RegPatMain;
|
||||
import com.transitPlatForm.common.core.domain.entity.reg.RegReportFile;
|
||||
import com.transitPlatForm.interfaceCommon.utils.CommonUtil;
|
||||
import com.transitPlatForm.interfaceCommon.utils.LisUtil;
|
||||
import com.transitPlatForm.transitPF.mapper.RegLisReportMapper;
|
||||
import com.transitPlatForm.transitPF.mapper.RegResultMapper;
|
||||
import com.transitPlatForm.transitPF.service.RegLisReportService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -25,6 +27,8 @@ public class RegLisReportServiceImpl implements RegLisReportService {
|
||||
RegLisReportMapper regLisReportMapper;
|
||||
@Autowired
|
||||
private CommonUtil commonUtil;
|
||||
@Autowired
|
||||
RegResultMapper regResultMapper;
|
||||
|
||||
@Value("${transitInterface.postURL:}")
|
||||
String postURL;
|
||||
@ -33,6 +37,11 @@ public class RegLisReportServiceImpl implements RegLisReportService {
|
||||
public Result printLisReport(String bgdh) {
|
||||
String isGetPdfdata = commonUtil.selectConfigByKey("IS_GET_PDFDATA");
|
||||
if(bgdh == null || bgdh.equals("")) return new Result("-1","报告还未出!");
|
||||
//修改打印标志
|
||||
RegPatMain regPatMain = new RegPatMain();
|
||||
regPatMain.setReportNo(bgdh);
|
||||
regPatMain.setPrintFlag("1");
|
||||
regResultMapper.updateRegPatMain(regPatMain);
|
||||
if("1".equals(isGetPdfdata)){
|
||||
//使用接口去查询数据
|
||||
String jsonStr = "{\"method\":\"pdfData\",\"bgdh\":\""+bgdh+"\"}";
|
||||
@ -41,7 +50,8 @@ public class RegLisReportServiceImpl implements RegLisReportService {
|
||||
return new Result("0","查询成功",LisUtil.isBank(result.getData()));
|
||||
}
|
||||
RegReportFile regReportFile = regLisReportMapper.getRegReportFile(bgdh);
|
||||
return new Result("0","查询成功",regReportFile);
|
||||
if(regReportFile == null) return new Result("-1","没有找到对应的pdf报告信息!");
|
||||
return new Result("0","查询成功",regReportFile.getReport());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -48,87 +48,87 @@ public class RegLisReportUtil {
|
||||
mergeBgdhList.add(bgdh);
|
||||
}
|
||||
//log.info("bgdhBase64List:"+bgdhBase64List);
|
||||
//过滤A4的报告单
|
||||
List<Map<String, Object>> collectA4 = bgdhBase64List.stream().filter(bgdhBase64 -> bgdhBase64.get("pageType").equals("A4")).collect(Collectors.toList());
|
||||
for (Map<String, Object> stringObjectMap : collectA4) {
|
||||
mergeBgdhList.add(stringObjectMap.get("data").toString());
|
||||
}
|
||||
|
||||
//过滤A5格式报告单
|
||||
List<Map<String, Object>> collectA5 = bgdhBase64List.stream().filter(bgdhBase64 -> bgdhBase64.get("pageType").equals("A5")).collect(Collectors.toList());
|
||||
//其中有可能格式虽然是A5,实际尺寸是A4,需要进行处理
|
||||
for (Map<String, Object> stringObjectMap : collectA5) {
|
||||
String bas64Str = stringObjectMap.get("data").toString();
|
||||
if(!PdfPaperConverter.isBase64PdfA4(bas64Str)) continue;
|
||||
try {
|
||||
String base64_A5 = PdfPaperConverter.convertBase64PdfToA5IfConfigured(bas64Str, "A5");
|
||||
stringObjectMap.put("data", base64_A5);
|
||||
} catch (Exception e) {
|
||||
log.error("裁剪pdf出错:",e);
|
||||
return new Result("0","裁剪pdf出错!"+e.getMessage());
|
||||
}
|
||||
}
|
||||
// //过滤A4的报告单
|
||||
// List<Map<String, Object>> collectA4 = bgdhBase64List.stream().filter(bgdhBase64 -> bgdhBase64.get("pageType").equals("A4")).collect(Collectors.toList());
|
||||
// for (Map<String, Object> stringObjectMap : collectA4) {
|
||||
// mergeBgdhList.add(stringObjectMap.get("data").toString());
|
||||
// }
|
||||
//
|
||||
// //过滤A5格式报告单
|
||||
// List<Map<String, Object>> collectA5 = bgdhBase64List.stream().filter(bgdhBase64 -> bgdhBase64.get("pageType").equals("A5")).collect(Collectors.toList());
|
||||
// //其中有可能格式虽然是A5,实际尺寸是A4,需要进行处理
|
||||
// for (Map<String, Object> stringObjectMap : collectA5) {
|
||||
// String bas64Str = stringObjectMap.get("data").toString();
|
||||
// if(!PdfPaperConverter.isBase64PdfA4(bas64Str)) continue;
|
||||
// try {
|
||||
// String base64_A5 = PdfPaperConverter.convertBase64PdfToA5IfConfigured(bas64Str, "A5");
|
||||
// stringObjectMap.put("data", base64_A5);
|
||||
// } catch (Exception e) {
|
||||
// log.error("裁剪pdf出错:",e);
|
||||
// return new Result("0","裁剪pdf出错!"+e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
//log.info("collectA5:"+collectA5);
|
||||
|
||||
//对A5格式的报告单进行排序
|
||||
collectA5.sort(new Comparator<Map<String, Object>>() {
|
||||
@Override
|
||||
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
||||
String brdh1 = o1.get("brdh").toString().trim() ;
|
||||
String brdh2 = o2.get("brdh").toString().trim() ;
|
||||
int i = brdh1.compareTo(brdh2);
|
||||
if(i == 0){
|
||||
Date confirmdt1 = (Date) o1.get("confirmdt");
|
||||
Date confirmdt2 = (Date) o2.get("confirmdt");
|
||||
return confirmdt1.compareTo(confirmdt2);
|
||||
}else{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
});
|
||||
// collectA5.sort(new Comparator<Map<String, Object>>() {
|
||||
// @Override
|
||||
// public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
||||
// String brdh1 = o1.get("brdh").toString().trim() ;
|
||||
// String brdh2 = o2.get("brdh").toString().trim() ;
|
||||
// int i = brdh1.compareTo(brdh2);
|
||||
// if(i == 0){
|
||||
// Date confirmdt1 = (Date) o1.get("confirmdt");
|
||||
// Date confirmdt2 = (Date) o2.get("confirmdt");
|
||||
// return confirmdt1.compareTo(confirmdt2);
|
||||
// }else{
|
||||
// return i;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
//合并A5格式的pdf为A4格式
|
||||
String A5BlankStr = "";
|
||||
for (int i = 0; i < collectA5.size(); i++) {
|
||||
if(i+1 >= collectA5.size()){
|
||||
//代表到了最后一个单数,把这个A5格式的先转换成A4格式的pdf
|
||||
try {
|
||||
A5BlankStr = reportUtil.convertA5ToA4Blank(collectA5.get(i).get("data").toString());
|
||||
//旋转90度,把之前的文件变成pdf
|
||||
String path2 = RuoYiConfig.getProfile() +"/config/static/printPDF/"+UUID.randomUUID().toString()+".pdf";
|
||||
String path3 = RuoYiConfig.getProfile() +"/config/static/printPDF/"+UUID.randomUUID().toString()+".pdf";
|
||||
cn.hutool.core.codec.Base64.decodeToFile(A5BlankStr,new File(path2));
|
||||
reportUtil.rotatePdf90Degrees(path2,path3,1);
|
||||
A5BlankStr = cn.hutool.core.codec.Base64.encode(new File(path3));
|
||||
//删除文件
|
||||
FileUtils.deleteFile(path2);
|
||||
FileUtils.deleteFile(path3);
|
||||
} catch (IOException e) {
|
||||
log.error("把A5格式的pdf增加空白变成A4格式的pdf失败:",e);
|
||||
}
|
||||
mergeBgdhList.add(A5BlankStr);
|
||||
break;
|
||||
}
|
||||
String path = RuoYiConfig.getProfile() +"/config/static/printPDF/"+UUID.randomUUID().toString()+".pdf";
|
||||
String path1 = RuoYiConfig.getProfile() +"/config/static/printPDF/"+UUID.randomUUID().toString()+".pdf";
|
||||
try {
|
||||
reportUtil.mergePdfsHorizontally(collectA5.get(i).get("data").toString(),collectA5.get(i+1).get("data").toString(),path);
|
||||
//旋转90度
|
||||
reportUtil.rotatePdf90Degrees(path,path1,1);
|
||||
File file = new File(path1);
|
||||
mergeBgdhList.add(cn.hutool.core.codec.Base64.encode(file));
|
||||
//删除文件
|
||||
FileUtils.deleteFile(path);
|
||||
FileUtils.deleteFile(path1);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("合并报告单出错:",e);
|
||||
return new Result("-1","合并报告单出错"+e.getMessage());
|
||||
}
|
||||
i=i+1;
|
||||
}
|
||||
// String A5BlankStr = "";
|
||||
// for (int i = 0; i < collectA5.size(); i++) {
|
||||
// if(i+1 >= collectA5.size()){
|
||||
// //代表到了最后一个单数,把这个A5格式的先转换成A4格式的pdf
|
||||
// try {
|
||||
// A5BlankStr = reportUtil.convertA5ToA4Blank(collectA5.get(i).get("data").toString());
|
||||
// //旋转90度,把之前的文件变成pdf
|
||||
// String path2 = RuoYiConfig.getProfile() +"/config/static/printPDF/"+UUID.randomUUID().toString()+".pdf";
|
||||
// String path3 = RuoYiConfig.getProfile() +"/config/static/printPDF/"+UUID.randomUUID().toString()+".pdf";
|
||||
// cn.hutool.core.codec.Base64.decodeToFile(A5BlankStr,new File(path2));
|
||||
// reportUtil.rotatePdf90Degrees(path2,path3,1);
|
||||
// A5BlankStr = cn.hutool.core.codec.Base64.encode(new File(path3));
|
||||
// //删除文件
|
||||
// FileUtils.deleteFile(path2);
|
||||
// FileUtils.deleteFile(path3);
|
||||
// } catch (IOException e) {
|
||||
// log.error("把A5格式的pdf增加空白变成A4格式的pdf失败:",e);
|
||||
// }
|
||||
// mergeBgdhList.add(A5BlankStr);
|
||||
// break;
|
||||
// }
|
||||
// String path = RuoYiConfig.getProfile() +"/config/static/printPDF/"+UUID.randomUUID().toString()+".pdf";
|
||||
// String path1 = RuoYiConfig.getProfile() +"/config/static/printPDF/"+UUID.randomUUID().toString()+".pdf";
|
||||
// try {
|
||||
// reportUtil.mergePdfsHorizontally(collectA5.get(i).get("data").toString(),collectA5.get(i+1).get("data").toString(),path);
|
||||
// //旋转90度
|
||||
// reportUtil.rotatePdf90Degrees(path,path1,1);
|
||||
// File file = new File(path1);
|
||||
// mergeBgdhList.add(cn.hutool.core.codec.Base64.encode(file));
|
||||
// //删除文件
|
||||
// FileUtils.deleteFile(path);
|
||||
// FileUtils.deleteFile(path1);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// log.error("合并报告单出错:",e);
|
||||
// return new Result("-1","合并报告单出错"+e.getMessage());
|
||||
// }
|
||||
// i=i+1;
|
||||
// }
|
||||
|
||||
String encode = "";
|
||||
try {
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
tubecode, tubename, sampletypecode, sampletypename, iser, orderitemcodes,
|
||||
orderitemnames, collectdate, signindate, testdate, reporttime, reportusercode,
|
||||
reportusername, sampletrait, reportkindcode, reportkindname, reportdescrpt,
|
||||
lisgroupcode, lisgroupname, dsthospcode, dsthospname)
|
||||
lisgroupcode, lisgroupname, dsthospcode, dsthospname, printFlag)
|
||||
values( #{ReportNo},
|
||||
#{HospCode},
|
||||
#{HospName},
|
||||
@ -63,7 +63,8 @@
|
||||
#{LisGroupCode},
|
||||
#{LisGroupName},
|
||||
#{DstHospCode},
|
||||
#{DstHospName}
|
||||
#{DstHospName},
|
||||
#{printFlag}
|
||||
|
||||
)
|
||||
</insert>
|
||||
@ -216,4 +217,18 @@
|
||||
delete from reg_report_file where reportno = #{reportno}
|
||||
</delete>
|
||||
|
||||
<update id="updateRegPatMain">
|
||||
update reg_pat_main
|
||||
<set>
|
||||
<if test="PatId != null">patid = #{PatId},</if>
|
||||
<if test="HospCode != null and HospCode != ''">hospcode = #{HospCode},</if>
|
||||
<if test="HospName != null and HospName != ''">hospname = #{HospName},</if>
|
||||
<if test="PatName != null and PatName != ''">patname = #{PatName},</if>
|
||||
<if test="PatSex != null and PatSex !=''">PatSex = #{PatSex},</if>
|
||||
<if test="printFlag != null and printFlag !=''">printFlag = #{printFlag},</if>
|
||||
ReportNo = #{ReportNo}
|
||||
</set>
|
||||
where ReportNo = #{ReportNo}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@ -11,4 +11,9 @@ if not exists(SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'reg_
|
||||
if not exists(SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'reg_TransitSample' AND COLUMN_NAME = 'opername')
|
||||
begin
|
||||
alter table dbo.reg_TransitSample add opername varchar(50)
|
||||
end
|
||||
|
||||
if not exists(SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'reg_pat_main' AND COLUMN_NAME = 'printFlag')
|
||||
begin
|
||||
alter table reg_pat_main add printFlag varchar(2)
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user