模板管理开发

This commit is contained in:
hejinbo
2023-11-17 17:49:53 +08:00
parent 736b189473
commit 35a9faeb6a
9 changed files with 265 additions and 29 deletions
@@ -6,7 +6,7 @@ import lombok.Data;
import java.util.Date;
@Data
public class DeptIdentify extends BaseEntity {
public class DeptIdentify extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
@@ -39,4 +39,10 @@ public class SealManage extends BaseEntity {
* 印章使用状态(0禁用,1启用)
*/
private Integer isUse;
/**
* 附件路径
*/
private String annexPath;
}
@@ -1,5 +1,7 @@
package com.ruoyi.wisdomarbitrate.domain.vo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
@Data
@@ -0,0 +1,16 @@
package com.ruoyi.wisdomarbitrate.mapper;
import com.ruoyi.wisdomarbitrate.domain.SealManage;
import com.ruoyi.wisdomarbitrate.domain.TemplateManage;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface TemplateManageMapper {
List<TemplateManage> selectTemplateList(TemplateManage templateManage);
int insertTemplateManage(TemplateManage templateManage);
int updateTemplateManage(TemplateManage templateManage);
}
@@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
import com.ruoyi.wisdomarbitrate.domain.SealManage;
import com.ruoyi.wisdomarbitrate.domain.TemplateManage;
import com.ruoyi.wisdomarbitrate.domain.vo.SealListVO;
import org.springframework.web.multipart.MultipartFile;
@@ -24,7 +25,7 @@ public interface IDeptIdentifyService {
AjaxResult receiveNotify(String body);
List<SealListVO> getSealList(DeptIdentify deptIdentify);
List<SealManage> getSealList(DeptIdentify deptIdentify);
AjaxResult updateSealLockStatus(SealManage sealManage);
@@ -34,4 +35,13 @@ public interface IDeptIdentifyService {
AjaxResult deleteDeptIdentify(Long id);
AjaxResult updateDeptIdentify(DeptIdentify deptIdentify);
AjaxResult insertTemplate(TemplateManage templateManage , MultipartFile file);
AjaxResult updateTemplate(TemplateManage templateManage, MultipartFile file);
AjaxResult deleteTemplate(Long id);
List<TemplateManage> getTemplateList(DeptIdentify deptIdentify);
}
@@ -1,6 +1,8 @@
package com.ruoyi.wisdomarbitrate.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.ruoyi.common.config.RuoYiConfig;
@@ -17,12 +19,15 @@ import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
import com.ruoyi.wisdomarbitrate.domain.SealManage;
import com.ruoyi.wisdomarbitrate.domain.TemplateManage;
import com.ruoyi.wisdomarbitrate.domain.vo.SealListVO;
import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
import com.ruoyi.wisdomarbitrate.mapper.DeptIdentifyMapper;
import com.ruoyi.wisdomarbitrate.mapper.SealManageMapper;
import com.ruoyi.wisdomarbitrate.mapper.TemplateManageMapper;
import com.ruoyi.wisdomarbitrate.service.IDeptIdentifyService;
import com.ruoyi.wisdomarbitrate.utils.SignAward;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -33,6 +38,9 @@ import java.io.IOException;
import java.time.LocalDate;
import java.util.*;
import static com.ruoyi.common.utils.PageUtils.startPage;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
@Service
public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
@@ -46,6 +54,8 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
private SysDeptMapper sysDeptMapper;
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private TemplateManageMapper templateManageMapper;
@Override
@@ -252,21 +262,15 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
}
@Override
public List<SealListVO> getSealList(DeptIdentify deptIdentify) {
public List<SealManage> getSealList(DeptIdentify deptIdentify) {
if (deptIdentify.getId() == null) {
return null;
}
SealManage sealManage = new SealManage();
sealManage.setIdentifyId(deptIdentify.getId());
List<SealManage> selectSealList = sealManageMapper.selectSealList(sealManage);
List<SealListVO> sealListVOS = new ArrayList<>();
if (selectSealList != null && selectSealList.size() > 0) {
for (SealManage sealManage1 : selectSealList) {
SealListVO sealListVO = new SealListVO();
sealListVO.setId(sealManage1.getId());
sealListVO.setSealId(sealManage1.getSealId());
sealListVO.setSealName(sealManage1.getSealName());
sealListVO.setSealStatus(sealManage1.getSealStatus());
Integer annexId = sealManage1.getAnnexId();
if (annexId != null) {
//根据附件id查询路径
@@ -276,17 +280,13 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
int startIndex = annexName.indexOf(prefix);
startIndex += prefix.length();
String annexPath = "/uploadPath" + annexName.substring(startIndex);
sealListVO.setAnnexPath(annexPath);
sealListVO.setAnnexType(caseAttach.getAnnexType());
sealManage1.setAnnexPath(annexPath);
} else {
sealListVO.setAnnexPath(null);
sealListVO.setAnnexType(null);
sealManage1.setAnnexPath(null);
}
sealListVO.setIsUse(sealManage1.getIsUse());
sealListVOS.add(sealListVO);
}
}
return sealListVOS;
return selectSealList;
}
@Override
@@ -374,6 +374,91 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
return null;
}
@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);
String prefix = "/profile";
int startIndex = fileName.indexOf(prefix);
startIndex += prefix.length();
String annexPath = "home/ruoyi/uploadPath" + fileName.substring(startIndex);
templateManage.setTemOrigPath(annexPath);
String format = getFileExtension(fileName);
templateManage.setTemFormat(format);
templateManage.setCreateBy(getUsername());
int i = templateManageMapper.insertTemplateManage(templateManage);
if (i>0){
return AjaxResult.success("新增成功");
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
public AjaxResult updateTemplate(TemplateManage templateManage, MultipartFile file) {
Long id = templateManage.getId();
if (id == null) {
return AjaxResult.error();
}
try {
String filePath = RuoYiConfig.getUploadPath();
// 上传
String fileName = FileUploadUtils.upload(filePath, file);
String prefix = "/profile";
int startIndex = fileName.indexOf(prefix);
startIndex += prefix.length();
String annexPath = "home/ruoyi/uploadPath" + fileName.substring(startIndex);
templateManage.setTemOrigPath(annexPath);
String format = getFileExtension(fileName);
templateManage.setTemFormat(format);
templateManage.setUpdateBy(getUsername());
int i = templateManageMapper.updateTemplateManage(templateManage);
if (i>0){
return AjaxResult.success("修改成功");
}
} catch (IOException e) {
e.printStackTrace();
}
return AjaxResult.error();
}
@Override
public AjaxResult deleteTemplate(Long id) {
TemplateManage templateManage = new TemplateManage();
templateManage.setId(id);
templateManage.setDelFlag(2);
int i = templateManageMapper.updateTemplateManage(templateManage);
if (i > 0) {
return AjaxResult.success("删除成功");
}
return AjaxResult.error();
}
@Override
public List<TemplateManage> getTemplateList(DeptIdentify deptIdentify) {
if (deptIdentify.getId() == null) {
return null;
}
TemplateManage templateManage = new TemplateManage();
templateManage.setIdentifyId(deptIdentify.getId());
List<TemplateManage> templateManages = templateManageMapper.selectTemplateList(templateManage);
if (templateManages != null && templateManages.size() > 0) {
return templateManages;
}
return null;
}
private String generateUniqueUsername() {
final Random random = new Random();
final Set<String> generatedUsernames = new HashSet<>();
@@ -387,5 +472,11 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
}
}
}
private String getFileExtension(String fileName) {
int lastDotIndex = fileName.lastIndexOf(".");
if (lastDotIndex > 0 && lastDotIndex < fileName.length() - 1) {
return fileName.substring(lastDotIndex + 1);
}
return "";
}
}