打印报告单和抗生素功能

This commit is contained in:
jiangs 2025-09-29 10:34:32 +08:00
parent 696a0d8403
commit d6fda2cde8
20 changed files with 534 additions and 36 deletions

View File

@ -0,0 +1,19 @@
package com.czlis.common.core.domain.entity.lis;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LabPurpose {
private String yq;
private String purno;
private String pruna;
private Integer itemcnt;
private String bk;
private BigDecimal price;
}

View File

@ -0,0 +1,17 @@
package com.czlis.common.core.domain.entity.lis;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class XmComp {
private String yq;
private String zhmc;
private String zhlx;
private String xmdh;
private String bz;
private Integer seq;
}

View File

@ -0,0 +1,37 @@
package com.czlis.common.core.domain.entity.lis;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class XmMed {
private String ywdh;
private String ywmc;
private String yf;
private String zjf;
private Integer seq;
private String bz;
private String xyfz;
private BigDecimal nymic;
private BigDecimal zjmic;
private String yfiv;
private String yfim;
private String yydh;
private String multimic;
private String nyfz;
private String medno;
private BigDecimal zjkb;
private BigDecimal nykb;
private BigDecimal zjetest;
private BigDecimal nyetest;
private String ikb;
private String whonet_kb;
private String whonet_mic;
private String whonet_etest;
private String whonet;
}

View File

@ -64,6 +64,12 @@
<artifactId>layout</artifactId>
</dependency>
<!-- 中文转拼音 -->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
</dependency>
</dependencies>

View File

