From f30364d5e70eb45c82f61001c69c7d3657f99df8 Mon Sep 17 00:00:00 2001 From: quyixiao <2621048238@qq.com> Date: Mon, 24 Aug 2020 12:27:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ResultRecordController.java | 45 +++++++++++++---- .../lz/modules/flow/model/TypeRoleDto.java | 18 ++----- .../modules/sys/entity/app/ResultComment.java | 50 +++++++++++++------ .../sys/service/app/ResultCommentService.java | 2 +- .../app/impl/ResultCommentServiceImpl.java | 4 +- .../app/impl/ResultRecordServiceImpl.java | 6 ++- .../mapper/app/ResultCommentMapper.xml | 12 +++-- .../mapper/app/ResultRecordMapper.xml | 2 +- .../mapper/flow/FlowRecordMapper.xml | 4 +- src/test/java/com/lz/mysql/MysqlMain.java | 5 +- 10 files changed, 94 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java index ec248c3c..12a84ee7 100644 --- a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java +++ b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java @@ -77,6 +77,11 @@ public class ResultRecordController extends AbstractController { @RequiresPermissions("user:lzresultrecord:list") public R list(ResultRecordReq req) { SysUserEntity user = getUser(); + + if(req.getIsSelf() == 1){ + req.setStaffId(user.getUserId()); + } + PageUtils page = lzResultRecordService.queryPage(req, user); List departmentList1 = departmentsService.selectByParentDepartmentId("0"); return R.ok().put("page", page) @@ -181,13 +186,19 @@ public class ResultRecordController extends AbstractController { if (CollectionUtils.isNotEmpty(comments)) { ResultDetailResp header = new ResultDetailResp(); header.setCheckRange("领导"); - header.setTarget("意见"); + header.setTarget("状态"); + header.setKeyResult("意见"); list.add(header); commentNum = comments.size(); for (ResultComment resultComment : comments) { ResultDetailResp comment = new ResultDetailResp(); comment.setCheckRange(resultComment.getStaffName()); - comment.setTarget(resultComment.getComment()); + String target = "审批通过"; + if (resultComment.getStatus() == 5) { + target = "驳回"; + } + comment.setTarget(target); + comment.setKeyResult(resultComment.getComment()); list.add(comment); } } @@ -211,28 +222,34 @@ public class ResultRecordController extends AbstractController { @RequestMapping("/commitApproval") public R commitApproval(ResultRecordReq req) { - resultCommentService.addOrUpdateComment(req, getUserId()); + R r = null; + int status = 1; if (req.getStatus() == 2) { - return resultRecordService.approval(req.getRecordResultId(), getUserId()); + r = resultRecordService.approval(req.getRecordResultId(), getUserId()); } else if (req.getStatus() == 3) { //侍提交 ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId()); resultRecord.setStatus(Constant.STATUS_3); resultRecordService.updateResultRecordById(resultRecord); - } else if (req.getStatus() == 4) { // 驳回 + } else if (req.getStatus() == 5) { // 驳回 + status = 5; List flowRecords = flowRecordService.selectFlowRecordByRecordId(req.getRecordResultId()); ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId()); if (flowRecords.size() > 0 && req.getRollbackFlowId() > 0) { for (FlowRecord flowRecord : flowRecords) { if (flowRecord.getId().equals(req.getRollbackFlowId())) { resultRecord.setFlowStaffIdRole(flowRecord.getFlowStaffIdRole()); - } else { - resultRecord.setStatus(1); + resultRecord.setStatus(req.getStatus()); + resultRecordService.updateResultRecordById(resultRecord); + } + if (flowRecord.getId() > req.getRollbackFlowId()) { + flowRecord.setStatus(1); + flowRecordService.updateFlowRecordById(flowRecord); } - resultRecordService.updateResultRecordById(resultRecord); } } } - return R.ok("成功"); + resultCommentService.addOrUpdateComment(req, getUserId(), status); + return r != null ? r : R.ok("成功"); } /** @@ -263,9 +280,15 @@ public class ResultRecordController extends AbstractController { if (resultComment == null || !getUserId().equals(resultComment.getStaffId())) { resultComment = new ResultComment(); } - List flowRecords = flowRecordService.selectFlowRecordByRecordId(recordId); + List flowRecords = flowRecordService.selectFlowRecordByResultRecordIdFlowId(recordId, 0l); + if (flowRecords != null && flowRecords.size() > 0) { + FlowRecord flowRecord = flowRecords.get(flowRecords.size()-1); + if(flowRecord.getApprovalStaffId().equals(getUserId())){ + flowRecords.remove(flowRecord); + } + } return R.ok().put("resultComment", resultComment) - .put("list",flowRecords); + .put("list", flowRecords); } /** diff --git a/src/main/java/com/lz/modules/flow/model/TypeRoleDto.java b/src/main/java/com/lz/modules/flow/model/TypeRoleDto.java index 2d82f19e..016492b8 100644 --- a/src/main/java/com/lz/modules/flow/model/TypeRoleDto.java +++ b/src/main/java/com/lz/modules/flow/model/TypeRoleDto.java @@ -3,6 +3,7 @@ package com.lz.modules.flow.model; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.lz.common.utils.Constant; +import com.lz.common.utils.NumberUtil; import lombok.Data; import java.util.HashMap; @@ -22,26 +23,15 @@ public class TypeRoleDto { } public static Long getRoleId(String flowInfo, Integer type) { - Map a = JSONObject.parseObject(JSON.toJSONBytes(flowInfo), Map.class); - return a.get(Constant.TYPE + type); + Map a = JSONObject.parseObject(flowInfo, Map.class); + return NumberUtil.objToLongDefault(a.get(Constant.TYPE + type),0l); } - public static void main(String[] args) { - Map map = new HashMap(); - map.put("type1",3l); - map.put("type2",3l); - System.out.println(JSON.toJSONString(map)); - - - Map a = JSONObject.parseObject(JSON.toJSONBytes(map),Map.class); + Map a = JSONObject.parseObject("{\"type2\":3,\"type1\":3}",Map.class); System.out.println(a.get("type1")); - - - } - } diff --git a/src/main/java/com/lz/modules/sys/entity/app/ResultComment.java b/src/main/java/com/lz/modules/sys/entity/app/ResultComment.java index d2390418..eeac5bea 100644 --- a/src/main/java/com/lz/modules/sys/entity/app/ResultComment.java +++ b/src/main/java/com/lz/modules/sys/entity/app/ResultComment.java @@ -32,15 +32,17 @@ public class ResultComment implements java.io.Serializable { private String comment; //评论用户名称 private String staffName; + //状态 + private Integer status; /** - * + * * @return */ public Long getId() { return id; } /** - * + * * @param id */ public void setId(Long id) { @@ -48,14 +50,14 @@ public class ResultComment implements java.io.Serializable { } /** - * 是否删除状态,1:删除,0:有效 + * 是否删除状态,1:删除,0:有效 * @return */ public Integer getIsDelete() { return isDelete; } /** - * 是否删除状态,1:删除,0:有效 + * 是否删除状态,1:删除,0:有效 * @param isDelete */ public void setIsDelete(Integer isDelete) { @@ -63,14 +65,14 @@ public class ResultComment implements java.io.Serializable { } /** - * 创建时间 + * 创建时间 * @return */ public Date getGmtCreate() { return gmtCreate; } /** - * 创建时间 + * 创建时间 * @param gmtCreate */ public void setGmtCreate(Date gmtCreate) { @@ -78,14 +80,14 @@ public class ResultComment implements java.io.Serializable { } /** - * 最后修改时间 + * 最后修改时间 * @return */ public Date getGmtModified() { return gmtModified; } /** - * 最后修改时间 + * 最后修改时间 * @param gmtModified */ public void setGmtModified(Date gmtModified) { @@ -93,14 +95,14 @@ public class ResultComment implements java.io.Serializable { } /** - * 记录id + * 记录id * @return */ public Long getRecordId() { return recordId; } /** - * 记录id + * 记录id * @param recordId */ public void setRecordId(Long recordId) { @@ -108,14 +110,14 @@ public class ResultComment implements java.io.Serializable { } /** - * 评论用户id + * 评论用户id * @return */ public Long getStaffId() { return staffId; } /** - * 评论用户id + * 评论用户id * @param staffId */ public void setStaffId(Long staffId) { @@ -123,14 +125,14 @@ public class ResultComment implements java.io.Serializable { } /** - * 评论内容 + * 评论内容 * @return */ public String getComment() { return comment; } /** - * 评论内容 + * 评论内容 * @param comment */ public void setComment(String comment) { @@ -138,20 +140,35 @@ public class ResultComment implements java.io.Serializable { } /** - * 评论用户名称 + * 评论用户名称 * @return */ public String getStaffName() { return staffName; } /** - * 评论用户名称 + * 评论用户名称 * @param staffName */ public void setStaffName(String staffName) { this.staffName = staffName; } + /** + * 状态 + * @return + */ + public Integer getStatus() { + return status; + } + /** + * 状态 + * @param status + */ + public void setStatus(Integer status) { + this.status = status; + } + @Override public String toString() { return "ResultComment{" + @@ -163,6 +180,7 @@ public class ResultComment implements java.io.Serializable { ",staffId=" + staffId + ",comment=" + comment + ",staffName=" + staffName + + ",status=" + status + "}"; } } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/sys/service/app/ResultCommentService.java b/src/main/java/com/lz/modules/sys/service/app/ResultCommentService.java index 964b1d3a..dad213aa 100644 --- a/src/main/java/com/lz/modules/sys/service/app/ResultCommentService.java +++ b/src/main/java/com/lz/modules/sys/service/app/ResultCommentService.java @@ -38,5 +38,5 @@ public interface ResultCommentService extends IService { ResultComment selectLastComment(Long recordId); - void addOrUpdateComment(ResultRecordReq req,Long userId); + void addOrUpdateComment(ResultRecordReq req,Long userId,int status ); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/sys/service/app/impl/ResultCommentServiceImpl.java b/src/main/java/com/lz/modules/sys/service/app/impl/ResultCommentServiceImpl.java index 1df0a862..96f6a6e7 100644 --- a/src/main/java/com/lz/modules/sys/service/app/impl/ResultCommentServiceImpl.java +++ b/src/main/java/com/lz/modules/sys/service/app/impl/ResultCommentServiceImpl.java @@ -80,7 +80,7 @@ public class ResultCommentServiceImpl extends ServiceImpl resultRecordMapper.selectByConditionByLeader(page, params) ); + List resultRecords = pageUtils.getList(); if(CollectionUtils.isNotEmpty(resultRecords)){ List list = new ArrayList<>(); @@ -360,7 +362,7 @@ public class ResultRecordServiceImpl extends ServiceImpl + - id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, record_id AS recordId, staff_id AS staffId, comment AS comment, staff_name AS staffName + id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, record_id AS recordId, staff_id AS staffId, comment AS comment, staff_name AS staffName, status AS status @@ -34,6 +35,7 @@ staff_id, comment, staff_name, + status, is_delete, gmt_create, gmt_modified @@ -42,6 +44,7 @@ #{ staffId}, #{ comment}, #{ staffName}, + #{ status}, 0, now(), now() @@ -58,7 +61,8 @@ record_id = #{recordId}, staff_id = #{staffId}, comment = #{comment}, - staff_name = #{staffName} + staff_name = #{staffName}, + status = #{status} ,gmt_modified = now() where id = #{id} @@ -74,7 +78,8 @@ record_id = #{recordId}, staff_id = #{staffId}, comment = #{comment}, - staff_name = #{staffName} + staff_name = #{staffName}, + status = #{status} ,gmt_modified = now() where id = #{id} @@ -85,6 +90,7 @@ + diff --git a/src/main/resources/mapper/app/ResultRecordMapper.xml b/src/main/resources/mapper/app/ResultRecordMapper.xml index b914eae4..5ccbf83b 100644 --- a/src/main/resources/mapper/app/ResultRecordMapper.xml +++ b/src/main/resources/mapper/app/ResultRecordMapper.xml @@ -173,7 +173,7 @@ select * from ( select rd.*,department_level,approval_staff_id,approval_staff_name,flow_name,flow_id,flow_index from lz_flow_record fr left join lz_result_record rd on fr.record_id= rd.id - where department_level = #{req.departmentLevel} + where department_level = #{req.departmentLevel} and fr.status = 0 AND DATE_FORMAT(rd.month_time, '%Y-%m-%d %H:%i:%S') = ]]> DATE_FORMAT(#{req.monthBeginDate}, '%Y-%m-%d %H:%i:%S') diff --git a/src/main/resources/mapper/flow/FlowRecordMapper.xml b/src/main/resources/mapper/flow/FlowRecordMapper.xml index 5d92a089..ec3c3e56 100644 --- a/src/main/resources/mapper/flow/FlowRecordMapper.xml +++ b/src/main/resources/mapper/flow/FlowRecordMapper.xml @@ -127,8 +127,10 @@ + + diff --git a/src/test/java/com/lz/mysql/MysqlMain.java b/src/test/java/com/lz/mysql/MysqlMain.java index fb0774b6..625dd184 100644 --- a/src/test/java/com/lz/mysql/MysqlMain.java +++ b/src/test/java/com/lz/mysql/MysqlMain.java @@ -61,10 +61,7 @@ public class MysqlMain { } List list = new ArrayList(); - - - list.add(new TablesBean("lz_staff_role")); - + list.add(new TablesBean("lz_result_comment")); List list2 = new ArrayList(); Map map = MysqlUtil2ShowCreateTable.getComments();