模板管理优化

This commit is contained in:
18792927508
2024-02-06 10:54:39 +08:00
parent c7149351bc
commit d73e891c3c
12 changed files with 385 additions and 106 deletions
@@ -1,7 +1,6 @@
package com.ruoyi.wisdomarbitrate.domain.dto.template;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.wisdomarbitrate.domain.dto.template.FatchRule;
import lombok.Data;
import java.util.List;
@@ -13,6 +12,14 @@ public class TemplateManage extends BaseEntity {
* ID
*/
private Long id;
/**
* 附件id
*/
private Long fileId;
/**
* 附件ids
*/
private List<Long> annexIds;
/**
* 机构关联id
@@ -44,10 +51,7 @@ public class TemplateManage extends BaseEntity {
* 修订后模板路径
*/
private String temRevisPath;
/**
* 删除标志(0代表存在 2代表删除)
*/
private Integer delFlag;
/**
* 机构关联id
*/
@@ -5,7 +5,6 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import java.util.List;
@NoArgsConstructor
@@ -20,6 +19,10 @@ public class MsCaseApplicationReq {
* 模板id
*/
private String templateId;
/**
* 模板附件id
*/
private Long fileId;
/**
* 批次
*/
@@ -2,6 +2,7 @@ package com.ruoyi.wisdomarbitrate.mapper.dept;
import com.ruoyi.wisdomarbitrate.domain.dto.dept.DeptIdentify;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -17,4 +18,10 @@ public interface DeptIdentifyMapper {
int updateDeptIdentify(DeptIdentify deptIdentify);
/**
* 根据机构id查询名称
* @param identifyId
* @return
*/
String selectById(@Param("id") Long identifyId);
}
@@ -21,4 +21,61 @@ public interface TemplateManageMapper {
* @return
*/
TemplateManage selectByType(@Param("type") int type);
/**
* 批量修改
* @param templateManage
* @return
*/
int updateByIds(TemplateManage templateManage);
/**
* 新增模板附件表
* @param templateManage
* @return
*/
int insertTemplateManageFile(TemplateManage templateManage);
/**
* 删除模板
* @param id
* @return
*/
int deleteTemplateManage(@Param("id") Long id);
/**
* 根据id修改附件表
* @param templateManage
*/
void updateFileByIds(@Param("manage") TemplateManage templateManage);
/**
* 根据条件删除附件
* @param id
* @param annexIds
*/
void deleteTemplateManageFileById(@Param("id")Long id, @Param("fileIds")List<Long> annexIds);
/**
* 根据模板id和类型查询
* @param templateId
* @param code
* @return
*/
TemplateManage selectByIdAndType(@Param("templateId")Long templateId, @Param("type")Integer code);
/**
* 根据附件id查询
* @param templateId
* @return
*/
TemplateManage selectFileById(@Param("fileId") Long templateId);
/**
* 根据模板id查询
* @param id
* @return
*/
List<TemplateManage> selectTemplateListById(@Param("id")Long id);
}
@@ -9,6 +9,7 @@ import com.ruoyi.wisdomarbitrate.domain.dto.dept.SealManage;
import com.ruoyi.wisdomarbitrate.domain.dto.template.TemplateManage;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
public interface IDeptIdentifyService {
@@ -37,9 +38,9 @@ public interface IDeptIdentifyService {
AjaxResult updateDeptIdentify(DeptIdentify deptIdentify);
AjaxResult insertTemplate(TemplateManage templateManage , MultipartFile file);
AjaxResult insertTemplate(TemplateManage templateManage );
AjaxResult updateTemplate(TemplateManage templateManage, MultipartFile file);
AjaxResult updateTemplate(TemplateManage templateManage);
AjaxResult deleteTemplate(Long id);
@@ -62,4 +63,19 @@ public interface IDeptIdentifyService {
* @return
*/
List<FatchRule> getTemplateInfoById(TemplateManage templateManage);
/**
* 上传附件
* @param file
* @param annexType
* @return
*/
AjaxResult uploadFile(MultipartFile file, Integer annexType) throws IOException;
/**
* 根据模板id查询详情
* @param id
* @return
*/
AjaxResult getTemplateDetail(Long id);
}
@@ -13,10 +13,12 @@ import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.AnnexTypeEnum;
import com.ruoyi.common.enums.TemplateTypeEnum;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SealUtil;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.system.mapper.*;
import com.ruoyi.wisdomarbitrate.domain.dto.dept.DeptIdentify;
import com.ruoyi.wisdomarbitrate.domain.dto.dept.SealManage;
@@ -41,6 +43,7 @@ import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -73,6 +76,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
private SysDictDataMapper dictDataMapper;
@Override
@Transactional
public List<DeptIdentify> selectDeptIdentify(DeptIdentify deptIdentify) {
@@ -405,70 +409,41 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
return null;
}
@Transactional
@Override
public AjaxResult insertTemplate(TemplateManage templateManage, MultipartFile file) {
//参数校验
if (templateManage.getIdentifyId() == null || file == null || templateManage.getTemName() == null) {
return AjaxResult.error("请检查参数是否完整");
}
if (templateManage.getTemType() == null) {
templateManage.setTemType(1); //默认模板类型为1(裁决书)
}
try {
String filePath = RuoYiConfig.getUploadPath();
// 上传
String fileName = FileUploadUtils.upload(filePath, file);
templateManage.setTemOrigPath(fileName);
String format = getFileExtension(fileName);
templateManage.setTemFormat(format);
templateManage.setFileName(file.getOriginalFilename());
public AjaxResult insertTemplate(TemplateManage templateManage) {
templateManage.setCreateBy(getUsername());
int i = templateManageMapper.insertTemplateManage(templateManage);
templateManage.setId(templateManage.getId());
templateManageMapper.updateFileByIds(templateManage);
if (i > 0) {
return AjaxResult.success("新增成功");
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Transactional
@Override
public AjaxResult updateTemplate(TemplateManage templateManage, MultipartFile file) {
public AjaxResult updateTemplate(TemplateManage templateManage) {
Long id = templateManage.getId();
if (id == null) {
return AjaxResult.error();
}
try {
if (file != null && file.getSize() > 0) {
String filePath = RuoYiConfig.getUploadPath();
// 上传
String fileName = FileUploadUtils.upload(filePath, file);
templateManage.setTemOrigPath(fileName);
templateManage.setFileName(file.getOriginalFilename());
String format = getFileExtension(fileName);
templateManage.setTemFormat(format);
}
templateManage.setUpdateBy(getUsername());
int i = templateManageMapper.updateTemplateManage(templateManage);
// 先删除附件
if(CollectionUtil.isNotEmpty(templateManage.getAnnexIds())) {
templateManageMapper.deleteTemplateManageFileById(id, templateManage.getAnnexIds());
// 修改附件表
templateManageMapper.updateFileByIds(templateManage);
}
if (i > 0) {
return AjaxResult.success("修改成功");
}
} catch (IOException e) {
e.printStackTrace();
}
return AjaxResult.error();
}
@Transactional
@Override
public AjaxResult deleteTemplate(Long id) {
TemplateManage templateManage = new TemplateManage();
templateManage.setId(id);
templateManage.setDelFlag(2);
int i = templateManageMapper.updateTemplateManage(templateManage);
int i = templateManageMapper.deleteTemplateManage(id);
if (i > 0) {
return AjaxResult.success("删除成功");
}
@@ -620,6 +595,58 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
return fatchRuleList;
}
@Transactional
@Override
public AjaxResult uploadFile(MultipartFile file, Integer annexType) throws IOException {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
TemplateManage templateManage=new TemplateManage();
templateManage.setTemOrigPath(fileName);
String format = getFileExtension(fileName);
templateManage.setTemFormat(format);
templateManage.setFileName(file.getOriginalFilename());
templateManage.setTemType(annexType);
int i = templateManageMapper.insertTemplateManageFile(templateManage);
if(i<1){
return AjaxResult.error("上传失败");
}
AjaxResult ajax = AjaxResult.success();
ajax.put("annexId", templateManage.getFileId());
ajax.put("annexType", annexType);
ajax.put("url", fileName);
ajax.put("fileName", fileName);
ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename());
return ajax;
}
@Override
public AjaxResult getTemplateDetail(Long id) {
List<TemplateManage> list = templateManageMapper.selectTemplateListById(id);
if(CollectionUtil.isEmpty(list)){
return AjaxResult.error("模板不存在");
}
Map<Integer, TemplateManage> manageMap = list.stream().collect(Collectors.toMap(TemplateManage::getTemType, Function.identity(), (oldValue, newValue) -> newValue));
AjaxResult ajax = AjaxResult.success();
ajax.put("id",id);
ajax.put("identifyId",list.get(0).getIdentifyId());
if(list.get(0).getIdentifyId()!=null) {
// 查询机构名称
ajax.put("identifyName", deptIdentifyMapper.selectById(list.get(0).getIdentifyId()));
}
ajax.put("temName",list.get(0).getTemName());
// 调节申请书
ajax.put("applicationFile",manageMap.get(TemplateTypeEnum.MEDIATION_APPLICATION.getCode()));
// 和解协议
ajax.put("agreementFile",manageMap.get(TemplateTypeEnum.MEDIATION_AGREEMENT.getCode()));
// 调解书
ajax.put("bookFile",manageMap.get(TemplateTypeEnum.MEDIATE_BOOK.getCode()));
return ajax;
}
private String getFileExtension(String fileName) {
int lastDotIndex = fileName.lastIndexOf(".");
@@ -14,6 +14,7 @@ import com.ruoyi.common.core.domain.entity.*;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.AnnexTypeEnum;
import com.ruoyi.common.enums.MediatorTypeEnum;
import com.ruoyi.common.enums.TemplateTypeEnum;
import com.ruoyi.common.enums.YesOrNoEnum;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.common.exception.ServiceException;
@@ -293,12 +294,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
if (StrUtil.isNotEmpty(affiliate.getRespondentEmail())) {
affiliate.setRespondentEmail(affiliate.getRespondentEmail().replace("\n", "").replaceAll("\\s", ""));
}
msCaseAffiliateMapper.insert(affiliate);
// 查询调解申请书模板id
TemplateManage templateManage=templateManageMapper.selectByType(2);
if(templateManage!=null) {
// 批量生成调解申请书
// 批量生成调解申请书
MsCaseApplicationReq req = new MsCaseApplicationReq();
req.setCaseFlowId(caseFlow.getId());
if(!caseApplication.isImportFlag()) {
@@ -308,11 +305,9 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
req.setBatchNumber(caseApplication.getBatchNumber());
}
// 生成调解申请书
req.setTemplateId(String.valueOf(templateManage.getId()));
req.setTemplateType(TemplateTypeEnum.MEDIATION_APPLICATION.getCode());
// todo 部署放开
// caseApplicationService.generateApplication(req);
}
caseApplicationService.generateApplication(req);
// 保存案件附件
@@ -637,7 +632,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
@Override
public AjaxResult generateApplication(MsCaseApplicationReq req) {
// 根据模板id查询申请书
TemplateManage templateManage=templateManageMapper.selectById(req.getTemplateId());
if(req.getTemplateId()==null || req.getTemplateType()==null){
return AjaxResult.error("模板id不能为空");
}
TemplateManage templateManage=templateManageMapper.selectByIdAndType(Long.valueOf(req.getTemplateId()),req.getTemplateType());
if(templateManage==null||StrUtil.isEmpty(templateManage.getTemOrigPath())){
throw new ServiceException("未找到模板");
}
@@ -879,12 +877,11 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
smsRecordMapper.saveSmsSendRecord(smsSendRecord);
}
// 给申请人被申请人发送短信
// 被申请人发送短信
if (StrUtil.isNotEmpty(affiliate.getRespondentPhone())) {
String sendContent = "尊敬的" + affiliate.getRespondentName() + "用户,您的" + application.getCaseNum() + "仲裁案件,已成功受理,请知晓,如非本人操作,请忽略本短信";
// 给被申请人发送案件受理短信 尊敬的{1}用户,您的{2}仲裁案件,已成功受理,请知晓,如非本人操作,请忽略本短信
// todo 发送申请人注册小程序短信
Boolean smsFlag = SmsUtils.sendSms(application.getId(), "2049503", affiliate.getRespondentPhone(), new String[]{affiliate.getRespondentName(), application.getCaseNum()});
String sendContent = "尊敬的用户,您的" + application.getCaseNum() + "的案件已经受理,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信";
// 给被申请人发送案件受理短信 2068468 待缴费通知 尊敬的用户,您编号为{1}的案件已经受理,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信
Boolean smsFlag = SmsUtils.sendSms(application.getId(), "2068468", affiliate.getRespondentPhone(), new String[]{ application.getCaseNum()});
CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getNodeName(), "向被申请人发送短信," + sendContent);
SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), affiliate.getRespondentPhone(), new Date(), sendContent);
if (smsFlag) {
@@ -1281,7 +1278,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
String templateId = String.valueOf(application.getTemplateId());
req.setTemplateId(templateId);
req.setTemplateType(1);
req.setTemplateType(TemplateTypeEnum.MEDIATE_BOOK.getCode());
AjaxResult result = generateApplication(req);
if (result != null && result.isSuccess()) {
List<MsCaseAttach> caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(req.getId());
@@ -374,7 +374,7 @@ public class VideoConferenceServiceImpl implements VideoConferenceService {
boolean isSecretaryRole=false;
if(CollectionUtil.isNotEmpty(roles)){
for (SysRole role : roles) {
if("法律顾问".equals(role.getRoleName()) || "秘书".equals(role.getRoleName())){
if("调解员".equals(role.getRoleName())){
isSecretaryRole=true;
break;
}
@@ -126,8 +126,8 @@
</where>
</update>
<select id="selectById" resultType="java.lang.String">
SELECT identify_name identifyName
FROM ms_dept_identify where id=#{id}
</select>
</mapper>
@@ -6,36 +6,26 @@
<resultMap type="com.ruoyi.wisdomarbitrate.domain.dto.template.TemplateManage" id="TemplateManageResult">
<id property="id" column="id" />
<result property="identifyId" column="identify_id" />
<result property="fileId" column="file_id" />
<result property="temName" column="tem_name" />
<result property="temType" column="tem_type" />
<result property="temFormat" column="tem_format" />
<result property="temOrigPath" column="tem_orig_path" />
<result property="temRevisPath" column="tem_revis_path" />
<result property="delFlag" column="del_flag" />
<result property="fileName" column="file_name" />
</resultMap>
<insert id="insertTemplateManage" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.template.TemplateManage" useGeneratedKeys="true" keyProperty="id">
insert into ms_template_manage(
<if test="identifyId != null">identify_id,</if>
<if test="temName != null and temName != ''">tem_name,</if>
<if test="temType != null">tem_type,</if>
<if test="temFormat != null and temFormat != '' ">tem_format,</if>
<if test="temOrigPath != null and temOrigPath != '' ">tem_orig_path,</if>
<if test="temRevisPath != null and temRevisPath != '' ">tem_revis_path,</if>
<if test="createBy != null and createBy != '' ">create_by,</if>
<if test="fileName != null and fileName != '' ">file_name,</if>
del_flag,create_time
identify_id,
tem_name,
create_by,
create_time
)values(
<if test="identifyId != null">#{identifyId},</if>
<if test="temName != null and temName != ''">#{temName},</if>
<if test="temType != null">#{temType},</if>
<if test="temFormat != null and temFormat != ''">#{temFormat},</if>
<if test="temOrigPath != null and temOrigPath != ''">#{temOrigPath},</if>
<if test="temRevisPath != null and temRevisPath != ''">#{temRevisPath},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="fileName != null and fileName != ''">#{fileName},</if>
0,sysdate()
#{identifyId},
#{temName},
#{createBy},
sysdate()
)
</insert>
@@ -44,13 +34,7 @@
<set>
<if test="identifyId != null">identify_id = #{identifyId},</if>
<if test="temName != null and temName != ''">tem_name = #{temName},</if>
<if test="temType != null">tem_type = #{temType},</if>
<if test="temFormat != null and temFormat != '' ">tem_format = #{temFormat},</if>
<if test="temOrigPath != null and temOrigPath != ''">tem_orig_path = #{temOrigPath},</if>
<if test="delFlag != null ">del_flag = #{delFlag},</if>
<if test="temRevisPath != null and temRevisPath != '' ">tem_revis_path = #{temRevisPath},</if>
<if test="updateBy != null and updateBy != '' ">update_by = #{updateBy},</if>
<if test="fileName != null and fileName != '' ">file_name = #{fileName},</if>
update_time = sysdate()
</set>
<where>
@@ -62,7 +46,7 @@
</update>
<select id="selectTemplateList" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.template.TemplateManage" resultMap="TemplateManageResult">
SELECT id, identify_id ,tem_name , tem_type,tem_format,tem_orig_path,tem_revis_path ,file_name
SELECT id, identify_id ,tem_name
FROM ms_template_manage
<where>
<if test="id != null">
@@ -77,7 +61,6 @@
<if test="temType != null ">
AND tem_type = #{temType}
</if>
AND del_flag =0
</where>
ORDER BY create_time DESC
</select>
@@ -89,4 +72,82 @@
<select id="selectByType" resultMap="TemplateManageResult">
select * from ms_template_manage where tem_type=#{type}
</select>
<update id="updateByIds">
update ms_template_manage
<set>
<if test="identifyId != null">identify_id = #{identifyId},</if>
<if test="temName != null and temName != ''">tem_name = #{temName},</if>
<if test="updateBy != null and updateBy != '' ">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where id in
<foreach collection="annexIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<insert id="insertTemplateManageFile" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.template.TemplateManage" useGeneratedKeys="true" keyProperty="fileId">
insert into ms_template_manage_file(
template_manage_id,
tem_type,
tem_format,
tem_orig_path,
file_name
)values(
#{id},
#{temType},
#{temFormat},
#{temOrigPath},
#{fileName}
)
</insert>
<delete id="deleteTemplateManage">
delete from ms_template_manage where id = #{id};
delete from ms_template_manage_file where template_manage_id = #{id};
</delete>
<update id="updateFileByIds">
update ms_template_manage_file
set template_manage_id=#{manage.id}
where file_id in
<foreach collection="manage.annexIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<delete id="deleteTemplateManageFileById">
delete from ms_template_manage_file where template_manage_id = #{id} and file_id not in
<foreach collection="fileIds" item="it" open="(" separator="," close=")">
#{it}
</foreach>
;
</delete>
<select id="selectByIdAndType" resultMap="TemplateManageResult">
select f.* from ms_template_manage m join ms_template_manage_file f on m.id=f.template_manage_id
where f.template_manage_id=#{templateId} and f.tem_type=#{type} oeder by f.file_id desc limit 1
</select>
<select id="selectFileById" resultMap="TemplateManageResult">
select f.* from ms_template_manage_file f
where f.id=#{fileId}
</select>
<select id="selectTemplateListById" resultMap="TemplateManageResult">
select m.* ,f.* from ms_template_manage m join ms_template_manage_file f on m.id=f.template_manage_id
where m.id=#{id}
</select>
</mapper>