瀏覽代碼

```快速構建增加流程設置

fangq 4 年之前
父節點
當前提交
74c84a0a9f

+ 25 - 8
pom.xml

@@ -47,6 +47,7 @@
                 <version>${spring.boot.version}</version>
                 <type>pom</type>
                 <scope>import</scope>
+
             </dependency>
             <dependency>
                 <groupId>io.spring.platform</groupId>
@@ -212,6 +213,22 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-ldap</artifactId>
         </dependency>
+
+        <!-- log4j 新版本依赖 start-->
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>2.15.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>2.15.0</version>
+        </dependency>
+
+        <!-- log4j 新版本依赖 end-->
+
+
     </dependencies>
 
     <build>
@@ -244,14 +261,14 @@
                             </include>
                         </includes>
                         <!-- 分包 -->
-                    </configuration>
-                    <executions>
-                        <execution>
-                            <goals>
-                                <goal>repackage</goal>
-                            </goals>
-                        </execution>
-                    </executions>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>repackage</goal>
+                                </goals>
+                            </execution>
+                        </executions>
                 </plugin>
                 <plugin>
                     <groupId>com.spotify</groupId>

+ 141 - 1
src/main/java/org/springblade/bank/autodata/controller/AutoDataController.java

@@ -16,6 +16,9 @@
  */
 package org.springblade.bank.autodata.controller;
 
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
@@ -37,13 +40,18 @@ import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.modules.system.entity.Dept;
 import org.springblade.modules.system.entity.User;
+import org.springblade.modules.system.service.IDeptService;
+import org.springblade.modules.system.service.IUserService;
 import org.springframework.util.Assert;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  *  控制器
@@ -59,6 +67,8 @@ public class AutoDataController extends BladeController {
 
 	private final IAutoDataService autoDataService;
 	private final IAutoStructService autoStructService;
+	private final IDeptService deptService;
+	private final IUserService userService;
 
 	/**
 	 * 详情
@@ -92,7 +102,21 @@ public class AutoDataController extends BladeController {
 	public R<IPage<AutoDataVO>> page(AutoDataVO autoData, Query query) {
 		BladeUser user = AuthUtil.getUser();
 		//當前部門id
-		autoData.setCurrentDeptId(AuthUtil.getDeptId());
+		Dept dept = deptService.getById(AuthUtil.getDeptId());
+		if (dept.getOrgNo().startsWith("999")){
+			List<Long> deptChildIds = deptService.getDeptChildIds(dept.getId());
+			String[] deptArr = new String[deptChildIds.size()];
+			for (int i = 0; i < deptChildIds.size(); i++) {
+				deptArr[i] = deptChildIds.get(i) + "";
+			}
+			autoData.setUserDeptList(deptArr);
+		}else{
+			String[] deptArr = new String[1];
+			deptArr[0] = AuthUtil.getDeptId();
+			autoData.setUserDeptList(deptArr);
+		}
+//		autoData.setCurrentDeptId(AuthUtil.getDeptId());
+		autoData.setCurrentuserId(AuthUtil.getUserId());
 
 		Assert.isTrue(autoData.getTableId() != null, "表ID不能為空!");
 		AutoStruct autoStruct = autoStructService.getById(autoData.getTableId());
@@ -153,6 +177,104 @@ public class AutoDataController extends BladeController {
 	}
 
 
+	/**
+	 * 審批通過
+	 */
+	@PostMapping("/approveYes")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "審批通過", notes = "传入autoData")
+	public R approveYes(@Valid @RequestBody AutoData autoData) {
+		Long tableId = autoData.getTableId();
+		AutoStruct struct = autoStructService.getById(tableId);
+
+		// 並行-直接把審批人信息追加到已審批人字段
+		AutoData oldData = autoDataService.getById(autoData.getId());
+		if (struct.getApproveType().equals(2)){
+			User user = userService.getById(AuthUtil.getUserId());
+			if (oldData.getProcess().equals(1)){
+				autoData.setApproveId(user.getId()+"");
+				autoData.setApproveName(user.getName());
+				autoData.setApproveNo(user.getEhr());
+			}else{
+				autoData.setApproveId(oldData.getApproveId() + "," + user.getId());
+				autoData.setApproveName(oldData.getApproveName() + "," + user.getName());
+				autoData.setApproveNo(oldData.getApproveNo() + "," + user.getEhr());
+			}
+		}else {
+			// 串行-統一設置-從設置中拿出相應位置的人員,填充到下一個審批人字段,process+1
+			String settingStr = struct.getSetting();
+			if (struct.getSettingType().equals(1)){
+				JSONArray jsonArray = JSONUtil.parseArray(settingStr);
+				// 取出下一個審批人
+				Map<String, String > tobePerson = (Map<String, String>) jsonArray.get(autoData.getProcess());
+				autoData.setReceiverId(tobePerson.get("id"));
+				autoData.setReceiverName(tobePerson.get("name"));
+				autoData.setReceiverNo(tobePerson.get("ehr"));
+				jsonArray.toJSONString(0);
+			}else{
+			// 串行-逐級設置-把前端傳過來的審批人,保存到待審批人字段,保存,process+1
+				JSONArray jsonArray;
+				if (settingStr == null){
+					jsonArray = new JSONArray(1);
+				}else{
+					jsonArray = JSONUtil.parseArray(settingStr);
+				}
+				Map<String, String > tobePerson = new HashMap<>();
+				tobePerson.put("id", oldData.getReceiverId());
+				tobePerson.put("name", oldData.getReceiverName());
+				tobePerson.put("ehr", oldData.getReceiverNo());
+				jsonArray.set(tobePerson);
+				String newSettingStr = jsonArray.toJSONString(0);
+				struct.setSetting(newSettingStr);
+				autoStructService.updateById(struct);
+			}
+			autoData.setProcess(oldData.getProcess()+1);
+		}
+
+		return R.status(autoDataService.saveOrUpdate(autoData));
+	}
+
+
+	/**
+	 * 審批駁回
+	 */
+	@PostMapping("/approveNo")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "審批駁回", notes = "传入autoData")
+	public R approveNo(@Valid @RequestBody AutoData autoData) {
+		AutoData oldData = autoDataService.getById(autoData.getId());
+		Assert.isTrue(!oldData.getProcess().equals(1), "無法駁回!因為已無路可退!");
+		Long tableId = autoData.getTableId();
+		AutoStruct struct = autoStructService.getById(tableId);
+
+		//串行(並行無駁回)
+		if (struct.getApproveType().equals(1)){
+			// 串行-統一設置-從設置中拿出相應位置的人員,填充到下一個審批人字段,process-1
+			String settingStr = struct.getSetting();
+			JSONArray jsonArray = JSONUtil.parseArray(settingStr);
+			// 取出上一個審批人
+			Map<String, String > tobePerson = (Map<String, String>) jsonArray.get(oldData.getProcess() - 2);
+			autoData.setReceiverId(tobePerson.get("id"));
+			autoData.setReceiverName(tobePerson.get("name"));
+			autoData.setReceiverNo(tobePerson.get("ehr"));
+			if (struct.getSettingType().equals(2)){
+			// 逐級審批-需刪除前審批人信息
+				Object remove = jsonArray.remove(oldData.getProcess() - 2);
+				if (jsonArray.size() == 0){
+					struct.setSetting(null);
+				}else {
+					String newSettingStr = jsonArray.toJSONString(0);
+					struct.setSetting(newSettingStr);
+				}
+				autoStructService.updateById(struct);
+			}
+			autoData.setProcess(oldData.getProcess()-1);
+		}
+
+		return R.status(autoDataService.saveOrUpdate(autoData));
+	}
+
+
 	/**
 	 * 删除
 	 */
@@ -163,5 +285,23 @@ public class AutoDataController extends BladeController {
 		return R.status(autoDataService.deleteLogic(Func.toLongList(ids)));
 	}
 
+	/*public static void main(String[] args) {
+		*//*String str = "[{\"id\":\"1432588697624535042\",\"name\":\"林嘉莉\",\"ehr\":\"0150800\"},{\"id\":\"1432588735327133698\",\"name\":\"陳麗華\",\"ehr\":\"0146072\"},{\"id\":\"1432588753018707969\",\"name\":\"盧思雅2\",\"ehr\":\"2064717\"}]";
+		JSONArray jsonArray = JSONUtil.parseArray(str);
+		String s = jsonArray.toJSONString(0);
+		System.out.println(s);*//*
+
+
+		JSONArray arr = new JSONArray();
+		Map<String, String > tobePerson = new HashMap<>();
+		tobePerson.put("id", "123123");
+		tobePerson.put("name", "看监控的方式");
+		tobePerson.put("ehr", "fgh1232");
+		arr.set(tobePerson);
+		arr.add(tobePerson);
+		System.out.println(arr.toJSONString(0));
+		arr.remove(1);
+		System.out.println(arr.toJSONString(0));
+	}*/
 
 }

+ 17 - 0
src/main/java/org/springblade/bank/autodata/entity/AutoData.java

@@ -193,5 +193,22 @@ public class AutoData extends BaseEntity {
 		@ApiModelProperty(value = "參數")
 		private String params30;
 
+		@ApiModelProperty(value = "參數")
+		private Integer process;
+		@ApiModelProperty(value = "下一個審核人id")
+		private String receiverId;
+		@ApiModelProperty(value = "下一個審核人名稱")
+		private String receiverName;
+		@ApiModelProperty(value = "下一個審核人工號")
+		private String receiverNo;
+		@ApiModelProperty(value = "已審核人id")
+		private String approveId;
+		@ApiModelProperty(value = "已審核人名稱")
+		private String approveName;
+		@ApiModelProperty(value = "已審核人工號")
+		private String approveNo;
+		@ApiModelProperty(value = "備註")
+		private String remark;
+
 
 }

+ 42 - 15
src/main/java/org/springblade/bank/autodata/mapper/AutoDataMapper.xml

@@ -43,38 +43,65 @@
         <result column="params28" property="params28"/>
         <result column="params29" property="params29"/>
         <result column="params30" property="params30"/>
+
+        <result column="process" property="process"/>
+        <result column="receiver_id" property="receiverId"/>
+        <result column="receiver_name" property="receiverName"/>
+        <result column="receiver_no" property="receiverNo"/>
+        <result column="approve_id" property="approveId"/>
+        <result column="approve_name" property="approveName"/>
+        <result column="approve_no" property="approveNo"/>
+        <result column="remark" property="remark"/>
     </resultMap>
 
 
     <select id="selectAutoDataPage" resultMap="autoDataResultMap">
-        select td.* from zh_auto_data td, zh_auto_struct ts
-        where td.is_deleted = 0 and td.table_id = #{autoData.tableId} and td.table_id = ts.id
 
-        <if test="autoData!=null">
-            <if test="autoData.isManageRole != true">
-                and td.create_dept = '${autoData.currentDeptId}'
-                and
-                <foreach item="roleId" collection="autoData.userRoleList" separator=" or " open="(" close=")" index="index">
-                    ts.role_id like '%${roleId}%'
-                </foreach>
+        SELECT c.* FROM
+        (
+            select td.* from zh_auto_data td, zh_auto_struct ts
+            where td.is_deleted = 0 and td.table_id = #{autoData.tableId} and td.table_id = ts.id
+            <if test="autoData!=null">
+                <if test="autoData.isManageRole != true">and td.create_dept in
+                    <foreach item="deptId"
+                             collection="autoData.userDeptList" separator="," open="(" close=")" index="ind
+                         x">
+                        #{deptId}
+                    </foreach>
+                    and
+                    <foreach
+                        item="roleId" collection="autoData.userRoleList" separator=" or " open="("
+                        close=")" index="index">
+                        ts.role_id like '%${roleId}%'
+                    </foreach>
+                </if>
             </if>
+
+            UNION
+
+            select td.* from zh_auto_data td, zh_auto_struct ts
+            where td.is_deleted = 0 and td.table_id = #{autoData.tableId} and td.table_id = ts.id
+            AND (td.create_user = '${autoData.currentuserId}' or LOCATE('${autoData.currentuserId}', td.receiver_id) > 0)
+        ) c
+        where 1=1
+        <if test="autoData!=null">
             <if test="autoData.params4!=null">
-                AND td.params4 like '${autoData.params4}%'
+                AND c.params4 like '${autoData.params4}%'
             </if>
             <if test="autoData.params5!=null">
-                AND td.params5 like '${autoData.params5}%'
+                AND c.params5 like '${autoData.params5}%'
             </if>
             <if test="autoData.params6!=null">
-                AND td.params6 like '${autoData.params6}%'
+                AND c.params6 like '${autoData.params6}%'
             </if>
             <if test="autoData.params7!=null">
-                AND td.params7 like '${autoData.params7}%'
+                AND c.params7 like '${autoData.params7}%'
             </if>
             <if test="autoData.params8!=null">
-                AND td.params8 like '${autoData.params8}%'
+                AND c.params8 like '${autoData.params8}%'
             </if>
         </if>
-        ORDER BY td.create_time DESC
+        ORDER BY c.create_time DESC
     </select>
 
 </mapper>

+ 3 - 1
src/main/java/org/springblade/bank/autodata/vo/AutoDataVO.java

@@ -35,11 +35,13 @@ import java.util.List;
 public class AutoDataVO extends AutoData {
 	private static final long serialVersionUID = 1L;
 
-	private String currentDeptId;
+	private String[] userDeptList;
 	private Boolean isManageRole;
 
 	private String createUserName;
 
 	private String[] userRoleList;
 
+	private Long currentuserId;
+
 }

+ 28 - 0
src/main/java/org/springblade/bank/autostruct/entity/AutoStruct.java

@@ -63,5 +63,33 @@ public class AutoStruct extends BaseEntity {
 	 */
 		@ApiModelProperty(value = "管理員角色")
 		private String manageRoleId;
+	/**
+	 * 審批開關
+	 */
+		@ApiModelProperty(value = "審批開關")
+		private Integer approveSwitch;
+	/**
+	 * 串并行(串:1,并:2)
+	 */
+		@ApiModelProperty(value = "串并行(串:1,并:2)")
+		private Integer approveType;
+	/**
+	 * 設置類型{1:统一设置;2:逐级设置}
+	 */
+		@ApiModelProperty(value = "設置類型")
+		private Integer settingType;
+	/**
+	 * 節點數
+	 */
+		@ApiModelProperty(value = "節點數")
+		private Integer num;
+	/**
+	 * 审批设置
+	 */
+		@ApiModelProperty(value = "审批设置")
+		private String setting;
+
+
+
 
 }

+ 6 - 1
src/main/java/org/springblade/bank/autostruct/mapper/AutoStructMapper.xml

@@ -16,7 +16,12 @@
         <result column="columns" property="columns"/>
         <result column="dept_id" property="deptId"/>
         <result column="role_id" property="roleId"/>
-        <result column="manage_role_id" property="manageRoleId"/>
+
+        <result column="setting" property="setting"/>
+        <result column="num" property="num"/>
+        <result column="setting_type" property="settingType"/>
+        <result column="approve_type" property="approveType"/>
+        <result column="approve_switch" property="approveSwitch"/>
     </resultMap>
 
 

+ 1 - 0
src/main/java/org/springblade/bank/keypwd/controller/KeyPwdController.java

@@ -32,6 +32,7 @@ import org.springblade.bank.keypwd.vo.KeyPwdVO;
 import org.springblade.bank.keypwd.wrapper.KeyPwdWrapper;
 import org.springblade.bank.userlog.entity.UserLog;
 import org.springblade.bank.userlog.service.IUserLogService;
+import org.springblade.common.cache.DictCache;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;

+ 3 - 1
src/main/java/org/springblade/bank/sealhandover/controller/SealHandoverController.java

@@ -274,7 +274,9 @@ public class SealHandoverController extends BladeController {
 		if (sealHandoverService.updateById(sealHandover)){
 			SealHandover keep = sealHandoverService.getKeyOneByOrgNoSealTypeNo(sealHandover.getBankNo(), sealHandover.getOrgNo(), sealHandover.getSealType(), sealHandover.getSealNo());
 			Long keepId = null;
-			keepId = keep.getId();
+			if (keep != null){
+				keepId = keep.getId();
+			}
 
 			if (keep == null){
 				keep = sealHandover;

+ 10 - 8
src/main/java/org/springblade/modules/desk/service/impl/NoticeServiceImpl.java

@@ -95,7 +95,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, Notice> imp
 			String join = StringUtil.join(userIdList);
 			notice.setTargetIds(join);
 		}
-		if (notice.getTargetEhrs() == null){
+		if (notice.getTargetEhrs() == null && StringUtil.isNotBlank(notice.getTargetIds())){
 			String[] split = notice.getTargetIds().split(",");
 			List<String> userEhrList = new ArrayList<>();
 			for (int i = 0; i < split.length; i++) {
@@ -221,14 +221,16 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, Notice> imp
 		notice.setTargetIds(message.getTargetIds());
 		notice.setContent("標題:" + message.getTitle() + ";內文:" + message.getContent());
 
-		String[] split = message.getTargetIds().split(",");
-		List<String> userEhrList = new ArrayList<>();
-		for (int i = 0; i < split.length; i++) {
-			String userIdStr = split[i];
-			User user = userService.getById(userIdStr);
-			userEhrList.add(user.getEhr());
+		if (StringUtil.isNotBlank(message.getTargetIds())){
+			String[] split = message.getTargetIds().split(",");
+			List<String> userEhrList = new ArrayList<>();
+			for (int i = 0; i < split.length; i++) {
+				String userIdStr = split[i];
+				User user = userService.getById(userIdStr);
+				userEhrList.add(user.getEhr());
+			}
+			notice.setTargetEhrs(StringUtil.join(userEhrList, "|"));
 		}
-		notice.setTargetEhrs(StringUtil.join(userEhrList, "|"));
 
 		return sendNotice(notice);
 	}

+ 22 - 2
src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.system.service.impl;
 
+import cn.hutool.core.collection.ListUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -26,6 +27,7 @@ import org.springblade.core.tool.constant.BladeConstant;
 import org.springblade.core.tool.node.ForestNodeMerger;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringPool;
+import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.modules.system.entity.Dept;
 import org.springblade.modules.system.mapper.DeptMapper;
 import org.springblade.modules.system.service.IDeptService;
@@ -146,8 +148,11 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
 				throw new ServiceException("父节点不可选择自身!");
 			}
 			dept.setTenantId(parent.getTenantId());
-			String ancestors = parent.getAncestors() + StringPool.COMMA + dept.getParentId();
-			dept.setAncestors(ancestors);
+//			String ancestors = parent.getAncestors() + StringPool.COMMA + dept.getParentId();
+			List<String> ancestorList = new ArrayList<>();
+			getAncestors(dept.getParentId()+"", ancestorList);
+			List<String> reverse = ListUtil.reverse(ancestorList);
+			dept.setAncestors(StringUtil.join(reverse, StringPool.COMMA));
 		}
 		dept.setIsDeleted(BladeConstant.DB_NOT_DELETED);
 		return saveOrUpdate(dept);
@@ -224,4 +229,19 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
 		return deptList;
 	}
 
+	public void getAncestors(String parentId, List<String> ancestors){
+		Assert.notNull(parentId, "parentId不能为空!");
+		if (ancestors == null){
+			ancestors = new ArrayList<>();
+		}
+		ancestors.add(parentId);
+		Dept parent = this.getById(parentId);
+		Assert.notNull(parent, "找不到该机构!");
+		if (!parent.getParentId().equals(BladeConstant.TOP_PARENT_ID)){
+			getAncestors(parent.getParentId()+"", ancestors);
+		}else{
+			ancestors.add("0");
+		}
+	}
+
 }

+ 1 - 1
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java

@@ -591,7 +591,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
 
 
 		Dept parentDept = deptService.getById(dept.getParentId());
-		if (parentDept.getOrgNo().startsWith("999")){
+		if (parentDept != null && parentDept.getOrgNo().startsWith("999")){
 			deptIdList.add(parentDept.getId());
 		}
 

+ 19 - 0
src/main/java/org/springblade/modules/systemexpand/controller/ExpandController.java

@@ -142,4 +142,23 @@ public class ExpandController extends BladeController {
 		return R.data(UserWrapper.build().pageVO(pages));
 	}
 
+	/**
+	 * 自定义用户列表 (全部-除admin超管)
+	 */
+	@GetMapping("/user/pageAll")
+	@ApiImplicitParams({
+		@ApiImplicitParam(name = "account", value = "账号名", paramType = "query", dataType = "string"),
+		@ApiImplicitParam(name = "realName", value = "姓名", paramType = "query", dataType = "string")
+	})
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "列表", notes = "传入account和realName")
+	public R<IPage<UserVO>> pageAll(@ApiIgnore User user, Query query, Long deptId, BladeUser bladeUser) {
+		if (deptId == null){
+			List<Dept> byParentId = deptService.getByParentId(0L);
+			deptId = byParentId.get(0).getId();
+		}
+		IPage<User> pages = userService.selectMyUserPage(Condition.getPage(query), user, deptId, null, (bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? StringPool.EMPTY : bladeUser.getTenantId()));
+		return R.data(UserWrapper.build().pageVO(pages));
+	}
+
 }