瀏覽代碼

审批流程及已办、发起页面

huangjn 3 年之前
父節點
當前提交
849e5b20e9

+ 7 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ContractInfoVO.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.manager.vo;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.springblade.manager.entity.ContractInfo;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -48,4 +49,10 @@ public class ContractInfoVO extends ContractInfo {
      */
     private List<WbsTreeContractVO3> idList;
 
+    /**
+     * 是否是默认项目
+     */
+    @ApiModelProperty("是否是默认项目")
+    private Integer isDefault;
+
 }

+ 7 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ProjectInfoVO.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.manager.vo;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.springblade.manager.entity.ProjectInfo;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -41,4 +42,10 @@ public class ProjectInfoVO extends ProjectInfo {
 	 */
 	private String name;
 
+	/**
+	 * 是否是默认项目
+	 */
+	@ApiModelProperty("是否是默认项目")
+	private Integer isDefault;
+
 }

+ 59 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/DefaultProjectController.java

@@ -0,0 +1,59 @@
+package org.springblade.business.controller;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.api.R;
+import org.springframework.web.bind.annotation.*;
+import org.springblade.business.entity.DefaultProject;
+import org.springblade.business.service.IDefaultProjectService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+import java.util.Date;
+
+/**
+ *  控制器
+ *
+ * @author BladeX
+ * @since 2022-07-06
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/defaultProject")
+@Api(value = "默认项目", tags = "默认项目接口")
+public class DefaultProjectController extends BladeController {
+
+	private final IDefaultProjectService defaultProjectService;
+
+	/**
+	 * 获取默认项目
+	 */
+	@GetMapping("/queryUserDefault")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "获取默认项目")
+	public R<DefaultProject> queryUserDefault(){
+		return R.data(this.defaultProjectService.getOne(Wrappers.<DefaultProject>lambdaQuery().eq(DefaultProject::getUserId, AuthUtil.getUserId().toString())));
+	}
+
+	/**
+	 * 新增 
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "新增", notes = "传入defaultProject")
+	public R<Boolean> save(@Valid @RequestBody DefaultProject defaultProject) {
+		//删掉原本的数据
+		this.defaultProjectService.update(Wrappers.<DefaultProject>lambdaUpdate().set(DefaultProject::getIsDeleted, 1).set(DefaultProject::getUpdateUser, AuthUtil.getUserId()).set(DefaultProject::getUpdateTime, new Date()).eq(DefaultProject::getUserId, AuthUtil.getUserId().toString()));
+		defaultProject.setUserId(AuthUtil.getUserId().toString());
+		defaultProject.setCreateUser(AuthUtil.getUserId());
+		defaultProject.setCreateTime(new Date());
+
+		return R.status(defaultProjectService.save(defaultProject));
+	}
+
+	
+}

+ 28 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/UserViewProjectContractController.java

@@ -2,10 +2,14 @@ package org.springblade.business.controller;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.apache.commons.lang.StringUtils;
+import org.springblade.business.entity.DefaultProject;
+import org.springblade.business.service.IDefaultProjectService;
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
@@ -21,6 +25,8 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -37,6 +43,8 @@ public class UserViewProjectContractController {
 
     private final ProjectAssignmentUserClient projectAssignmentUserClient;
 
+    private final IDefaultProjectService defaultProjectService;
+
     /**
      * 获取客户端首页当前用户关联的项目及合同段信息
      * @return 项目及合同段结果集
@@ -49,6 +57,14 @@ public class UserViewProjectContractController {
         if(user == null){
             return R.data(null);
         }
+        //获取当前用户的默认项目
+        List<DefaultProject> defaultProjects =  this.defaultProjectService.list(Wrappers.<DefaultProject>lambdaQuery().eq(DefaultProject::getUserId, AuthUtil.getUserId().toString()));
+        String defaultProject = null, defaultContract = null;
+        if(defaultProjects != null && defaultProjects.size() > 0){
+            defaultProject = defaultProjects.get(0).getProjectId();
+            defaultContract = defaultProjects.get(0).getContractId();
+        }
+
         //获取当前用户的所有相关项目及合同段ID
         List<SaveUserInfoByProjectDTO> userDownAll = this.projectAssignmentUserClient.queryCurrentUserDownAllContractAndProjectId(user.getUserId());
 
@@ -75,9 +91,14 @@ public class UserViewProjectContractController {
                 List<ContractInfoVO> contractInfoVOS = JSONArray.parseArray(JSONObject.toJSONString(contractInfos), ContractInfoVO.class);
                 contractInfoVOS.removeIf(vo -> !contractIds.contains(String.valueOf(vo.getId())));
 
+                //用户默认的项目及合同段
+                String finalDefaultProject = defaultProject;
+                String finalDefaultContract = defaultContract;
+
                 projectInfoVOS.forEach(vo -> {
                     //统一返回格式
                     vo.setName(vo.getProjectName());
+                    vo.setIsDefault(StringUtils.isNotEmpty(finalDefaultProject) && vo.getId().toString().equals(finalDefaultProject) ? 1 : 0);
 
                     Iterator<ContractInfoVO> iterator = contractInfoVOS.iterator();
                     while (iterator.hasNext()){
@@ -87,11 +108,18 @@ public class UserViewProjectContractController {
 
                         //找到对应的合同段
                         if(String.valueOf(vo.getId()).equals(String.valueOf(next.getPId()))){
+                            next.setIsDefault(StringUtils.isNotEmpty(finalDefaultContract) && next.getId().toString().equals(finalDefaultContract) ? 1 : 0);
                             vo.getContractInfoList().add(next);
                             iterator.remove();
                         }
                     }
+                    //排序合同段
+                    List<ContractInfoVO> contractInfoList = vo.getContractInfoList();
+                    contractInfoList.sort(Comparator.comparingInt(ContractInfoVO::getIsDefault).reversed());
+                    vo.setContractInfoList(contractInfoList);
                 });
+                //排序项目
+                projectInfoVOS.sort(Comparator.comparingInt(ProjectInfoVO::getIsDefault).reversed());
             }
             return R.data(projectInfoVOS);
         }

+ 34 - 0
blade-service/blade-business/src/main/java/org/springblade/business/dto/DefaultProjectDTO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.dto;
+
+import org.springblade.business.entity.DefaultProject;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2022-07-06
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class DefaultProjectDTO extends DefaultProject {
+	private static final long serialVersionUID = 1L;
+
+}

+ 43 - 0
blade-service/blade-business/src/main/java/org/springblade/business/entity/DefaultProject.java

@@ -0,0 +1,43 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import org.springblade.core.mp.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 实体类
+ *
+ * @author BladeX
+ * @since 2022-07-06
+ */
+@Data
+@TableName("u_default_project")
+@EqualsAndHashCode(callSuper = true)
+public class DefaultProject extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	private String projectId;
+	private String contractId;
+	private String userId;
+
+
+}

