新增了外链不生成证书和分享二维码
This commit is contained in:
parent
013931418c
commit
df5265db93
@ -156,10 +156,13 @@ public class CaseClinicalArticleService {
|
|||||||
// 新增统计
|
// 新增统计
|
||||||
IncClinicalArticleStats(String.valueOf(caseClinicalArticle.getArticleId()),4,1);
|
IncClinicalArticleStats(String.valueOf(caseClinicalArticle.getArticleId()),4,1);
|
||||||
|
|
||||||
// 生成文章分享二维码
|
byte[] qrcodeBytes = new byte[0];
|
||||||
byte[] qrcodeBytes = addUnlimitedQrcode(caseClinicalArticle.getArticleId());
|
if (addForm.getIsLink() == 1){
|
||||||
if (qrcodeBytes == null || qrcodeBytes.length == 0) {
|
// 生成文章分享二维码
|
||||||
return ResponseDTO.userErrorParam("添加失败");
|
qrcodeBytes = addUnlimitedQrcode(caseClinicalArticle.getArticleId());
|
||||||
|
if (qrcodeBytes == null || qrcodeBytes.length == 0) {
|
||||||
|
return ResponseDTO.userErrorParam("添加失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理文章作者
|
// 处理文章作者
|
||||||
@ -753,49 +756,168 @@ public class CaseClinicalArticleService {
|
|||||||
// 增加需要增加的医院数据
|
// 增加需要增加的医院数据
|
||||||
addHospitalSet.add(String.valueOf(caseClinicalDoctor.getHospitalId()));
|
addHospitalSet.add(String.valueOf(caseClinicalDoctor.getHospitalId()));
|
||||||
|
|
||||||
// 生成用户证书-文章/视频
|
// 处理证书问题-非外链时才会更新
|
||||||
if (qrCodeBytes == null || qrCodeBytes.length == 0) {
|
if (caseClinicalArticle.getIsLink() == 1){
|
||||||
// 生成二维码图片
|
// 生成用户证书-文章/视频
|
||||||
if (caseClinicalArticle.getShareQrcode() == null){
|
if (qrCodeBytes == null || qrCodeBytes.length == 0) {
|
||||||
try {
|
// 生成二维码图片
|
||||||
// 生成用户分享二维码-文章/视频
|
if (caseClinicalArticle.getShareQrcode() == null){
|
||||||
qrCodeBytes = addUnlimitedQrcode(caseClinicalArticle.getArticleId());
|
try {
|
||||||
} catch (Exception e) {
|
// 生成用户分享二维码-文章/视频
|
||||||
// 不处理
|
qrCodeBytes = addUnlimitedQrcode(caseClinicalArticle.getArticleId());
|
||||||
throw new BusinessException("操作失败");
|
} catch (Exception e) {
|
||||||
|
// 不处理
|
||||||
|
throw new BusinessException("操作失败");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// 下载二维码图片
|
||||||
|
qrCodeBytes = Oss.getObjectToByte(caseClinicalArticle.getShareQrcode().replaceFirst("^/+", ""));
|
||||||
|
if (qrCodeBytes == null) {
|
||||||
|
throw new BusinessException("操作失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载头像
|
||||||
|
byte[] avatarByte = new byte[0];
|
||||||
|
if (caseClinicalDoctor.getAvatar() != null && !caseClinicalDoctor.getAvatar().isEmpty()) {
|
||||||
|
avatarByte = Oss.getObjectToByte(caseClinicalDoctor.getAvatar().replaceFirst("^/+", ""));
|
||||||
}else{
|
}else{
|
||||||
// 下载二维码图片
|
try {
|
||||||
qrCodeBytes = Oss.getObjectToByte(caseClinicalArticle.getShareQrcode().replaceFirst("^/+", ""));
|
avatarByte = ImageUtil.readImageToBytes("static/cert/avatar.png");
|
||||||
if (qrCodeBytes == null) {
|
} catch (Exception e) {
|
||||||
throw new BusinessException("操作失败");
|
throw new BusinessException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 下载头像
|
if (avatarByte == null) {
|
||||||
byte[] avatarByte = new byte[0];
|
throw new BusinessException("操作失败");
|
||||||
if (caseClinicalDoctor.getAvatar() != null && !caseClinicalDoctor.getAvatar().isEmpty()) {
|
}
|
||||||
avatarByte = Oss.getObjectToByte(caseClinicalDoctor.getAvatar().replaceFirst("^/+", ""));
|
|
||||||
}else{
|
userService.CreateUserCert(
|
||||||
try {
|
String.valueOf(caseClinicalArticle.getArticleId()),
|
||||||
avatarByte = ImageUtil.readImageToBytes("static/cert/avatar.png");
|
1,
|
||||||
} catch (Exception e) {
|
String.valueOf(caseClinicalDoctor.getDoctorId()),
|
||||||
throw new BusinessException(e.getMessage());
|
qrCodeBytes,
|
||||||
|
avatarByte
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!addHospitalSet.isEmpty()){
|
||||||
|
// 增加医院统计
|
||||||
|
for (String hospitalId : addHospitalSet ){
|
||||||
|
LocalDateTime lastPushDate = caseClinicalArticleDao.selectLastArticlePushDateByHospitalId(Long.valueOf(hospitalId));
|
||||||
|
|
||||||
|
caseClinicalService.IncStatsCaseClinicalHospital(hospitalId,1,
|
||||||
|
lastPushDate,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理文章作者
|
||||||
|
public void HandleArticleAuthorWithLink(CaseClinicalArticleEntity caseClinicalArticle,List<CaseClinicalArticleAuthorForm> r){
|
||||||
|
// 需新增的
|
||||||
|
List<CaseClinicalArticleAuthorForm> addList = new ArrayList<>();
|
||||||
|
|
||||||
|
// 需删除的
|
||||||
|
List<CaseClinicalArticleAuthorEntity> deleteList = new ArrayList<>();
|
||||||
|
|
||||||
|
// 获取全部作者
|
||||||
|
LambdaQueryWrapper<CaseClinicalArticleAuthorEntity> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
authorQueryWrapper.eq(CaseClinicalArticleAuthorEntity::getArticleId, caseClinicalArticle.getArticleId());
|
||||||
|
List<CaseClinicalArticleAuthorEntity> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
|
||||||
|
|
||||||
|
// 处理新增的情况
|
||||||
|
for (CaseClinicalArticleAuthorForm a : r){
|
||||||
|
// 默认本条为新增
|
||||||
|
boolean exists = true;
|
||||||
|
for (CaseClinicalArticleAuthorEntity b : caseClinicalArticleAuthors){
|
||||||
|
if (Objects.equals(a.getDoctorId(), b.getDoctorId())){
|
||||||
|
exists = false;
|
||||||
|
break; // 已存在,跳出内层循环
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avatarByte == null) {
|
if (exists) {
|
||||||
|
addList.add(a); // 不存在于旧数据中,加入新增列表
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理删除的情况
|
||||||
|
for (CaseClinicalArticleAuthorEntity b : caseClinicalArticleAuthors){
|
||||||
|
// 默认本条为删除
|
||||||
|
boolean exists = true;
|
||||||
|
for (CaseClinicalArticleAuthorForm a : r){
|
||||||
|
if (Objects.equals(a.getDoctorId(), b.getDoctorId())){
|
||||||
|
exists = false;
|
||||||
|
break; // 已存在,跳出内层循环
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exists) {
|
||||||
|
deleteList.add(b); // 加入删除列表
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
Set<String> deleteHospitalSet = new LinkedHashSet<>();
|
||||||
|
for (CaseClinicalArticleAuthorEntity author : deleteList){
|
||||||
|
// 获取医生数据
|
||||||
|
LambdaQueryWrapper<CaseClinicalDoctorEntity> doctorQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
doctorQueryWrapper.eq(CaseClinicalDoctorEntity::getDoctorId, author.getDoctorId());
|
||||||
|
CaseClinicalDoctorEntity caseClinicalDoctor = caseClinicalDoctorDao.selectOne(doctorQueryWrapper);
|
||||||
|
if (caseClinicalDoctor == null) {
|
||||||
throw new BusinessException("操作失败");
|
throw new BusinessException("操作失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
userService.CreateUserCert(
|
// 获取医院数据
|
||||||
String.valueOf(caseClinicalArticle.getArticleId()),
|
BasicHospitalEntity basicHospital = basicHospitalDao.selectById(caseClinicalDoctor.getHospitalId());
|
||||||
1,
|
if (basicHospital == null) {
|
||||||
String.valueOf(caseClinicalDoctor.getDoctorId()),
|
throw new BusinessException("操作失败");
|
||||||
qrCodeBytes,
|
}
|
||||||
avatarByte
|
|
||||||
);
|
// 减少作者统计
|
||||||
|
caseClinicalService.DecStatsCaseClinicalDoctor(String.valueOf(caseClinicalDoctor.getDoctorId()),1);
|
||||||
|
|
||||||
|
// 增加需要减少的医院数据
|
||||||
|
deleteHospitalSet.add(String.valueOf(caseClinicalDoctor.getHospitalId()));
|
||||||
|
|
||||||
|
// 删除该作者
|
||||||
|
caseClinicalArticleAuthorDao.deleteById(author.getAuthorId());
|
||||||
|
|
||||||
|
// 删除该作者证书
|
||||||
|
LambdaQueryWrapper<CaseClinicalDoctorCertEntity> certWrapper = new LambdaQueryWrapper<>();
|
||||||
|
certWrapper.eq(CaseClinicalDoctorCertEntity::getDoctorId, caseClinicalDoctor.getDoctorId());
|
||||||
|
certWrapper.eq(CaseClinicalDoctorCertEntity::getId, caseClinicalArticle.getArticleId());
|
||||||
|
certWrapper.eq(CaseClinicalDoctorCertEntity::getType, 1);
|
||||||
|
caseClinicalDoctorCertDao.delete(certWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!deleteHospitalSet.isEmpty()){
|
||||||
|
// 减少医院统计
|
||||||
|
for (String hospitalId : deleteHospitalSet ){
|
||||||
|
caseClinicalService.DecStatsCaseClinicalHospital(hospitalId,1,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增新的作者
|
||||||
|
Set<String> addHospitalSet = new LinkedHashSet<>();
|
||||||
|
for (CaseClinicalArticleAuthorForm author : addList){
|
||||||
|
CaseClinicalDoctorEntity caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||||||
|
|
||||||
|
CaseClinicalArticleAuthorEntity caseClinicalArticleAuthor = new CaseClinicalArticleAuthorEntity();
|
||||||
|
caseClinicalArticleAuthor.setArticleId(caseClinicalArticle.getArticleId());
|
||||||
|
caseClinicalArticleAuthor.setDoctorId(caseClinicalDoctor.getDoctorId());
|
||||||
|
caseClinicalArticleAuthorDao.insert(caseClinicalArticleAuthor);
|
||||||
|
|
||||||
|
LocalDateTime lastPushDate = caseClinicalArticleDao.selectLastArticlePushDateByDoctorId(caseClinicalDoctor.getDoctorId());
|
||||||
|
|
||||||
|
// 新增作者统计
|
||||||
|
caseClinicalService.IncStatsCaseClinicalDoctor(String.valueOf(caseClinicalDoctor.getDoctorId()),1,lastPushDate);
|
||||||
|
|
||||||
|
// 增加需要增加的医院数据
|
||||||
|
addHospitalSet.add(String.valueOf(caseClinicalDoctor.getHospitalId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addHospitalSet.isEmpty()){
|
if (!addHospitalSet.isEmpty()){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user