添加毒品库实体和service、mapper接口

master
陈江保 7 days ago
parent b51b9c28a2
commit 90af39d012
  1. 108
      src/main/java/digital/laboratory/platform/imr/controller/DrugDepotsController.java
  2. 50
      src/main/java/digital/laboratory/platform/imr/convert/DrugCaseInfoConvert.java
  3. 37
      src/main/java/digital/laboratory/platform/imr/convert/DrugMaterialInfoConvert.java
  4. 3
      src/main/java/digital/laboratory/platform/imr/dto/DepositDTO.java
  5. 55
      src/main/java/digital/laboratory/platform/imr/dto/DrugDepotsDTO.java
  6. 49
      src/main/java/digital/laboratory/platform/imr/dto/DrugMaterialInfoDTO.java
  7. 8
      src/main/java/digital/laboratory/platform/imr/entity/DrugCaseInfo.java
  8. 17
      src/main/java/digital/laboratory/platform/imr/entity/DrugMaterialInfo.java
  9. 2
      src/main/java/digital/laboratory/platform/imr/mapper/DrugCaseInfoMapper.java
  10. 20
      src/main/java/digital/laboratory/platform/imr/mapper/DrugMaterialInfoMapper.java
  11. 39
      src/main/java/digital/laboratory/platform/imr/query/DrugDepotsQuery.java
  12. 80
      src/main/java/digital/laboratory/platform/imr/service/CommonFeignService.java
  13. 23
      src/main/java/digital/laboratory/platform/imr/service/DrugCaseInfoService.java
  14. 59
      src/main/java/digital/laboratory/platform/imr/service/DrugMaterialInfoService.java
  15. 7
      src/main/java/digital/laboratory/platform/imr/service/SampleInboundRecordService.java
  16. 7
      src/main/java/digital/laboratory/platform/imr/service/SampleStorageService.java
  17. 206
      src/main/java/digital/laboratory/platform/imr/service/impl/CommonFeignServiceImpl.java
  18. 90
      src/main/java/digital/laboratory/platform/imr/service/impl/DrugCaseInfoServiceImpl.java
  19. 264
      src/main/java/digital/laboratory/platform/imr/service/impl/DrugMaterialInfoServiceImpl.java
  20. 11
      src/main/java/digital/laboratory/platform/imr/service/impl/SampleInboundRecordServiceImpl.java
  21. 39
      src/main/java/digital/laboratory/platform/imr/service/impl/SamplePutInStorageServiceImpl.java
  22. 11
      src/main/java/digital/laboratory/platform/imr/service/impl/SampleStorageServiceImpl.java
  23. 55
      src/main/java/digital/laboratory/platform/imr/vo/DrugCaseInfoVO.java
  24. 106
      src/main/java/digital/laboratory/platform/imr/vo/DrugMaterialInfoVO.java
  25. 4
      src/main/resources/bootstrap.yml
  26. 46
      src/main/resources/mapper/DrugMaterialInfoMapper.xml

@ -1,10 +1,46 @@
package digital.laboratory.platform.imr.controller; package digital.laboratory.platform.imr.controller;
import cn.hutool.core.collection.CollUtil;
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.constant.CommonConstants;
import digital.laboratory.platform.common.core.util.R;
import digital.laboratory.platform.common.feign.RemoteTemplate2htmlService;
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
import digital.laboratory.platform.imr.convert.DrugCaseInfoConvert;
import digital.laboratory.platform.imr.dto.DrugDepotsDTO;
import digital.laboratory.platform.imr.dto.InRepositoryDTO;
import digital.laboratory.platform.imr.entity.DrugCaseInfo;
import digital.laboratory.platform.imr.entity.DrugMaterialInfo;
import digital.laboratory.platform.imr.query.DrugDepotsQuery;
import digital.laboratory.platform.imr.service.CommonFeignService;
import digital.laboratory.platform.imr.service.DrugCaseInfoService;
import digital.laboratory.platform.imr.service.DrugMaterialInfoService;
import digital.laboratory.platform.imr.vo.DrugCaseInfoVO;
import digital.laboratory.platform.imr.vo.DrugMaterialInfoVO;
import digital.laboratory.platform.imr.vo.OutSampleVO;
import digital.laboratory.platform.sys.entity.Drug;
import digital.laboratory.platform.sys.feign.RemoteOrgService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RestController; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.security.Principal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@ -12,4 +48,72 @@ import org.springframework.web.bind.annotation.RestController;
@Api(value = "DrugDepotsController", tags = "毒品库信息管理接口") @Api(value = "DrugDepotsController", tags = "毒品库信息管理接口")
public class DrugDepotsController { public class DrugDepotsController {
@Resource
private DrugCaseInfoService drugCaseInfoService;
@Resource
private DrugMaterialInfoService drugMaterialInfoService;
@ApiOperation(value = "新增毒品案件信息")
@PostMapping("/drugCase/save")
public R drugCaseSave(@RequestBody @Valid DrugDepotsDTO dto) {
DrugCaseInfo save = drugCaseInfoService.drugCaseSave(dto);
return R.ok(save);
}
@ApiOperation(value = "新增毒品案件信息和毒品检材信息")
@PostMapping("/save")
public R save(@RequestBody @Valid DrugDepotsDTO dto) {
List<DrugMaterialInfoVO> save = drugCaseInfoService.save(dto);
return R.ok(save);
}
@ApiOperation(value = "毒品案件信息和毒品检材信息分页接口")
@PostMapping("/drugMaterial/page")
public R<IPage<DrugMaterialInfoVO>> drugMaterialPage(@RequestBody DrugDepotsQuery query) {
IPage<DrugMaterialInfoVO> page = drugMaterialInfoService.page(query);
return R.ok(page);
}
@ApiOperation(value = "毒品案件信息分页接口")
@PostMapping("/drugCase/page")
public R<IPage<DrugCaseInfoVO>> drugCasePage(@RequestBody DrugDepotsQuery query) {
Page<DrugCaseInfoVO> drugCaseInfoVOPage = drugCaseInfoService.getDrugCaseInfoVOPage(query);
return R.ok(drugCaseInfoVOPage);
}
@ApiOperation("删除毒品检材信息")
@PostMapping("/delete/drugMaterial")
public R deleteDrugMaterial(@RequestBody List<String> ids) {
boolean removeBatchByIds = drugMaterialInfoService.removeBatchByIds(ids);
return removeBatchByIds ? R.ok(true, "删除成功!") : R.failed(false, "删除失败!");
}
@ApiOperation(value = "根据模板生成样本标签的 html, 供 qz 打印使用", notes = "根据模板生成样本标签的 html, 供 qz 打印使用")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "检材标识", required = true, paramType = "path")
})
@GetMapping("/drug_label/{id}")
public String getDrugLabelHtml(@PathVariable(value = "id") String id) {
return drugMaterialInfoService.buildDrugLabelHtml(id);
}
@ApiOperation(value = "根据毒品编号录入仓库(入库)", notes = "根据样本编号录入仓库(入库)")
@PostMapping("/drugMaterialPutInRepository")
public R drugMaterialPutInRepository(@RequestBody List<InRepositoryDTO> sample, HttpServletRequest theHttpServletRequest) {
Principal principal = theHttpServletRequest.getUserPrincipal();
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal();
if (CollUtil.isEmpty(sample)) {
throw new RuntimeException("入库样本编号不能为空");
}
List<OutSampleVO> vo = drugMaterialInfoService.drugMaterialPutInRepository(sample, dlpUser);
if (vo != null) {
return R.ok(vo, "样本入库成功,本次入库样本数为" + sample.size() + "份");
} else {
return R.failed("入库失败");
}
}
} }

