parent
5378210b8e
commit
ab35ba6ae9
@ -1,13 +1,76 @@ |
|||||||
package digital.laboratory.platform.imr.controller; |
package digital.laboratory.platform.imr.controller; |
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||||
|
import digital.laboratory.platform.common.core.util.R; |
||||||
|
import digital.laboratory.platform.imr.convert.DrugUsageRecordConvert; |
||||||
|
import digital.laboratory.platform.imr.dto.DrugUsageRecordDTO; |
||||||
|
import digital.laboratory.platform.imr.entity.DrugMaterialInfo; |
||||||
|
import digital.laboratory.platform.imr.entity.DrugUsageRecord; |
||||||
|
import digital.laboratory.platform.imr.mapper.DrugMaterialInfoMapper; |
||||||
|
import digital.laboratory.platform.imr.query.DrugUsageRecordQuery; |
||||||
|
import digital.laboratory.platform.imr.service.DrugUsageRecordService; |
||||||
|
import digital.laboratory.platform.imr.vo.DrugUsageRecordVO; |
||||||
import io.swagger.annotations.Api; |
import io.swagger.annotations.Api; |
||||||
import org.springframework.web.bind.annotation.RequestMapping; |
import io.swagger.annotations.ApiModelProperty; |
||||||
import org.springframework.web.bind.annotation.RestController; |
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.validation.Valid; |
||||||
|
|
||||||
@RestController |
@RestController |
||||||
@RequestMapping("/drugUsageRecord") |
@RequestMapping("/drugUsageRecord") |
||||||
@Api(value = "DrugUsageRecordController", tags = "毒品检材的领用归还记录表相关接口") |
@Api(value = "DrugUsageRecordController", tags = "毒品检材的领用归还记录表相关接口") |
||||||
public class DrugUsageRecordController { |
public class DrugUsageRecordController { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private DrugUsageRecordService drugUsageRecordService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private DrugMaterialInfoMapper drugMaterialInfoMapper; |
||||||
|
|
||||||
|
@ApiOperation("毒品检材领用出库") |
||||||
|
@PostMapping("/outbound") |
||||||
|
public R outbound(@RequestBody @Valid DrugUsageRecordDTO dto) { |
||||||
|
boolean success = drugUsageRecordService.outbound(dto); |
||||||
|
return R.ok(success); |
||||||
|
} |
||||||
|
|
||||||
|
@ApiOperation("毒品检材领用记录分页列表") |
||||||
|
@PostMapping("/page") |
||||||
|
public R<IPage<DrugUsageRecordVO>> page(@RequestBody DrugUsageRecordQuery query) { |
||||||
|
String keywords = query.getKeywords(); |
||||||
|
IPage<DrugUsageRecord> page = drugUsageRecordService.page( |
||||||
|
new Page<>(query.getCurrent(), query.getSize()), |
||||||
|
Wrappers.<DrugUsageRecord>lambdaQuery() |
||||||
|
.and(StrUtil.isNotBlank(keywords), |
||||||
|
wrapper -> wrapper |
||||||
|
.like(DrugUsageRecord::getUsageName, keywords) |
||||||
|
.or() |
||||||
|
.like(DrugUsageRecord::getApplicantName, keywords) |
||||||
|
.or() |
||||||
|
.like(DrugUsageRecord::getUsagePurpose, keywords) |
||||||
|
) |
||||||
|
.ge(query.getStartDate() != null, DrugUsageRecord::getUsageDate, query.getStartDate()) |
||||||
|
.le(query.getEndDate() != null, DrugUsageRecord::getUsageDate, query.getEndDate())); |
||||||
|
IPage<DrugUsageRecordVO> voiPage = new Page<>(); |
||||||
|
BeanUtils.copyProperties(page, voiPage, "records"); |
||||||
|
voiPage.setRecords(DrugUsageRecordConvert.entityToVOList(page.getRecords())); |
||||||
|
return R.ok(voiPage); |
||||||
|
} |
||||||
|
|
||||||
|
@ApiOperation("毒品检材领用记录详情") |
||||||
|
@GetMapping("/details") |
||||||
|
public R details(@RequestParam("id") String id) { |
||||||
|
DrugUsageRecord drugUsageRecord = drugUsageRecordService.getById(id); |
||||||
|
DrugUsageRecordVO drugUsageRecordVO = DrugUsageRecordConvert.entityToVO(drugUsageRecord); |
||||||
|
drugUsageRecordVO.setDrugMaterialInfoVOList(drugMaterialInfoMapper.getDrugMaterialVO(Wrappers.<DrugMaterialInfo>query().in("dm.id", drugUsageRecordVO.getDrugIds()))); |
||||||
|
return R.ok(drugUsageRecordVO); |
||||||
|
} |
||||||
|
|
||||||
} |
} |
||||||
|
@ -0,0 +1,46 @@ |
|||||||
|
package digital.laboratory.platform.imr.convert; |
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil; |
||||||
|
import cn.hutool.core.util.StrUtil; |
||||||
|
import digital.laboratory.platform.imr.dto.DrugUsageRecordDTO; |
||||||
|
import digital.laboratory.platform.imr.entity.DrugUsageRecord; |
||||||
|
import digital.laboratory.platform.imr.vo.DrugUsageRecordVO; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
import java.util.List; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* 毒品检材的领用归还记录表相关 实体类转换 |
||||||
|
*/ |
||||||
|
public class DrugUsageRecordConvert { |
||||||
|
|
||||||
|
public static DrugUsageRecord dtoToEntity(DrugUsageRecordDTO dto) { |
||||||
|
if (dto == null) return null; |
||||||
|
|
||||||
|
DrugUsageRecord drugUsageRecord = new DrugUsageRecord(); |
||||||
|
drugUsageRecord.setDrugId(dto.getDrugIds().stream().collect(Collectors.joining(","))); |
||||||
|
drugUsageRecord.setUsageDate(dto.getUsageDate()); |
||||||
|
drugUsageRecord.setUsagePurpose(dto.getUsagePurpose()); |
||||||
|
return drugUsageRecord; |
||||||
|
} |
||||||
|
|
||||||
|
public static DrugUsageRecordVO entityToVO(DrugUsageRecord entity) { |
||||||
|
if (entity == null) return null; |
||||||
|
|
||||||
|
DrugUsageRecordVO drugUsageRecordVO = new DrugUsageRecordVO(); |
||||||
|
drugUsageRecordVO.setId(entity.getId()); |
||||||
|
drugUsageRecordVO.setDrugIds(StrUtil.split(entity.getDrugId(), StrUtil.COMMA)); |
||||||
|
drugUsageRecordVO.setUsageName(entity.getUsageName()); |
||||||
|
drugUsageRecordVO.setUsageDate(entity.getUsageDate()); |
||||||
|
drugUsageRecordVO.setUsagePurpose(entity.getUsagePurpose()); |
||||||
|
drugUsageRecordVO.setApplicant(entity.getApplicant()); |
||||||
|
drugUsageRecordVO.setApplicantName(entity.getApplicantName()); |
||||||
|
return drugUsageRecordVO; |
||||||
|
} |
||||||
|
|
||||||
|
public static List<DrugUsageRecordVO> entityToVOList(List<DrugUsageRecord> entityList) { |
||||||
|
if (CollUtil.isEmpty(entityList)) return Collections.emptyList(); |
||||||
|
return entityList.stream().map(entity -> entityToVO(entity)).collect(Collectors.toList()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package digital.laboratory.platform.imr.enums; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
|
||||||
|
@Getter |
||||||
|
public enum DrugUsageStatus { |
||||||
|
|
||||||
|
IN_USAGE(1, "领用中"), |
||||||
|
FINISH_USAGE(5, "已归还"), |
||||||
|
; |
||||||
|
|
||||||
|
private final Integer status; |
||||||
|
|
||||||
|
private final String desc; |
||||||
|
|
||||||
|
DrugUsageStatus(Integer status, String desc) { |
||||||
|
this.status = status; |
||||||
|
this.desc = desc; |
||||||
|
} |
||||||
|
|
||||||
|
public static DrugUsageStatus fromStatus(Integer status) { |
||||||
|
for (DrugUsageStatus drugUsageStatus : values()) { |
||||||
|
if (drugUsageStatus.getStatus().equals(status)) { |
||||||
|
return drugUsageStatus; |
||||||
|
} |
||||||
|
} |
||||||
|
throw new IllegalArgumentException("No enum constant with code: " + status); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package digital.laboratory.platform.imr.query; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import digital.laboratory.platform.imr.component.DateUtils; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.time.LocalDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 毒品库领用记录信息查询对象 Query |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "DrugUsageRecordQuery", description = "毒品库领用记录信息查询对象 Query") |
||||||
|
public class DrugUsageRecordQuery { |
||||||
|
|
||||||
|
@ApiModelProperty(value = "分页参数,每页多少条, 默认10") |
||||||
|
private Long size = 10L; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "分页参数, 当前页, 默认1") |
||||||
|
private Long current = 1L; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "关键字,支持 案件名称, 毒品名称") |
||||||
|
private String keywords; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "开始日期") |
||||||
|
@JsonFormat(pattern = DateUtils.yyyy_MM_dd) |
||||||
|
private LocalDate startDate; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "结束日期") |
||||||
|
@JsonFormat(pattern = DateUtils.yyyy_MM_dd) |
||||||
|
private LocalDate endDate; |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package digital.laboratory.platform.imr.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import digital.laboratory.platform.imr.entity.SampleInboundAndOutboundTable; |
||||||
|
import digital.laboratory.platform.imr.entity.SampleOutboundRecord; |
||||||
|
|
||||||
|
/** |
||||||
|
* 服务类 |
||||||
|
* |
||||||
|
* @author Zhang Xiaolong created at 2023-03-21 |
||||||
|
* @describe 服务类 |
||||||
|
*/ |
||||||
|
public interface SampleOutboundRecordService extends IService<SampleOutboundRecord> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
package digital.laboratory.platform.imr.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import digital.laboratory.platform.imr.entity.SampleOutboundRecord; |
||||||
|
import digital.laboratory.platform.imr.mapper.SampleOutboundRecordMapper; |
||||||
|
import digital.laboratory.platform.imr.service.SampleOutboundRecordService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
@Service |
||||||
|
public class SampleOutboundRecordServiceImpl extends ServiceImpl<SampleOutboundRecordMapper, SampleOutboundRecord> implements SampleOutboundRecordService { |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
package digital.laboratory.platform.imr.vo; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import digital.laboratory.platform.imr.component.DateUtils; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty; |
||||||
|
import java.time.LocalDateTime; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 毒品检材的领用归还记录表 VO类 |
||||||
|
* @TableName b_drug_usage_record |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "DrugUsageRecordVO", description = "毒品检材的领用归还记录表 VO类") |
||||||
|
public class DrugUsageRecordVO { |
||||||
|
|
||||||
|
@ApiModelProperty("主键id") |
||||||
|
private String id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 关联领用的毒品id |
||||||
|
*/ |
||||||
|
@ApiModelProperty("关联领用的毒品id") |
||||||
|
private List<String> drugIds; |
||||||
|
|
||||||
|
/** |
||||||
|
* 领用物品名称 |
||||||
|
*/ |
||||||
|
@ApiModelProperty("领用物品名称") |
||||||
|
private String usageName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 领用时间 |
||||||
|
*/ |
||||||
|
@ApiModelProperty("领用时间") |
||||||
|
@JsonFormat(pattern = DateUtils.yyyy_MM_dd_HH_mm_ss, timezone = DateUtils.TIME_ZONE) |
||||||
|
private LocalDateTime usageDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 领用目的 |
||||||
|
*/ |
||||||
|
@ApiModelProperty("领用目的") |
||||||
|
private String usagePurpose; |
||||||
|
|
||||||
|
/** |
||||||
|
* 领用申请人 |
||||||
|
*/ |
||||||
|
@ApiModelProperty("领用申请人id") |
||||||
|
private String applicant; |
||||||
|
|
||||||
|
/** |
||||||
|
* 领用申请人姓名 |
||||||
|
*/ |
||||||
|
@ApiModelProperty("领用申请人姓名") |
||||||
|
private String applicantName; |
||||||
|
|
||||||
|
@ApiModelProperty("领用的毒品检材详情信息列表") |
||||||
|
private List<DrugMaterialInfoVO> drugMaterialInfoVOList; |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
<?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="digital.laboratory.platform.imr.mapper.DrugUsageRecordMapper"> |
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="digital.laboratory.platform.imr.entity.DrugUsageRecord"> |
||||||
|
<id property="id" column="id" jdbcType="VARCHAR"/> |
||||||
|
<result property="drugId" column="drug_id" jdbcType="VARCHAR"/> |
||||||
|
<result property="applicant" column="applicant" jdbcType="VARCHAR"/> |
||||||
|
<result property="applicantName" column="applicant_name" jdbcType="VARCHAR"/> |
||||||
|
<result property="usageDate" column="usage_date" jdbcType="TIMESTAMP"/> |
||||||
|
<result property="usageName" column="usage_name" jdbcType="TIMESTAMP"/> |
||||||
|
<result property="usagePurpose" column="usage_purpose" jdbcType="VARCHAR"/> |
||||||
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
||||||
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
||||||
|
<result property="createBy" column="create_by" jdbcType="VARCHAR"/> |
||||||
|
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/> |
||||||
|
</resultMap> |
||||||
|
|
||||||
|
<sql id="Base_Column_List"> |
||||||
|
id,drug_id,applicant,applicant_name, |
||||||
|
usage_date,usage_purpose, |
||||||
|
create_time,update_time, |
||||||
|
create_by,update_by |
||||||
|
</sql> |
||||||
|
|
||||||
|
<select id="queryUsageRecordVOPage"> |
||||||
|
SELECT |
||||||
|
<include refid="Base_Column_List"/> |
||||||
|
FROM b_drug_usage_record du |
||||||
|
<where> |
||||||
|
<if test="query.keywords != null and query.keywords != ''"> |
||||||
|
OR du.applicant_name = #{query.keywords} |
||||||
|
</if> |
||||||
|
<if test="query.startDate != null"> |
||||||
|
AND du.usage_date >= #{query.startDate} |
||||||
|
</if> |
||||||
|
<if test="query.endDate != null"> |
||||||
|
AND du.usage_date <= #{query.endDate} |
||||||
|
</if> |
||||||
|
</where> |
||||||
|
ORDER BY du.usage_date DESC |
||||||
|
</select> |
||||||
|
</mapper> |
Loading…
Reference in new issue