增加页面存储当前用户对象

This commit is contained in:
wanggeng 2022-04-27 23:33:10 +08:00
parent 9b948b4b5a
commit 71b80b57e1
5 changed files with 94 additions and 18 deletions

View File

@ -0,0 +1,44 @@
package ink.wgink.module.activiti.pojo.vos.oa.page;
import ink.wgink.pojo.dtos.department.DepartmentSimpleDTO;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName: CurrentUserVO
* @Description: 当前用户
* @Author: wanggeng
* @Date: 2022/4/27 23:17
* @Version: 1.0
*/
public class CurrentUserVO {
private String userId;
private String userName;
private List<DepartmentSimpleDTO> departments;
public String getUserId() {
return userId == null ? "" : userId.trim();
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName == null ? "" : userName.trim();
}
public void setUserName(String userName) {
this.userName = userName;
}
public List<DepartmentSimpleDTO> getDepartments() {
return departments == null ? new ArrayList() : departments;
}
public void setDepartments(List<DepartmentSimpleDTO> departments) {
this.departments = departments;
}
}

View File

@ -13,6 +13,7 @@ public class FieldVO {
private Integer isEditable;
private Integer isVisible;
private String editHistory;
private String autoBackFill;
public String getFieldName() {
return fieldName == null ? "" : fieldName.trim();
@ -45,4 +46,12 @@ public class FieldVO {
public void setEditHistory(String editHistory) {
this.editHistory = editHistory;
}
public String getAutoBackFill() {
return autoBackFill == null ? "" : autoBackFill.trim();
}
public void setAutoBackFill(String autoBackFill) {
this.autoBackFill = autoBackFill;
}
}

View File

@ -8,15 +8,13 @@ import ink.wgink.interfaces.user.IUserBaseService;
import ink.wgink.module.activiti.pojo.dtos.oa.NodeButtonDTO;
import ink.wgink.module.activiti.pojo.dtos.oa.NodeFieldDTO;
import ink.wgink.module.activiti.pojo.pos.oa.OaNodeAssigneePO;
import ink.wgink.module.activiti.pojo.vos.oa.page.FormButtonVO;
import ink.wgink.module.activiti.pojo.vos.oa.page.ConfirmAssigneeVO;
import ink.wgink.module.activiti.pojo.vos.oa.page.FieldVO;
import ink.wgink.module.activiti.pojo.vos.oa.page.GoBackUserTaskVO;
import ink.wgink.module.activiti.pojo.vos.oa.page.*;
import ink.wgink.module.activiti.service.activiti.IActivitiModelService;
import ink.wgink.module.activiti.service.oa.*;
import ink.wgink.module.form.enums.design.FormTypeEnum;
import ink.wgink.module.form.service.design.IFormFieldService;
import ink.wgink.module.form.service.report.IFormReportRouteService;
import ink.wgink.pojo.bos.UserInfoBO;
import ink.wgink.pojo.dtos.user.UserDTO;
import org.activiti.bpmn.model.FlowNode;
import org.activiti.bpmn.model.SequenceFlow;
@ -89,6 +87,7 @@ public class OaFormReportRouteServiceImpl extends DefaultBaseService implements
setPageFields(deploymentId, firstUserTask, model);
setPageFormButtonsAndHistoryUserTasks(deploymentId, null, firstUserTask, model);
setPageCurrentUser(model);
formReportRouteService.save(formCode, formVersion, httpSession, httpServletRequest, httpServletResponse, model);
}
@ -119,10 +118,25 @@ public class OaFormReportRouteServiceImpl extends DefaultBaseService implements
setPageFields(deploymentId, currentUserTask, model);
setPageFormButtonsAndHistoryUserTasks(deploymentId, null, currentUserTask, model);
setPageCurrentUser(model);
// 设置代理人
formReportRouteService.update(formCode, formVersion, httpSession, httpServletRequest, httpServletResponse, model);
}
/**
* 设置页面当前用户
*
* @param model
*/
private void setPageCurrentUser(Map<String, Object> model) {
CurrentUserVO currentUserVO = new CurrentUserVO();
UserInfoBO currentUser = securityComponent.getCurrentUser();
currentUserVO.setUserId(currentUser.getUserId());
currentUserVO.setUserName(currentUser.getUserName());
currentUserVO.setDepartments(currentUser.getDepartments());
model.put("currentUser", JSONObject.toJSONString(currentUserVO));
}
@Override
public void show(String formCode, Integer formVersion, HttpSession httpSession, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
Map<String, Object> model = getHashMap(10);
@ -166,6 +180,7 @@ public class OaFormReportRouteServiceImpl extends DefaultBaseService implements
fieldVO.setIsEditable(nodeFieldDTO.getIsEditable());
fieldVO.setIsVisible(nodeFieldDTO.getIsVisible());
fieldVO.setEditHistory(nodeFieldDTO.getEditHistory());
nodeFieldDTO.getAutoBackFill();
return fieldVO;
}).collect(Collectors.toList());
model.put("fields", JSONObject.toJSONString(fieldVOs));

View File

