Merge branch 'version_performance_2.0' of http://gitlab.ldxinyong.com/enterpriseManagement/lz_management into version_performance_2.0

This commit is contained in:
杜建超 2020-11-06 15:41:52 +08:00
commit 6f5a4105d2
15 changed files with 205 additions and 35 deletions

View File

@ -249,9 +249,10 @@
</dependency>
<dependency>
<artifactId>taobao-sdk-java-auto_1479188381469</artifactId>
<groupId>dingtalk</groupId>
<version>20200811</version>
<groupId>com.aliyun</groupId>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
<version>1.0.0</version>
<classifier>suibian</classifier>
</dependency>
</dependencies>

View File

@ -266,7 +266,7 @@ public class DingTalkUtil {
String token = dingTalkUtil.getAccessToken("856016278");
}
//发送钉钉消息
public String sendSingleActionCardMSG(String appid, StaffEntity staff, String title, String marDown,
String singleTitle, String singleUrl, String token) {
String msg = "OK";
@ -318,6 +318,59 @@ public class DingTalkUtil {
thirdMsgSendRecordService.insert(thirdMsgSendRecord);
return msg;
}
//发送待办任务
public String sendSingleWorkMSG(String appid, StaffEntity staff, String title, String marDown,
String singleTitle, String singleUrl, String token) {
String msg = "OK";
ThirdMsgSendRecord thirdMsgSendRecord = new ThirdMsgSendRecord();
thirdMsgSendRecord.setMsgType("work_msg");
thirdMsgSendRecord.setStaffId(staff.getId());
thirdMsgSendRecord.setMsgTitle(singleTitle);
thirdMsgSendRecord.setAppId(Long.parseLong(appid));
thirdMsgSendRecord.setHeadText(title);
thirdMsgSendRecord.setMsgContent(marDown);
thirdMsgSendRecord.setMsgUrl(singleUrl);
thirdMsgSendRecord.setStatus(0);
try{
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/workrecord/add");
OapiWorkrecordAddRequest req = new OapiWorkrecordAddRequest();
req.setUserid(staff.getEmployeeId());
req.setCreateTime(System.currentTimeMillis());
req.setTitle(singleTitle);
req.setUrl(singleUrl);
List<OapiWorkrecordAddRequest.FormItemVo> list2 = new ArrayList<OapiWorkrecordAddRequest.FormItemVo>();
OapiWorkrecordAddRequest.FormItemVo obj3 = new OapiWorkrecordAddRequest.FormItemVo();
list2.add(obj3);
obj3.setTitle(title);
obj3.setContent(marDown);
req.setFormItemList(list2);
OapiWorkrecordAddResponse rsp = client.execute(req, token);
logger.info("钉钉待办任务请求返回{}", rsp.getBody());
//插入数据库
JSONObject json = JSONObject.parseObject(rsp.getBody());
if(json.getIntValue("errcode") == 0){
thirdMsgSendRecord.setTaskId(json.getLong("record_id"));
thirdMsgSendRecord.setStatus(1);
}else{
thirdMsgSendRecord.setTaskId(0L);
thirdMsgSendRecord.setStatus(6);
thirdMsgSendRecord.setRemark(json.getString("errmsg"));
msg = thirdMsgSendRecord.getRemark();
}
}catch (ApiException e) {
e.printStackTrace();
thirdMsgSendRecord.setStatus(6);
thirdMsgSendRecord.setRemark(e.getErrMsg());
msg = thirdMsgSendRecord.getRemark();
}
thirdMsgSendRecordService.insert(thirdMsgSendRecord);
return msg;
}
public R getUserIdByCode(String code, String token) {
try {

View File

@ -53,6 +53,7 @@ public class ShiroConfig {
filterMap.put("/webjars/**", "anon");
filterMap.put("/file/**", "anon");
filterMap.put("/user/lzstaffrole/role/**", "anon");
filterMap.put("/user/lzresultrecord/**", "anon");
filterMap.put("/test/**", "anon");
filterMap.put("/druid/**", "anon");
filterMap.put("/app/**", "anon");

View File

@ -999,7 +999,7 @@ public class ResultRecordController extends AbstractController {
/**
* 删除
*/
// http://localhost:8080/lz_management/user/lzresultrecord/new/resultRecordDetail?resultRecordId=331&loginUserId=825
// http://localhost:8080/lz_management/user/lzresultrecord/new/resultRecordDetail?resultRecordId=387&loginUserId=380
@RequestMapping("/new/resultRecordDetail")
public R newResultRecordList(RecordDetailDto recordDetailDto) {
if(recordDetailDto.getLoginUserId() ==null && getUser() !=null ){

View File

@ -261,7 +261,7 @@ public class TestController {
}
}
// http://localhost:8080/lz_management/test/resultrecord?resultRecordId=215
// http://localhost:8080/lz_management/test/resultrecord?resultRecordId=381
@RequestMapping("/test/resultrecord")
public void resultRecorcd(Long resultRecordId) throws Exception{
R r = resultRecordService.initFlowRecord(resultRecordId);

View File

@ -157,7 +157,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
case 5:
return R.error(groupStaffs.getEvaluationGroup().getName() + "——初始化考核流程失败");
}
dingtalkBusiness.sendWorkMSGWithThread(staffSimpleInfos, WorkMsgTypeEnum.START_WORK.getType());
dingtalkBusiness.sendWorkMSGWithAsyn(staffSimpleInfos, WorkMsgTypeEnum.START_WORK.getType());
}
return R.ok("发起成功").put("data", flowStart);
@ -281,7 +281,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
case 5:
return R.error(evaluationGroup.getName() + "——初始化考核流程失败");
}
dingtalkBusiness.sendWorkMSGWithThread(staffIds, WorkMsgTypeEnum.START_WORK.getType());
dingtalkBusiness.sendWorkMSGWithAsyn(staffIds, WorkMsgTypeEnum.START_WORK.getType());
}
return R.ok("发起成功").put("data", flowStart);
}

View File

@ -193,13 +193,9 @@ public class DingtalkBusiness {
return sendWorkMSGByEntity(appid, fromStaffEntity, toStaffEntity, workMsgTypeEnum, "https://www.baidu.com");
}
public String sendWorkMSGWithAsyn(List<Long> toStaffids, int type) {
List<StaffSimpleInfo> staffSimpleInfos = staffService.selectStaffSimpleInfos(toStaffids);
return sendWorkMSGWithThread(staffSimpleInfos, type);
}
public String sendWorkMSGWithThread(List<StaffSimpleInfo> toStaffids, int type) {
public String sendWorkMSGWithAsyn(List<StaffSimpleInfo> toStaffids, int type) {
if(toStaffids.get(0).getEmployeeId() == null || toStaffids.get(0).getEmployeeId().length() == 0){
//查询第三方id
@ -293,7 +289,7 @@ public class DingtalkBusiness {
List<StaffSimpleInfo> toStaffids;
WorkMsgTypeEnum workMsgTypeEnum;
String appid;
String url = "";
String hostUrl = "https://lzmanagement.ldxinyong.com/digitization/dingTalkLogin";
public ThreadSendMessage(List<StaffSimpleInfo> toStaffids, WorkMsgTypeEnum typeEnum, String appid){
this.toStaffids = toStaffids;
workMsgTypeEnum = typeEnum;
@ -309,14 +305,15 @@ public class DingtalkBusiness {
) {
if(token != null && token.length() > 0){
//下面防止第二次发送消息时钉钉不推送
String url = hostUrl;
if(url.contains("?")){
url += "&halokit=" + System.currentTimeMillis();
}else{
url += "?halokit=" + System.currentTimeMillis();
}
url += ("&detail=1&id=" + info.getRecordId());
url = URLEncoder.encode(url);
/* url = "dingtalk://dingtalkclient/action/openapp?corpid=" + thirdAppConfig.getCorpId() +
"&container_type=work_platform&app_id=0_" + appid + "&redirect_type=jump&redirect_url=" + url;*/
url = "dingtalk://dingtalkclient/page/link?pc_slide=true&url=" + url;
@ -324,7 +321,7 @@ public class DingtalkBusiness {
StaffEntity entity = new StaffEntity();
entity.setId(info.getId());
entity.setEmployeeId(info.getEmployeeId());
dingTalkUtil.sendSingleActionCardMSG(appid, entity, workMsgTypeEnum.getTitle(),
dingTalkUtil.sendSingleWorkMSG(appid, entity, workMsgTypeEnum.getTitle(),
content, workMsgTypeEnum.getBtnText(), url, token);
}else{
logger.info("ThreadSendMessage token无效"); ;

View File

@ -311,7 +311,7 @@ public class AssessManagerServiceImpl implements AssessManagerService {
//通知评分
try {
dingtalkBusiness.sendWorkMSGWithThread(toStaffids, WorkMsgTypeEnum.START_SCORE.getType());
dingtalkBusiness.sendWorkMSGWithAsyn(toStaffids, WorkMsgTypeEnum.START_SCORE.getType());
} catch (Exception e) {
log.error("通知评分异常:",e);
}

View File

@ -19,12 +19,14 @@ import com.lz.common.validator.group.AddGroup;
import com.lz.common.validator.group.UpdateGroup;
import com.lz.modules.app.entity.UserEntity;
import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.sys.entity.SysUserEntityDto;
import com.lz.modules.sys.form.PasswordForm;
import com.lz.modules.sys.service.SysUserRoleService;
import com.lz.modules.sys.service.SysUserService;
import org.apache.commons.lang.ArrayUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -67,7 +69,10 @@ public class SysUserController extends AbstractController {
*/
@GetMapping("/info")
public R info() {
return R.ok().put("user", getUser());
SysUserEntity sysUserEntity = getUser();
SysUserEntityDto entityDto = new SysUserEntityDto();
BeanUtils.copyProperties(sysUserEntity, entityDto);
return R.ok().put("user", entityDto);
}
/**

View File

@ -49,12 +49,19 @@ public class SysUserEntity implements Serializable {
@NotBlank(message="工号不能为空", groups = AddGroup.class)
private String userNo;
/**
* 用户名
*/
@NotBlank(message="账号不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String username;
/**
* 头像
*/
@TableField(exist = false)
private String avatar;
/**
* 密码
*/

View File

@ -0,0 +1,97 @@
/**
* Copyright (c) 2020 fumeiai All rights reserved.
*
*
*
* 版权所有侵权必究
*/
package com.lz.modules.sys.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lz.common.validator.group.AddGroup;
import com.lz.common.validator.group.UpdateGroup;
import lombok.Data;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 系统用户
*
* @author Mark sunlightcs@gmail.com
*/
@Data
@TableName("sys_user")
public class SysUserEntityDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
@TableId
private Long userId;
/**
* 员工姓名
*/
@NotBlank(message="员工姓名不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String realName;
/**
* 员工工号
*/
@NotBlank(message="工号不能为空", groups = AddGroup.class)
private String userNo;
/**
* 头像
*/
@TableField(exist = false)
private String avatar;
/**
* 用户名
*/
@NotBlank(message="账号不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String username;
/**
* 手机号
*/
@NotBlank(message="手机号不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String mobile;
// /**
// * 邮箱
// */
// @NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
@Email(message="邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
private String email;
/**
* 状态 0禁用 1正常
*/
private Integer status;
private int type ;// 0 表示系统用户1 表示普通员工
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}

View File

@ -11,6 +11,7 @@ package com.lz.modules.sys.oauth2;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.sys.entity.SysUserEntityDto;
import com.lz.modules.sys.entity.SysUserTokenEntity;
import com.lz.modules.sys.service.ShiroService;
import org.apache.shiro.authc.*;
@ -71,16 +72,19 @@ public class OAuth2Realm extends AuthorizingRealm {
//查询用户信息
SysUserEntity user = null;
StaffEntity staffEntity = staffService.selectStaffById(tokenEntity.getUserId());
if(tokenEntity.getType() == 0){ //如果是系统用户
user = shiroService.queryUser(tokenEntity.getUserId());
if(staffEntity != null){
user.setAvatar(staffEntity.getAvatar());
}
}else{
user = new SysUserEntity();//如果是普通用户
StaffEntity staffEntity = staffService.selectStaffById(tokenEntity.getUserId());
user.setPassword(staffEntity.getPassword());
user = new SysUserEntity();
user.setMobile(staffEntity.getMobile());
user.setAvatar(staffEntity.getAvatar());
user.setUserId(staffEntity.getId());
user.setEmail(staffEntity.getEmail());
user.setSalt(staffEntity.getSalt());
user.setStatus(1);
user.setType(1);
user.setUsername(staffEntity.getMobile());

View File

@ -773,7 +773,6 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
}
List<FlowApprovalRole> flowApprovalRoles =flowApprovalRoleService.selectFlowApprovalRoleList(flowIds);
int i = 0;
List<FlowRecord> flowRecords = new ArrayList<>();
for (FlowApprovalRole flowApprovalRole : flowApprovalRoles) {
FlowRecord flowRecord = new FlowRecord();
flowRecord.setRecordId(resultRecord.getId());
@ -814,9 +813,9 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
flowRecord.setFlowIndex(flowApprovalRole.getStepIndex());
flowRecord.setType(flowApprovalRole.getStepType()); //步骤类型0依次1或签同时通知一人通过或拒绝即可2会签同时通知所有人同意才可
i++;
flowRecords.add(flowRecord);
flowRecordService.insertFlowRecord(flowRecord);
}
flowRecordService.insertFlowRecords(flowRecords);
resultRecordService.updateResultRecordById(resultRecord);
return R.ok();
}
@ -824,6 +823,7 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
@Override
////1 提交审批,审批通过,2 撤回,3 催办,4 跳过,5 驳回6 申述7 流程终止8 转交
public R newApproval(ApprovalDto approvalDto) throws Exception{
log.info("newApproval args :" + JSON.toJSONString(approvalDto));
if(approvalDto.getResultRecordId() == null){
throw new RRException("resultRecordId 不能为空");
}
@ -923,6 +923,7 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
}
private R newSubmit(ApprovalDto approvalDto,Integer finishedStatus) {
ResultRecord resultRecord = resultRecordMapper.selectResultRecordById(approvalDto.getResultRecordId());
if(approvalDto.getLoginUserId() == null){
approvalDto.setLoginUserId(resultRecord.getCurrentApprovalStaffId());
@ -1113,8 +1114,8 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
flowIndex = flowRecord.getFlowIndex();
}
boolean flag = true;
for(FlowRecordResp flowRecordResp : flowRecordList) {
if (flowRecordResp.getStatus() == 0) {
for (FlowRecord flowRecord : flowRecords) {
if (flowRecord.getStatus() == 2) {
flag = false;
break;
}
@ -1133,15 +1134,16 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
auth.put("showScore",1);
auth.put("showResult",1);
List<FlowRecord> currentResultRecords = flowRecordService.selectFlowRecordByRecordIdStatus(recordDetailDto.getResultRecordId(),2);
log.info("当前用户登陆用户 id :" + recordDetailDto.getLoginUserId());
if(currentResultRecords !=null && currentResultRecords.size() > 0 ){
FlowRecord currentResultRecord = null;
for(FlowRecord flowRecord:currentResultRecords){
if(flowRecord.getApprovalStaffId().equals(recordDetailDto.getLoginUserId())){
currentResultRecord = flowRecord;
log.info("当前审批用户 id id :" + currentResultRecord.getApprovalStaffId());
break;
}
}
if(currentResultRecord !=null){
if(StringUtil.isNotBlank(currentResultRecord.getFlowStaffIdRole())){
Map<String,Object> map = JSONObject.parseObject(currentResultRecord.getFlowStaffIdRole(),Map.class);

View File

@ -21,12 +21,13 @@
<result column="status_name" property="statusName"/>
<result column="type" property="type"/>
<result column="process_id" property="processId"/>
<result column="flow_process" property="flowProcess"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, department_level AS departmentLevel, record_id AS recordId, approval_staff_id AS approvalStaffId, approval_staff_name AS approvalStaffName, flow_name AS flowName, record_staff_id AS recordStaffId, flow_id AS flowId, flow_index AS flowIndex, status AS status, flow_staff_id_role AS flowStaffIdRole, status_name AS statusName, type AS type, process_id AS processId
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, department_level AS departmentLevel, record_id AS recordId, approval_staff_id AS approvalStaffId, approval_staff_name AS approvalStaffName, flow_name AS flowName, record_staff_id AS recordStaffId, flow_id AS flowId, flow_index AS flowIndex, status AS status, flow_staff_id_role AS flowStaffIdRole, status_name AS statusName, type AS type, process_id AS processId, flow_process AS flowProcess
</sql>
@ -52,6 +53,7 @@
<if test="statusName != null">status_name, </if>
<if test="type != null">type, </if>
<if test="processId != null">process_id, </if>
<if test="flowProcess != null">flow_process, </if>
is_delete,
gmt_create,
gmt_modified
@ -69,6 +71,7 @@
<if test="statusName != null">#{ statusName}, </if>
<if test="type != null">#{ type}, </if>
<if test="processId != null">#{ processId}, </if>
<if test="flowProcess != null">#{ flowProcess}, </if>
0,
now(),
now()
@ -94,7 +97,8 @@
<if test="flowStaffIdRole != null">flow_staff_id_role = #{flowStaffIdRole},</if>
<if test="statusName != null">status_name = #{statusName},</if>
<if test="type != null">type = #{type},</if>
<if test="processId != null">process_id = #{processId}</if>
<if test="processId != null">process_id = #{processId},</if>
<if test="flowProcess != null">flow_process = #{flowProcess}</if>
</trim>
,gmt_modified = now()
where id = #{id}
@ -119,7 +123,8 @@
flow_staff_id_role = #{flowStaffIdRole},
status_name = #{statusName},
type = #{type},
process_id = #{processId}
process_id = #{processId},
flow_process = #{flowProcess}
,gmt_modified = now()
where id = #{id}
</update>
@ -130,8 +135,6 @@
</update>
<select id="selectLastFlowRecordByRecordId" resultType="com.lz.modules.flow.entity.FlowRecord">
select * from lz_flow_record where is_delete = 0 and record_id = #{recordId} and status = 0 order by id desc limit 1
</select>

View File

@ -126,7 +126,7 @@ public class MysqlMain {
List<TablesBean> list = new ArrayList<TablesBean>();
list.add(new TablesBean("lz_evaluation_group"));
list.add(new TablesBean("lz_flow_record"));
List<TablesBean> list2 = new ArrayList<TablesBean>();
Map<String, String> map = MysqlUtil2ShowCreateTable.getComments();