11.9开发

This commit is contained in:
hejinbo
2023-11-09 17:34:12 +08:00
parent ae2c8fe59f
commit 94d3f1cb1e
10 changed files with 351 additions and 124 deletions
@@ -3,6 +3,7 @@ package com.ruoyi.wisdomarbitrate.service;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -15,4 +16,8 @@ public interface IDeptIdentifyService {
DeptIdentify selectDeptIndefiUrl(DeptIdentify deptIdentify) throws EsignDemoException;
AjaxResult enableDept(DeptIdentify deptIdentify);
AjaxResult sealUpload(DeptIdentify deptIdentify, MultipartFile file);
}
@@ -1,18 +1,26 @@
package com.ruoyi.wisdomarbitrate.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.common.utils.SealUtil;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
import com.ruoyi.wisdomarbitrate.mapper.DeptIdentifyMapper;
import com.ruoyi.wisdomarbitrate.service.IDeptIdentifyService;
import com.ruoyi.wisdomarbitrate.utils.SignAward;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Date;
import java.util.List;
@@ -21,19 +29,21 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
@Autowired
private DeptIdentifyMapper deptIdentifyMapper;
@Autowired
private CaseAttachMapper caseAttachMapper;
@Override
@Transactional
public List<DeptIdentify> selectDeptIdentify(DeptIdentify deptIdentify) {
List<DeptIdentify> deptIdentifys = deptIdentifyMapper.selectDeptIdentify(deptIdentify);
if(deptIdentifys!=null&&deptIdentifys.size()>0){
if (deptIdentifys != null && deptIdentifys.size() > 0) {
for (int i = 0; i < deptIdentifys.size(); i++) {
DeptIdentify deptIdentifyselect = deptIdentifys.get(i);
List<DeptIdentify> deptIdentifylist = deptIdentifyMapper.selectDeptIdentifyBydeptid(deptIdentifyselect);
if(deptIdentifylist!=null&&deptIdentifylist.size()>0){
if (deptIdentifylist != null && deptIdentifylist.size() > 0) {
continue;
}else {
} else {
deptIdentifyselect.setIdentifyStatus(0);
deptIdentifyMapper.insertDeptIdentify(deptIdentifyselect);
}
@@ -49,21 +59,21 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
public DeptIdentify selectDeptIndefiUrl(DeptIdentify deptIdentify) throws EsignDemoException {
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
DeptIdentify deptIdentifynew = new DeptIdentify();
if(deptIdentifysnew!=null&&deptIdentifysnew.size()>0){
if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) {
Gson gson = new Gson();
DeptIdentify deptIdentifyselect = deptIdentifysnew.get(0);
EsignHttpResponse identifyUrl = SignAward.deptIdentifyUrl(deptIdentifyselect);
JsonObject signUrlJsonObject = gson.fromJson(identifyUrl.getBody(), JsonObject.class);
int code = signUrlJsonObject.get("code").getAsInt();
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
String url = signUrlData.get("authUrl").getAsString();
//获取本次认证授权流程ID
String authFlowId = signUrlData.get("authFlowId").getAsString();
deptIdentify.setAuthFlowId(authFlowId);
deptIdentifynew.setIdentifyUrl(url);
deptIdentify.setIdentifyDate(new Date());
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentify);
}
deptIdentify.setIdentifyDate(new Date());
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentify);
return deptIdentifynew;
}
@@ -73,9 +83,9 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
DeptIdentify deptIdentifyselect = deptIdentifysnew.get(0);
Integer identifyStatus = deptIdentifyselect.getIdentifyStatus();
if(identifyStatus.intValue()==0){
if (identifyStatus.intValue() == 0) {
return AjaxResult.error("这个认证数据未进行认证,不能启用");
}else if(identifyStatus.intValue()==1){
} else if (identifyStatus.intValue() == 1) {
deptIdentifyselect.setIsUse(1);
deptIdentifyMapper.updateDeptIdentify(deptIdentifyselect);
@@ -83,7 +93,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
deptIdentifySel.setId(deptIdentify.getId());
deptIdentifySel.setIdentifyStatus(1);
List<DeptIdentify> deptIdentifysother = deptIdentifyMapper.selectDeptIdentifylistother(deptIdentifySel);
if(deptIdentifysother!=null&&deptIdentifysother.size()>0){
if (deptIdentifysother != null && deptIdentifysother.size() > 0) {
for (int i = 0; i < deptIdentifysother.size(); i++) {
DeptIdentify deptIdentifyother = deptIdentifysother.get(i);
deptIdentifyother.setIsUse(0);
@@ -96,5 +106,53 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
}
@Override
public AjaxResult sealUpload(DeptIdentify deptIdentify, MultipartFile file) {
try {
if (file.isEmpty()) {
return AjaxResult.error("请选择要上传的文件");
}
String filePath = RuoYiConfig.getUploadPath();
// 上传
String fileName = FileUploadUtils.upload(filePath, file);
List<DeptIdentify> deptIdentifies = deptIdentifyMapper.selectDeptIdentifyBydeptid(deptIdentify);
if (deptIdentifies != null && deptIdentifies.size() > 0) {
for (DeptIdentify identify : deptIdentifies) {
//先判断企业用户是否授予资源管理权限
String authFlowId = identify.getAuthFlowId();
EsignHttpResponse response1 = SealUtil.queryAuthProcess(authFlowId);
JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody());
int authorizedStatus = jsonObject1.getJSONObject("data").getIntValue("authorizedStatus");
if (authorizedStatus == 1){//授权流程状态 0流程过期失效 1已授权 2授权中 3审批未通过
String prefix = "/profile";
int startIndex = fileName.indexOf(prefix);
startIndex += prefix.length();
String annexPath = "/uploadPath" + fileName.substring(startIndex);
//创建机构图片印章
EsignHttpResponse response = SignAward.createOrgByImage(identify, annexPath);
JSONObject jsonObject = JSONObject.parseObject(response.getBody());
int code = jsonObject.getIntValue("code");
if (code == 0) { //业务码,0表示成功,非0表示异常。
String sealId = jsonObject.getJSONObject("data").getString("sealId");
identify.setSealId(sealId);
identify.setIsUse(0); //设置印章使用状态为未启用
//保存到表里
int i = deptIdentifyMapper.updateDeptIdentify(identify);
if (i>0){
return AjaxResult.success("上传成功");
}
}
}
return AjaxResult.error("企业用户未授予资源管理权限");
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (EsignDemoException e) {
e.printStackTrace();
}
return AjaxResult.error();
}
}