@ -100,6 +100,8 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo
setFormReportAssignee(oaFormReportUnWantedValueBO.getSelectType(), oaFormReportUnWantedValueBO.getAssignees(), params);
}
setRecordFields(task.getId(), oaFormReportUnWantedValueBO.getRecordFields(), userId, userName, params);
// 保存代理人昵称
params.put(KEY_ASSIGNEE_USER_NAME, userName);
taskService.setVariablesLocal(task.getId(), params);
taskService.complete(task.getId(), params);
}
@ -132,6 +134,8 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo
setFormReportAssignee(oaFormReportUnWantedValueBO.getSelectType(), oaFormReportUnWantedValueBO.getAssignees(), params);
}
setRecordFields(taskId, oaFormReportUnWantedValueBO.getRecordFields(), userId, userName, params);
// 保存代理人昵称
params.put(KEY_ASSIGNEE_USER_NAME, userName);
taskService.setVariablesLocal(taskId, params);
taskService.complete(taskId, params);
}
@ -164,7 +168,8 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo
taskSignJsonObject.put("time", currentTime);
reportParams.put(taskVariableKey, taskSignJsonObject.toJSONString());
if (StringUtils.equals(oaFormReportRecordFieldVO.getEditHistory(), FieldEditRecordEnum.LATEST.getValue())) {
// 审批存储在流程变量中
// 内容变更为 [签批人XX 内容XXXXXX 时间XXXX-XX-XX XX:XX:XX]
reportParams.put(oaFormReportRecordFieldVO.getFieldName(), String.format("签批人:%s。 内容:%s。 时间:%s。", userName, reportRecordValue, currentTime));
continue;
}
if (StringUtils.equals(oaFormReportRecordFieldVO.getEditHistory(), FieldEditRecordEnum.ALL.getValue())) {

View File

@ -225,12 +225,14 @@ public class OaServiceImpl extends DefaultBaseService implements IOaService {
oaProcessLogDTO.setTaskName(historicTaskInstance.getName());
oaProcessLogDTO.setTaskStatus(ProcessTaskStatusEnum.ALREADY_DONE.getValue());
Map<String, Object> taskLocalVariables = historicTaskInstance.getTaskLocalVariables();
Object assigneeUserNameObj = taskLocalVariables.get(IOaFormReportService.KEY_ASSIGNEE_USER_NAME);
oaProcessLogDTO.setUserIds(userIds);
oaProcessLogDTO.setUserNames(userIds);
oaProcessLogDTO.setUserNames(assigneeUserNameObj == null ? "" : assigneeUserNameObj.toString());
oaProcessLogDTO.setStartTime(DateUtil.getDateTime(historicTaskInstance.getCreateTime()));
oaProcessLogDTO.setEndTime(DateUtil.getDateTime(historicTaskInstance.getEndTime()));
oaProcessLogDTO.setUsedTime(DateUtil.getUsedTime(historicTaskInstance.getDurationInMillis()));
oaProcessLogDTO.setTaskVariables(historicTaskInstance.getTaskLocalVariables());
oaProcessLogDTOs.add(oaProcessLogDTO);
});
// 待办
@ -244,23 +246,24 @@ public class OaServiceImpl extends DefaultBaseService implements IOaService {
oaProcessLogDTO.setTaskName(task.getName());
oaProcessLogDTO.setTaskStatus(ProcessTaskStatusEnum.NEED_TO_BE_DEALT_WITH.getValue());
Map<String, Object> taskLocalVariables = task.getTaskLocalVariables();
Object assigneeUserNameObj = taskLocalVariables.get(IOaFormReportService.KEY_ASSIGNEE_USER_NAME);
String userIdString = WStringUtil.listToStr(userIds, ",");
oaProcessLogDTO.setUserIds(userIdString);
oaProcessLogDTO.setUserNames(userIdString);
oaProcessLogDTO.setUserNames(assigneeUserNameObj == null ? "" : assigneeUserNameObj.toString());
oaProcessLogDTO.setStartTime(DateUtil.getDateTime(task.getCreateTime()));
oaProcessLogDTO.setTaskVariables(task.getTaskLocalVariables());
oaProcessLogDTOs.add(oaProcessLogDTO);
});
// 查询用户
List<UserDTO> userDTOs = userBaseService.listByUserIds(userIdSet.stream().collect(Collectors.toList()));
oaProcessLogDTOs.forEach(oaProcessLogDTO -> {
userDTOs.forEach(userDTO -> {
if (StringUtils.contains(oaProcessLogDTO.getUserNames(), userDTO.getUserId())) {
oaProcessLogDTO.setUserNames(oaProcessLogDTO.getUserNames().replaceAll(userDTO.getUserId(), userDTO.getUserName()));
}
});
});
// List<UserDTO> userDTOs = userBaseService.listByUserIds(userIdSet.stream().collect(Collectors.toList()));
// oaProcessLogDTOs.forEach(oaProcessLogDTO -> {
// userDTOs.forEach(userDTO -> {
// if (StringUtils.contains(oaProcessLogDTO.getUserNames(), userDTO.getUserId())) {
// oaProcessLogDTO.setUserNames(oaProcessLogDTO.getUserNames().replaceAll(userDTO.getUserId(), userDTO.getUserName()));
// }
// });
// });
return oaProcessLogDTOs;
}