@ -0,0 +1,50 @@
package digital.laboratory.platform.imr.convert;
import cn.hutool.core.collection.CollUtil;
import digital.laboratory.platform.imr.dto.DrugDepotsDTO;
import digital.laboratory.platform.imr.entity.DrugCaseInfo;
import digital.laboratory.platform.imr.vo.DrugCaseInfoVO;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* 毒品案件转换类
*/
public class DrugCaseInfoConvert {
public static DrugCaseInfo dtoTOEntity(DrugDepotsDTO dto) {
if (dto == null) {
return null;
}
DrugCaseInfo drugCaseInfo = new DrugCaseInfo();
drugCaseInfo.setId(dto.getId());
drugCaseInfo.setCaseName(dto.getCaseName());
drugCaseInfo.setCaseNo(dto.getCaseNo());
drugCaseInfo.setHandingOverOrg(dto.getHandingOverOrg());
drugCaseInfo.setHandingOverDate(dto.getHandingOverDate());
return drugCaseInfo;
}
public static DrugCaseInfoVO entityToVO(DrugCaseInfo entity) {
if (entity == null) {
return null;
}
DrugCaseInfoVO drugCaseInfoVO = new DrugCaseInfoVO();
drugCaseInfoVO.setId(entity.getId());
drugCaseInfoVO.setCaseName(entity.getCaseName());
drugCaseInfoVO.setCaseNo(entity.getCaseNo());
drugCaseInfoVO.setHandingOverOrg(entity.getHandingOverOrg());
drugCaseInfoVO.setHandingOverDate(entity.getHandingOverDate());
return drugCaseInfoVO;
}
public static List<DrugCaseInfoVO> entityToVOList(List<DrugCaseInfo> entityList) {
if (CollUtil.isEmpty(entityList)) {
return Collections.emptyList();
}
return entityList.stream().map(entity -> entityToVO(entity)).collect(Collectors.toList());
}
}

@ -0,0 +1,37 @@
package digital.laboratory.platform.imr.convert;
import cn.hutool.core.collection.CollUtil;
import digital.laboratory.platform.imr.dto.DrugMaterialInfoDTO;
import digital.laboratory.platform.imr.entity.DrugMaterialInfo;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* 毒品检材信息转换类
*/
public class DrugMaterialInfoConvert {
public static DrugMaterialInfo dtoToEntity(DrugMaterialInfoDTO dto) {
if (dto == null) {
return null;
}
DrugMaterialInfo drugMaterialInfo = new DrugMaterialInfo();
drugMaterialInfo.setId(dto.getId());
drugMaterialInfo.setCaseId(dto.getCaseId());
drugMaterialInfo.setDrugName(dto.getDrugName());
drugMaterialInfo.setMassVolume(dto.getMassVolume());
drugMaterialInfo.setUnit(dto.getUnit());
drugMaterialInfo.setPackageComplete(dto.getPackageComplete());
return drugMaterialInfo;
}
public static List<DrugMaterialInfo> dtoToEntityList(List<DrugMaterialInfoDTO> dtos) {
if (CollUtil.isEmpty(dtos)) {
return Collections.emptyList();
}
return dtos.stream().map(dto -> dtoToEntity(dto)).collect(Collectors.toList());
}
}

@ -58,4 +58,7 @@ public class DepositDTO {
@ApiModelProperty(value="格子状态") @ApiModelProperty(value="格子状态")
private String cellStatus; private String cellStatus;
@ApiModelProperty(value="存放类型,0 系统检材存放 | 1 毒品检材存放")
private Integer type = 0;
} }

@ -0,0 +1,55 @@
package digital.laboratory.platform.imr.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import digital.laboratory.platform.imr.entity.DrugMaterialInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
/**
* 保存毒品库信息中的案件和检材信息DTO类
*/
@Data
@ApiModel(value = "DrugDepotsDTO", description = "保存毒品库信息中的案件和检材信息DTO类")
public class DrugDepotsDTO {
@ApiModelProperty("案件id")
private String id;
/**
* 案事件名称
*/
@ApiModelProperty("案事件名称")
@NotBlank(message = "案事件名称不能为空!")
private String caseName;
/**
* 案件编号
*/
@ApiModelProperty("案件编号")
private String caseNo;
/**
* 送缴单位
*/
@ApiModelProperty("送缴单位")
@NotBlank(message = "送缴单位不能为空!")
private String handingOverOrg;
/**
* 送缴日期
*/
@ApiModelProperty("送缴日期")
@NotNull(message = "送缴日期不能为空!")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate handingOverDate;
@ApiModelProperty("关联的检材列表")
private List<DrugMaterialInfoDTO> drugMaterialInfoDTOList;
}

@ -0,0 +1,49 @@
package digital.laboratory.platform.imr.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 毒品库中的毒品检材信息 保存DTO类
* @TableName b_drug_material_info
*/
@Data
@ApiModel(value = "DrugMaterialInfoDTO", description = "毒品库中的毒品检材信息 保存DTO类")
public class DrugMaterialInfoDTO {
@ApiModelProperty("毒品检材id")
private String id;
/**
* 关联的案件id
*/
@ApiModelProperty("关联的案件id")
private String caseId;
/**
* 毒品检材名称
*/
@ApiModelProperty("毒品检材名称")
private String drugName;
/**
* 质量/体积
*/
@ApiModelProperty("质量/体积")
private String massVolume;
/**
* 质量/体积 单位
*/
@ApiModelProperty("质量/体积 单位")
private String unit;
/**
* 包装是否完整 1 完整 | 0 不完整
*/
@ApiModelProperty("包装是否完整, 1 完整 | 0 不完整")
private Boolean packageComplete;
}

