ソースを参照

审批人管理

gaodd 5 年 前
コミット
3ec5d0dc5d

+ 3 - 3
src/main/java/com/unissoft/mapper/ProcessBasisMapper.java

@@ -1,6 +1,6 @@
1 1
 package com.unissoft.mapper;
2 2
 
3
-import com.unissoft.model.ProcessBasis;
3
+import com.unissoft.model.ProcessBasisSon;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 
6 6
 /**
@@ -9,8 +9,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
9 9
  * </p>
10 10
  *
11 11
  * @author My SunShine
12
- * @since 2020-12-09
12
+ * @since 2020-12-17
13 13
  */
14
-public interface ProcessBasisMapper extends BaseMapper<ProcessBasis> {
14
+public interface ProcessBasisSonMapper extends BaseMapper<ProcessBasisSon> {
15 15
 
16 16
 }

+ 5 - 8
src/main/java/com/unissoft/mapper/ProcessBasisMapper.xml

@@ -1,21 +1,18 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.unissoft.mapper.ProcessBasisMapper">
3
+<mapper namespace="com.unissoft.mapper.ProcessBasisSonMapper">
4 4
 
5 5
     <!-- 通用查询映射结果 -->
6
-    <resultMap id="BaseResultMap" type="com.unissoft.model.ProcessBasis">
6
+    <resultMap id="BaseResultMap" type="com.unissoft.model.ProcessBasisSon">
7 7
         <id column="id" property="id" />
8
-        <result column="main_id" property="mainId" />
9
-        <result column="type" property="type" />
10
-        <result column="title" property="title" />
8
+        <result column="zid" property="zid" />
11 9
         <result column="content" property="content" />
12
-        <result column="step" property="step" />
13
-        <result column="create_time" property="createTime" />
10
+        <result column="depot_id" property="depotId" />
14 11
     </resultMap>
15 12
 
16 13
     <!-- 通用查询结果列 -->
17 14
     <sql id="Base_Column_List">
18
-        id, main_id, type, title, content, step, create_time
15
+        id, zid, content, depot_id
19 16
     </sql>
20 17
 
21 18
 </mapper>

+ 0 - 116
src/main/java/com/unissoft/model/ProcessBasis.java

@@ -1,116 +0,0 @@
1
-package com.unissoft.model;
2
-
3
-import com.baomidou.mybatisplus.annotation.TableName;
4
-import com.baomidou.mybatisplus.annotation.IdType;
5
-import java.util.Date;
6
-import com.baomidou.mybatisplus.annotation.TableId;
7
-import com.baomidou.mybatisplus.annotation.TableField;
8
-import java.io.Serializable;
9
-import io.swagger.annotations.ApiModel;
10
-import io.swagger.annotations.ApiModelProperty;
11
-
12
-/**
13
- * <p>
14
- * 
15
- * </p>
16
- *
17
- * @author My SunShine
18
- * @since 2020-12-09
19
- */
20
-@TableName("process_basis")
21
-@ApiModel(value="ProcessBasis对象", description="")
22
-public class ProcessBasis implements Serializable {
23
-
24
-    private static final long serialVersionUID = 1L;
25
-
26
-    @ApiModelProperty(value = "流程基础表")
27
-    @TableId(value = "id", type = IdType.AUTO)
28
-    private Integer id;
29
-
30
-    @ApiModelProperty(value = "主流程的id")
31
-    @TableField("main_id")
32
-    private Integer mainId;
33
-
34
-    @ApiModelProperty(value = "流程的类型")
35
-    @TableField("type")
36
-    private String type;
37
-
38
-    @ApiModelProperty(value = "每一项流程的名称")
39
-    @TableField("title")
40
-    private String title;
41
-
42
-    @ApiModelProperty(value = "每一项流程的内容")
43
-    @TableField("content")
44
-    private String content;
45
-
46
-    @ApiModelProperty(value = "执行顺序")
47
-    @TableField("step")
48
-    private String step;
49
-
50
-    @ApiModelProperty(value = "创建时间")
51
-    @TableField("create_time")
52
-    private Date createTime;
53
-
54
-    public Integer getId() {
55
-        return id;
56
-    }
57
-
58
-    public void setId(Integer id) {
59
-        this.id = id;
60
-    }
61
-    public Integer getMainId() {
62
-        return mainId;
63
-    }
64
-
65
-    public void setMainId(Integer mainId) {
66
-        this.mainId = mainId;
67
-    }
68
-    public String getType() {
69
-        return type;
70
-    }
71
-
72
-    public void setType(String type) {
73
-        this.type = type;
74
-    }
75
-    public String getTitle() {
76
-        return title;
77
-    }
78
-
79
-    public void setTitle(String title) {
80
-        this.title = title;
81
-    }
82
-    public String getContent() {
83
-        return content;
84
-    }
85
-
86
-    public void setContent(String content) {
87
-        this.content = content;
88
-    }
89
-    public String getStep() {
90
-        return step;
91
-    }
92
-
93
-    public void setStep(String step) {
94
-        this.step = step;
95
-    }
96
-    public Date getCreateTime() {
97
-        return createTime;
98
-    }
99
-
100
-    public void setCreateTime(Date createTime) {
101
-        this.createTime = createTime;
102
-    }
103
-
104
-    @Override
105
-    public String toString() {
106
-        return "ProcessBasis{" +
107
-            "id=" + id +
108
-            ", mainId=" + mainId +
109
-            ", type=" + type +
110
-            ", title=" + title +
111
-            ", content=" + content +
112
-            ", step=" + step +
113
-            ", createTime=" + createTime +
114
-        "}";
115
-    }
116
-}

+ 78 - 0
src/main/java/com/unissoft/model/ProcessBasisSon.java

@@ -0,0 +1,78 @@
1
+package com.unissoft.model;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableName;
4
+import com.baomidou.mybatisplus.annotation.IdType;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import com.baomidou.mybatisplus.annotation.TableField;
7
+import java.io.Serializable;
8
+import io.swagger.annotations.ApiModel;
9
+import io.swagger.annotations.ApiModelProperty;
10
+
11
+/**
12
+ * <p>
13
+ * 
14
+ * </p>
15
+ *
16
+ * @author My SunShine
17
+ * @since 2020-12-17
18
+ */
19
+@TableName("process_basis_son")
20
+@ApiModel(value="ProcessBasisSon对象", description="")
21
+public class ProcessBasisSon implements Serializable {
22
+
23
+    private static final long serialVersionUID = 1L;
24
+
25
+    @TableId(value = "id", type = IdType.AUTO)
26
+    private Integer id;
27
+
28
+    @ApiModelProperty(value = "basis的id")
29
+    @TableField("zid")
30
+    private Integer zid;
31
+
32
+    @ApiModelProperty(value = "审批人")
33
+    @TableField("content")
34
+    private Integer content;
35
+
36
+    @ApiModelProperty(value = "库id")
37
+    @TableField("depot_id")
38
+    private Integer depotId;
39
+
40
+    public Integer getId() {
41
+        return id;
42
+    }
43
+
44
+    public void setId(Integer id) {
45
+        this.id = id;
46
+    }
47
+    public Integer getZid() {
48
+        return zid;
49
+    }
50
+
51
+    public void setZid(Integer zid) {
52
+        this.zid = zid;
53
+    }
54
+    public Integer getContent() {
55
+        return content;
56
+    }
57
+
58
+    public void setContent(Integer content) {
59
+        this.content = content;
60
+    }
61
+    public Integer getDepotId() {
62
+        return depotId;
63
+    }
64
+
65
+    public void setDepotId(Integer depotId) {
66
+        this.depotId = depotId;
67
+    }
68
+
69
+    @Override
70
+    public String toString() {
71
+        return "ProcessBasisSon{" +
72
+            "id=" + id +
73
+            ", zid=" + zid +
74
+            ", content=" + content +
75
+            ", depotId=" + depotId +
76
+        "}";
77
+    }
78
+}

+ 3 - 3
src/main/java/com/unissoft/ventilation/controller/ProcessBasisController.java

@@ -49,9 +49,9 @@ public class ProcessBasisController {
49 49
 	 * @return
50 50
 	 */
51 51
 	@ApiOperation(value = "根据类型获取审批人信息", notes = "")
52
-	@GetMapping("/getBasisByType/{type}/{userId}")
53
-    public ResultView getAllProcess(@PathVariable String type,@PathVariable Integer userId) {
54
-		List<ProcessBasis> list = processBasisService.getBasisByType(type,userId);
52
+	@GetMapping("/getBasisByType/{type}/{userId}/{depotId}")
53
+    public ResultView getAllProcess(@PathVariable String type,@PathVariable Integer userId,@PathVariable Integer depotId) {
54
+		List<ProcessBasis> list = processBasisService.getBasisByType(type,userId,depotId);
55 55
         return ResultView.success(list);
56 56
     }
57 57
 	

+ 20 - 0
src/main/java/com/unissoft/ventilation/controller/ProcessBasisSonController.java

@@ -0,0 +1,20 @@
1
+package com.unissoft.ventilation.controller;
2
+
3
+
4
+import org.springframework.web.bind.annotation.RequestMapping;
5
+
6
+import org.springframework.web.bind.annotation.RestController;
7
+
8
+/**
9
+ * <p>
10
+ *  前端控制器
11
+ * </p>
12
+ *
13
+ * @author My SunShine
14
+ * @since 2020-12-17
15
+ */
16
+@RestController
17
+@RequestMapping("/process-basis-son")
18
+public class ProcessBasisSonController {
19
+
20
+}

+ 1 - 1
src/main/java/com/unissoft/ventilation/service/ProcessBasisService.java

@@ -20,7 +20,7 @@ public interface ProcessBasisService extends IService<ProcessBasis> {
20 20
 
21 21
 	//List<ProcessBasis> getBasicProcess(String type,Integer mainId);
22 22
 
23
-	List<ProcessBasis> getBasisByType(String type, Integer userId);
23
+	List<ProcessBasis> getBasisByType(String type, Integer userId, Integer depotId);
24 24
 
25 25
 
26 26
 }

+ 16 - 0
src/main/java/com/unissoft/ventilation/service/ProcessBasisSonService.java

@@ -0,0 +1,16 @@
1
+package com.unissoft.ventilation.service;
2
+
3
+import com.unissoft.model.ProcessBasisSon;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ *  服务类
9
+ * </p>
10
+ *
11
+ * @author My SunShine
12
+ * @since 2020-12-17
13
+ */
14
+public interface ProcessBasisSonService extends IService<ProcessBasisSon> {
15
+
16
+}

+ 84 - 28
src/main/java/com/unissoft/ventilation/service/impl/ProcessBasisServiceImpl.java

@@ -1,5 +1,6 @@
1 1
 package com.unissoft.ventilation.service.impl;
2 2
 
3
+import java.util.ArrayList;
3 4
 import java.util.Date;
4 5
 import java.util.List;
5 6
 
@@ -11,8 +12,10 @@ import com.alibaba.fastjson.JSONObject;
11 12
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
12 13
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
13 14
 import com.unissoft.mapper.ProcessBasisMapper;
15
+import com.unissoft.mapper.ProcessBasisSonMapper;
14 16
 import com.unissoft.mapper.ProcessMainMapper;
15 17
 import com.unissoft.model.ProcessBasis;
18
+import com.unissoft.model.ProcessBasisSon;
16 19
 import com.unissoft.model.ProcessMain;
17 20
 import com.unissoft.ventilation.service.ProcessBasisService;
18 21
 
@@ -32,36 +35,86 @@ public class ProcessBasisServiceImpl extends ServiceImpl<ProcessBasisMapper, Pro
32 35
     private ProcessBasisMapper processBasisMapper;
33 36
 	
34 37
 	@Autowired
38
+    private ProcessBasisSonMapper processBasisSonMapper;
39
+	
40
+	@Autowired
35 41
     private ProcessMainMapper processMainMapper;
36 42
 	
37 43
 	/**
38
-	 * 1、根据传过来的数据,获取到type,根据type查询数据,通过title对比,更改content的值
44
+	 * 1、根据传过来的depotId和类型查询该库有没有设置审批人,如果没有的话则增加,有的话则修改(通过title对比,更改content的值)
39 45
 	 * 2、查询主流程表,把有流程的数据id保存到审批人管理里面的main_id字段
40 46
 	 */
41 47
 	@Override
42 48
 	public void add(String parameter) {
49
+		//解析获取传过来的数据
43 50
 		JSONObject jsStr = JSONObject.parseObject(parameter);
51
+		Integer depotId = jsStr.getInteger("depot_id");
44 52
 		String type = jsStr.getString("type");
53
+		JSONArray jsonArray = jsStr.getJSONArray("data");
54
+		JSONObject row = null;
55
+		
45 56
 		QueryWrapper<ProcessBasis> ew = new QueryWrapper<>();
46 57
         ew.eq("type", type);
47 58
 		List<ProcessBasis> pList  = processBasisMapper.selectList(ew);
59
+		List<Integer> intList = new ArrayList<Integer>();
60
+		if(pList.size()>0){
61
+			for (ProcessBasis basis : pList) {
62
+				intList.add(basis.getId());
63
+			}
64
+		}
48 65
 		
49
-		QueryWrapper<ProcessMain> ew1 = new QueryWrapper<>();
50
-		ew.eq("type", type);
51
-		ew.eq("exist_process", 0);//存在审批流程的主流程
52
-		List<ProcessMain> mainList = processMainMapper.selectList(ew1);
53 66
 		
54
-		if(pList.size()>0){
55
-			JSONArray jsonArray = jsStr.getJSONArray("data");
56
-			JSONObject row = null;
57
-			for (int i = 0; i < pList.size(); i++) {//pList的值和jsonArray是一样的(长度一样)
58
-				for (int j = 0; j < jsonArray.size(); j++) {
59
-					row = jsonArray.getJSONObject(j); 
60
-					String title = (String) row.get("title");
67
+		//根据类型查询主流程中哪个流程下是有审批流程的
68
+		 QueryWrapper<ProcessMain> ew1 = new QueryWrapper<>();
69
+		 ew.eq("type", type);
70
+	     ew.eq("exist_process", 0);//存在审批流程的主流程
71
+	     List<ProcessMain> mainList = processMainMapper.selectList(ew1);
72
+			
73
+			
74
+		//审批人表数据
75
+		QueryWrapper<ProcessBasisSon> ew2 = new QueryWrapper<>();
76
+        ew2.eq("depot_id", depotId);
77
+        ew2.in("zid", intList);
78
+        List<ProcessBasisSon> sonList = processBasisSonMapper.selectList(ew2);
79
+        
80
+        if(sonList.size()>0){//修改
81
+        	for (int i = 0; i < sonList.size(); i++) {
82
+        		if(!sonList.get(i).getContent().equals(0)){//不是保管员 修改设置的值
83
+        			ProcessBasis processBasis = processBasisMapper.selectById(sonList.get(i).getZid());
84
+        			for (int j = 0; j < jsonArray.size(); j++) {
85
+            			row = jsonArray.getJSONObject(j); 
86
+            			String title = (String) row.get("title");
87
+    					String content = (String) row.get("content");
88
+    					if(processBasis.getTitle().equals(title)){
89
+    						sonList.get(i).setContent(Integer.parseInt(content));
90
+    						processBasisSonMapper.updateById(sonList.get(i));
91
+    					}
92
+            		}
93
+        			
94
+				}
95
+        		
96
+        	}
97
+        }else{//新增
98
+        	ProcessBasisSon processBasisSon = new ProcessBasisSon();
99
+        	
100
+        	for (int i = 0; i < pList.size(); i++) {
101
+        		for (int j = 0; j < jsonArray.size(); j++) {
102
+        			row = jsonArray.getJSONObject(j); 
103
+        			String title = (String) row.get("title");
61 104
 					String step = (String) row.get("step");
62 105
 					String content = (String) row.get("content");
63
-                    if(title.equals(pList.get(i).getTitle()) && step.equals(pList.get(i).getStep())){
64
-                    	pList.get(i).setContent(content);
106
+					if(pList.get(i).getTitle().equals(title)){
107
+						processBasisSon.setZid(pList.get(i).getId());
108
+						processBasisSon.setDepotId(depotId);
109
+						if(content.equals("保管员")){
110
+							processBasisSon.setContent(0);
111
+						}else{
112
+							processBasisSon.setContent(Integer.parseInt(content));
113
+						}
114
+						processBasisSonMapper.insert(processBasisSon);
115
+					}
116
+					
117
+					if(title.equals(pList.get(i).getTitle()) && step.equals(pList.get(i).getStep())){
65 118
                     	if(type.equals("sswxgz")){//分两个流程 前五行是一个
66 119
                     		if(i<5){
67 120
                     			pList.get(i).setMainId(mainList.get(0).getId());
@@ -74,10 +127,11 @@ public class ProcessBasisServiceImpl extends ServiceImpl<ProcessBasisMapper, Pro
74 127
                     	}
75 128
                     	processBasisMapper.updateById(pList.get(i));
76 129
 					}
77
-				}	
78
-				
130
+				}
131
+        		
79 132
 			}
80
-		}
133
+        }
134
+		
81 135
 	   
82 136
 	}
83 137
 
@@ -94,7 +148,7 @@ public class ProcessBasisServiceImpl extends ServiceImpl<ProcessBasisMapper, Pro
94 148
 
95 149
 
96 150
 	@Override
97
-	public List<ProcessBasis> getBasisByType(String type,Integer userId) {
151
+	public List<ProcessBasis> getBasisByType(String type,Integer userId,Integer depotId) {
98 152
 		// TODO Auto-generated method stub
99 153
 		
100 154
 		QueryWrapper<ProcessBasis> ew = new QueryWrapper<>();
@@ -103,18 +157,20 @@ public class ProcessBasisServiceImpl extends ServiceImpl<ProcessBasisMapper, Pro
103 157
 		}
104 158
 		List<ProcessBasis> list = processBasisMapper.selectList(ew);
105 159
 		
106
-			if(list.size()>0){
107
-				if(null != userId ){//content 字段全部是id 传到前端展示
108
-					for (ProcessBasis processBasis : list) {
109
-						if(processBasis.getContent().equals("保管员")){
110
-							processBasis.setContent(userId+"");
111
-						}
112
-					}
113
-					
160
+		
161
+		QueryWrapper<ProcessBasisSon> ew1 = new QueryWrapper<>();
162
+		if(null != depotId){
163
+			ew1.eq("depot_id", depotId);
164
+		}
165
+		List<ProcessBasisSon> sonList = processBasisSonMapper.selectList(ew1);
166
+		for (ProcessBasis processBasis : list) {
167
+			for (ProcessBasisSon processBasisSon : sonList) {
168
+				if(processBasis.getId().equals(processBasisSon.getZid())){
169
+					processBasis.setContent(processBasisSon.getContent());
170
+					processBasis.setDepotId(processBasisSon.getDepotId());
114 171
 				}
115 172
 			}
116
-				
117
-		 
173
+		}
118 174
 		return list;
119 175
 	}
120 176
 

+ 20 - 0
src/main/java/com/unissoft/ventilation/service/impl/ProcessBasisSonServiceImpl.java

@@ -0,0 +1,20 @@
1
+package com.unissoft.ventilation.service.impl;
2
+
3
+import com.unissoft.model.ProcessBasisSon;
4
+import com.unissoft.mapper.ProcessBasisSonMapper;
5
+import com.unissoft.ventilation.service.ProcessBasisSonService;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ *  服务实现类
12
+ * </p>
13
+ *
14
+ * @author My SunShine
15
+ * @since 2020-12-17
16
+ */
17
+@Service
18
+public class ProcessBasisSonServiceImpl extends ServiceImpl<ProcessBasisSonMapper, ProcessBasisSon> implements ProcessBasisSonService {
19
+
20
+}