优化流程保存和更新接口、优化流程信息查询接口 #139
+44
@@ -0,0 +1,44 @@
|
||||
package com.ruoyi.system.domain.entity.flow;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Table(name = "ms_case_flow_role_sms_related")
|
||||
public class MsCaseFlowRoleSmsRelated {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(generator = "JDBC")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 案件流程id
|
||||
*/
|
||||
@Column(name = "flow_id")
|
||||
private Integer flowId;
|
||||
|
||||
/**
|
||||
* 用户角色id
|
||||
*/
|
||||
@Column(name = "receive_role_id")
|
||||
private Long receiveRoleId;
|
||||
|
||||
/**
|
||||
* 短信模版id
|
||||
*/
|
||||
@Column(name = "sms_template_id")
|
||||
private Long smsTemplateId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.system.domain.vo.flow;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Data
|
||||
public class MsCaseFlowRoleSmsRelatedVO {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 流程节点id
|
||||
*/
|
||||
private Integer flowId;
|
||||
|
||||
|
||||
/**
|
||||
* 短信模版id
|
||||
*/
|
||||
private Long smsTemplateId;
|
||||
/**
|
||||
* 发送短信的角色id
|
||||
*/
|
||||
private List<Long> receiveRoleIds;
|
||||
/**
|
||||
* 接收短信角色名称
|
||||
*/
|
||||
public List<JSONObject> receiveRoleNames;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.system.domain.vo.flow;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -64,5 +65,16 @@ public class MsCaseFlowVO {
|
||||
* svg图片路径
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 短信模版id
|
||||
*/
|
||||
private Long smsTemplateId;
|
||||
/**
|
||||
* 发送短信的角色id
|
||||
*/
|
||||
private List<Long> receiveRoleIds;
|
||||
/**
|
||||
* 接收短信角色名称
|
||||
*/
|
||||
public List<JSONObject> receiveRoleNames;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.ruoyi.system.mapper.flow;
|
||||
|
||||
import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleSmsRelated;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface MsCaseFlowRoleSmsRelatedMapper extends Mapper<MsCaseFlowRoleSmsRelated> {
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.system.service.flow;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.system.domain.vo.flow.MsCaseFlowRoleSmsRelatedVO;
|
||||
import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO;
|
||||
import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO;
|
||||
|
||||
@@ -9,18 +10,22 @@ import java.util.Set;
|
||||
public interface CaseFlowService {
|
||||
/**
|
||||
* 查询案件流程节点信息
|
||||
*
|
||||
* @param caseFlowSearchVO
|
||||
* @return
|
||||
*/
|
||||
Object queryCaseFlowInfo(MsCaseFlowSearchVO caseFlowSearchVO);
|
||||
|
||||
/**
|
||||
* 查询案件流程信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
AjaxResult selectCaseFlow();
|
||||
|
||||
/**
|
||||
* 新增或编辑案件流程节点信息
|
||||
*
|
||||
* @param caseFlowVO
|
||||
* @return
|
||||
*/
|
||||
@@ -28,6 +33,7 @@ public interface CaseFlowService {
|
||||
|
||||
/**
|
||||
* 删除案件流程节点信息
|
||||
*
|
||||
* @param caseFlowVO
|
||||
* @return
|
||||
*/
|
||||
@@ -35,6 +41,7 @@ public interface CaseFlowService {
|
||||
|
||||
/**
|
||||
* 排序案件流程节点
|
||||
*
|
||||
* @param caseFlowSearchVO
|
||||
* @return
|
||||
*/
|
||||
@@ -42,10 +49,14 @@ public interface CaseFlowService {
|
||||
|
||||
/**
|
||||
* 查询用户角色关联的案件状态
|
||||
*
|
||||
* @param roles
|
||||
* @return
|
||||
*/
|
||||
Set<Integer> getCaseStatusIdByRoleKey(Set<String> roles);
|
||||
|
||||
|
||||
/**
|
||||
* 查询流程节点接收信息配置记录
|
||||
*/
|
||||
MsCaseFlowRoleSmsRelatedVO queryFlowReceiveRoleSmsRelated(Integer flowId);
|
||||
}
|
||||
|
||||
+137
-32
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.system.service.flow;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
@@ -7,12 +8,15 @@ import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
|
||||
import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated;
|
||||
import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleSmsRelated;
|
||||
import com.ruoyi.system.domain.vo.flow.MsBaseCaseFlow;
|
||||
import com.ruoyi.system.domain.vo.flow.MsCaseFlowRoleSmsRelatedVO;
|
||||
import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO;
|
||||
import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO;
|
||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.flow.MsCaseFlowMapper;
|
||||
import com.ruoyi.system.mapper.flow.MsCaseFlowRoleRelatedMapper;
|
||||
import com.ruoyi.system.mapper.flow.MsCaseFlowRoleSmsRelatedMapper;
|
||||
import com.ruoyi.system.util.NewStringUtil;
|
||||
import com.ruoyi.system.util.TableDataUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -90,6 +94,30 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
||||
MsCaseFlow msCaseFlow1 = msCaseFlowMapper.selectByPrimaryKey(msCaseFlow.getBackFlowId());
|
||||
temp.setBackFlowName(msCaseFlow1 != null ? msCaseFlow1.getNodeName() : "");
|
||||
}
|
||||
//短信接收角色
|
||||
if (msCaseFlow.getId() != null) {
|
||||
Example example1 = new Example(MsCaseFlowRoleSmsRelated.class);
|
||||
Example.Criteria criteria1 = example1.createCriteria();
|
||||
criteria1.andEqualTo("flowId", msCaseFlow.getId());
|
||||
List<MsCaseFlowRoleSmsRelated> msCaseFlowRoleSmsRelateds = msCaseFlowRoleSmsRelatedMapper.selectByExample(example1);
|
||||
List<JSONObject> receiveRoleNames = new ArrayList<>();
|
||||
List<Long> receiveRoleIds = new ArrayList<>();
|
||||
for (int k = 0; k < msCaseFlowRoleSmsRelateds.size(); k++) {
|
||||
MsCaseFlowRoleSmsRelated msCaseFlowRoleSmsRelated = msCaseFlowRoleSmsRelateds.get(k);
|
||||
if (msCaseFlowRoleSmsRelated.getReceiveRoleId() != null) {
|
||||
SysRole sysRole = sysRoleMapper.selectRoleById(msCaseFlowRoleSmsRelated.getReceiveRoleId());
|
||||
if (sysRole != null) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("roleId", sysRole.getRoleId());
|
||||
jsonObject.put("roleName", sysRole.getRoleName());
|
||||
receiveRoleNames.add(jsonObject);
|
||||
receiveRoleIds.add(sysRole.getRoleId());
|
||||
}
|
||||
}
|
||||
}
|
||||
temp.setReceiveRoleIds(receiveRoleIds);
|
||||
temp.setReceiveRoleNames(receiveRoleNames);
|
||||
}
|
||||
list.add(temp);
|
||||
}
|
||||
TableDataInfo tableDataInfo = TableDataUtil.rebuildTableDataInfo(list, total);
|
||||
@@ -134,15 +162,16 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
||||
|
||||
/**
|
||||
* 本地图片装64
|
||||
*
|
||||
* @param imgPath
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String convertToBase64( String imgPath) {
|
||||
public static String convertToBase64(String imgPath) {
|
||||
byte[] data = null;
|
||||
// 读取图片字节数组
|
||||
try {
|
||||
imgPath=imgPath.replace("/profile/upload", "/home/ruoyi/uploadPath/upload/");
|
||||
imgPath = imgPath.replace("/profile/upload", "/home/ruoyi/uploadPath/upload/");
|
||||
InputStream in = Files.newInputStream(Paths.get(imgPath));
|
||||
data = new byte[in.available()];
|
||||
in.read(data);
|
||||
@@ -153,6 +182,7 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
||||
// 返回Base64编码过的字节数组字符串
|
||||
return Base64.getEncoder().encodeToString(Objects.requireNonNull(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或编辑案件流程节点信息
|
||||
*
|
||||
@@ -161,40 +191,78 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean saveCaseFlow(MsCaseFlowVO caseFlowVO) {
|
||||
|
||||
if (caseFlowVO.getId() != null) {
|
||||
//更新案件流程信息
|
||||
MsCaseFlow msCaseFlow = new MsCaseFlow();
|
||||
BeanUtils.copyProperties(caseFlowVO, msCaseFlow);
|
||||
int i = msCaseFlowMapper.updateByPrimaryKey(msCaseFlow);
|
||||
if (i > 0) {
|
||||
//更新流程节点和角色之间的关系
|
||||
updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
int sort = 1;
|
||||
Example example = new Example(MsCaseFlow.class);
|
||||
example.setOrderByClause("sort DESC limit 1");
|
||||
Example.Criteria criteria = example.createCriteria();
|
||||
List<MsCaseFlow> msCaseFlows = msCaseFlowMapper.selectByExample(example);
|
||||
if (msCaseFlows != null && msCaseFlows.size() > 0) {
|
||||
sort = msCaseFlows.get(0).getSort() + 1;
|
||||
}
|
||||
//新增案件流程信息
|
||||
MsCaseFlow msCaseFlow = new MsCaseFlow();
|
||||
BeanUtils.copyProperties(caseFlowVO, msCaseFlow);
|
||||
msCaseFlow.setSort(sort);
|
||||
int insert = msCaseFlowMapper.insert(msCaseFlow);
|
||||
if (insert > 0) {
|
||||
//更新流程节点和角色之间的关系
|
||||
updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds());
|
||||
return true;
|
||||
try {
|
||||
if (caseFlowVO.getId() != null) {
|
||||
//更新案件流程信息
|
||||
MsCaseFlow msCaseFlow = new MsCaseFlow();
|
||||
BeanUtils.copyProperties(caseFlowVO, msCaseFlow);
|
||||
int i = msCaseFlowMapper.updateByPrimaryKey(msCaseFlow);
|
||||
if (i > 0) {
|
||||
//更新流程节点和角色之间的关系
|
||||
updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds());
|
||||
//更新流程节点和短信模板之间的关系
|
||||
updateFlowMessageRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getReceiveRoleIds(), caseFlowVO.getSmsTemplateId());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
int sort = 1;
|
||||
Example example = new Example(MsCaseFlow.class);
|
||||
example.setOrderByClause("sort DESC limit 1");
|
||||
Example.Criteria criteria = example.createCriteria();
|
||||
List<MsCaseFlow> msCaseFlows = msCaseFlowMapper.selectByExample(example);
|
||||
if (msCaseFlows != null && msCaseFlows.size() > 0) {
|
||||
sort = msCaseFlows.get(0).getSort() + 1;
|
||||
}
|
||||
//新增案件流程信息
|
||||
MsCaseFlow msCaseFlow = new MsCaseFlow();
|
||||
BeanUtils.copyProperties(caseFlowVO, msCaseFlow);
|
||||
msCaseFlow.setSort(sort);
|
||||
int insert = msCaseFlowMapper.insert(msCaseFlow);
|
||||
if (insert > 0) {
|
||||
//更新流程节点和角色之间的关系
|
||||
updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds());
|
||||
//更新流程节点和短信模板之间的关系
|
||||
updateFlowMessageRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getReceiveRoleIds(), caseFlowVO.getSmsTemplateId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
MsCaseFlowRoleSmsRelatedMapper msCaseFlowRoleSmsRelatedMapper;
|
||||
|
||||
/**
|
||||
* 更新流程节点和短信模板之间的关系
|
||||
*
|
||||
* @param flowId
|
||||
* @param receiveRoleIds
|
||||
* @param smsTemplateId
|
||||
*/
|
||||
private void updateFlowMessageRoleByFlowId(Integer flowId, List<Long> receiveRoleIds, Long smsTemplateId) {
|
||||
if (receiveRoleIds != null && receiveRoleIds.size() > 0) {
|
||||
//删除历史流程与短信发送设置记录
|
||||
Example example = new Example(MsCaseFlowRoleSmsRelated.class);
|
||||
example.createCriteria().andEqualTo("flowId", flowId);
|
||||
int count = msCaseFlowRoleSmsRelatedMapper.deleteByExample(example);
|
||||
//新增流程节点与短信发送设置记录
|
||||
for (int i = 0; i < receiveRoleIds.size(); i++) {
|
||||
MsCaseFlowRoleSmsRelated msCaseFlowRoleSmsRelated = new MsCaseFlowRoleSmsRelated();
|
||||
msCaseFlowRoleSmsRelated.setFlowId(flowId);
|
||||
msCaseFlowRoleSmsRelated.setReceiveRoleId(receiveRoleIds.get(i));
|
||||
msCaseFlowRoleSmsRelated.setSmsTemplateId(smsTemplateId);
|
||||
msCaseFlowRoleSmsRelated.setCreateTime(new Date());
|
||||
msCaseFlowRoleSmsRelatedMapper.insertSelective(msCaseFlowRoleSmsRelated);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新流程节点和角色之间的关系
|
||||
*
|
||||
@@ -258,7 +326,6 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 排序案件流程节点
|
||||
*
|
||||
@@ -352,6 +419,44 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
||||
return caseStatusIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程节点接收信息配置记录
|
||||
*
|
||||
* @param flowId
|
||||
*/
|
||||
@Override
|
||||
public MsCaseFlowRoleSmsRelatedVO queryFlowReceiveRoleSmsRelated(Integer flowId) {
|
||||
MsCaseFlowRoleSmsRelatedVO result = new MsCaseFlowRoleSmsRelatedVO();
|
||||
//短信接收角色
|
||||
if (flowId != null) {
|
||||
Example example1 = new Example(MsCaseFlowRoleSmsRelated.class);
|
||||
Example.Criteria criteria1 = example1.createCriteria();
|
||||
criteria1.andEqualTo("flowId", flowId);
|
||||
List<MsCaseFlowRoleSmsRelated> msCaseFlowRoleSmsRelateds = msCaseFlowRoleSmsRelatedMapper.selectByExample(example1);
|
||||
List<JSONObject> receiveRoleNames = new ArrayList<>();
|
||||
List<Long> receiveRoleIds = new ArrayList<>();
|
||||
for (int k = 0; k < msCaseFlowRoleSmsRelateds.size(); k++) {
|
||||
MsCaseFlowRoleSmsRelated msCaseFlowRoleSmsRelated = msCaseFlowRoleSmsRelateds.get(k);
|
||||
if (k == 0) {
|
||||
BeanUtils.copyProperties(msCaseFlowRoleSmsRelated, result);
|
||||
}
|
||||
if (msCaseFlowRoleSmsRelated.getReceiveRoleId() != null) {
|
||||
SysRole sysRole = sysRoleMapper.selectRoleById(msCaseFlowRoleSmsRelated.getReceiveRoleId());
|
||||
if (sysRole != null) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("roleId", sysRole.getRoleId());
|
||||
jsonObject.put("roleName", sysRole.getRoleName());
|
||||
receiveRoleNames.add(jsonObject);
|
||||
receiveRoleIds.add(sysRole.getRoleId());
|
||||
}
|
||||
}
|
||||
}
|
||||
result.setReceiveRoleIds(receiveRoleIds);
|
||||
result.setReceiveRoleNames(receiveRoleNames);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色的案件状态id
|
||||
*
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.system.mapper.flow.MsCaseFlowRoleSmsRelatedMapper">
|
||||
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleSmsRelated">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
-->
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="flow_id" jdbcType="INTEGER" property="flowId" />
|
||||
<result column="receive_role_id" jdbcType="BIGINT" property="receiveRoleId" />
|
||||
<result column="sms_template_id" jdbcType="BIGINT" property="smsTemplateId" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
</resultMap>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user