From 4dd07a1444d30e1769b1b7d52d9d9fff7713a421 Mon Sep 17 00:00:00 2001
From: quyixiao <2621048238@qq.com>
Date: Fri, 21 Aug 2020 17:23:57 +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
---
.../java/com/lz/common/utils/StringUtil.java | 10 +-
.../controller/ResultRecordController.java | 126 ++++++++++++------
.../app/dao/DepartmentsStaffRelateDao.java | 2 +
.../lz/modules/app/req/ResultRecordReq.java | 1 +
.../DepartmentsStaffRelateService.java | 2 +
.../DepartmentsStaffRelateServiceImpl.java | 6 +-
.../java/com/lz/modules/flow/model/Auth.java | 3 +-
.../flow/service/RecordAuthService.java | 2 +
.../service/impl/RecordAuthServiceImpl.java | 38 ++++++
.../sys/dao/app/ResultCommentMapper.java | 8 ++
.../sys/dao/app/ResultRecordMapper.java | 2 +
.../modules/sys/entity/app/ResultComment.java | 52 ++++++--
.../sys/service/app/ResultCommentService.java | 9 ++
.../sys/service/app/ResultRecordService.java | 2 +
.../app/impl/ResultCommentServiceImpl.java | 45 +++++++
.../app/impl/ResultRecordServiceImpl.java | 8 +-
.../mapper/app/ResultCommentMapper.xml | 60 ++++++---
.../mapper/app/ResultRecordMapper.xml | 8 +-
.../generator/DepartmentsStaffRelateDao.xml | 5 +
src/test/java/com/lz/mysql/MysqlMain.java | 2 +-
20 files changed, 316 insertions(+), 75 deletions(-)
diff --git a/src/main/java/com/lz/common/utils/StringUtil.java b/src/main/java/com/lz/common/utils/StringUtil.java
index 97a9da1d..5b6c748b 100644
--- a/src/main/java/com/lz/common/utils/StringUtil.java
+++ b/src/main/java/com/lz/common/utils/StringUtil.java
@@ -632,9 +632,12 @@ public class StringUtil extends StringUtils {
return String.valueOf(cs);
}
- public static String decodeBase64(String res){
+ public static String decodeBase64(String res) {
+ if (StringUtil.isBlank(res)) {
+ return null;
+ }
try {
- return new String(Base64.getDecoder().decode(res), "UTF-8");
+ return new String(Base64.getDecoder().decode(res), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
@@ -642,6 +645,9 @@ public class StringUtil extends StringUtils {
}
public static String removeHtml(String html) {
+ if(StringUtil.isBlank(html)){
+ return null;
+ }
return html.replaceAll("\\<.*?>","");
}
}
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 b3eb5d70..a888aa3f 100644
--- a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java
+++ b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java
@@ -65,6 +65,7 @@ public class ResultRecordController extends AbstractController {
private ResultCommentService resultCommentService;
+
/**
* 列表
*/
@@ -87,11 +88,10 @@ public class ResultRecordController extends AbstractController {
@RequestMapping("/getStaffResultDetail")
public R getStaffResultDetail(ResultRecordReq req) {
- int firstRowspan = 0;
- int secondRowspan = 0;
- int threeRowspan = 0;
- int fourRowspan = 0;
- int fiveRowspan = 0;
+ int yeJiCheckNum = 0;
+ int wenHuaJiaZhiGuanNum = 0;
+ int lastResultNum = 2;
+ int commentNum = 0;
int recordType = req.getRecordType();
ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId());
StaffEntity staffEntity = staffService.getById(resultRecord != null ? resultRecord.getStaffId() : getUserId());
@@ -146,55 +146,41 @@ public class ResultRecordController extends AbstractController {
Map details = resultDetails.stream().collect(Collectors.groupingBy(ResultDetail::getType, Collectors.counting()));
int tempType1 = NumberUtil.objToIntDefault(details.get(new Integer(1)), 0);
int tempType2 = NumberUtil.objToIntDefault(details.get(new Integer(2)), 0);
- int type1 = tempType1;
- int type2 = tempType2;
+ yeJiCheckNum = tempType1;
+ wenHuaJiaZhiGuanNum = tempType2;
if (tempType1 == 0) {
- type1 = 1;
+ yeJiCheckNum = 1;
list.add(resultDetailService.getYeJi());
list.add(resultDetailService.getYeJiKaoHe());
}
- if (tempType2 == 0) {
- type2 = 2;
- }
- firstRowspan = type1;
- secondRowspan = type1 + 1;
- threeRowspan = type1 + 1 + type2;
- fourRowspan = type1 + 1 + type2 + 1;
- fiveRowspan = type1 + 1 + type2 + 2;
int count = 0;
for (ResultDetail resultDetail : resultDetails) {
count++;
ResultDetailResp resp = new ResultDetailResp();
BeanUtils.copyProperties(resultDetail, resp);
- resp.setCheckWeight(BigDecimalUtil.set2Scale(resp.getCheckWeight()));
if (resultDetail.getType() == 1) {
resp.setCheckRange("业绩");
} else if (resultDetail.getType() == 2) {
resp.setCheckRange("文化价值观");
}
- if (count == type1) {
+ if (count == yeJiCheckNum) {
resp.setIsAdd(1);
}
resp.setIsEdit(1);
- if (count == type1 + 1 && tempType1 != 0) {
+ if (count == yeJiCheckNum + 1 && tempType1 != 0) {
list.add(resultDetailService.getYeJiKaoHe());
}
list.add(resp);
}
if (tempType2 == 0) {
+ wenHuaJiaZhiGuanNum = 2;
list.add(resultDetailService.getYeJiKaoHe());
list.add(resultDetailService.getWenHuaJiaZhiGua1(auth));
list.add(resultDetailService.getWenHuaJiaZhiGua2(auth));
}
} else {
- int type1 = 1;
- int type2 = 2;
- firstRowspan = type1;
- secondRowspan = type1 + 1;
- threeRowspan = type1 + 1 + type2;
- fourRowspan = type1 + 1 + type2 + 1;
- fiveRowspan = type1 + 1 + type2 + 2;
-
+ yeJiCheckNum = 1;
+ wenHuaJiaZhiGuanNum = 2;
list.add(resultDetailService.getYeJi());
list.add(resultDetailService.getYeJiKaoHe());
list.add(resultDetailService.getWenHuaJiaZhiGua1(auth));
@@ -203,34 +189,44 @@ public class ResultRecordController extends AbstractController {
list.add(resultDetailService.getWenHuaJiaZhiGuaResult1());
list.add(resultDetailService.getWenHuaJiaZhiGuaResult2());
list.add(resultDetailService.getLastResult());
+
+ List comments = resultCommentService.selectByRecordId(resultRecord.getId());
+ if (CollectionUtils.isNotEmpty(comments)) {
+ ResultDetailResp header = new ResultDetailResp();
+ header.setCheckRange("领导");
+ header.setTarget("意见");
+ list.add(header);
+ commentNum = comments.size();
+ for (ResultComment resultComment : comments) {
+ ResultDetailResp comment = new ResultDetailResp();
+ comment.setCheckRange(resultComment.getStaffName());
+ comment.setTarget(resultComment.getComment());
+ list.add(comment);
+ }
+ }
+
+ String superStaff = recordAuthService.selectByStaffId(resultRecord.getStaffId());
return R.ok()
.put("staffName", staffEntity.getName())
.put("department1", departmentDto.getDepartment1())
.put("department2", departmentDto.getDepartment2())
.put("department3", departmentDto.getDepartment3())
.put("checkMonth", sdf3.format(resultRecord == null ? new Date() : resultRecord.getGmtCreate()))
- .put("firstRowspan", firstRowspan)
- .put("secondRowspan", secondRowspan)
- .put("threeRowspan", threeRowspan)
- .put("fourRowspan", fourRowspan)
- .put("fiveRowspan", fiveRowspan)
.put("list", list)
.put("auth", auth)
.put("recordType", recordType)
- .put("recordResultId", recordResultId);
+ .put("recordResultId", recordResultId)
+ .put("yeJiCheckNum", yeJiCheckNum)
+ .put("wenHuaJiaZhiGuanNum", wenHuaJiaZhiGuanNum)
+ .put("lastResultNum", lastResultNum)
+ .put("commentNum", commentNum)
+ .put("superStaff",superStaff);
}
@RequestMapping("/commitApproval")
public R commitApproval(ResultRecordReq req) {
+ resultCommentService.addOrUpdateComment(req, getUserId());
if (req.getStatus() == 2) {
- String resultComment = StringUtil.decodeBase64(req.getResultComment());
- resultComment = StringUtil.removeHtml(resultComment);
- if (StringUtil.isNotBlank(resultComment)) {
- ResultComment comment = new ResultComment();
- comment.setCommentUserId(getUserId());
- comment.setRecordId(req.getRecordResultId());
- resultCommentService.insertResultComment(comment);
- }
return resultRecordService.approval(req.getRecordResultId(), getUserId());
} else if (req.getStatus() == 3) { //侍提交
ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId());
@@ -259,6 +255,17 @@ public class ResultRecordController extends AbstractController {
return R.ok().put("detailInfo", detail);
}
+ /**
+ * 信息
+ */
+ @RequestMapping("/getResultComment/{recordId}")
+ public R getResultComment(@PathVariable("recordId") Long recordId) {
+ ResultComment resultComment = resultCommentService.selectLastComment(recordId);
+ if (resultComment == null || !getUserId().equals(resultComment.getStaffId())) {
+ resultComment = new ResultComment();
+ }
+ return R.ok().put("resultComment", resultComment);
+ }
/**
* 信息
@@ -269,6 +276,43 @@ public class ResultRecordController extends AbstractController {
return R.ok("删除成功");
}
+ /**
+ * 信息
+ */
+ @RequestMapping("/recordIdsSubmit")
+ public R recordIdsSubmit(String recordIds) {
+ if (StringUtil.isBlank(recordIds)) {
+ return R.error("请选择状态为待提交的记录");
+ }
+ List records = new ArrayList<>();
+ String ids[] = recordIds.split(",");
+ if (ids != null && ids.length > 0) {
+ for (String id : ids) {
+ if (StringUtil.isNotBlank(id)) {
+ records.add(NumberUtil.objToLongDefault(id, 0));
+ }
+ }
+ }
+ if (recordIds == null) {
+ return R.error("请选择状态为待提交的记录");
+ }
+ List resultRecords = resultRecordService.selectResultRecordByIds(records);
+ for (ResultRecord resultRecord : resultRecords) {
+ if (!resultRecord.getStatus().equals(3)) {
+ return R.error("您的提交记录中有状态不为侍提交的,请重新选择。");
+ }
+ }
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ for (ResultRecord resultRecord : resultRecords) {
+ resultRecordService.approval(resultRecord.getId(), getUserId());
+ }
+ }
+ }).start();
+ return R.ok("批量提交成功");
+ }
+
/**
* 信息
*/
diff --git a/src/main/java/com/lz/modules/app/dao/DepartmentsStaffRelateDao.java b/src/main/java/com/lz/modules/app/dao/DepartmentsStaffRelateDao.java
index 119610f9..8c9d9459 100644
--- a/src/main/java/com/lz/modules/app/dao/DepartmentsStaffRelateDao.java
+++ b/src/main/java/com/lz/modules/app/dao/DepartmentsStaffRelateDao.java
@@ -54,4 +54,6 @@ public interface DepartmentsStaffRelateDao extends BaseMapper {
Map selectRoleIdByStaffRoleInfo(String flowStaffIdRole);
Auth getAuth(List listAuth);
+
+ String selectByStaffId(Long staffId);
}
\ No newline at end of file
diff --git a/src/main/java/com/lz/modules/flow/service/impl/RecordAuthServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/RecordAuthServiceImpl.java
index 9ce3e087..a9e913f3 100644
--- a/src/main/java/com/lz/modules/flow/service/impl/RecordAuthServiceImpl.java
+++ b/src/main/java/com/lz/modules/flow/service/impl/RecordAuthServiceImpl.java
@@ -4,6 +4,12 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lz.common.utils.NumberUtil;
import com.lz.common.utils.StringUtil;
+import com.lz.modules.app.entity.DepartmentsEntity;
+import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
+import com.lz.modules.app.entity.StaffEntity;
+import com.lz.modules.app.service.DepartmentsService;
+import com.lz.modules.app.service.DepartmentsStaffRelateService;
+import com.lz.modules.app.service.StaffService;
import com.lz.modules.flow.dao.RecordAuthMapper;
import com.lz.modules.flow.entity.RecordAuth;
import com.lz.modules.flow.model.Auth;
@@ -34,6 +40,14 @@ public class RecordAuthServiceImpl extends ServiceImpl {
@@ -30,4 +33,9 @@ public interface ResultCommentMapper extends BaseMapper {
int deleteResultCommentById(@Param("id")Long id);
+ List selectByRecordId(@Param("recordId") Long recordId);
+
+ ResultComment selectLastComment(@Param("recordId") Long recordId);
+
+
}
\ No newline at end of file
diff --git a/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java b/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java
index fc9844f2..88662612 100644
--- a/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java
+++ b/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java
@@ -48,4 +48,6 @@ public interface ResultRecordMapper extends BaseMapper {
List selectByConditionByLeader(@Param("page") IPage page, @Param("req") ResultRecordReq params);
void updateFlowStaffIdRoleToNull(@Param("id") Long id);
+
+ List selectResultRecordByIds(@Param("recordIds") List recordIds);
}
\ No newline at end of file
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 1de6e70b..d2390418 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
@@ -9,7 +9,7 @@ import java.util.Date;
* 菜单权限表
*
*业绩评论表
* @author quyixiao
-* @since 2020-08-10
+* @since 2020-08-21
*/
@Data
@@ -27,7 +27,11 @@ public class ResultComment implements java.io.Serializable {
//记录id
private Long recordId;
//评论用户id
- private Long commentUserId;
+ private Long staffId;
+ //评论内容
+ private String comment;
+ //评论用户名称
+ private String staffName;
/**
*
* @return
@@ -107,15 +111,45 @@ public class ResultComment implements java.io.Serializable {
* 评论用户id
* @return
*/
- public Long getCommentUserId() {
- return commentUserId;
+ public Long getStaffId() {
+ return staffId;
}
/**
* 评论用户id
- * @param commentUserId
+ * @param staffId
*/
- public void setCommentUserId(Long commentUserId) {
- this.commentUserId = commentUserId;
+ public void setStaffId(Long staffId) {
+ this.staffId = staffId;
+ }
+
+ /**
+ * 评论内容
+ * @return
+ */
+ public String getComment() {
+ return comment;
+ }
+ /**
+ * 评论内容
+ * @param comment
+ */
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ /**
+ * 评论用户名称
+ * @return
+ */
+ public String getStaffName() {
+ return staffName;
+ }
+ /**
+ * 评论用户名称
+ * @param staffName
+ */
+ public void setStaffName(String staffName) {
+ this.staffName = staffName;
}
@Override
@@ -126,7 +160,9 @@ public class ResultComment implements java.io.Serializable {
",gmtCreate=" + gmtCreate +
",gmtModified=" + gmtModified +
",recordId=" + recordId +
- ",commentUserId=" + commentUserId +
+ ",staffId=" + staffId +
+ ",comment=" + comment +
+ ",staffName=" + staffName +
"}";
}
}
\ 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 41ed5a9c..964b1d3a 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
@@ -1,8 +1,11 @@
package com.lz.modules.sys.service.app;
import com.baomidou.mybatisplus.extension.service.IService;
+import com.lz.modules.app.req.ResultRecordReq;
import com.lz.modules.sys.entity.app.ResultComment;
+import java.util.List;
+
/**
*
* 业绩评论表 服务类
@@ -30,4 +33,10 @@ public interface ResultCommentService extends IService {
int deleteResultCommentById(Long id);
+ List selectByRecordId(Long id);
+
+ ResultComment selectLastComment(Long recordId);
+
+
+ void addOrUpdateComment(ResultRecordReq req,Long userId);
}
\ No newline at end of file
diff --git a/src/main/java/com/lz/modules/sys/service/app/ResultRecordService.java b/src/main/java/com/lz/modules/sys/service/app/ResultRecordService.java
index b5bbe93e..ee0788fe 100644
--- a/src/main/java/com/lz/modules/sys/service/app/ResultRecordService.java
+++ b/src/main/java/com/lz/modules/sys/service/app/ResultRecordService.java
@@ -46,4 +46,6 @@ public interface ResultRecordService extends IService {
void updateFlowStaffIdRoleToNull(Long id);
R approval(Long resultRecordId, Long userId);
+
+ List selectResultRecordByIds(List recordIds);
}
\ 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 252a6b16..1df0a862 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
@@ -1,12 +1,18 @@
package com.lz.modules.sys.service.app.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.lz.common.utils.StringUtil;
+import com.lz.modules.app.entity.StaffEntity;
+import com.lz.modules.app.req.ResultRecordReq;
+import com.lz.modules.app.service.StaffService;
import com.lz.modules.sys.dao.app.ResultCommentMapper;
import com.lz.modules.sys.entity.app.ResultComment;
import com.lz.modules.sys.service.app.ResultCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.List;
+
/**
*
* 业绩评论表 服务类
@@ -23,6 +29,11 @@ public class ResultCommentServiceImpl extends ServiceImpl selectByRecordId(Long recordId) {
+ return resultCommentMapper.selectByRecordId(recordId);
+ }
+ @Override
+ public ResultComment selectLastComment(Long recordId) {
+ return resultCommentMapper.selectLastComment(recordId);
+ }
+
+ @Override
+ public void addOrUpdateComment(ResultRecordReq req, Long staffId) {
+ ResultComment comment = resultCommentService.selectResultCommentById(req.getResultCommitId());
+ //如果评论不为空
+ String resultComment = StringUtil.decodeBase64(req.getResultComment());
+ String content = StringUtil.removeHtml(resultComment);
+ if (StringUtil.isNotBlank(content)) { //如果不为空,则
+ if (comment == null) {
+ StaffEntity mySelf = staffService.selectStaffById(staffId);
+ comment = new ResultComment();
+ comment.setStaffId(staffId);
+ comment.setRecordId(req.getRecordResultId());
+ comment.setComment(resultComment);
+ comment.setStaffName(mySelf.getName());
+ resultCommentService.insertResultComment(comment);
+ } else {
+ comment.setComment(resultComment);
+ resultCommentService.updateResultCommentById(comment);
+ }
+ } else {
+ if (comment != null) { //如果 comment 不为空,删除评论
+ resultCommentService.deleteResultCommentById(comment.getId());
+ }
+ }
+ }
}
diff --git a/src/main/java/com/lz/modules/sys/service/app/impl/ResultRecordServiceImpl.java b/src/main/java/com/lz/modules/sys/service/app/impl/ResultRecordServiceImpl.java
index aa24009f..f16b163e 100644
--- a/src/main/java/com/lz/modules/sys/service/app/impl/ResultRecordServiceImpl.java
+++ b/src/main/java/com/lz/modules/sys/service/app/impl/ResultRecordServiceImpl.java
@@ -91,6 +91,7 @@ public class ResultRecordServiceImpl extends ServiceImpl selectResultRecordByIds(List recordIds) {
+ return resultRecordMapper.selectResultRecordByIds(recordIds);
+ }
+
public int getDepartmentLevelIndex(List list, int flowIndex) {
if (flowIndex > list.size()) {
diff --git a/src/main/resources/mapper/app/ResultCommentMapper.xml b/src/main/resources/mapper/app/ResultCommentMapper.xml
index 65857a65..5552695e 100644
--- a/src/main/resources/mapper/app/ResultCommentMapper.xml
+++ b/src/main/resources/mapper/app/ResultCommentMapper.xml
@@ -9,48 +9,56 @@
-
+
+
+
- id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, record_id AS recordId, comment_user_id AS commentUserId
+ 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