处方管理

This commit is contained in:
piaobo 2025-07-12 12:15:25 +08:00
parent 1b51ccfb50
commit 60fd054e8b
14 changed files with 1166 additions and 8 deletions

View File

@ -175,14 +175,6 @@
<artifactId>jjwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<!--热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>3.4.0</version>
<optional>true</optional>
</dependency>
<!-- 验证码 -->
<dependency>
<groupId>pro.fessional</groupId>

View File

@ -0,0 +1,105 @@
package com.zhyc.module.biosafety.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.zhyc.module.biosafety.service.ISwPrescriptionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.biosafety.domain.SwPrescription;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 处方Controller
*
* @author ruoyi
* @date 2025-07-11
*/
@RestController
@RequestMapping("/biosafety/prescription")
public class SwPrescriptionController extends BaseController
{
@Autowired
private ISwPrescriptionService swPrescriptionService;
/**
* 查询处方列表
*/
@PreAuthorize("@ss.hasPermi('biosafety:prescription:list')")
@GetMapping("/list")
public TableDataInfo list(SwPrescription swPrescription)
{
startPage();
List<SwPrescription> list = swPrescriptionService.selectSwPrescriptionList(swPrescription);
return getDataTable(list);
}
/**
* 导出处方列表
*/
@PreAuthorize("@ss.hasPermi('biosafety:prescription:export')")
@Log(title = "处方", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SwPrescription swPrescription)
{
List<SwPrescription> list = swPrescriptionService.selectSwPrescriptionList(swPrescription);
ExcelUtil<SwPrescription> util = new ExcelUtil<SwPrescription>(SwPrescription.class);
util.exportExcel(response, list, "处方数据");
}
/**
* 获取处方详细信息
*/
@PreAuthorize("@ss.hasPermi('biosafety:prescription:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(swPrescriptionService.selectSwPrescriptionById(id));
}
/**
* 新增处方
*/
@PreAuthorize("@ss.hasPermi('biosafety:prescription:add')")
@Log(title = "处方", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SwPrescription swPrescription)
{
return toAjax(swPrescriptionService.insertSwPrescription(swPrescription));
}
/**
* 修改处方
*/
@PreAuthorize("@ss.hasPermi('biosafety:prescription:edit')")
@Log(title = "处方", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SwPrescription swPrescription)
{
return toAjax(swPrescriptionService.updateSwPrescription(swPrescription));
}
/**
* 删除处方
*/
@PreAuthorize("@ss.hasPermi('biosafety:prescription:remove')")
@Log(title = "处方", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(swPrescriptionService.deleteSwPrescriptionByIds(ids));
}
}

View File

@ -0,0 +1,105 @@
package com.zhyc.module.biosafety.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.zhyc.module.biosafety.domain.SwUnit;
import com.zhyc.module.biosafety.service.ISwUnitService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 药品单位Controller
*
* @author ruoyi
* @date 2025-07-11
*/
@RestController
@RequestMapping("/biosafety/unit")
public class SwUnitController extends BaseController
{
@Autowired
private ISwUnitService swUnitService;
/**
* 查询药品单位列表
*/
@PreAuthorize("@ss.hasPermi('biosafety:unit:list')")
@GetMapping("/list")
public TableDataInfo list(SwUnit swUnit)
{
startPage();
List<SwUnit> list = swUnitService.selectSwUnitList(swUnit);
return getDataTable(list);
}
/**
* 导出药品单位列表
*/
@PreAuthorize("@ss.hasPermi('biosafety:unit:export')")
@Log(title = "药品单位", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SwUnit swUnit)
{
List<SwUnit> list = swUnitService.selectSwUnitList(swUnit);
ExcelUtil<SwUnit> util = new ExcelUtil<SwUnit>(SwUnit.class);
util.exportExcel(response, list, "药品单位数据");
}
/**
* 获取药品单位详细信息
*/
@PreAuthorize("@ss.hasPermi('biosafety:unit:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(swUnitService.selectSwUnitById(id));
}
/**
* 新增药品单位
*/
@PreAuthorize("@ss.hasPermi('biosafety:unit:add')")
@Log(title = "药品单位", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SwUnit swUnit)
{
return toAjax(swUnitService.insertSwUnit(swUnit));
}
/**
* 修改药品单位
*/
@PreAuthorize("@ss.hasPermi('biosafety:unit:edit')")
@Log(title = "药品单位", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SwUnit swUnit)
{
return toAjax(swUnitService.updateSwUnit(swUnit));
}
/**
* 删除药品单位
*/
@PreAuthorize("@ss.hasPermi('biosafety:unit:remove')")
@Log(title = "药品单位", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(swUnitService.deleteSwUnitByIds(ids));
}
}