+ 33 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/DefaultProjectMapper.java

@@ -0,0 +1,33 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.mapper;
+
+import org.springblade.business.entity.DefaultProject;
+import org.springblade.business.vo.DefaultProjectVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2022-07-06
+ */
+public interface DefaultProjectMapper extends BaseMapper<DefaultProject> {
+
+}

+ 20 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/DefaultProjectMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.business.mapper.DefaultProjectMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="defaultProjectResultMap" type="org.springblade.business.entity.DefaultProject">
+        <result column="id" property="id"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_dept" property="createDept"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="status" property="status"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="project_id" property="projectId"/>
+        <result column="contract_id" property="contractId"/>
+        <result column="user_id" property="userId"/>
+    </resultMap>
+
+</mapper>

+ 32 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/IDefaultProjectService.java

@@ -0,0 +1,32 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.service;
+
+import org.springblade.business.entity.DefaultProject;
+import org.springblade.business.vo.DefaultProjectVO;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2022-07-06
+ */
+public interface IDefaultProjectService extends BaseService<DefaultProject> {
+
+}

+ 36 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/DefaultProjectServiceImpl.java

@@ -0,0 +1,36 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.service.impl;
+
+import org.springblade.business.entity.DefaultProject;
+import org.springblade.business.vo.DefaultProjectVO;
+import org.springblade.business.mapper.DefaultProjectMapper;
+import org.springblade.business.service.IDefaultProjectService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ *  服务实现类
+ *
+ * @author BladeX
+ * @since 2022-07-06
+ */
+@Service
+public class DefaultProjectServiceImpl extends BaseServiceImpl<DefaultProjectMapper, DefaultProject> implements IDefaultProjectService {
+
+}

+ 34 - 0
blade-service/blade-business/src/main/java/org/springblade/business/vo/DefaultProjectVO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.vo;
+
+import org.springblade.business.entity.DefaultProject;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 视图实体类
+ *
+ * @author BladeX
+ * @since 2022-07-06
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class DefaultProjectVO extends DefaultProject {
+	private static final long serialVersionUID = 1L;
+
+}

+ 10 - 0
blade-service/blade-business/src/main/java/sql/defaultproject.menu.sql

@@ -0,0 +1,10 @@
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1544591499286163458', 1123598815738675201, 'defaultproject', '默认项目', 'menu', '/DefaultProject/defaultproject', NULL, 1, 1, 0, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1544591499286163459', '1544591499286163458', 'defaultproject_add', '新增', 'add', '/DefaultProject/defaultproject/add', 'plus', 1, 2, 1, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1544591499286163460', '1544591499286163458', 'defaultproject_edit', '修改', 'edit', '/DefaultProject/defaultproject/edit', 'form', 2, 2, 2, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1544591499286163461', '1544591499286163458', 'defaultproject_delete', '删除', 'delete', '/api/DefaultProject/defaultproject/remove', 'delete', 3, 2, 3, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1544591499286163462', '1544591499286163458', 'defaultproject_view', '查看', 'view', '/DefaultProject/defaultproject/view', 'file-text', 4, 2, 2, 1, NULL, 0);

+ 1 - 1
blade-service/blade-desk/src/main/java/org/springblade/desk/service/impl/LeaveServiceImpl.java

@@ -72,7 +72,7 @@ public class LeaveServiceImpl extends BaseServiceImpl<LeaveMapper, ProcessLeave>
 				leave.setProcessInstanceId(result.getData().getProcessInstanceId());
 				updateById(leave);
 			} else {
-//				throw new ServiceException("开启流程失败");
+				throw new ServiceException("开启流程失败");
 			}
 		} else {