|
|
@ -1,26 +1,39 @@ |
|
|
|
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 cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
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.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
//import com.lcsoft.dlp.common.aop.annotation.DlpResultProc;
|
|
|
|
import digital.laboratory.platform.common.aop.annotation.DlpResultProc; |
|
|
|
import digital.laboratory.platform.common.core.exception.ValidateCodeException; |
|
|
|
import digital.laboratory.platform.common.core.exception.ValidateCodeException; |
|
|
|
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
|
|
|
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
|
|
|
import digital.laboratory.platform.common.security.util.SecurityUtils; |
|
|
|
import digital.laboratory.platform.common.security.util.SecurityUtils; |
|
|
|
import digital.laboratory.platform.imr.convert.DrugHandingOverApplyConvert; |
|
|
|
import digital.laboratory.platform.imr.convert.DrugHandingOverApplyConvert; |
|
|
|
|
|
|
|
import digital.laboratory.platform.imr.dto.DrugHandingOverReviewDTO; |
|
|
|
|
|
|
|
import digital.laboratory.platform.imr.entity.DrugCaseInfo; |
|
|
|
import digital.laboratory.platform.imr.entity.DrugHandingOverApply; |
|
|
|
import digital.laboratory.platform.imr.entity.DrugHandingOverApply; |
|
|
|
|
|
|
|
import digital.laboratory.platform.imr.entity.DrugMaterialInfo; |
|
|
|
import digital.laboratory.platform.imr.enums.DrugHandingOverApplyStatus; |
|
|
|
import digital.laboratory.platform.imr.enums.DrugHandingOverApplyStatus; |
|
|
|
|
|
|
|
import digital.laboratory.platform.imr.enums.DrugMaterialStatus; |
|
|
|
import digital.laboratory.platform.imr.query.DrugHandingOverApplyQuery; |
|
|
|
import digital.laboratory.platform.imr.query.DrugHandingOverApplyQuery; |
|
|
|
|
|
|
|
import digital.laboratory.platform.imr.service.DrugCaseInfoService; |
|
|
|
import digital.laboratory.platform.imr.service.DrugHandingOverApplyService; |
|
|
|
import digital.laboratory.platform.imr.service.DrugHandingOverApplyService; |
|
|
|
import digital.laboratory.platform.imr.mapper.DrugHandingOverApplyMapper; |
|
|
|
import digital.laboratory.platform.imr.mapper.DrugHandingOverApplyMapper; |
|
|
|
|
|
|
|
import digital.laboratory.platform.imr.service.DrugMaterialInfoService; |
|
|
|
import digital.laboratory.platform.imr.vo.DrugHandingOverApplyVO; |
|
|
|
import digital.laboratory.platform.imr.vo.DrugHandingOverApplyVO; |
|
|
|
|
|
|
|
import digital.laboratory.platform.sys.entity.Drug; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
|
|
|
import org.springframework.security.core.parameters.P; |
|
|
|
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.time.LocalDateTime; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author ChenJiangBao |
|
|
|
* @author ChenJiangBao |
|
|
@ -31,12 +44,18 @@ import java.util.List; |
|
|
|
public class DrugHandingOverApplyServiceImpl extends ServiceImpl<DrugHandingOverApplyMapper, DrugHandingOverApply> |
|
|
|
public class DrugHandingOverApplyServiceImpl extends ServiceImpl<DrugHandingOverApplyMapper, DrugHandingOverApply> |
|
|
|
implements DrugHandingOverApplyService{ |
|
|
|
implements DrugHandingOverApplyService{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private DrugCaseInfoService drugCaseInfoService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private DrugMaterialInfoService drugMaterialInfoService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 创建毒品送缴申请-委托单位操作 |
|
|
|
* 创建毒品送缴申请-委托单位操作 |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
// @DlpResultProc
|
|
|
|
@DlpResultProc |
|
|
|
public DrugHandingOverApplyVO create() { |
|
|
|
public DrugHandingOverApplyVO create() { |
|
|
|
DLPUser user = SecurityUtils.getUser(); |
|
|
|
DLPUser user = SecurityUtils.getUser(); |
|
|
|
DrugHandingOverApply entity = new DrugHandingOverApply(); |
|
|
|
DrugHandingOverApply entity = new DrugHandingOverApply(); |
|
|
@ -73,6 +92,7 @@ public class DrugHandingOverApplyServiceImpl extends ServiceImpl<DrugHandingOver |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public boolean delete(List<String> ids) { |
|
|
|
public boolean delete(List<String> ids) { |
|
|
|
List<DrugHandingOverApply> drugHandingOverApplies = super.listByIds(ids); |
|
|
|
List<DrugHandingOverApply> drugHandingOverApplies = super.listByIds(ids); |
|
|
|
for (DrugHandingOverApply drugHandingOverApply : drugHandingOverApplies) { |
|
|
|
for (DrugHandingOverApply drugHandingOverApply : drugHandingOverApplies) { |
|
|
@ -80,7 +100,83 @@ public class DrugHandingOverApplyServiceImpl extends ServiceImpl<DrugHandingOver |
|
|
|
throw new ValidateCodeException(String.format("id为 %s 的申请已经送缴,不能删除!")); |
|
|
|
throw new ValidateCodeException(String.format("id为 %s 的申请已经送缴,不能删除!")); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return super.removeByIds(ids); |
|
|
|
|
|
|
|
|
|
|
|
if (super.removeByIds(ids)) { |
|
|
|
|
|
|
|
List<DrugCaseInfo> drugCaseInfoList = drugCaseInfoService.list(Wrappers.<DrugCaseInfo>lambdaQuery().in(DrugCaseInfo::getApplyId, ids)); |
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(drugCaseInfoList)) { |
|
|
|
|
|
|
|
List<String> caseIdList = drugCaseInfoList.stream().map(DrugCaseInfo::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
drugCaseInfoService.removeByIds(caseIdList); |
|
|
|
|
|
|
|
List<DrugMaterialInfo> drugMaterialInfos = drugMaterialInfoService.list(Wrappers.<DrugMaterialInfo>lambdaQuery().in(DrugMaterialInfo::getCaseId, caseIdList)); |
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(drugMaterialInfos)) { |
|
|
|
|
|
|
|
drugMaterialInfoService.remove(Wrappers.<DrugMaterialInfo>lambdaQuery().in(DrugMaterialInfo::getCaseId, caseIdList)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 审核送缴申请 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param dto |
|
|
|
|
|
|
|
* @param user |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
|
|
public DrugHandingOverApplyVO review(DrugHandingOverReviewDTO dto, DLPUser user) { |
|
|
|
|
|
|
|
DrugHandingOverApply byId = super.getById(dto.getId()); |
|
|
|
|
|
|
|
if (byId == null) { |
|
|
|
|
|
|
|
throw new ValidateCodeException("数据不存在!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!byId.getStatus().equals(DrugHandingOverApplyStatus.WAIT_ACCEPT.getStatus())) { |
|
|
|
|
|
|
|
throw new ValidateCodeException("该申请不在 [待审核] 状态!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean update = super.update(Wrappers.<DrugHandingOverApply>lambdaUpdate() |
|
|
|
|
|
|
|
.eq(DrugHandingOverApply::getId, dto.getId()) |
|
|
|
|
|
|
|
.set(DrugHandingOverApply::getReason, dto.getReason()) |
|
|
|
|
|
|
|
.set(DrugHandingOverApply::getReviewer, user.getId()) |
|
|
|
|
|
|
|
.set(DrugHandingOverApply::getReviewDate, LocalDateTime.now()) |
|
|
|
|
|
|
|
.set(DrugHandingOverApply::getStatus, |
|
|
|
|
|
|
|
dto.getIsPass() == 1 ? DrugHandingOverApplyStatus.AGREE_ACCEPT.getStatus() : DrugHandingOverApplyStatus.REJECT_ACCEPT.getStatus() |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if (update) { |
|
|
|
|
|
|
|
if (dto.getIsPass() == 1) { |
|
|
|
|
|
|
|
// 更新毒品检材状态
|
|
|
|
|
|
|
|
drugMaterialInfoService.update( |
|
|
|
|
|
|
|
Wrappers.<DrugMaterialInfo>lambdaUpdate() |
|
|
|
|
|
|
|
.inSql(DrugMaterialInfo::getCaseId, String.format("SELECT case_id FROM b_drug_case_info WHERE apply_id = '%s'", dto.getId())) |
|
|
|
|
|
|
|
.set(DrugMaterialInfo::getStatus, DrugMaterialStatus.WAIT_INBOUND.getStatus()) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return DrugHandingOverApplyConvert.entityToVO(super.getById(dto.getId())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 提交送缴申请 |
|
|
|
|
|
|
|
* @param applyId |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean submit(String applyId) { |
|
|
|
|
|
|
|
DrugHandingOverApply preInfo = super.getById(applyId); |
|
|
|
|
|
|
|
if (preInfo == null) { |
|
|
|
|
|
|
|
throw new ValidateCodeException("数据不存在!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!preInfo.getStatus().equals(DrugHandingOverApplyStatus.WAIT_HANDING_OVER.getStatus())) { |
|
|
|
|
|
|
|
throw new ValidateCodeException("该申请不在 [待提交] 状态!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return super.update(Wrappers.<DrugHandingOverApply>lambdaUpdate() |
|
|
|
|
|
|
|
.eq(DrugHandingOverApply::getId, applyId) |
|
|
|
|
|
|
|
.set(DrugHandingOverApply::getHandingOverDate, LocalDateTime.now()) |
|
|
|
|
|
|
|
.set(DrugHandingOverApply::getStatus, DrugHandingOverApplyStatus.WAIT_ACCEPT.getStatus()) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -95,6 +191,8 @@ public class DrugHandingOverApplyServiceImpl extends ServiceImpl<DrugHandingOver |
|
|
|
Integer userQueryType = query.getUserQueryType(); |
|
|
|
Integer userQueryType = query.getUserQueryType(); |
|
|
|
LambdaQueryWrapper<DrugHandingOverApply> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
LambdaQueryWrapper<DrugHandingOverApply> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
lambdaQueryWrapper.eq(!user.isStaff(), DrugHandingOverApply::getHandingOverOrg, user.getOrgId()); |
|
|
|
lambdaQueryWrapper.eq(!user.isStaff(), DrugHandingOverApply::getHandingOverOrg, user.getOrgId()); |
|
|
|
|
|
|
|
// 受理单位不需要看待提交的申请
|
|
|
|
|
|
|
|
lambdaQueryWrapper.ne(user.isStaff(), DrugHandingOverApply::getStatus, DrugHandingOverApplyStatus.WAIT_HANDING_OVER.getStatus()); |
|
|
|
if (timeRangeType != null) { |
|
|
|
if (timeRangeType != null) { |
|
|
|
if (timeRangeType == 1) { |
|
|
|
if (timeRangeType == 1) { |
|
|
|
lambdaQueryWrapper.ge(query.getStartDate() != null, DrugHandingOverApply::getApplyDate, query.getStartDate()) |
|
|
|
lambdaQueryWrapper.ge(query.getStartDate() != null, DrugHandingOverApply::getApplyDate, query.getStartDate()) |
|
|
@ -109,7 +207,7 @@ public class DrugHandingOverApplyServiceImpl extends ServiceImpl<DrugHandingOver |
|
|
|
if (userQueryType == 1) { |
|
|
|
if (userQueryType == 1) { |
|
|
|
lambdaQueryWrapper.eq(StrUtil.isNotBlank(query.getUserId()), DrugHandingOverApply::getHandingOverUser, query.getUserId()); |
|
|
|
lambdaQueryWrapper.eq(StrUtil.isNotBlank(query.getUserId()), DrugHandingOverApply::getHandingOverUser, query.getUserId()); |
|
|
|
} else if (userQueryType == 2) { |
|
|
|
} else if (userQueryType == 2) { |
|
|
|
lambdaQueryWrapper.eq(StrUtil.isNotBlank(query.getUserId()), DrugHandingOverApply::getRecipient, query.getUserId()); |
|
|
|
lambdaQueryWrapper.eq(StrUtil.isNotBlank(query.getUserId()), DrugHandingOverApply::getReviewer, query.getUserId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return lambdaQueryWrapper; |
|
|
|
return lambdaQueryWrapper; |
|
|
|