View File

@ -0,0 +1,107 @@
package com.zhyc.module.biosafety.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 处方详情对象 sw_pres_detail
*
* @author ruoyi
* @date 2025-07-11
*/
public class SwPresDetail extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 处方id */
private Long persId;
/** 药品id */
@Excel(name = "药品id")
private Integer mediId;
/** 用量 */
@Excel(name = "用量")
private BigDecimal dosage;
/** 单位 */
@Excel(name = "单位")
private Integer unitId;
/** 使用方法 */
@Excel(name = "使用方法")
private Integer usageId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setPersId(Long persId)
{
this.persId = persId;
}
public Long getPersId()
{
return persId;
}
public void setMediId(Integer mediId)
{
this.mediId = mediId;
}
public Integer getMediId()
{
return mediId;
}
public void setDosage(BigDecimal dosage)
{
this.dosage = dosage;
}
public BigDecimal getDosage()
{
return dosage;
}
public void setUnitId(Integer unitId)
{
this.unitId = unitId;
}
public Integer getUnitId()
{
return unitId;
}
public void setUsageId(Integer usageId)
{
this.usageId = usageId;
}
public Integer getUsageId()
{
return usageId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("persId", getPersId())
.append("mediId", getMediId())
.append("dosage", getDosage())
.append("unitId", getUnitId())
.append("usageId", getUsageId())
.toString();
}
}

View File

@ -0,0 +1,131 @@
package com.zhyc.module.biosafety.domain;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 处方对象 sw_prescription
*
* @author ruoyi
* @date 2025-07-11
*/
public class SwPrescription extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 处方编号 */
@Excel(name = "处方编号")
private String no;
/** 处方名称 */
@Excel(name = "处方名称")
private String name;
/** 类型(免疫/保健/驱虫/消毒/疾病治疗) */
@Excel(name = "类型", readConverterExp = "免=疫/保健/驱虫/消毒/疾病治疗")
private Integer persType;
/** 备注 */
@Excel(name = "备注")
private String comment;
/** 状态(0禁用1启用) */
@Excel(name = "状态(0禁用1启用)")
private Integer status;
/** 处方详情信息 */
private List<SwPresDetail> swPresDetailList;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setNo(String no)
{
this.no = no;
}
public String getNo()
{
return no;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setPersType(Integer persType)
{
this.persType = persType;
}
public Integer getPersType()
{
return persType;
}
public void setComment(String comment)
{
this.comment = comment;
}
public String getComment()
{
return comment;
}
public void setStatus(Integer status)
{
this.status = status;
}
public Integer getStatus()
{
return status;
}
public List<SwPresDetail> getSwPresDetailList()
{
return swPresDetailList;
}
public void setSwPresDetailList(List<SwPresDetail> swPresDetailList)
{
this.swPresDetailList = swPresDetailList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("no", getNo())
.append("name", getName())
.append("persType", getPersType())
.append("comment", getComment())
.append("status", getStatus())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("swPresDetailList", getSwPresDetailList())
.toString();
}
}

View File