@ -18,6 +18,10 @@ public class BarCodeParam {
private String ksmc;
private Date sqsj;
private String brdh;
private Date jyrq;
private String yq;
private String ybh;
private String hospitalName;

View File

@ -439,12 +439,12 @@ public class JasperReportUtil {
* @param templatePath JRXML模板文件路径
* @param outputPath 生成的PDF文件保存路径
* @param parameters 报表参数
* @param dataSource 报表数据源
* @param connection 报表数据源
* @throws JRException JasperReports异常
*/
public static void generatePdf(String templatePath, String outputPath,
Map<String, Object> parameters,
JRDataSource dataSource) throws Exception {
Connection connection) throws Exception {
// 检查模板文件是否存在 + 是否为文件(避免误传目录路径)
File templateFile = new File(templatePath);
@ -471,7 +471,7 @@ public class JasperReportUtil {
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
// 填充报表数据
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, connection);
// 导出为PDF
JasperExportManager.exportReportToPdfFile(jasperPrint, outputPath);

View File

@ -25,10 +25,11 @@ import net.sf.jasperreports.engine.JREmptyDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Connection;
import java.util.*;
@ -41,6 +42,8 @@ public class ReportUtil {
CommonUtil commonUtil;
@Autowired
BackPaperMapper backPaperMapper;
@Autowired
private DataSource dataSource; // 实际是 DruidDataSource 实例
@Value("${server.port:}")
private String port;
@ -105,20 +108,30 @@ public class ReportUtil {
}
public Result printToPdf(BarCodeParam barCodeParam, String pdfName){
String templatePath = RuoYiConfig.getProfile()+"/templates/barcode_zy.jrxml"; // 模板文件路径
String outputPath = RuoYiConfig.getProfile()+"/config/static/printPDF/"+pdfName+".pdf"; // PDF输出路径(多级目录会自动创建)
log.info("打印输入输出地址:{},{}",templatePath,outputPath);
return printToPdf(templatePath,barCodeParam,pdfName,false);
}
public Result printToPdf(String path,BarCodeParam barCodeParam, String pdfName,boolean base64){
String outputPath = RuoYiConfig.getProfile()+"/config/static/printPDF/"+UUID.randomUUID().toString()+".pdf"; // PDF输出路径(多级目录会自动创建)
log.info("打印输入输出地址:{},{}",path,outputPath);
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(barCodeParam);
try {
JasperReportUtil.generatePdf(templatePath,outputPath,stringObjectMap,new JREmptyDataSource());
Connection connection = dataSource.getConnection();
JasperReportUtil.generatePdf(path,outputPath,stringObjectMap,connection);
} catch (Exception e) {
e.printStackTrace();
log.error("打印条码失败,参数{}",barCodeParam,e);
}
String httpPath = getPrintURL(pdfName);
log.info("传给前端的pdf地址:{}",httpPath);
return new Result("0","打印成功!",httpPath);
if(base64){
File file = new File(outputPath);
return new Result("0","打印成功!",Base64.encode(file));
}else{
return new Result("0","打印成功!",httpPath);
}
}
public String getPrintURL(String pdfName){
@ -294,32 +307,16 @@ public class ReportUtil {
}
}
/*** 获取服务器当前的数据库连接事务对象
* 通过@Qualifier获取实际当前连接事务对象,一般是DynamicDataSource
* 传递服务器获取连接(使用 Spring 工具类确保连接与事务同步)
*/
/*
@Autowired
@Qualifier("dataSource")
private DataSource dataSource;
public void fillReportWithConnection() {
Connection connection = null;
try {
// 从数据源获取连接(自动关联当前事务,避免手动管理事务问题)
connection = DataSourceUtils.getConnection(dataSource);
public Result printReport(Date jyrq,String yq,String ybh,String sqh){
String hospitalName = commonUtil.getComDictNameById("HOS", "1");
BarCodeParam barCodeParam = new BarCodeParam();
barCodeParam.setJyrq(jyrq);
barCodeParam.setYq(yq);
barCodeParam.setYbh(ybh);
barCodeParam.setSqh(sqh);
barCodeParam.setHospitalName(hospitalName);
String templatePath = RuoYiConfig.getProfile()+"/templates/report_ST.jrxml"; // 报告模板文件路径
return printToPdf(templatePath,barCodeParam,UUID.randomUUID().toString(),true);
// 3. 调用 JasperFillManager.fillReport
// InputStream reportStream = ...; // 模板输入流
// Map<String, Object> params = ...; // 报表参数
// JasperPrint jasperPrint = JasperFillManager.fillReport(reportStream, params, connection);
} catch (Exception e) {
log.error("填充报表失败", e);
} finally {
// 4. 释放连接(Spring 环境下需用 DataSourceUtils 关闭,避免事务问题)
if (connection != null) {
DataSourceUtils.releaseConnection(connection, dataSource);
}
}
}*/
}
}

View File

@ -151,4 +151,10 @@ public class LisWorkController extends BaseController {
public Result deleteresult(@RequestBody List<LabResult> labResultlist) {
return labResultService.delLabResultList(labResultlist);
}
@ApiOperation("打印报告")
@GetMapping("/print")
public Result printReport(LabPat labPat) {
return lisWorkService.printReport(labPat);
}
}

View File

@ -0,0 +1,52 @@
package com.czlis.liswork.controller.xtwh;
import com.czlis.common.annotation.Log;
import com.czlis.common.core.domain.Result;
import com.czlis.common.core.domain.entity.lis.XmComp;
import com.czlis.common.enums.BusinessType;
import com.czlis.liswork.service.XmCompService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@Api(tags = "项目组合")
@RestController
@RequestMapping("/xmComp")
@Slf4j
public class XmCompController {
@Resource
private XmCompService xmCompService;
@ApiOperation("查询项目组合")
@GetMapping("query")
public Result getXmCompList(XmComp xmComp) {
return xmCompService.getXmCompList(xmComp);
}
@Log(title = "项目组合",businessType = BusinessType.INSERT)
@ApiOperation("增加项目组合")
@PostMapping("/add")
public Result addXmComp(@RequestBody List<XmComp> xmComp) {
return xmCompService.addXmComp(xmComp);
}
@Log(title = "项目组合",businessType = BusinessType.UPDATE)
@ApiOperation("修改项目组合")
@PostMapping("/update")
public Result updateXmComp(@RequestBody List<XmComp> xmComp) {
return xmCompService.updateXmComp(xmComp);
}
@Log(title = "项目组合",businessType = BusinessType.DELETE)
@ApiOperation("删除项目组合")
@GetMapping("/del")
public Result deleteXmComp(XmComp xmComp) {
return xmCompService.deleteXmComp(xmComp);
}
}

View File

@ -0,0 +1,44 @@
package com.czlis.liswork.controller.xtwh;
import com.czlis.common.annotation.Log;
import com.czlis.common.core.domain.Result;
import com.czlis.common.core.domain.entity.lis.XmMed;
import com.czlis.common.enums.BusinessType;
import com.czlis.liswork.service.XmMedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Api(tags = "常用抗生素")
@RestController
@RequestMapping("/xmMed")
@Slf4j
public class XmMedController {
@Autowired
private XmMedService xmMedService;
@ApiOperation("获取列表数据")
@GetMapping("query")
public Result queryList(XmMed xmMed){
return xmMedService.queryList(xmMed);
}
@Log(title = "常用抗生素",businessType = BusinessType.INSERT)
@ApiOperation("新增常用抗生素")
@PostMapping("/add")
public Result add(@RequestBody List<XmMed> xmMed){
return xmMedService.add(xmMed);
}
@Log(title = "常用抗生素",businessType = BusinessType.DELETE)
@ApiOperation("删除常用抗生素")
@GetMapping("/del")
public Result delete(XmMed xmMed){
return xmMedService.delete(xmMed);
}
}

View File

@ -0,0 +1,15 @@
package com.czlis.liswork.mapper.xtwh;
import com.czlis.common.core.domain.entity.lis.XmComp;
import java.util.List;
public interface XmCompMapper {
List<XmComp> getXmCompList(XmComp xmComp);
void addXmComp(XmComp xmComp);
void updateXmComp(XmComp xmComp);
void deleteXmComp(XmComp xmComp);
}

View File

@ -0,0 +1,15 @@
package com.czlis.liswork.mapper.xtwh;
import com.czlis.common.core.domain.entity.lis.XmMed;
import java.util.List;
public interface XmMedMapper {
List<XmMed> queryList(XmMed xmMed);
void add(XmMed xmMed);
void delete(XmMed xmMed);
void update(XmMed xmMed);
}

View File

@ -20,4 +20,6 @@ public interface LisWorkService {
Result checkUser(String yhdh, String mm);
Result getXmInfo(String yq);
Result getXmVal(String yq,String xmdh);
Result printReport(LabPat labPat);
}

View File

@ -0,0 +1,17 @@
package com.czlis.liswork.service;
import com.czlis.common.core.domain.Result;
import com.czlis.common.core.domain.entity.lis.XmComp;
import java.util.List;
public interface XmCompService {
Result getXmCompList(XmComp xmComp);
Result addXmComp(List<XmComp> xmComp);
Result updateXmComp(List<XmComp> xmComp);
Result deleteXmComp(XmComp xmComp);
}

View File

@ -0,0 +1,14 @@
package com.czlis.liswork.service;
import com.czlis.common.core.domain.Result;
import com.czlis.common.core.domain.entity.lis.XmMed;
import java.util.List;
public interface XmMedService {
Result queryList(XmMed xmMed);
Result add(List<XmMed> xmMed);
Result delete(XmMed xmMed);
}

View File

@ -10,6 +10,7 @@ import com.czlis.common.utils.SecurityUtils;
import com.czlis.common.utils.StringUtils;
import com.czlis.interfaceCommon.utils.CommonUtil;
import com.czlis.interfaceCommon.utils.LoginConfigParamUtil;
import com.czlis.interfaceCommon.utils.ReportUtil;
import com.czlis.liswork.mapper.LisWorkMapper;
@ -33,6 +34,8 @@ public class LisWorkServiceImpl implements LisWorkService {
private InstrMapper instrMapper;
@Autowired
LoginConfigParamUtil loginConfigParamUtil;
@Autowired
ReportUtil reportUtil;
@Override
public Result getXmInfo(String yq) {
@ -44,6 +47,16 @@ public class LisWorkServiceImpl implements LisWorkService {
List<XmVal> xmInfoList =commonUtil.getXmVal(yq,xmdh);
return new Result("0","获取成功!",xmInfoList);
}
@Override
public Result printReport(LabPat labPat) {
Date jyrq = labPat.getJyrq();
String yq = labPat.getYq();
String ybh = labPat.getYbh();
String sqh = labPat.getSqh();
return reportUtil.printReport(jyrq,yq,ybh,sqh);
}
@Override
public Result getInstrdList(Long userId) {

View File

@ -0,0 +1,48 @@
package com.czlis.liswork.service.impl.xtwh;
import com.czlis.common.core.domain.Result;
import com.czlis.common.core.domain.entity.lis.XmComp;
import com.czlis.liswork.mapper.xtwh.XmCompMapper;
import com.czlis.liswork.service.XmCompService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
public class XmCompServiceImpl implements XmCompService {
@Autowired
private XmCompMapper xmCompMapper;
@Override
public Result getXmCompList(XmComp xmComp) {
List<XmComp> xmCompList = xmCompMapper.getXmCompList(xmComp);
return new Result("0","查询成功!",xmCompList);
}
@Override
public Result addXmComp(List<XmComp> xmCompList) {
for (XmComp xmComp : xmCompList) {
xmCompMapper.addXmComp(xmComp);
}
return new Result("0","新增数据成功!");
}
@Override
public Result updateXmComp(List<XmComp> xmCompList) {
for (XmComp xmComp : xmCompList) {
xmCompMapper.updateXmComp(xmComp);
}
return new Result("0","修改成功!");
}
@Override
public Result deleteXmComp(XmComp xmComp) {
xmCompMapper.deleteXmComp(xmComp);
return new Result("0","删除数据成功!");
}
}

View File

@ -0,0 +1,49 @@
package com.czlis.liswork.service.impl.xtwh;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.czlis.common.core.domain.Result;
import com.czlis.common.core.domain.entity.lis.XmMed;
import com.czlis.liswork.mapper.xtwh.XmMedMapper;
import com.czlis.liswork.service.XmMedService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class XmMedServiceImpl implements XmMedService {
@Autowired
XmMedMapper xmMedMapper;
@Override
public Result queryList(XmMed xmMed) {
List<XmMed> xmMedList = xmMedMapper.queryList(xmMed);
return new Result("0","查询成功!",xmMedList);
}
@Override
public Result add(List<XmMed> xmMedList) {
for (XmMed xmMed : xmMedList) {
XmMed med = new XmMed();
med.setYwdh(xmMed.getYwdh());
List<XmMed> xmMeds = xmMedMapper.queryList(med);
if(xmMeds.size() > 0){
xmMedMapper.update(xmMed);
}else{
String py = PinyinUtil.getFirstLetter(xmMed.getYwmc(), "");
xmMed.setZjf(py);
xmMedMapper.add(xmMed);
}
}
return new Result("0","新增成功!");
}
@Override
public Result delete(XmMed xmMed) {
xmMedMapper.delete(xmMed);
return new Result("0","删除数据成功!");
}
}

View File

@ -0,0 +1,46 @@
<?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="com.czlis.liswork.mapper.xtwh.XmCompMapper">
<select id="getXmCompList" resultType="com.czlis.common.core.domain.entity.lis.XmComp">
select * from xm_comp
<where>
<if test="yq != null and yq != ''"> and yq = #{yq}</if>
<if test="zhmc != null and zhmc != ''"> and zhmc = #{zhmc}</if>
<if test="zhlx != null and zhlx != ''"> and zhlx = #{zhlx}</if>
<if test="xmdh != null and xmdh != ''"> and xmdh = #{xmdh}</if>
<if test="bz != null and bz != ''"> and bz = #{bz}</if>
<if test="seq != null"> and seq = #{seq}</if>
</where>
</select>
<insert id="addXmComp">
insert into xm_comp(
yq,zhmc,zhlx,xmdh,bz,seq
)values(
#{yq},#{zhmc},#{zhlx},#{xmdh},#{bz},#{seq}
)
</insert>
<update id="updateXmComp">
update xm_comp
<set>
<if test="zhlx != null and zhlx != ''">zhlx = #{zhlx},</if>
<if test="xmdh != null and xmdh != ''">xmdh = #{xmdh},</if>
<if test="bz != null and bz != ''">bz = #{bz},</if>
<if test="seq != null">seq = #{seq},</if>
yq = #{yq},zhmc = #{zhmc}
</set>
where yq = #{yq},zhmc = #{zhmc} and zhlx = #{zhlx} and xmdh = #{xmdh}
</update>
<delete id="deleteXmComp">
delete from xm_comp where yq = #{yq} and zhmc = #{zhmc} and zhlx = #{zhlx}
<if test="xmdh != null and xmdh != ''"> and xmdh = #{xmdh}</if>
</delete>
</mapper>

View File

@ -0,0 +1,97 @@
<?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="com.czlis.liswork.mapper.xtwh.XmMedMapper">
<select id="queryList" resultType="com.czlis.common.core.domain.entity.lis.XmMed">
select * from xm_med
<where>
<if test="ywdh != null and ywdh != ''"> and ywdh = #{ywdh}</if>
<if test="ywmc != null and ywmc != ''">and ywmc like '%'+#{ywmc}+'%' </if>
<if test="zjf != null and zjf != ''">and zjf like '%'+#{zjf}+'%' </if>
</where>
</select>
<insert id="add">
INSERT INTO xm_med
(
<if test="bz != null and bz !=''">bz,</if>
<if test="xyfz != null and xyfz !=''">xyfz,</if>
<if test="nymic != null ">nymic,</if>
<if test="zjmic != null ">zjmic,</if>
<if test="yfiv != null and yfiv != ''">yfiv,</if>
<if test="yfim != null and yfim != ''">yfim,</if>
<if test="yydh != null and yydh != ''">yydh,</if>
<if test="multimic != null and multimic != ''">multimic,</if>
<if test="nyfz != null and nyfz != ''">nyfz,</if>
<if test="medno != null and medno != ''">medno,</if>
<if test="zjkb != null ">zjkb,</if>
<if test="nykb != null ">nykb,</if>
<if test="zjetest != null ">zjetest,</if>
<if test="nyetest != null ">nyetest,</if>
<if test="ikb != null and ikb != ''">ikb,</if>
<if test="whonet_kb != null and whonet_kb != ''">whonet_kb,</if>
<if test="whonet_mic != null and whonet_mic != ''">whonet_mic,</if>
<if test="whonet_etest != null and whonet_etest != ''">whonet_etest,</if>
<if test="whonet != null and whonet != ''">whonet,</if>
ywdh,ywmc,yf,zjf,seq
)
VALUES(
<if test="bz != null and bz !=''">#{bz},</if>
<if test="xyfz != null and xyfz !=''">#{xyfz},</if>
<if test="nymic != null ">#{nymic},</if>
<if test="zjmic != null ">#{zjmic},</if>
<if test="yfiv != null and yfiv != ''">#{yfiv},</if>
<if test="yfim != null and yfim != ''">#{yfim},</if>
<if test="yydh != null and yydh != ''">#{yydh},</if>
<if test="multimic != null and multimic != ''">#{multimic},</if>
<if test="nyfz != null and nyfz != ''">#{nyfz},</if>
<if test="medno != null and medno != ''">#{medno},</if>
<if test="zjkb != null ">#{zjkb},</if>
<if test="nykb != null ">#{nykb},</if>
<if test="zjetest != null ">#{zjetest},</if>
<if test="nyetest != null ">#{nyetest},</if>
<if test="ikb != null and ikb != ''">#{ikb},</if>
<if test="whonet_kb != null and whonet_kb != ''">#{whonet_kb},</if>
<if test="whonet_mic != null and whonet_mic != ''">#{whonet_mic},</if>
<if test="whonet_etest != null and whonet_etest != ''">#{whonet_etest},</if>
<if test="whonet != null and whonet != ''">#{whonet},</if>
#{ywdh},#{ywmc},#{yf},#{zjf},#{seq}
)
</insert>
<delete id="delete">
delete from xm_med where ywdh = #{ywdh}
</delete>
<update id="update">
update xm_med
<set>
<if test="seq != null">seq = #{seq},</if>
<if test="zjf != null and zjf !=''">zjf = #{zjf},</if>
<if test="yf != null and yf !=''">yf = #{yf},</if>
<if test="ywmc != null and ywmc !=''">ywmc = #{ywmc},</if>
<if test="bz != null and bz !=''">bz = #{bz},</if>
<if test="xyfz != null and xyfz !=''">xyfz=#{xyfz},</if>
<if test="nymic != null ">nymic=#{nymic},</if>
<if test="zjmic != null ">zjmic=#{zjmic},</if>
<if test="yfiv != null and yfiv != ''">yfiv=#{yfiv},</if>
<if test="yfim != null and yfim != ''">yfim=#{yfim},</if>
<if test="yydh != null and yydh != ''">yydh=#{yydh},</if>
<if test="multimic != null and multimic != ''">multimic=#{multimic},</if>
<if test="nyfz != null and nyfz != ''">nyfz=#{nyfz},</if>
<if test="medno != null and medno != ''">medno=#{medno},</if>
<if test="zjkb != null ">zjkb=#{zjkb},</if>
<if test="nykb != null ">nykb=#{nykb},</if>
<if test="zjetest != null ">zjetest=#{zjetest},</if>
<if test="nyetest != null ">nyetest=#{nyetest},</if>
<if test="ikb != null and ikb != ''">ikb=#{ikb},</if>
<if test="whonet_kb != null and whonet_kb != ''">whonet_kb=#{whonet_kb},</if>
<if test="whonet_mic != null and whonet_mic != ''">whonet_mic=#{whonet_mic},</if>
<if test="whonet_etest != null and whonet_etest != ''">whonet_etest=#{whonet_etest},</if>
<if test="whonet != null and whonet != ''">whonet=#{whonet},</if>
ywdh
</set>
where ywdh = #{ywdh}
</update>
</mapper>