From e2263a0bfa524cd11bb1e9406459527b69146933 Mon Sep 17 00:00:00 2001 From: 15036302109 Date: Sat, 9 Dec 2023 22:29:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E6=96=87=E7=AE=A1=E7=90=86=E5=80=9F?= =?UTF-8?q?=E5=85=A5=E5=80=9F=E5=87=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ehs/EhsDocTransferController.java | 55 +++ .../controller/ehs/EhsDocumentController.java | 22 ++ .../ehsDocTransfer/domain/EhsDocTransfer.java | 2 +- .../ruoyi/ehsDocument/domain/EhsDocument.java | 5 + .../service/impl/EhsDocumentServiceImpl.java | 14 + .../ruoyi/ehsDocument/vo/DocResponseVo.java | 16 + .../mapper/ehs/EhsDocTransferMapper.xml | 1 + .../mapper/ehs/EhsDocumentMapper.xml | 5 +- ruoyi-ui/src/api/ehs/ehsDocTransfer.js | 17 + ruoyi-ui/src/api/ehs/ehsDocument.js | 7 + ruoyi-ui/src/views/ehs/ehsDocument/index.vue | 316 ++++++++++++------ 11 files changed, 348 insertions(+), 112 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/ehsDocument/vo/DocResponseVo.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocTransferController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocTransferController.java index 8fcd450..d2c24df 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocTransferController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocTransferController.java @@ -1,11 +1,18 @@ package com.ruoyi.web.controller.ehs; +import java.util.Date; import java.util.List; import java.util.Arrays; +import java.util.Objects; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.ehsDocument.domain.EhsDocument; +import com.ruoyi.ehsDocument.service.IEhsDocumentService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -37,6 +44,8 @@ import com.ruoyi.common.core.page.TableDataInfo; public class EhsDocTransferController extends BaseController { @Autowired private IEhsDocTransferService ehsDocTransferService; + @Autowired + private IEhsDocumentService ehsDocumentService; /** * 查询公文流转列表 @@ -77,6 +86,52 @@ public class EhsDocTransferController extends BaseController { return toAjax(ehsDocTransferService.save(ehsDocTransfer)); } + /** + * 借出 + */ + @ApiOperation("公文借出") + @Log(title = "公文流转", businessType = BusinessType.INSERT) + @Transactional + @PostMapping("/lend") + public AjaxResult lend(@RequestBody EhsDocTransfer ehsDocTransfer) { + EhsDocument ehsDocument = ehsDocumentService.selectEhsDocumentById(ehsDocTransfer.getDocumentId()); + if (ehsDocument.getStatus() == 0) { + return AjaxResult.error("该公文已被借出"); + } + ehsDocTransfer.setDocTransferStatus(0); + boolean result = ehsDocTransferService.save(ehsDocTransfer); + // 借出成功后,此公文状态变为0-借出 + ehsDocument.setStatus(0); + ehsDocumentService.updateById(ehsDocument); + return toAjax(result); + } + + /** + * 归还 + */ + @ApiOperation("公文归还") + @Log(title = "公文流转", businessType = BusinessType.INSERT) + @Transactional + @GetMapping("/return/{id}") + public AjaxResult returnEhsDoc(@PathVariable("id") Long documentId) { + EhsDocument ehsDocument = ehsDocumentService.selectEhsDocumentById(documentId); + if (ehsDocument.getStatus() == 1){ + return AjaxResult.error("该公文已归还"); + } + ehsDocument.setStatus(1); + ehsDocumentService.updateById(ehsDocument); + + EhsDocTransfer ehsDocTransfer = new EhsDocTransfer(); + SysUser user = SecurityUtils.getLoginUser().getUser(); + ehsDocTransfer.setTransferUserId(user.getUserId()); + ehsDocTransfer.setTransferName(user.getNickName()); + ehsDocTransfer.setTransferTime(new Date()); + ehsDocTransfer.setDocTransferStatus(ehsDocument.getStatus()); + ehsDocTransfer.setDocumentId(documentId); + ehsDocTransfer.setDocumentName(ehsDocument.getDocName()); + return toAjax(ehsDocTransferService.save(ehsDocTransfer)); + } + /** * 修改公文流转 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocumentController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocumentController.java index c850ad3..8216ef2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocumentController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocumentController.java @@ -1,11 +1,17 @@ package com.ruoyi.web.controller.ehs; +import java.util.Date; import java.util.List; import java.util.Arrays; import javax.servlet.http.HttpServletResponse; +import cn.hutool.core.date.DateUtil; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.ehsDocTransfer.domain.EhsDocTransfer; import com.ruoyi.ehsDocTransfer.service.IEhsDocTransferService; +import com.ruoyi.ehsDocument.vo.DocResponseVo; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -83,6 +89,22 @@ public class EhsDocumentController extends BaseController { return success(ehsDocumentService.selectEhsDocumentById(id)); } + /** + * 获取借出表单数据 + */ + @GetMapping(value = "/formData/{id}") + public AjaxResult getFormData(@PathVariable("id") Long id) { + EhsDocument ehsDocument = ehsDocumentService.selectEhsDocumentById(id); + DocResponseVo docResponseVo = new DocResponseVo(); + docResponseVo.setDocumentName(ehsDocument.getDocName()); + docResponseVo.setTransferTime(new Date()); + SysUser user = SecurityUtils.getLoginUser().getUser(); + docResponseVo.setTransferName(user.getNickName()); + docResponseVo.setTransferUserId(user.getUserId()); + docResponseVo.setDocumentId(ehsDocument.getId()); + return success(docResponseVo); + } + /** * 根据公文id获取公文流转信息 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/domain/EhsDocTransfer.java b/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/domain/EhsDocTransfer.java index a95084e..2c71d6b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/domain/EhsDocTransfer.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/domain/EhsDocTransfer.java @@ -48,7 +48,7 @@ public class EhsDocTransfer extends BaseEntity { /** * 流转时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "流转时间", width = 30, dateFormat = "yyyy-MM-dd") private Date transferTime; diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/domain/EhsDocument.java b/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/domain/EhsDocument.java index e6cf349..ba9f58a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/domain/EhsDocument.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/domain/EhsDocument.java @@ -71,4 +71,9 @@ public class EhsDocument extends BaseEntity { @Excel(name = "收文日期", width = 30, dateFormat = "yyyy-MM-dd") private Date receiveTime; + /** + * 状态 + */ + @Excel(name = "状态") + private Integer status; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/service/impl/EhsDocumentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/service/impl/EhsDocumentServiceImpl.java index 35f1271..438b4ae 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/service/impl/EhsDocumentServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/service/impl/EhsDocumentServiceImpl.java @@ -3,12 +3,16 @@ package com.ruoyi.ehsDocument.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.utils.SecurityUtils; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; import com.ruoyi.common.utils.StringUtils; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import com.ruoyi.ehsDocument.mapper.EhsDocumentMapper; import com.ruoyi.ehsDocument.domain.EhsDocument; @@ -45,11 +49,21 @@ public class EhsDocumentServiceImpl extends ServiceImpl selectEhsDocumentList(EhsDocument ehsDocument) { + // 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文 + SysUser currentUser = SecurityUtils.getLoginUser().getUser(); + List roleIds = currentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()); + Long deptParentId = currentUser.getDept().getParentId(); + if (!roleIds.contains(1L) && + deptParentId != null && + deptParentId.longValue() != 0) { + ehsDocument.setDeptId(currentUser.getDept().getDeptId().longValue()); + } return ehsDocumentMapper.selectEhsDocumentList(ehsDocument); } /** * 获取拟稿部门下拉列表 + * * @return */ @Override diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/vo/DocResponseVo.java b/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/vo/DocResponseVo.java new file mode 100644 index 0000000..8cd90b8 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsDocument/vo/DocResponseVo.java @@ -0,0 +1,16 @@ +package com.ruoyi.ehsDocument.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; + +@Data +public class DocResponseVo { + private String transferName; + private Long transferUserId; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date transferTime; + private String documentName; + private Long documentId; +} diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsDocTransferMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsDocTransferMapper.xml index bc72147..68561c4 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsDocTransferMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsDocTransferMapper.xml @@ -47,6 +47,7 @@ SELECT t.* FROM ehs_document d,ehs_doc_transfer t WHERE d.id = t.document_id AND d.id = #{id} + order by t.transfer_time desc diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsDocumentMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsDocumentMapper.xml index df7c3f4..73ea733 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsDocumentMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsDocumentMapper.xml @@ -12,6 +12,7 @@ + @@ -23,7 +24,7 @@ - select id, doc_name, doc_font, draft_dept, doc_type, doc_number, receive_time, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id from ehs_document + select id, doc_name, doc_font, draft_dept, doc_type, doc_number, receive_time, status, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id from ehs_document diff --git a/ruoyi-ui/src/api/ehs/ehsDocTransfer.js b/ruoyi-ui/src/api/ehs/ehsDocTransfer.js index ac3ceb6..67a4a4a 100644 --- a/ruoyi-ui/src/api/ehs/ehsDocTransfer.js +++ b/ruoyi-ui/src/api/ehs/ehsDocTransfer.js @@ -26,6 +26,23 @@ export function addEhsDocTransfer(data) { }) } +// 归还 +export function returnEhsDoc(id) { + return request({ + url: '/ehs/ehsDocTransfer/return/' + id, + method: 'get' + }) +} + +// 借出 +export function lendEhsDoc(data) { + return request({ + url: '/ehs/ehsDocTransfer/lend', + method: 'post', + data: data + }) +} + // 修改公文流转 export function updateEhsDocTransfer(data) { return request({ diff --git a/ruoyi-ui/src/api/ehs/ehsDocument.js b/ruoyi-ui/src/api/ehs/ehsDocument.js index 4442442..f095a69 100644 --- a/ruoyi-ui/src/api/ehs/ehsDocument.js +++ b/ruoyi-ui/src/api/ehs/ehsDocument.js @@ -17,6 +17,13 @@ export function getEhsDocument(id) { }) } +export function getEhsDocumentById(id) { + return request({ + url: '/ehs/ehsDocument/formData/' + id, + method: 'get' + }) +} + // 获取拟稿部门下拉列表 export function getAllDraftDept() { return request({ diff --git a/ruoyi-ui/src/views/ehs/ehsDocument/index.vue b/ruoyi-ui/src/views/ehs/ehsDocument/index.vue index e0a2fd5..54f36e2 100644 --- a/ruoyi-ui/src/views/ehs/ehsDocument/index.vue +++ b/ruoyi-ui/src/views/ehs/ehsDocument/index.vue @@ -34,17 +34,10 @@ size="mini" @click="handleAdd" v-hasPermi="['ehs:ehsDocument:add']" - >公文登记 - - - 公文流转 + >公文登记 + + 修改 + >修改 + 删除 + >删除 + 导出 + >导出 + - + - - - + + + - + - + @@ -140,10 +145,10 @@ - + - + @@ -201,36 +207,87 @@ {{ Number(scope.$index) + 1 }} - + + - + + + + + + + + + + + + + + + + + + + + + + +