模板管理开发 #219

Merged
hejinbo merged 1 commits from hjb into dev 2023-11-17 09:59:25 +00:00
9 changed files with 265 additions and 29 deletions
@@ -104,10 +104,10 @@ public class DeptIdentifyController extends BaseController {
* @return
*/
@GetMapping("/sealList")
public TableDataInfo getSealList( DeptIdentify deptIdentify){
public TableDataInfo getSealList( DeptIdentify deptIdentify ){
startPage();
List<SealListVO> list = deptIdentifyService.getSealList(deptIdentify);
return getDataTable(list);
List<SealManage> sealList = deptIdentifyService.getSealList(deptIdentify);
return getDataTable(sealList);
}
/**
@@ -123,14 +123,44 @@ public class DeptIdentifyController extends BaseController {
return deptIdentifyService.updateSealLockStatus(sealManage);
}
// /**
// * 新增模板
// * @param deptIdentify
// * @return
// */
// @PostMapping("/insert")
// public AjaxResult insertDeptIdentify(@RequestBody DeptIdentify deptIdentify){
// return deptIdentifyService.insertDeptIdentify(deptIdentify);
// }
/**
* 新增模板
* @param templateManage
* @return
*/
@PostMapping("/insertTemplate")
public AjaxResult insertTemplate(@RequestBody TemplateManage templateManage,@RequestParam("file") MultipartFile file){
return deptIdentifyService.insertTemplate(templateManage,file);
}
/**
* 修改模板
* @param templateManage
* @return
*/
@PostMapping("/updateTemplate")
public AjaxResult updateTemplate(@RequestBody TemplateManage templateManage,@RequestParam("file") MultipartFile file){
return deptIdentifyService.updateTemplate(templateManage,file);
}
/**
* 删除模板
* @param id
* @return
*/
@DeleteMapping("/deleteTemplate")
public AjaxResult deleteTemplate(Long id){
return deptIdentifyService.deleteTemplate(id);
}
/**
* 根据机构id查询模板
* @param deptIdentify
* @return
*/
@GetMapping("/getTemplate")
public TableDataInfo getTemplateList( DeptIdentify deptIdentify){
startPage();
List<TemplateManage> sealList = deptIdentifyService.getTemplateList(deptIdentify);
return getDataTable(sealList);
}
}
@@ -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 "";
}
}
@@ -83,6 +83,7 @@
update dept_identify
<set>
<if test="identifyDate != null">identify_date = #{identifyDate},</if>
<if test="identifyName != null">identify_name = #{identifyName},</if>
<if test="isUse != null">is_use = #{isUse},</if>
<if test="identifyStatus != null ">identify_status = #{identifyStatus},</if>
<if test="orgId != null and orgId != ''">org_id = #{orgId},</if>
@@ -0,0 +1,80 @@
<?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.wisdomarbitrate.mapper.TemplateManageMapper">
<resultMap type="TemplateManage" id="TemplateManageResult">
<id property="id" column="id" />
<result property="identifyId" column="identify_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" />
</resultMap>
<insert id="insertTemplateManage" parameterType="TemplateManage" useGeneratedKeys="true" keyProperty="id">
insert into 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>
del_flag,create_time
)values(
<if test="identifyId != null">#{identifyId},</if>
<if test="sealName != null and sealName != ''">#{sealName},</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>
0,sysdate()
)
</insert>
<update id="updateTemplateManage" parameterType="TemplateManage">
update template_manage
<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>
update_time = sysdate()
</set>
<where>
<if test="id != null">
AND id = #{id}
</if>
</where>
</update>
<select id="selectTemplateList" parameterType="TemplateManage" resultMap="TemplateManageResult">
SELECT id, identify_id ,tem_name , tem_type,tem_format,tem_orig_path,tem_revis_path
FROM template_manage
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="identifyId != null">
AND identify_id = #{identifyId}
</if>
<if test="temName != null and temName != ''">
AND tem_name = #{temName}
</if>
<if test="temType != null ">
AND tem_type = #{temType}
</if>
AND del_flag =0
</where>
</select>
</mapper>