|
|
@@ -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
|
|