|
@@ -0,0 +1,113 @@
|
|
|
+package org.springblade.control.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.commons.lang.time.DateUtils;
|
|
|
+import org.springblade.control.dto.TaskProcessInfoDTO;
|
|
|
+import org.springblade.control.entity.DictInfo;
|
|
|
+import org.springblade.control.entity.TaskProcessInfo;
|
|
|
+import org.springblade.control.mapper.TaskProcessMapper;
|
|
|
+import org.springblade.control.service.TaskProcessService;
|
|
|
+import org.springblade.control.vo.TaskProcessInfoVO;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.secure.utils.SecureUtil;
|
|
|
+import org.springblade.core.tool.utils.DateUtil;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springblade.system.user.feign.IUserClient;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, TaskProcessInfo> implements TaskProcessService {
|
|
|
+
|
|
|
+ private final IUserClient iUserClient;
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<TaskProcessInfoVO> taskPage(IPage<TaskProcessInfo> page, TaskProcessInfoDTO dto) {
|
|
|
+ if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
|
|
|
+ throw new ServiceException("未获取到当前用户信息,请联系管理员");
|
|
|
+ }
|
|
|
+ QueryWrapper<TaskProcessInfo> queryWrapper = Condition.getQueryWrapper(dto);
|
|
|
+ if (dto.getSelectType().equals("1")) { //待审批为待办任务
|
|
|
+ queryWrapper.lambda().like(TaskProcessInfo::getAuditUserIds, SecureUtil.getUserId());
|
|
|
+ queryWrapper.lambda().eq(TaskProcessInfo::getStatus, 1);
|
|
|
+ } else if (dto.getSelectType().equals("2")) { //已审核、已驳回为已办任务
|
|
|
+ queryWrapper.lambda().like(TaskProcessInfo::getAuditUserIds, SecureUtil.getUserId());
|
|
|
+ queryWrapper.lambda().in(TaskProcessInfo::getStatus, 2, 3);
|
|
|
+ } else if (dto.getSelectType().equals("3")) { //我发起的任务
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getSelectStatus()) && !dto.getSelectStatus().equals("1")) {
|
|
|
+ queryWrapper.lambda().eq(TaskProcessInfo::getStatus, dto.getSelectStatus());
|
|
|
+ }
|
|
|
+ queryWrapper.lambda().eq(TaskProcessInfo::getReportUserId, SecureUtil.getUserId());
|
|
|
+ } else if (dto.getSelectType().equals("4")) { //抄送给我的
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getSelectStatus()) && !dto.getSelectStatus().equals("1")) {
|
|
|
+ queryWrapper.lambda().eq(TaskProcessInfo::getStatus, dto.getSelectStatus());
|
|
|
+ }
|
|
|
+ queryWrapper.lambda().like(TaskProcessInfo::getCcUserIds, SecureUtil.getUserId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(dto.getStartTime()) && StringUtils.isNotEmpty(dto.getEndTime())) {
|
|
|
+ String endTime = dto.getEndTime();
|
|
|
+ endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd"), 1), "yyyy-MM-dd");
|
|
|
+ queryWrapper.lambda().between(TaskProcessInfo::getReportDate, dto.getStartTime(), endTime);
|
|
|
+ }
|
|
|
+ IPage<TaskProcessInfo> pages = this.page(page, queryWrapper.lambda().orderBy(true, true, TaskProcessInfo::getReportDate));
|
|
|
+
|
|
|
+ List<DictInfo> dictInfoList = jdbcTemplate.query("select dict_name,dict_value from c_dict_info where code = 'report_type'", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
+
|
|
|
+ Map<Long, String> userMap = iUserClient.selectUserAll().stream().collect(Collectors.toMap(User::getId, User::getRealName));
|
|
|
+
|
|
|
+ return pages.convert((obj -> {
|
|
|
+ TaskProcessInfoVO vo = new TaskProcessInfoVO();
|
|
|
+ BeanUtils.copyProperties(obj, vo);
|
|
|
+ vo.setReportUserName(userMap.get(vo.getReportUserId()));
|
|
|
+ List<String> auditUserNames = Arrays.stream(vo.getAuditUserIds().split(","))
|
|
|
+ .map(Long::parseLong).map(userMap::get)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setAuditUserNames(StringUtils.join(auditUserNames, "、"));
|
|
|
+
|
|
|
+ vo.setStatusName(vo.getStatus().equals(1) ? "待审批" : (vo.getStatus().equals(2) ? "已审核" : "已驳回"));
|
|
|
+
|
|
|
+ for (DictInfo dictInfo : dictInfoList) {
|
|
|
+ if ((vo.getTaskType() + "").equals(dictInfo.getDictValue())) {
|
|
|
+ vo.setReportTypeName(dictInfo.getDictName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TaskProcessInfoVO taskDetail(String id) {
|
|
|
+ TaskProcessInfo taskProcessInfo = baseMapper.selectById(id);
|
|
|
+ if (taskProcessInfo != null) {
|
|
|
+ if (taskProcessInfo.getTaskType().equals(1)) {
|
|
|
+ //任务审批=1
|
|
|
+
|
|
|
+ } else if (("2,3,4,5,6").contains(taskProcessInfo.getTaskType() + "")) {
|
|
|
+ //财务2、支付3、借款4、采购5、外包6
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //其他
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|