@ -1,5 +1,6 @@
package digital.laboratory.platform.imr.entity; package digital.laboratory.platform.imr.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -7,6 +8,7 @@ import digital.laboratory.platform.common.mybatis.base.BaseEntity;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
@ -16,11 +18,11 @@ import java.util.Date;
*/ */
@TableName(value ="b_drug_case_info") @TableName(value ="b_drug_case_info")
@Data @Data
public class DrugCaseInfo extends BaseEntity implements Serializable { public class DrugCaseInfo extends BaseEntity{
/** /**
* 主键标识 * 主键标识
*/ */
@TableId @TableId(value = "id", type = IdType.ASSIGN_ID)
private String id; private String id;
/** /**
@ -41,7 +43,7 @@ public class DrugCaseInfo extends BaseEntity implements Serializable {
/** /**
* 送缴日期 * 送缴日期
*/ */
private LocalDateTime handingOverDate; private LocalDate handingOverDate;
@TableField(exist = false) @TableField(exist = false)
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

@ -1,5 +1,6 @@
package digital.laboratory.platform.imr.entity; package digital.laboratory.platform.imr.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -14,11 +15,11 @@ import java.io.Serializable;
*/ */
@TableName(value ="b_drug_material_info") @TableName(value ="b_drug_material_info")
@Data @Data
public class DrugMaterialInfo extends BaseEntity implements Serializable { public class DrugMaterialInfo extends BaseEntity {
/** /**
* 主键标识 * 主键标识
*/ */
@TableId @TableId(value = "id", type = IdType.ASSIGN_ID)
private String id; private String id;
/** /**
@ -41,10 +42,20 @@ public class DrugMaterialInfo extends BaseEntity implements Serializable {
*/ */
private String massVolume; private String massVolume;
/**
* 质量/体积 单位
*/
private String unit;
/** /**
* 包装是否完整 1 完整 | 0 不完整 * 包装是否完整 1 完整 | 0 不完整
*/ */
private Integer packageComplete; private Boolean packageComplete;
/**
* 毒品检材状态 0 未入库 | 1 已入库
*/
private Integer status;
@TableField(exist = false) @TableField(exist = false)
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

@ -2,6 +2,7 @@ package digital.laboratory.platform.imr.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import digital.laboratory.platform.imr.entity.DrugCaseInfo; import digital.laboratory.platform.imr.entity.DrugCaseInfo;
import org.apache.ibatis.annotations.Mapper;
/** /**
* @author ChenJiangBao * @author ChenJiangBao
@ -9,6 +10,7 @@ import digital.laboratory.platform.imr.entity.DrugCaseInfo;
* @createDate 2024-11-07 12:04:42 * @createDate 2024-11-07 12:04:42
* @Entity generator.entity.DrugCaseInfo * @Entity generator.entity.DrugCaseInfo
*/ */
@Mapper
public interface DrugCaseInfoMapper extends BaseMapper<DrugCaseInfo> { public interface DrugCaseInfoMapper extends BaseMapper<DrugCaseInfo> {
} }

@ -1,7 +1,16 @@
package digital.laboratory.platform.imr.mapper; package digital.laboratory.platform.imr.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import digital.laboratory.platform.imr.entity.DrugMaterialInfo; import digital.laboratory.platform.imr.entity.DrugMaterialInfo;
import digital.laboratory.platform.imr.query.DrugDepotsQuery;
import digital.laboratory.platform.imr.vo.DrugMaterialInfoVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @author ChenJiangBao * @author ChenJiangBao
@ -9,7 +18,18 @@ import digital.laboratory.platform.imr.entity.DrugMaterialInfo;
* @createDate 2024-11-07 12:04:42 * @createDate 2024-11-07 12:04:42
* @Entity generator.entity.DrugMaterialInfo * @Entity generator.entity.DrugMaterialInfo
*/ */
@Mapper
public interface DrugMaterialInfoMapper extends BaseMapper<DrugMaterialInfo> { public interface DrugMaterialInfoMapper extends BaseMapper<DrugMaterialInfo> {
/**
* 分页查询毒品库中的毒品检材信息VO列表
* @param page
* @param query
* @return
*/
IPage<DrugMaterialInfoVO> getDrugMaterialVOPage(IPage<DrugMaterialInfoVO> page, @Param("query") DrugDepotsQuery query);
List<DrugMaterialInfoVO> getDrugMaterialVO(@Param(Constants.WRAPPER) Wrapper<DrugMaterialInfo> qw);
} }

@ -0,0 +1,39 @@
package digital.laboratory.platform.imr.query;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
/**
* 毒品库信息查询对象 Query
*/
@Data
@ApiModel(value = "DrugDepotsQuery", description = "毒品库信息查询对象 Query")
public class DrugDepotsQuery {
@ApiModelProperty(value = "分页参数,每页多少条, 默认10")
private Long size = 10L;
@ApiModelProperty(value = "分页参数, 当前页, 默认1")
private Long current = 1L;
@ApiModelProperty(value = "关键字,支持 案件名称, 毒品名称")
private String keywords;
@ApiModelProperty(value = "送缴单位id查询")
private String orgId;
@ApiModelProperty(value = "案件id查询")
private String caseId;
@ApiModelProperty(value = "开始日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate startDate;
@ApiModelProperty(value = "结束日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate endDate;
}

@ -0,0 +1,80 @@
package digital.laboratory.platform.imr.service;
import com.deepoove.poi.XWPFTemplate;
import digital.laboratory.platform.sys.entity.SysOrg;
import digital.laboratory.platform.sys.entity.SysUser;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.Map;
/**
* 通用的feign请求封装接口服务层接口
*/
public interface CommonFeignService {
/**
* 远程调用获取用户机构
* @param orgId
* @return
*/
SysOrg remoteGetSysOrg(String orgId);
/**
* 远程调用获取用户信息
* @param username
* @return
*/
SysUser remoteGetUserByUsername(String username);
/**
* 远程调用获取用户信息
* @param userId
* @return
*/
SysUser remoteGetUserById(String userId);
/**
* 远程调用生成word,并转成pdf
*
* @param template
* @param originalFilename 文件名
* @param savePath 保存到minio路径
* @return
* @throws Exception
*/
boolean remoteGenerateWord2PDF(XWPFTemplate template, String originalFilename, String savePath) throws Exception;
/**
* 远程调用根据文件路径获取文件
* @param filePath minio上的文件路径
* @return
* @throws Exception
*/
ByteArrayInputStream remoteGetFile(String filePath) throws Exception;
/**
* 远程调用根据文件路径获取文件
* @param filePath minio上的文件路径
* @param fileName 名称
* @param httpServletResponse
* @throws Exception
*/
void remoteGetFile(String filePath, String fileName, HttpServletResponse httpServletResponse) throws Exception;
/**
* 远程调用根据文件路径获取文件列表
* @param filePath minio上的文件路径
*/
List<String> remoteGetFileList(String filePath);
/**
* 远程调用-上传文件
* @param file 上传的文件对象
* @param path 上传到minio的位置
* @return
*/
Map<String, String> remoteUploadFile(MultipartFile file, String path);
}

@ -1,7 +1,14 @@
package digital.laboratory.platform.imr.service; package digital.laboratory.platform.imr.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import digital.laboratory.platform.imr.dto.DrugDepotsDTO;
import digital.laboratory.platform.imr.entity.DrugCaseInfo; import digital.laboratory.platform.imr.entity.DrugCaseInfo;
import digital.laboratory.platform.imr.query.DrugDepotsQuery;
import digital.laboratory.platform.imr.vo.DrugCaseInfoVO;
import digital.laboratory.platform.imr.vo.DrugMaterialInfoVO;
import java.util.List;
/** /**
* @author ChenJiangBao * @author ChenJiangBao
@ -10,4 +17,20 @@ import digital.laboratory.platform.imr.entity.DrugCaseInfo;
*/ */
public interface DrugCaseInfoService extends IService<DrugCaseInfo> { public interface DrugCaseInfoService extends IService<DrugCaseInfo> {
/**
* 保存案件实体信息和毒品检材信息
*
* @param dto
* @return
*/
List<DrugMaterialInfoVO> save(DrugDepotsDTO dto);
/**
* 分页接口
* @param query
* @return
*/
Page<DrugCaseInfoVO> getDrugCaseInfoVOPage(DrugDepotsQuery query);
DrugCaseInfo drugCaseSave(DrugDepotsDTO dto);
} }

@ -1,7 +1,18 @@
package digital.laboratory.platform.imr.service; package digital.laboratory.platform.imr.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
import digital.laboratory.platform.imr.dto.InRepositoryDTO;
import digital.laboratory.platform.imr.entity.DrugCaseInfo;
import digital.laboratory.platform.imr.entity.DrugMaterialInfo; import digital.laboratory.platform.imr.entity.DrugMaterialInfo;
import digital.laboratory.platform.imr.entity.SampleStorage;
import digital.laboratory.platform.imr.query.DrugDepotsQuery;
import digital.laboratory.platform.imr.vo.DrugMaterialInfoVO;
import digital.laboratory.platform.imr.vo.OutSampleVO;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* @author ChenJiangBao * @author ChenJiangBao
@ -10,4 +21,52 @@ import digital.laboratory.platform.imr.entity.DrugMaterialInfo;
*/ */
public interface DrugMaterialInfoService extends IService<DrugMaterialInfo> { public interface DrugMaterialInfoService extends IService<DrugMaterialInfo> {
/**
* 批量生成毒品检材编号
* JC5201010020240001
* JC 标识是检材 520100 地市行政编码 00 预留给派出所 2024 年份 0001 流水号
* @param drugCaseInfo 案件信息
* @param number
* @return
*/
List<String> batchBuildDrugMaterialNO(DrugCaseInfo drugCaseInfo, Integer number);
/**
* 批量保存毒品检材信息
*
* @param drugMaterialInfos
* @param drugCaseInfo
* @return
*/
boolean saveDrugMaterialBatch(List<DrugMaterialInfo> drugMaterialInfos, DrugCaseInfo drugCaseInfo);
/**
* 分页查询毒品库中的毒品检材信息VO列表
* @param query
* @return
*/
IPage<DrugMaterialInfoVO> page(DrugDepotsQuery query);
/**
* 打印标签
* @param id
* @return
*/
String buildDrugLabelHtml(String id);
/***
* 毒品检材入库
* @param sample
* @param dlpUser
* @return
*/
List<OutSampleVO> drugMaterialPutInRepository(List<InRepositoryDTO> sample, DLPUser dlpUser);
/**
* 毒品检材封装
* @param sampleStorage
* @param drugId
* @return
*/
OutSampleVO drugMaterialToOutSampleVO(SampleStorage sampleStorage, String drugId);
} }

@ -0,0 +1,7 @@
package digital.laboratory.platform.imr.service;
import com.baomidou.mybatisplus.extension.service.IService;
import digital.laboratory.platform.imr.entity.SampleInboundRecord;
public interface SampleInboundRecordService extends IService<SampleInboundRecord> {
}

@ -0,0 +1,7 @@
package digital.laboratory.platform.imr.service;
import com.baomidou.mybatisplus.extension.service.IService;
import digital.laboratory.platform.imr.entity.SampleStorage;
public interface SampleStorageService extends IService<SampleStorage> {
}

@ -0,0 +1,206 @@
package digital.laboratory.platform.imr.service.impl;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.io.file.FileNameUtil;
import cn.hutool.core.util.StrUtil;
import com.deepoove.poi.XWPFTemplate;
import digital.laboratory.platform.common.core.constant.CommonConstants;
import digital.laboratory.platform.common.core.util.R;
import digital.laboratory.platform.common.feign.RemoteWord2PDFService;
import digital.laboratory.platform.common.oss.service.OssFile;
import digital.laboratory.platform.imr.service.CommonFeignService;
import digital.laboratory.platform.sys.dto.UserInfo;
import digital.laboratory.platform.sys.entity.SysOrg;
import digital.laboratory.platform.sys.entity.SysUser;
import digital.laboratory.platform.sys.feign.RemoteOrgService;
import digital.laboratory.platform.sys.feign.RemoteUserService;
import feign.Response;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 通用的feign请求封装接口服务层接口 实现类
*/
@Slf4j
@Service
public class CommonFeignServiceImpl implements CommonFeignService {
@Resource
private RemoteOrgService remoteOrgService;
@Resource
private RemoteUserService remoteUserService;
@Resource
private RemoteWord2PDFService remoteWord2PDFService;
@Resource
private OssFile ossFile;
/**
* 根据用户获取远程系统机构信息
*
* @param orgId 用户信息
* @return 对应的远程系统机构信息
* @throws RuntimeException 如果未找到对应的机构信息则抛出运行时异常
*/
@Override
public SysOrg remoteGetSysOrg(String orgId) {
SysOrg sysOrg = null;
R<SysOrg> r = remoteOrgService.getById(orgId);
if (r != null && r.getCode() == CommonConstants.SUCCESS) {
sysOrg = r.getData();
} else {
throw new RuntimeException(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", orgId));
}
return sysOrg;
}
/**
* 远程调用或者用户信息
* @param username
* @return
*/
@Override
public SysUser remoteGetUserByUsername(String username){
R<UserInfo> info = remoteUserService.innerGetUserInfoByUsername(username);
if (info != null && info.getCode() == CommonConstants.FAIL) {
throw new RuntimeException(String.format("获取用户名为 %s 的用户信息失败!", username));
}
return info.getData().getSysUser();
}
/**
* 远程调用获取用户信息
* @param userId
* @return
*/
@Override
public SysUser remoteGetUserById(String userId){
R<SysUser> info = remoteUserService.innerGetById(userId);
if (info != null && info.getCode() == CommonConstants.FAIL) {
throw new RuntimeException(String.format("获取用户名id为 %s 的用户信息失败!", userId));
}
return info.getData();
}
@Override
public boolean remoteGenerateWord2PDF(XWPFTemplate template, String originalFilename, String savePath) throws Exception{
ByteArrayOutputStream fosWord = new ByteArrayOutputStream();
template.write(fosWord);
template.close();
//------------
ByteArrayInputStream fisWord = new ByteArrayInputStream(fosWord.toByteArray());
fosWord.close();
MockMultipartFile mockMultipartFile = new MockMultipartFile("file", originalFilename + ".docx", "image/jpg", fisWord);
Response response = remoteWord2PDFService.word2pdf(mockMultipartFile);
fisWord.close();
ByteArrayOutputStream outPDF = new ByteArrayOutputStream();
IoUtil.copy(response.body().asInputStream(), outPDF, IoUtil.DEFAULT_MIDDLE_BUFFER_SIZE);
ByteArrayInputStream isPDF = new ByteArrayInputStream(outPDF.toByteArray());
outPDF.close();
boolean b = ossFile.fileSave(savePath, isPDF);
isPDF.close();
log.info("转换为 PDF 结束");
return b;
}
/**
* 远程调用根据文件路径获取文件
* @param filePath minio上的文件路径
* @return
* @throws Exception
*/
@Override
public ByteArrayInputStream remoteGetFile(String filePath) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ossFile.fileGet(filePath, bos);
byte[] templateArray = bos.toByteArray();
ByteArrayInputStream bis = new ByteArrayInputStream(templateArray);
bos.close();
return bis;
}
/**
* 远程调用根据文件路径获取文件
* @param filePath minio上的文件路径
* @param fileName 名称
* @param httpServletResponse
* @throws Exception
*/
@Override
public void remoteGetFile(String filePath, String fileName, HttpServletResponse httpServletResponse) throws Exception {
ossFile.fileGet(filePath, httpServletResponse.getOutputStream());
if (StrUtil.isNotBlank(fileName)) {
httpServletResponse.setContentType(fileName);
}
}
/**
* 远程调用根据文件路径获取文件列表
* @param filePath minio上的文件路径
*/
@Override
public List<String> remoteGetFileList(String filePath) {
if (StrUtil.isNotBlank(filePath)) {
List<String> fileNameList = ossFile.fileList(filePath);
List<String> fileList = fileNameList.stream().map(fileName -> {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
ossFile.fileGet(filePath + "/" + fileName, byteArrayOutputStream);
return Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());
} catch (Exception e) {
e.printStackTrace();
log.error("文件获取失败, 文件路径为: {}", filePath + "/" + fileName);
}
return null;
}).collect(Collectors.toList());
return fileList;
} else {
throw new RuntimeException("文件路径不能为空!");
}
}
/**
* 远程调用-上传文件
* @param file 上传的文件对象
* @param path 上传到minio的位置
* @return
*/
@Override
public Map<String, String> remoteUploadFile(MultipartFile file, String path) {
boolean r = ossFile.fileUpload(file, path);
if (r) {
HashMap<String, String> resultData = new HashMap<>();
resultData.put("fileName", FileNameUtil.getName(file.getOriginalFilename()));
resultData.put("path", path);
log.info("文件上传成功!");
return resultData;
} else {
String failMsg = String.format("文件名为 %s 的文件上传失败!", file.getOriginalFilename());
log.error(failMsg);
throw new RuntimeException(failMsg);
}
}
}

@ -1,10 +1,30 @@
package digital.laboratory.platform.imr.service.impl; package digital.laboratory.platform.imr.service.impl;
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import digital.laboratory.platform.imr.convert.DrugCaseInfoConvert;
import digital.laboratory.platform.imr.convert.DrugMaterialInfoConvert;
import digital.laboratory.platform.imr.dto.DrugDepotsDTO;
import digital.laboratory.platform.imr.entity.DrugCaseInfo; import digital.laboratory.platform.imr.entity.DrugCaseInfo;
import digital.laboratory.platform.imr.entity.DrugMaterialInfo;
import digital.laboratory.platform.imr.mapper.DrugCaseInfoMapper; import digital.laboratory.platform.imr.mapper.DrugCaseInfoMapper;
import digital.laboratory.platform.imr.mapper.DrugMaterialInfoMapper;
import digital.laboratory.platform.imr.query.DrugDepotsQuery;
import digital.laboratory.platform.imr.service.CommonFeignService;
import digital.laboratory.platform.imr.service.DrugCaseInfoService; import digital.laboratory.platform.imr.service.DrugCaseInfoService;
import digital.laboratory.platform.imr.service.DrugMaterialInfoService;
import digital.laboratory.platform.imr.vo.DrugCaseInfoVO;
import digital.laboratory.platform.imr.vo.DrugMaterialInfoVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* @author ChenJiangBao * @author ChenJiangBao
@ -15,6 +35,76 @@ import org.springframework.stereotype.Service;
public class DrugCaseInfoServiceImpl extends ServiceImpl<DrugCaseInfoMapper, DrugCaseInfo> public class DrugCaseInfoServiceImpl extends ServiceImpl<DrugCaseInfoMapper, DrugCaseInfo>
implements DrugCaseInfoService { implements DrugCaseInfoService {
@Resource
private DrugMaterialInfoService drugMaterialInfoService;
@Resource
private DrugMaterialInfoMapper drugMaterialInfoMapper;
@Resource
private CommonFeignService commonFeignService;
/**
* 保存案件实体信息和毒品检材信息
*
* @param dto
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public List<DrugMaterialInfoVO> save(DrugDepotsDTO dto) {
DrugCaseInfo drugCaseInfo = DrugCaseInfoConvert.dtoTOEntity(dto);
boolean flag = false;
if (StrUtil.isBlank(drugCaseInfo.getId())) {
if (super.save(drugCaseInfo)) {
// 保存毒品检材
List<DrugMaterialInfo> drugMaterialInfos = DrugMaterialInfoConvert.dtoToEntityList(dto.getDrugMaterialInfoDTOList());
flag = drugMaterialInfoService.saveDrugMaterialBatch(drugMaterialInfos, drugCaseInfo);
}
} else {
if (this.updateById(drugCaseInfo)) {
// 转换成毒品检材实体
List<DrugMaterialInfo> drugMaterialInfos = DrugMaterialInfoConvert.dtoToEntityList(dto.getDrugMaterialInfoDTOList());
// 根据id 是否存在判断调用更新还是新增
List<DrugMaterialInfo> saveList = drugMaterialInfos.stream().filter(o -> StrUtil.isBlank(o.getId())).collect(Collectors.toList());
List<DrugMaterialInfo> updateList = drugMaterialInfos.stream().filter(o -> StrUtil.isNotBlank(o.getId())).collect(Collectors.toList());
// 直接更新
flag = drugMaterialInfoService.updateBatchById(updateList);
flag = drugMaterialInfoService.saveDrugMaterialBatch(saveList, drugCaseInfo);
}
}
if (flag) {
return drugMaterialInfoMapper.getDrugMaterialVO(Wrappers.<DrugMaterialInfo>lambdaQuery().eq(DrugMaterialInfo::getCaseId, dto.getId()));
}
return null;
}
@Override
public Page<DrugCaseInfoVO> getDrugCaseInfoVOPage(DrugDepotsQuery query) {
String keywords = query.getKeywords();
IPage<DrugCaseInfo> page = super.page(
new Page<>(query.getCurrent(), query.getSize()),
Wrappers.<DrugCaseInfo>lambdaQuery().and(
StrUtil.isNotBlank(keywords),
wrapper -> wrapper
.like(DrugCaseInfo::getCaseNo, keywords)
.or()
.like(DrugCaseInfo::getCaseName, keywords))
.orderByDesc(DrugCaseInfo::getUpdateTime));
Page<DrugCaseInfoVO> drugCaseInfoVOPage = new Page<>();
BeanUtils.copyProperties(page, drugCaseInfoVOPage, "records");
List<DrugCaseInfoVO> drugCaseInfoVOS = DrugCaseInfoConvert.entityToVOList(page.getRecords());
drugCaseInfoVOS.parallelStream().forEach(item -> item.setHandingOverOrgName(commonFeignService.remoteGetSysOrg(item.getHandingOverOrg()).getName()));
drugCaseInfoVOPage.setRecords(drugCaseInfoVOS);
return drugCaseInfoVOPage;
}
@Override
public DrugCaseInfo drugCaseSave(DrugDepotsDTO dto) {
DrugCaseInfo drugCaseInfo = DrugCaseInfoConvert.dtoTOEntity(dto);
super.save(drugCaseInfo);
return drugCaseInfo;
}
} }

@ -1,20 +1,274 @@
package digital.laboratory.platform.imr.service.impl; package digital.laboratory.platform.imr.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import digital.laboratory.platform.imr.entity.DrugMaterialInfo; import digital.laboratory.platform.common.core.constant.CommonConstants;
import digital.laboratory.platform.common.core.exception.ValidateCodeException;
import digital.laboratory.platform.common.feign.RemoteTemplate2htmlService;
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
import digital.laboratory.platform.imr.dto.InRepositoryDTO;
import digital.laboratory.platform.imr.entity.*;
import digital.laboratory.platform.imr.mapper.DrugMaterialInfoMapper; import digital.laboratory.platform.imr.mapper.DrugMaterialInfoMapper;
import digital.laboratory.platform.imr.mapper.SampleStorageMapper;
import digital.laboratory.platform.imr.query.DrugDepotsQuery;
import digital.laboratory.platform.imr.service.DrugMaterialInfoService; import digital.laboratory.platform.imr.service.DrugMaterialInfoService;
import digital.laboratory.platform.imr.service.SampleInboundAndOutboundTableService;
import digital.laboratory.platform.imr.service.SampleInboundRecordService;
import digital.laboratory.platform.imr.service.SampleStorageService;
import digital.laboratory.platform.imr.vo.DrugMaterialInfoVO;
import digital.laboratory.platform.imr.vo.OutSampleVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* @author ChenJiangBao * @author ChenJiangBao
* @description 针对表b_drug_material_info(毒品库中的毒品检材信息)的数据库操作Service实现 * @description 针对表b_drug_material_info(毒品库中的毒品检材信息)的数据库操作Service实现
* @createDate 2024-11-07 12:04:42 * @createDate 2024-11-07 12:04:42
*/ */
@Service @Service
public class DrugMaterialInfoServiceImpl extends ServiceImpl<DrugMaterialInfoMapper, DrugMaterialInfo> public class DrugMaterialInfoServiceImpl extends ServiceImpl<DrugMaterialInfoMapper, DrugMaterialInfo>
implements DrugMaterialInfoService { implements DrugMaterialInfoService {
@Resource
private RemoteTemplate2htmlService remoteTemplate2htmlService;
@Resource
private SampleStorageMapper sampleStorageMapper;
@Resource
private SampleStorageService sampleStorageService;
@Resource
private SampleInboundAndOutboundTableService sampleInboundAndOutboundTableService;
@Resource
private SampleInboundRecordService sampleInboundRecordService;
/**
* 批量生成毒品检材编号
* JC5201010020240001
* JC 标识是检材 520100 地市行政编码 00 预留给派出所 2024 年份 0001 流水号
*
* @param drugCaseInfo 案件信息
* @param number
* @return
*/
@Override
public List<String> batchBuildDrugMaterialNO(DrugCaseInfo drugCaseInfo, Integer number) {
;
Calendar calendar = Calendar.getInstance();
String prefixNO = CommonConstants.CODE_PREFIX_IDENTIFICATION_MATERIAL + drugCaseInfo.getHandingOverOrg() + "00" + calendar.get(Calendar.YEAR);
List<DrugMaterialInfo> drugMaterialInfos = this.list(Wrappers.<DrugMaterialInfo>lambdaQuery()
.likeRight(DrugMaterialInfo::getDrugNo, prefixNO)
.orderByDesc(DrugMaterialInfo::getDrugNo));
Integer startNO = 0;
if (CollUtil.isNotEmpty(drugMaterialInfos)) {
DrugMaterialInfo drugMaterialInfo = drugMaterialInfos.get(0);
startNO = Integer.parseUnsignedInt(StrUtil.removePrefixIgnoreCase(drugMaterialInfo.getDrugNo(), prefixNO));
}
List<String> drugNoList = new ArrayList<>();
for (int i = 0; i < number; i++) {
drugNoList.add(prefixNO + String.format("%04d", ++startNO));
}
return drugNoList;
}
/**
* 批量保存毒品检材信息
*
* @param drugMaterialInfos
* @param drugCaseInfo
* @return
*/
@Override
public boolean saveDrugMaterialBatch(List<DrugMaterialInfo> drugMaterialInfos, DrugCaseInfo drugCaseInfo) {
int size = drugMaterialInfos.size();
// 获取编号
List<String> drugMaterialNOList = this.batchBuildDrugMaterialNO(drugCaseInfo, size);
for (int i = 0; i < size; i++) {
DrugMaterialInfo drugMaterialInfo = drugMaterialInfos.get(i);
drugMaterialInfo.setDrugNo(drugMaterialNOList.get(i));
drugMaterialInfo.setCaseId(drugCaseInfo.getId());
}
return super.saveBatch(drugMaterialInfos);
}
/**
* 分页查询毒品库中的毒品检材信息VO列表
*
* @param query
* @return
*/
@Override
public IPage<DrugMaterialInfoVO> page(DrugDepotsQuery query) {
return baseMapper.getDrugMaterialVOPage(new Page<>(query.getCurrent(), query.getSize()), query);
}
@Override
public String buildDrugLabelHtml(String id) {
List<DrugMaterialInfoVO> drugMaterialInfoVOList = baseMapper.getDrugMaterialVO(Wrappers.<DrugMaterialInfo>query().eq("dm.id", id));
if (CollUtil.isEmpty(drugMaterialInfoVOList)) {
throw new RuntimeException(String.format("没有找到 id 为 %s 的毒品检材", id));
}
Map<String, Object> data = new HashMap<>();
data.put("drugInfo", drugMaterialInfoVOList.get(0));
String templateFileName = "毒品库毒品检材条码模板.vm";
return remoteTemplate2htmlService.getHtml(templateFileName, data);
}
/***
* 毒品检材入库
* @param sample
* @param dlpUser
* @return
*/
@Override
@Transactional
public List<OutSampleVO> drugMaterialPutInRepository(List<InRepositoryDTO> sample, DLPUser dlpUser) {
// 一次性获取到所有的入库毒品检材信息,并根据编号转成map
List<DrugMaterialInfoVO> drugMaterialInfoVOS = baseMapper
.getDrugMaterialVO(Wrappers.<DrugMaterialInfo>query()
.in("drug_no",
sample.stream().map(InRepositoryDTO::getSampleNo).collect(Collectors.toList())));
Map<String, DrugMaterialInfoVO> drugMaterialInfoVOMap = drugMaterialInfoVOS.stream()
.collect(Collectors.toMap(DrugMaterialInfoVO::getDrugNo, Function.identity()));
Map<String, SampleStorage> sampleStorageMap = sampleStorageMapper
.selectList(Wrappers.<SampleStorage>lambdaQuery()
.in(SampleStorage::getSampleId,
drugMaterialInfoVOS.stream().map(DrugMaterialInfoVO::getId).collect(Collectors.toList())))
.stream().collect(Collectors.toMap(SampleStorage::getSampleId, Function.identity()));
// 存储需要批量保存的实体信息
List<SampleStorage> updateSampleStorageList = new ArrayList<>();
List<SampleStorage> saveSampleStorageList = new ArrayList<>();
List<SampleInboundAndOutboundTable> saveSampleInboundAndOutboundTableList = new ArrayList<>();
List<SampleInboundRecord> saveSampleInboundRecordList = new ArrayList<>();
ArrayList<OutSampleVO> sampleVOS = new ArrayList<>();
for (InRepositoryDTO dto : sample) {
//先通过样本编号查询出这个样本的基本信息(重点是获取到id)
DrugMaterialInfoVO drugMaterialInfoVO = drugMaterialInfoVOMap.get(dto.getSampleNo());
if (drugMaterialInfoVO == null) {
throw new ValidateCodeException(String.format("毒品检材编号为 %s 的毒品信息不存在请重试!", dto.getSampleNo()));
}
if (drugMaterialInfoVO.getStatus() != 0) {// 判断检材是否是未入库状态
throw new ValidateCodeException(String.format("编号为 %s 的样本当前状态不是入库状态!", dto.getSampleNo()));
}
// 查询当前毒品检材是否已经录入过
SampleStorage sampleStorage = sampleStorageMap.get(drugMaterialInfoVO.getId());
//已经录入到关联表;待存放状态
if (sampleStorage != null) {
if (sampleStorage.getStatus() == 1 || sampleStorage.getStatus() == 2) {
throw new RuntimeException(String.format("编号为" + dto.getSampleNo() + "的样本已录入"));
} else if (sampleStorage.getStatus() == 3) {//已出库;现在是重新入库
//重新入库是更新(二次入库)
sampleStorage.setInRepositoryDate(LocalDateTime.now());
sampleStorage.setRecipientId(null);
sampleStorage.setDepositorId(dlpUser.getId());
sampleStorage.setStatus(1);
sampleStorage.setOutRepositoryDate(null);
// sampleStorageMapper.updateById(sampleStorage);
updateSampleStorageList.add(sampleStorage);
}
} else {
//新录入仓库样本(添加操作)
sampleStorage = new SampleStorage();
sampleStorage.setId(IdWorker.get32UUID().toUpperCase());
sampleStorage.setStatus(1);//入库待存放
sampleStorage.setDepositorId(dlpUser.getId());//当前持有人变成入库人
sampleStorage.setInRepositoryDate(LocalDateTime.now());//入库时间
//毒品和其他存储时间为长期(100年)
sampleStorage.setStorageDate(LocalDateTime.now().plusYears(100));
sampleStorage.setSampleId(drugMaterialInfoVO.getId()); //毒品检材id
sampleStorage.setEarlyWarning(0);//创建默认未到"销毁"
sampleStorage.setUnit(dto.getUnit());//单位
sampleStorage.setQuality(dto.getQuality());//入库时的质量
sampleStorage.setName(drugMaterialInfoVO.getDrugName());
sampleStorage.setSampleType("A");//样本类型
//数据存储
// sampleStorageMapper.insert(sampleStorage);
saveSampleStorageList.add(sampleStorage);
}
//更新出入库登记表(这里因为只有入库,所以就创建部分数据;入库一定是添加数据)
SampleInboundAndOutboundTable table = new SampleInboundAndOutboundTable();
table.setId(IdWorker.get32UUID().toUpperCase());
table.setImAdministrators(dlpUser.getId());
table.setRecipient(dlpUser.getId());//持有人变入库人
table.setRemarks("检材入库");
table.setWarehousingDate(LocalDateTime.now());//入库时间
table.setSampleId(drugMaterialInfoVO.getId());
table.setInboundSupervisor(dto.getSupervisor());//入库监督人
// tableMapper.insert(table);
saveSampleInboundAndOutboundTableList.add(table);
//新出入库登记表
//入库记录
SampleInboundRecord record = new SampleInboundRecord();
record.setId(IdWorker.get32UUID().toUpperCase());
record.setWarehousingPersonId(dlpUser.getId());//入库人
record.setWarehousingDate(LocalDateTime.now());
record.setImAdministrators(dlpUser.getId());
record.setSampleId(drugMaterialInfoVO.getId());
record.setName(drugMaterialInfoVO.getDrugName());
record.setRemarks("检材入库");
// recordMapper.insert(record);
saveSampleInboundRecordList.add(record);
OutSampleVO outSampleVO = getOutSampleVO(sampleStorage, drugMaterialInfoVO);
sampleVOS.add(outSampleVO);
}
sampleStorageService.updateBatchById(updateSampleStorageList);
sampleStorageService.saveBatch(saveSampleStorageList);
sampleInboundAndOutboundTableService.saveBatch(saveSampleInboundAndOutboundTableList);
sampleInboundRecordService.saveBatch(saveSampleInboundRecordList);
return sampleVOS;
}
/**
* 毒品检材封装
* @param sampleStorage
* @param drugId
* @return
*/
@Override
public OutSampleVO drugMaterialToOutSampleVO(SampleStorage sampleStorage, String drugId) {
List<DrugMaterialInfoVO> drugMaterialVOs = baseMapper.getDrugMaterialVO(Wrappers.<DrugMaterialInfo>query().eq("dm.id", drugId));
if (CollUtil.isEmpty(drugMaterialVOs)) {
return null;
}
return getOutSampleVO(sampleStorage, drugMaterialVOs.get(0));
}
private OutSampleVO getOutSampleVO(SampleStorage sampleStorage, DrugMaterialInfoVO drugMaterialInfoVO) {
OutSampleVO outSampleVO = new OutSampleVO();
outSampleVO.setId(sampleStorage.getId());
outSampleVO.setSampleId(drugMaterialInfoVO.getId());
outSampleVO.setName(drugMaterialInfoVO.getDrugName());
outSampleVO.setCategory("常规毒品");
outSampleVO.setSampleNo(drugMaterialInfoVO.getDrugNo());
outSampleVO.setStorageMethod("常规");
outSampleVO.setStorageLocation(drugMaterialInfoVO.getStorageLocation());
outSampleVO.setSampleStatus(1);
return outSampleVO;
}
} }

@ -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.SampleInboundRecord;
import digital.laboratory.platform.imr.mapper.SampleInboundRecordMapper;
import digital.laboratory.platform.imr.service.SampleInboundRecordService;
import org.springframework.stereotype.Service;
@Service
public class SampleInboundRecordServiceImpl extends ServiceImpl<SampleInboundRecordMapper, SampleInboundRecord> implements SampleInboundRecordService {
}

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
import digital.laboratory.platform.imr.dto.DepositDTO; import digital.laboratory.platform.imr.dto.DepositDTO;
@ -15,6 +16,7 @@ import digital.laboratory.platform.imr.entity.*;
import digital.laboratory.platform.imr.feign.TransferFeignService; import digital.laboratory.platform.imr.feign.TransferFeignService;
import digital.laboratory.platform.imr.feign.dto.UpdateHolderDTO; import digital.laboratory.platform.imr.feign.dto.UpdateHolderDTO;
import digital.laboratory.platform.imr.mapper.*; import digital.laboratory.platform.imr.mapper.*;
import digital.laboratory.platform.imr.service.DrugMaterialInfoService;
import digital.laboratory.platform.imr.service.SamplePutInStorageService; import digital.laboratory.platform.imr.service.SamplePutInStorageService;
import digital.laboratory.platform.imr.vo.InboundRecordVO; import digital.laboratory.platform.imr.vo.InboundRecordVO;
import digital.laboratory.platform.imr.vo.OutSampleVO; import digital.laboratory.platform.imr.vo.OutSampleVO;
@ -51,6 +53,8 @@ public class SamplePutInStorageServiceImpl implements SamplePutInStorageService
private final CabinetOpeningRecordMapper openingRecordMapper; private final CabinetOpeningRecordMapper openingRecordMapper;
private final DrugMaterialInfoService drugMaterialInfoService;
private static Map<String, Set<String>> tempSampleInMap = new ConcurrentHashMap<>(); private static Map<String, Set<String>> tempSampleInMap = new ConcurrentHashMap<>();
@ -412,31 +416,6 @@ public class SamplePutInStorageServiceImpl implements SamplePutInStorageService
table.setInboundSupervisor(dto.getSupervisor());//入库监督人 table.setInboundSupervisor(dto.getSupervisor());//入库监督人
tableMapper.insert(table); tableMapper.insert(table);
//新出入库登记表 //新出入库登记表
/*
存在分析样本和留存样本两种
*/
// if("A".equals(sampleVO.getSampleType())){//分析样
// IdentificationMaterialTransferAnalysisAnnex analysisSample = new IdentificationMaterialTransferAnalysisAnnex();
// analysisSample.setId(IdWorker.get32UUID().toUpperCase());
// analysisSample.setAnalysisSampleInboundQuality(sampleVO.getExistingQuality());//现有质量
// analysisSample.setInboundAdminId(dlpUser.getId());
// analysisSample.setInboundHandledBy(sampleVO.getHolder());//经手人
// analysisSample.setSampleId(sampleVO.getId());//样本id
// analysisSample.setAnalysisSampleInboundDate(LocalDateTime.now());//日期
// analysisSample.setInboundAppraiserId(dto.getSupervisor());//入库监督人
// analysisAnnexMapper.insert(analysisSample);
// }else {
// //留存样本
// IdentificationMaterialTransferRetainedAnnex retainedAnnex = new IdentificationMaterialTransferRetainedAnnex();
// retainedAnnex.setId(IdWorker.get32UUID().toUpperCase());
// retainedAnnex.setRetainedSampleInboundQuality(sampleVO.getExistingQuality());//现有质量
// retainedAnnex.setInboundAdminId(dlpUser.getId());
// retainedAnnex.setInboundHandledBy(sampleVO.getHolder());//经手人
// retainedAnnex.setSampleId(sampleVO.getId());//样本id
// retainedAnnex.setRetainedSampleInboundDate(LocalDateTime.now());//日期
// retainedAnnex.setInboundAppraiserId(dto.getSupervisor());//入库监督人
// retainedAnnexMapper.insert(retainedAnnex);
// }
//入库记录 //入库记录
SampleInboundRecord record = new SampleInboundRecord(); SampleInboundRecord record = new SampleInboundRecord();
@ -492,8 +471,14 @@ public class SamplePutInStorageServiceImpl implements SamplePutInStorageService
//添加样本id //添加样本id
sampleIds.add(sampleStorage.getSampleId()); sampleIds.add(sampleStorage.getSampleId());
OutSampleVO sampleVO;
OutSampleVO sampleVO = storageMapper.getSampleById(sampleStorage.getSampleId()); if (dto.getType() == 0) {
sampleVO = storageMapper.getSampleById(sampleStorage.getSampleId());
} else {
sampleVO = drugMaterialInfoService.drugMaterialToOutSampleVO(sampleStorage, sampleStorage.getSampleId());
//3.毒品库中的毒品检材信息样本状态为已入库
drugMaterialInfoService.update(Wrappers.<DrugMaterialInfo>lambdaUpdate().eq(DrugMaterialInfo::getId, sampleStorage.getSampleId()).set(DrugMaterialInfo::getStatus, 1));
}
sampleVO.setStorageLocation(dto.getStorageLocation()); sampleVO.setStorageLocation(dto.getStorageLocation());
outSampleVOS.add(sampleVO); outSampleVOS.add(sampleVO);
} }

@ -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.SampleStorage;
import digital.laboratory.platform.imr.mapper.SampleStorageMapper;
import digital.laboratory.platform.imr.service.SampleStorageService;
import org.springframework.stereotype.Service;
@Service
public class SampleStorageServiceImpl extends ServiceImpl<SampleStorageMapper, SampleStorage> implements SampleStorageService {
}

@ -0,0 +1,55 @@
package digital.laboratory.platform.imr.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* 毒品库中关联的案事件信息 VO 返回前台显示类
* @TableName b_drug_case_info
*/
@Data
@ApiModel(value = "DrugCaseInfoVO", description = "毒品库中关联的案事件信息 VO 返回前台显示类")
public class DrugCaseInfoVO{
/**
* 主键标识
*/
@ApiModelProperty("id")
private String id;
/**
* 案事件名称
*/
@ApiModelProperty("案事件名称")
private String caseName;
/**
* 案件编号
*/
@ApiModelProperty("案件编号")
private String caseNo;
/**
* 送缴单位
*/
@ApiModelProperty("送缴单位")
private String handingOverOrg;
/**
* 送缴单位
*/
@ApiModelProperty("送缴单位")
private String handingOverOrgName;
/**
* 送缴日期
*/
@ApiModelProperty("送缴日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate handingOverDate;
}

@ -0,0 +1,106 @@
package digital.laboratory.platform.imr.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* 毒品库中的毒品检材信息 VO 返回前台显示类
* @TableName b_drug_material_info
*/
@Data
@ApiModel(value = "DrugMaterialInfoVO", description = "毒品库中的毒品检材信息 VO 返回前台显示类")
public class DrugMaterialInfoVO {
/**
* 主键标识
*/
@ApiModelProperty("主键标识")
private String id;
/**
* 关联的案件id
*/
@ApiModelProperty("关联的案件id")
private String caseId;
/**
* 关联的入库记录id
*/
@ApiModelProperty("关联的入库记录id")
private String sampleStorageId;
@ApiModelProperty("存放位置")
private String storageLocation;
/**
* 毒品检材编号
*/
@ApiModelProperty("毒品检材编号")
private String drugNo;
/**
* 毒品检材名称
*/
@ApiModelProperty("毒品检材名称")
private String drugName;
/**
* 质量/体积
*/
@ApiModelProperty("质量/体积")
private String massVolume;
/**
* 质量/体积 单位
*/
@ApiModelProperty("质量/体积 单位")
private String unit;
/**
* 包装是否完整 1 完整 | 0 不完整
*/
@ApiModelProperty("包装是否完整, 1 完整 | 0 不完整")
private Boolean packageComplete;
/**
* 毒品检材状态 0 未入库 | 1 已入库
*/
@ApiModelProperty("毒品检材状态, 0 未入库 | 1 已入库")
private Integer status;
/**
* 案事件名称
*/
@ApiModelProperty("案事件名称")
private String caseName;
/**
* 案件编号
*/
@ApiModelProperty("案件编号")
private String caseNo;
/**
* 送缴单位
*/
@ApiModelProperty("送缴单位")
private String handingOverOrg;
/**
* 送缴单位
*/
@ApiModelProperty("送缴单位")
private String handingOverOrgName;
/**
* 送缴日期
*/
@ApiModelProperty("送缴日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate handingOverDate;
}

@ -10,6 +10,8 @@ mybatis-plus:
type-aliases-package: digital.laboratory.platform.imr.entity type-aliases-package: digital.laboratory.platform.imr.entity
mapper-locations: classpath:mapper/*Mapper.xml mapper-locations: classpath:mapper/*Mapper.xml
typeEnumsPackage: digital.laboratory.platform.imr.entity.enums # 支持统配符 * 或者 ; 分割 typeEnumsPackage: digital.laboratory.platform.imr.entity.enums # 支持统配符 * 或者 ; 分割
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
spring: spring:
application: application:
@ -30,7 +32,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
username: root username: root
password: 7990016 password: 7990016
url: jdbc:mysql://dlp-mysql:3306/dlp_identification_material_repository?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://dlp-mysql:3306/dlp_identification_material_repository?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true
servlet: servlet:
multipart: multipart:
# 根据实际需求作调整 # 根据实际需求作调整

@ -10,6 +10,7 @@
<result property="drugNo" column="drug_no" jdbcType="VARCHAR"/> <result property="drugNo" column="drug_no" jdbcType="VARCHAR"/>
<result property="drugName" column="drug_name" jdbcType="VARCHAR"/> <result property="drugName" column="drug_name" jdbcType="VARCHAR"/>
<result property="massVolume" column="mass_volume" jdbcType="VARCHAR"/> <result property="massVolume" column="mass_volume" jdbcType="VARCHAR"/>
<result property="unit" column="unit" jdbcType="VARCHAR"/>
<result property="packageComplete" column="package_complete" jdbcType="TINYINT"/> <result property="packageComplete" column="package_complete" jdbcType="TINYINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
@ -19,8 +20,51 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id,case_id,drug_no, id,case_id,drug_no,
drug_name,mass_volume,package_complete, drug_name,mass_volume,unit,package_complete,
create_time,update_time,create_by, create_time,update_time,create_by,
update_by update_by
</sql> </sql>
<sql id="queryVOSQL">
SELECT
dm.*,
dc.case_name,
dc.case_no,
dc.handing_over_org,
dc.handing_over_date,
ss.id as sampleStorageId,
ss.storage_location
FROM b_drug_material_info dm
LEFT JOIN b_drug_case_info dc ON dm.case_id = dc.id
LEFT JOIN b_sample_storage ss ON dm.id = ss.sample_id
</sql>
<select id="getDrugMaterialVOPage" resultType="digital.laboratory.platform.imr.vo.DrugMaterialInfoVO">
<include refid="queryVOSQL"/>
<where>
<if test="query.keywords != null and query.keywords != ''">
OR dc.case_name LIKE CONCAT('%', #{query.keywords}, '%')
OR dm.drug_name LIKE CONCAT('%', #{query.keywords}, '%')
OR dm.drug_no LIKE CONCAT('%', #{query.keywords}, '%')
</if>
<if test="query.orgId != null and query.orgId != ''">
AND dc.handing_over_org = #{query.orgId}
</if>
<if test="query.caseId != null and query.caseId != ''">
AND dm.case_id = #{query.caseId}
</if>
<if test="query.startDate != null">
AND dc.handing_over_date &gt;= #{query.startDate}
</if>
<if test="query.endDate != null">
AND dc.handing_over_date &lt;= #{query.endDate}
</if>
</where>
ORDER BY dm.update_time DESC
</select>
<select id="getDrugMaterialVO" resultType="digital.laboratory.platform.imr.vo.DrugMaterialInfoVO">
<include refid="queryVOSQL"/>
${ew.customSqlSegment}
</select>
</mapper> </mapper>

Loading…
Cancel
Save