Commit 6ec8d43e by huangtao

修复权限、签名问题

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