@ -0,0 +1,29 @@
package com.zhyc.module.biosafety.domain;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 药品单位对象 sw_unit
*
* @author ruoyi
* @date 2025-07-11
*/
@Data
public class SwUnit extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 编号 */
private Long id;
/** 单位 */
@Excel(name = "单位")
private String name;
/* 国际单位*/
private String unit;
}

View File

@ -0,0 +1,87 @@
package com.zhyc.module.biosafety.mapper;
import java.util.List;
import com.zhyc.module.biosafety.domain.SwPrescription;
import com.zhyc.module.biosafety.domain.SwPresDetail;
/**
* 处方Mapper接口
*
* @author ruoyi
* @date 2025-07-11
*/
public interface SwPrescriptionMapper
{
/**
* 查询处方
*
* @param id 处方主键
* @return 处方
*/
public SwPrescription selectSwPrescriptionById(Long id);
/**
* 查询处方列表
*
* @param swPrescription 处方
* @return 处方集合
*/
public List<SwPrescription> selectSwPrescriptionList(SwPrescription swPrescription);
/**
* 新增处方
*
* @param swPrescription 处方
* @return 结果
*/
public int insertSwPrescription(SwPrescription swPrescription);
/**
* 修改处方
*
* @param swPrescription 处方
* @return 结果
*/
public int updateSwPrescription(SwPrescription swPrescription);
/**
* 删除处方
*
* @param id 处方主键
* @return 结果
*/
public int deleteSwPrescriptionById(Long id);
/**
* 批量删除处方
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteSwPrescriptionByIds(Long[] ids);
/**
* 批量删除处方详情
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteSwPresDetailByPersIds(Long[] ids);
/**
* 批量新增处方详情
*
* @param swPresDetailList 处方详情列表
* @return 结果
*/
public int batchSwPresDetail(List<SwPresDetail> swPresDetailList);
/**
* 通过处方主键删除处方详情信息
*
* @param id 处方ID
* @return 结果
*/
public int deleteSwPresDetailByPersId(Long id);
}

View File

@ -0,0 +1,62 @@
package com.zhyc.module.biosafety.mapper;
import com.zhyc.module.biosafety.domain.SwUnit;
import java.util.List;
/**
* 药品单位Mapper接口
*
* @author ruoyi
* @date 2025-07-11
*/
public interface SwUnitMapper
{
/**
* 查询药品单位
*
* @param id 药品单位主键
* @return 药品单位
*/
public SwUnit selectSwUnitById(Long id);
/**
* 查询药品单位列表
*
* @param swUnit 药品单位
* @return 药品单位集合
*/
public List<SwUnit> selectSwUnitList(SwUnit swUnit);
/**
* 新增药品单位
*
* @param swUnit 药品单位
* @return 结果
*/
public int insertSwUnit(SwUnit swUnit);
/**
* 修改药品单位
*
* @param swUnit 药品单位
* @return 结果
*/
public int updateSwUnit(SwUnit swUnit);
/**
* 删除药品单位
*
* @param id 药品单位主键
* @return 结果
*/
public int deleteSwUnitById(Long id);
/**
* 批量删除药品单位
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteSwUnitByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.biosafety.service;
import java.util.List;
import com.zhyc.module.biosafety.domain.SwPrescription;
/**
* 处方Service接口
*
* @author ruoyi
* @date 2025-07-11
*/
public interface ISwPrescriptionService
{
/**
* 查询处方
*
* @param id 处方主键
* @return 处方
*/
public SwPrescription selectSwPrescriptionById(Long id);
/**
* 查询处方列表
*
* @param swPrescription 处方
* @return 处方集合
*/
public List<SwPrescription> selectSwPrescriptionList(SwPrescription swPrescription);
/**
* 新增处方
*
* @param swPrescription 处方
* @return 结果
*/
public int insertSwPrescription(SwPrescription swPrescription);
/**
* 修改处方
*
* @param swPrescription 处方
* @return 结果
*/
public int updateSwPrescription(SwPrescription swPrescription);
/**
* 批量删除处方
*
* @param ids 需要删除的处方主键集合
* @return 结果
*/
public int deleteSwPrescriptionByIds(Long[] ids);
/**
* 删除处方信息
*
* @param id 处方主键
* @return 结果
*/
public int deleteSwPrescriptionById(Long id);
}

View File

@ -0,0 +1,62 @@
package com.zhyc.module.biosafety.service;
import java.util.List;
import com.zhyc.module.biosafety.domain.SwUnit;
/**
* 药品单位Service接口
*
* @author ruoyi
* @date 2025-07-11
*/
public interface ISwUnitService
{
/**
* 查询药品单位
*
* @param id 药品单位主键
* @return 药品单位
*/
public SwUnit selectSwUnitById(Long id);
/**
* 查询药品单位列表
*
* @param swUnit 药品单位
* @return 药品单位集合
*/
public List<SwUnit> selectSwUnitList(SwUnit swUnit);
/**
* 新增药品单位
*
* @param swUnit 药品单位
* @return 结果
*/
public int insertSwUnit(SwUnit swUnit);
/**
* 修改药品单位
*
* @param swUnit 药品单位
* @return 结果
*/
public int updateSwUnit(SwUnit swUnit);
/**
* 批量删除药品单位
*
* @param ids 需要删除的药品单位主键集合
* @return 结果
*/
public int deleteSwUnitByIds(Long[] ids);
/**
* 删除药品单位信息
*
* @param id 药品单位主键
* @return 结果
*/
public int deleteSwUnitById(Long id);
}

View File

@ -0,0 +1,134 @@
package com.zhyc.module.biosafety.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.module.biosafety.domain.SwPresDetail;
import com.zhyc.module.biosafety.domain.SwPrescription;
import com.zhyc.module.biosafety.mapper.SwPrescriptionMapper;
import com.zhyc.module.biosafety.service.ISwPrescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.zhyc.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* 处方Service业务层处理
*
* @author ruoyi
* @date 2025-07-11
*/
@Service
public class SwPrescriptionServiceImpl implements ISwPrescriptionService
{
@Autowired
private SwPrescriptionMapper swPrescriptionMapper;
/**
* 查询处方
*
* @param id 处方主键
* @return 处方
*/
@Override
public SwPrescription selectSwPrescriptionById(Long id)
{
return swPrescriptionMapper.selectSwPrescriptionById(id);
}
/**
* 查询处方列表
*
* @param swPrescription 处方
* @return 处方
*/
@Override
public List<SwPrescription> selectSwPrescriptionList(SwPrescription swPrescription)
{
return swPrescriptionMapper.selectSwPrescriptionList(swPrescription);
}
/**
* 新增处方
*
* @param swPrescription 处方
* @return 结果
*/
@Transactional
@Override
public int insertSwPrescription(SwPrescription swPrescription)
{
swPrescription.setCreateTime(DateUtils.getNowDate());
int rows = swPrescriptionMapper.insertSwPrescription(swPrescription);
insertSwPresDetail(swPrescription);
return rows;
}
/**
* 修改处方
*
* @param swPrescription 处方
* @return 结果
*/
@Transactional
@Override
public int updateSwPrescription(SwPrescription swPrescription)
{
swPrescription.setUpdateTime(DateUtils.getNowDate());
swPrescriptionMapper.deleteSwPresDetailByPersId(swPrescription.getId());
insertSwPresDetail(swPrescription);
return swPrescriptionMapper.updateSwPrescription(swPrescription);
}
/**
* 批量删除处方
*
* @param ids 需要删除的处方主键
* @return 结果
*/
@Transactional
@Override
public int deleteSwPrescriptionByIds(Long[] ids)
{
swPrescriptionMapper.deleteSwPresDetailByPersIds(ids);
return swPrescriptionMapper.deleteSwPrescriptionByIds(ids);
}
/**
* 删除处方信息
*
* @param id 处方主键
* @return 结果
*/
@Transactional
@Override
public int deleteSwPrescriptionById(Long id)
{
swPrescriptionMapper.deleteSwPresDetailByPersId(id);
return swPrescriptionMapper.deleteSwPrescriptionById(id);
}
/**
* 新增处方详情信息
*
* @param swPrescription 处方对象
*/
public void insertSwPresDetail(SwPrescription swPrescription)
{
List<SwPresDetail> swPresDetailList = swPrescription.getSwPresDetailList();
Long id = swPrescription.getId();
if (StringUtils.isNotNull(swPresDetailList))
{
List<SwPresDetail> list = new ArrayList<SwPresDetail>();
for (SwPresDetail swPresDetail : swPresDetailList)
{
swPresDetail.setPersId(id);
list.add(swPresDetail);
}
if (list.size() > 0)
{
swPrescriptionMapper.batchSwPresDetail(list);
}
}
}
}

View File

@ -0,0 +1,95 @@
package com.zhyc.module.biosafety.service.impl;
import java.util.List;
import com.zhyc.module.biosafety.domain.SwUnit;
import com.zhyc.module.biosafety.mapper.SwUnitMapper;
import com.zhyc.module.biosafety.service.ISwUnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 药品单位Service业务层处理
*
* @author ruoyi
* @date 2025-07-11
*/
@Service
public class SwUnitServiceImpl implements ISwUnitService
{
@Autowired
private SwUnitMapper swUnitMapper;
/**
* 查询药品单位
*
* @param id 药品单位主键
* @return 药品单位
*/
@Override
public SwUnit selectSwUnitById(Long id)
{
return swUnitMapper.selectSwUnitById(id);
}
/**
* 查询药品单位列表
*
* @param swUnit 药品单位
* @return 药品单位
*/
@Override
public List<SwUnit> selectSwUnitList(SwUnit swUnit)
{
return swUnitMapper.selectSwUnitList(swUnit);
}
/**
* 新增药品单位
*
* @param swUnit 药品单位
* @return 结果
*/
@Override
public int insertSwUnit(SwUnit swUnit)
{
return swUnitMapper.insertSwUnit(swUnit);
}
/**
* 修改药品单位
*
* @param swUnit 药品单位
* @return 结果
*/
@Override
public int updateSwUnit(SwUnit swUnit)
{
return swUnitMapper.updateSwUnit(swUnit);
}
/**
* 批量删除药品单位
*
* @param ids 需要删除的药品单位主键
* @return 结果
*/
@Override
public int deleteSwUnitByIds(Long[] ids)
{
return swUnitMapper.deleteSwUnitByIds(ids);
}
/**
* 删除药品单位信息
*
* @param id 药品单位主键
* @return 结果
*/
@Override
public int deleteSwUnitById(Long id)
{
return swUnitMapper.deleteSwUnitById(id);
}
}

View File

@ -0,0 +1,129 @@
<?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.zhyc.module.biosafety.mapper.SwPrescriptionMapper">
<resultMap type="SwPrescription" id="SwPrescriptionResult">
<result property="id" column="id" />
<result property="no" column="no" />
<result property="name" column="name" />
<result property="persType" column="pers_type" />
<result property="comment" column="comment" />
<result property="status" column="status" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
</resultMap>
<resultMap id="SwPrescriptionSwPresDetailResult" type="SwPrescription" extends="SwPrescriptionResult">
<collection property="swPresDetailList" ofType="SwPresDetail" column="id" select="selectSwPresDetailList" />
</resultMap>
<resultMap type="SwPresDetail" id="SwPresDetailResult">
<result property="id" column="id" />
<result property="persId" column="pers_id" />
<result property="mediId" column="medi_id" />
<result property="dosage" column="dosage" />
<result property="unitId" column="unit_id" />
<result property="usageId" column="usage_id" />
</resultMap>
<sql id="selectSwPrescriptionVo">
select id, no, name, pers_type, comment, status, update_by, update_time, create_by, create_time from sw_prescription
</sql>
<select id="selectSwPrescriptionList" parameterType="SwPrescription" resultMap="SwPrescriptionResult">
<include refid="selectSwPrescriptionVo"/>
<where>
<if test="no != null and no != ''"> and no like concat('%', #{no}, '%')</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="persType != null "> and pers_type = #{persType}</if>
<if test="status != null "> and status = #{status}</if>
</where>
</select>
<select id="selectSwPrescriptionById" parameterType="Long" resultMap="SwPrescriptionSwPresDetailResult">
select id, no, name, pers_type, comment, status, update_by, update_time, create_by, create_time
from sw_prescription
where id = #{id}
</select>
<select id="selectSwPresDetailList" resultMap="SwPresDetailResult">
select id, pers_id, medi_id, dosage, unit_id, usage_id
from sw_pres_detail
where pers_id = #{pers_id}
</select>
<insert id="insertSwPrescription" parameterType="SwPrescription" useGeneratedKeys="true" keyProperty="id">
insert into sw_prescription
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="no != null">no,</if>
<if test="name != null">name,</if>
<if test="persType != null">pers_type,</if>
<if test="comment != null">comment,</if>
<if test="status != null">status,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="no != null">#{no},</if>
<if test="name != null">#{name},</if>
<if test="persType != null">#{persType},</if>
<if test="comment != null">#{comment},</if>
<if test="status != null">#{status},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateSwPrescription" parameterType="SwPrescription">
update sw_prescription
<trim prefix="SET" suffixOverrides=",">
<if test="no != null">no = #{no},</if>
<if test="name != null">name = #{name},</if>
<if test="persType != null">pers_type = #{persType},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="status != null">status = #{status},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSwPrescriptionById" parameterType="Long">
delete from sw_prescription where id = #{id}
</delete>
<delete id="deleteSwPrescriptionByIds" parameterType="String">
delete from sw_prescription where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteSwPresDetailByPersIds" parameterType="String">
delete from sw_pres_detail where pers_id in
<foreach item="persId" collection="array" open="(" separator="," close=")">
#{persId}
</foreach>
</delete>
<delete id="deleteSwPresDetailByPersId" parameterType="Long">
delete from sw_pres_detail where pers_id = #{persId}
</delete>
<insert id="batchSwPresDetail">
insert into sw_pres_detail( id, pers_id, medi_id, dosage, unit_id, usage_id) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.id}, #{item.persId}, #{item.mediId}, #{item.dosage}, #{item.unitId}, #{item.usageId})
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,59 @@
<?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.zhyc.module.biosafety.mapper.SwUnitMapper">
<resultMap type="SwUnit" id="SwUnitResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="unit" column="unit" />
</resultMap>
<sql id="selectSwUnitVo">
select id, name,unit from sw_unit
</sql>
<select id="selectSwUnitList" parameterType="SwUnit" resultMap="SwUnitResult">
<include refid="selectSwUnitVo"/>
<where>
</where>
</select>
<select id="selectSwUnitById" parameterType="Long" resultMap="SwUnitResult">
<include refid="selectSwUnitVo"/>
where id = #{id}
</select>
<insert id="insertSwUnit" parameterType="SwUnit" useGeneratedKeys="true" keyProperty="id">
insert into sw_unit
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="unit != null">unit,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="unit != null">#{unit},</if>
</trim>
</insert>
<update id="updateSwUnit" parameterType="SwUnit">
update sw_unit
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="unit != null">unit = #{unit},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSwUnitById" parameterType="Long">
delete from sw_unit where id = #{id}
</delete>
<delete id="deleteSwUnitByIds" parameterType="String">
delete from sw_unit where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>