Commit 6ec8d43e by huangtao

修复权限、签名问题

parent 42ee1364
......@@ -6,11 +6,16 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
@ApiModel(description = "药品申请信息")
public class PhysicApplyCreateReq {
private Long physicApplyId;
@NotBlank(message = "药品名称不能为空")
@ApiModelProperty(value = "药品名称")
private String physicName;
......@@ -18,24 +23,36 @@ public class PhysicApplyCreateReq {
private String physicType;
@NotBlank(message = "药品规格不能为空")
@ApiModelProperty(value = "药品规格")
private String physicSpec;
private String unit;
@NotNull(message = "交回空安瓿不能为空")
@ApiModelProperty(value = "交回空安瓿数量")
private Integer returnNum;
@NotNull(message = "处方数量不能为空")
@ApiModelProperty(value = "处方数量")
private Integer prescriptionNum;
@NotNull(message = "请领数量不能为空")
@ApiModelProperty(value = "请领数量")
private Integer requisitionNum;
@NotNull(message = "实发数量不能为空")
@ApiModelProperty(value = "实发数量")
private Integer actualNum;
@ApiModelProperty(value = "批号")
private String batchNo;
@NotBlank(message = "生产厂家不能为空")
@ApiModelProperty(value = "厂家名称")
private String factoryName;
}
......@@ -17,5 +17,6 @@ public class SignInfoDTO {
public SignInfoDTO(String signBase64Data, LocalDateTime time,Long userId) {
this.signBase64Data = signBase64Data;
this.time = time;
this.userId =userId;
}
}
......@@ -20,12 +20,15 @@ public class PhysicApply extends BaseVersionEntity{
private String unit;
@ApiModelProperty(value = "交回空安瓿数量")
private Integer returnNum;
@ApiModelProperty(value = "处方数量")
private Integer prescriptionNum;
@ApiModelProperty(value = "请领数量")
private Integer requisitionNum;
@ApiModelProperty(value = "实发数量")
private Integer actualNum;
@ApiModelProperty(value = "批号")
......
......@@ -38,20 +38,22 @@ public class PhysicBill extends BaseVersionEntity {
private Integer type;
@ApiModelProperty(value = "收入")
private Integer acquireNum;
@ApiModelProperty(value = "发出")
private Integer expendNum;
@ApiModelProperty(value = "状态 0 -待验收 1 -已完成")
private Integer status;
private String ysUser;
private String shUser;
@ApiModelProperty(value = "结存")
private Integer balance;
@ApiModelProperty(value = "总结存")
private Integer balanceAll;
......
......@@ -3,6 +3,7 @@ package com.jmai.physic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jmai.api.exception.ServiceException;
import com.jmai.physic.cloudsign.CloudsignService;
import com.jmai.physic.dto.*;
import com.jmai.physic.entity.PhysicApply;
......@@ -22,6 +23,7 @@ import com.jmai.sys.entity.SysUser;
import com.jmai.sys.mapper.SysDeptMapper;
import com.jmai.sys.mapper.SysUserMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
......@@ -48,7 +50,7 @@ public class PhysicApplyServiceImpl extends AbstractService implements PhysicApp
@Resource
private PhysicBillService physicBillService;
@Transactional
@Override
public PhysicApplyVO createPhysicApply(PhysicApplyCreateReq req) {
PhysicApply apply =new PhysicApply();
......@@ -96,7 +98,7 @@ public class PhysicApplyServiceImpl extends AbstractService implements PhysicApp
List<Long> roleList = sysUser.getRoleAsList();
LambdaQueryWrapper<PhysicApply> queryWrapper = new LambdaQueryWrapper<>();
List<PhysicApply> physicApplyList = new ArrayList<>();
List<Integer> ly_statusList=new ArrayList<>();
for (Long roleId : roleList) {
......@@ -107,11 +109,7 @@ public class PhysicApplyServiceImpl extends AbstractService implements PhysicApp
ly_statusList.add(1);
}
}
if(!CollectionUtils.isEmpty(ly_statusList)){
queryWrapper.and(o->{
o.eq(PhysicApply::getLyDeptId,deptId).in(PhysicApply::getStatus,ly_statusList);
});
}
List<Integer> fy_statusList=new ArrayList<>();
for (Long roleId : roleList) {
RoleTypeEum roleTypeEum = RoleTypeEum.getEnum(roleId);
......@@ -121,16 +119,23 @@ public class PhysicApplyServiceImpl extends AbstractService implements PhysicApp
fy_statusList.add(3);
}
}
if(CollectionUtils.isEmpty(ly_statusList) && !CollectionUtils.isEmpty(fy_statusList)){
if(!CollectionUtils.isEmpty(ly_statusList)){
queryWrapper.and(o->{
o.eq(PhysicApply::getFyDeptId,deptId).in(PhysicApply::getStatus,fy_statusList);
o.eq(PhysicApply::getLyDeptId,deptId).in(PhysicApply::getStatus,ly_statusList);
});
}else if(!CollectionUtils.isEmpty(ly_statusList) && !CollectionUtils.isEmpty(fy_statusList)){
queryWrapper.or().and(o->{
}
if(!CollectionUtils.isEmpty(fy_statusList)){
queryWrapper.and(o->{
o.eq(PhysicApply::getFyDeptId,deptId).in(PhysicApply::getStatus,fy_statusList);
});
}
List<PhysicApply> physicApplyList = physicApplyMapper.selectList(queryWrapper);
if(!CollectionUtils.isEmpty(ly_statusList) || !CollectionUtils.isEmpty(fy_statusList)){
physicApplyMapper.selectList(queryWrapper);
}
return physicApplyList.stream().map(o->{
PhysicApplyVO vo =new PhysicApplyVO();
......@@ -139,28 +144,43 @@ public class PhysicApplyServiceImpl extends AbstractService implements PhysicApp
return vo;
}).collect(Collectors.toList());
}
@Transactional
@Override
public PhysicApplyVO sign(PhysicApplySignReq physicApplySignReq) {
Boolean f =false;
Long userId = SpringContextUtils.getUserId();
SysUser sysUser = sysUserMapper.selectById(userId);
String getstamp = cloudsignService.sign(physicApplySignReq.getEncryptedToken(), physicApplySignReq.getRelBizNo(), physicApplySignReq.getBase64SourceData());
PhysicApply physicApply = physicApplyMapper.selectById(physicApplySignReq.getPhysicApplyId());
if(physicApply.getStatus().equals(0)){
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.LY)){
throw new ServiceException("需要领药人权限才可进行签名");
}
physicApply.setStatus(1);
SignInfoDTO signInfoDTO = new SignInfoDTO(getstamp, LocalDateTime.now(),userId);
physicApply.setLyUser(JSONUtil.toJsonStr(signInfoDTO));
}else if(physicApply.getStatus().equals(1)){
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.SH)){
throw new ServiceException("需要审核人权限才可进行签名");
}
physicApply.setStatus(2);
SignInfoDTO signInfoDTO = new SignInfoDTO(getstamp, LocalDateTime.now(),userId);;
physicApply.setShUser(JSONUtil.toJsonStr(signInfoDTO));
}else if(physicApply.getStatus().equals(2)){
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.FY)){
throw new ServiceException("需要发药人权限才可进行签名");
}
physicApply.setStatus(3);
SignInfoDTO signInfoDTO = new SignInfoDTO(getstamp, LocalDateTime.now(),userId);;
physicApply.setFyUser(JSONUtil.toJsonStr(signInfoDTO));
}
else if(physicApply.getStatus().equals(3)){
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.FH)){
throw new ServiceException("需要复核人权限才可进行签名");
}
physicApply.setStatus(4);
SignInfoDTO signInfoDTO = new SignInfoDTO(getstamp, LocalDateTime.now(),userId);;
physicApply.setFhUser(JSONUtil.toJsonStr(signInfoDTO));
......@@ -171,6 +191,7 @@ public class PhysicApplyServiceImpl extends AbstractService implements PhysicApp
BillDTO billDTO = new BillDTO();
BeanUtil.copyProperties(physicApply,billDTO);
billDTO.setType(2);
billDTO.setPhysicNum(physicApply.getActualNum());
billDTO.setDeptId(physicApply.getLyDeptId());
physicBillService.createBill(billDTO);
}
......
......@@ -18,6 +18,7 @@ import com.jmai.physic.vo.BillQueryVO;
import com.jmai.sys.AbstractService;
import com.jmai.sys.ctx.SpringContextUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
......@@ -32,7 +33,7 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
@Resource
private CloudsignService cloudsignService;
@Transactional
@Override
public void createBill(BillDTO billDTO) {
PhysicBill bill = new PhysicBill();
......
......@@ -3,6 +3,7 @@ package com.jmai.physic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jmai.api.exception.ServiceException;
import com.jmai.physic.cloudsign.CloudsignService;
import com.jmai.physic.dto.BillDTO;
import com.jmai.physic.dto.PhysicWarehouseCreateReq;
......@@ -80,19 +81,31 @@ public class PhysicWarehouseServiceImpl extends AbstractService implements Phys
Long userId = SpringContextUtils.getUserId();
String getstamp = cloudsignService.sign(physicWarehouseSignReq.getEncryptedToken(), physicWarehouseSignReq.getRelBizNo(), physicWarehouseSignReq.getBase64SourceData());
PhysicWarehouse physicWarehouse = physicWarehouseMapper.selectById(physicWarehouseSignReq.getPhysicWarehouseId());
SysUser sysUser = sysUserMapper.selectById(userId);
if(physicWarehouse.getStatus().equals(0)){
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.YS)){
throw new ServiceException("需要验收人权限才可进行签名");
}
physicWarehouse.setStatus(1);
SignInfoDTO signInfoDTO = new SignInfoDTO(getstamp, LocalDateTime.now(),userId);
physicWarehouse.setYsUser(JSONUtil.toJsonStr(signInfoDTO));
}else if(physicWarehouse.getStatus().equals(1)){
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.FH)){
throw new ServiceException("需要验收人权限才可进行签名");
}
physicWarehouse.setStatus(2);
SignInfoDTO signInfoDTO = new SignInfoDTO(getstamp, LocalDateTime.now(),userId);;
physicWarehouse.setYsUser(JSONUtil.toJsonStr(signInfoDTO));
physicWarehouse.setFhUser(JSONUtil.toJsonStr(signInfoDTO));
}else if(physicWarehouse.getStatus().equals(2)){
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.BG)){
throw new ServiceException("需要保管权限才可进行签名");
}
physicWarehouse.setStatus(3);
SignInfoDTO signInfoDTO = new SignInfoDTO(getstamp, LocalDateTime.now(),userId);;
physicWarehouse.setBgUser(JSONUtil.toJsonStr(signInfoDTO));
}
if(f){
BillDTO billDTO = new BillDTO();
......
......@@ -3,6 +3,8 @@ package com.jmai.sys.consts.enums;
import lombok.Getter;
import java.util.List;
@Getter
public enum RoleTypeEum {
YS(1, "验收人"),
......@@ -39,4 +41,14 @@ public enum RoleTypeEum {
}
return null;
}
public static Boolean isPass(List<Long> roleIds,RoleTypeEum roleTypeEum){
boolean f = false;
for (Long roleId : roleIds) {
if(roleId.equals(roleTypeEum.code)){
return true;
}
}
return false;
}
}
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment