Skip to content

Commit 4a059b9

Browse files
committed
fix bug
1 parent 7ced140 commit 4a059b9

File tree

12 files changed

+227
-50
lines changed

12 files changed

+227
-50
lines changed

admin-ui/src/api/flow.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ export async function transfer(body:any) {
5858
return post('/api/cmd/flowRecord/transfer', body);
5959
}
6060

61+
export async function urge(body:any) {
62+
return post('/api/cmd/flowRecord/urge', body);
63+
}
64+
6165

6266
// 待办中心控制
6367

admin-ui/src/components/Flow/view/FlowView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ interface FlowViewProps {
2323
setVisible: (visible: boolean) => void;
2424
view: FlowFormView;
2525
review?: boolean;
26-
isFlowManager?: boolean;
2726
}
2827

2928
const FlowView: React.FC<FlowViewProps> = (props) => {
@@ -209,7 +208,7 @@ const FlowView: React.FC<FlowViewProps> = (props) => {
209208
>
210209
<Row justify="end">
211210
<Space>
212-
{props.isFlowManager && (
211+
{props.review && (
213212
<Button
214213
type={"primary"}
215214
danger={true}
@@ -529,6 +528,7 @@ const FlowView: React.FC<FlowViewProps> = (props) => {
529528
userId: user.id,
530529
userName: user.name
531530
});
531+
setSelectUserVisible(false);
532532
}
533533
}}
534534
/>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.record-read{
2+
font-weight: normal;
3+
}
4+
5+
.record-unread{
6+
font-weight: bold;
7+
}

admin-ui/src/pages/flow/record/index.tsx

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import {
66
findPostponedTodoByOperatorId,
77
findTimeoutTodoByOperatorId,
88
findTodoByOperatorId,
9-
flowRecordList
9+
flowRecordList, saveFlow, urge
1010
} from "@/api/flow";
1111
import moment from "moment";
12-
import {Tabs} from "antd";
12+
import {message, Tabs} from "antd";
1313
import FlowView from "@/components/Flow/view/FlowView";
1414
import DefaultFlowView from "@/pages/flow/leave/default";
15+
import "./index.scss";
1516

1617

1718
const FlowRecordPage = () => {
@@ -28,12 +29,30 @@ const FlowRecordPage = () => {
2829
const timeoutTodoActionRef = React.useRef<ActionType>();
2930
const postponedTodoActionRef = React.useRef<ActionType>();
3031
const allTodoActionRef = React.useRef<ActionType>();
32+
33+
34+
const handlerUrgeFlow = (recordId:any) => {
35+
const body = {
36+
recordId,
37+
}
38+
urge(body).then(res => {
39+
if (res.success) {
40+
message.success('催办提醒已发送').then();
41+
reloadTable();
42+
}
43+
})
44+
}
45+
3146
const columns = [
3247
{
3348
title: '编号',
3449
dataIndex: 'id',
3550
search: false
3651
},
52+
{
53+
title: '流程编号',
54+
dataIndex: 'processId',
55+
},
3756
{
3857
title: '标题',
3958
dataIndex: 'title',
@@ -43,25 +62,18 @@ const FlowRecordPage = () => {
4362
dataIndex: 'createTime',
4463
valueType: 'dateTime'
4564
},
46-
{
47-
title: '是否已读',
48-
dataIndex: 'read',
49-
render: (text: any) => {
50-
return text ? '已读' : '未读';
51-
}
52-
},
5365
{
5466
title: '是否延期',
5567
dataIndex: 'postponedCount',
5668
render: (text: any) => {
57-
return text > 1 ? '延期' : '未延期';
69+
return text > 1 ? '延期' : '-';
5870
}
5971
},
6072
{
6173
title: '超时到期时间',
6274
dataIndex: 'timeoutTime',
6375
render: (text: any) => {
64-
return text <= 0 ? '不限时间' : moment(text).format("YYYY-MM-DD HH:mm:ss");
76+
return text <= 0 ? '-' : moment(text).format("YYYY-MM-DD HH:mm:ss");
6577
}
6678
},
6779
{
@@ -74,7 +86,7 @@ const FlowRecordPage = () => {
7486
},
7587
{
7688
title: '状态',
77-
dataIndex: 'recodeType',
89+
dataIndex: 'flowType',
7890
render: (text: any) => {
7991
if (text === 'TODO') {
8092
return '办理中';
@@ -89,10 +101,19 @@ const FlowRecordPage = () => {
89101
}
90102
},
91103
{
92-
title: '是否干预',
93-
dataIndex: 'interfere',
104+
title: '办理意见',
105+
dataIndex: 'flowSourceDirection',
94106
render: (text: any) => {
95-
return text ? '干预' : '未干预';
107+
if (text === 'PASS') {
108+
return '同意';
109+
}
110+
if (text === 'REJECT') {
111+
return '拒绝';
112+
}
113+
if (text === 'TRANSFER') {
114+
return '已转办';
115+
}
116+
return text;
96117
}
97118
},
98119
{
@@ -136,14 +157,20 @@ const FlowRecordPage = () => {
136157
setFlowViewVisible(true);
137158
}}
138159
>办理</a>,
139-
<a>催办</a>,
160+
161+
<a
162+
key={"urge"}
163+
onClick={() => {
164+
handlerUrgeFlow(record.id);
165+
}}
166+
>催办</a>,
140167
]
141168
}
142169
}
143170
] as any[];
144171

145172

146-
useEffect(() => {
173+
const reloadTable = ()=>{
147174
if (key === 'todo') {
148175
todoActionRef.current?.reload();
149176
}
@@ -162,6 +189,10 @@ const FlowRecordPage = () => {
162189
if (key === 'all') {
163190
allTodoActionRef.current?.reload();
164191
}
192+
}
193+
194+
useEffect(() => {
195+
reloadTable();
165196
}, [flowViewVisible, key]);
166197

167198
return (
@@ -180,6 +211,9 @@ const FlowRecordPage = () => {
180211
actionRef={todoActionRef}
181212
search={false}
182213
columns={columns}
214+
rowClassName={(record) => {
215+
return record.read?"record-read":"record-unread";
216+
}}
183217
request={async (params, sort, filter) => {
184218
return findTodoByOperatorId(params, sort, filter, []);
185219
}}
@@ -194,6 +228,9 @@ const FlowRecordPage = () => {
194228
actionRef={doneActionRef}
195229
search={false}
196230
columns={columns}
231+
rowClassName={(record) => {
232+
return record.read?"record-read":"record-unread";
233+
}}
197234
request={async (params, sort, filter) => {
198235
return findDoneByOperatorId(params, sort, filter, []);
199236
}}
@@ -208,6 +245,9 @@ const FlowRecordPage = () => {
208245
actionRef={initiatedActionRef}
209246
search={false}
210247
columns={columns}
248+
rowClassName={(record) => {
249+
return record.read?"record-read":"record-unread";
250+
}}
211251
request={async (params, sort, filter) => {
212252
return findInitiatedByOperatorId(params, sort, filter, []);
213253
}}
@@ -222,6 +262,9 @@ const FlowRecordPage = () => {
222262
actionRef={timeoutTodoActionRef}
223263
search={false}
224264
columns={columns}
265+
rowClassName={(record) => {
266+
return record.read?"record-read":"record-unread";
267+
}}
225268
request={async (params, sort, filter) => {
226269
return findTimeoutTodoByOperatorId(params, sort, filter, []);
227270
}}
@@ -237,6 +280,9 @@ const FlowRecordPage = () => {
237280
actionRef={postponedTodoActionRef}
238281
search={false}
239282
columns={columns}
283+
rowClassName={(record) => {
284+
return record.read?"record-read":"record-unread";
285+
}}
240286
request={async (params, sort, filter) => {
241287
return findPostponedTodoByOperatorId(params, sort, filter, []);
242288
}}
@@ -251,6 +297,9 @@ const FlowRecordPage = () => {
251297
actionRef={allTodoActionRef}
252298
search={false}
253299
columns={columns}
300+
rowClassName={(record) => {
301+
return record.read?"record-read":"record-unread";
302+
}}
254303
request={async (params, sort, filter) => {
255304
return flowRecordList(params, sort, filter, []);
256305
}}

example/example-application/src/main/java/com/codingapi/example/command/FlowRecordCmdController.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ public Response startFlow(@RequestBody FlowCmd.StartFlow request) {
3434
@PostMapping("/submitFlow")
3535
public Response submitFlow(@RequestBody FlowCmd.SubmitFlow request) {
3636
User current = userRepository.getUserByUsername(request.getUserName());
37-
flowService.submitFlow(request.getRecordId(), current, request.getBindData(), request.getOpinion());
37+
if(current.isFlowManager()){
38+
flowService.interfere(request.getRecordId(), current, request.getBindData(), request.getOpinion());
39+
}else {
40+
flowService.submitFlow(request.getRecordId(), current, request.getBindData(), request.getOpinion());
41+
}
3842
return Response.buildSuccess();
3943
}
4044

@@ -63,14 +67,6 @@ public Response transfer(@RequestBody FlowCmd.TransferFlow request) {
6367
}
6468

6569

66-
@PostMapping("/interfere")
67-
public Response interfere(@RequestBody FlowCmd.InterfereFlow request) {
68-
User current = userRepository.getUserByUsername(request.getUserName());
69-
flowService.interfere(request.getRecordId(), current, request.getBindData(), request.getOpinion());
70-
return Response.buildSuccess();
71-
}
72-
73-
7470
@PostMapping("/postponed")
7571
public Response postponed(@RequestBody FlowCmd.PostponedFlow request) {
7672
User current = userRepository.getUserByUsername(request.getUserName());
@@ -87,11 +83,5 @@ public Response urge(@RequestBody FlowCmd.UrgeFlow request) {
8783
}
8884

8985

90-
@PostMapping("/read")
91-
public SingleResponse<FlowDetail> read(@RequestBody FlowCmd.ReadFlow request) {
92-
User current = userRepository.getUserByUsername(request.getUserName());
93-
return SingleResponse.of(flowService.detail(request.getRecordId(), current));
94-
}
95-
9686

9787
}

example/example-application/src/main/java/com/codingapi/example/query/FlowRecordQueryController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public MultiResponse<FlowRecordEntity> list(SearchRequest searchRequest) {
3636
@GetMapping("/detail")
3737
public SingleResponse<FlowDetail> detail(SearchRequest searchRequest) {
3838
long id = Long.parseLong(searchRequest.getParameter("id"));
39-
return SingleResponse.of(flowService.detail(id));
39+
User user = userRepository.getUserByUsername(TokenContext.current().getUsername());
40+
return SingleResponse.of(flowService.detail(id,user));
4041
}
4142

4243

example/example-infra-flow/src/main/java/com/codingapi/example/jpa/FlowRecordEntityRepository.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public interface FlowRecordEntityRepository extends FastRepository<FlowRecordEnt
1818

1919
List<FlowRecordEntity> findFlowRecordEntityByProcessId(String processId);
2020

21+
@Query(value = "select r from FlowRecordEntity r where r.flowType = 'TODO' and r.flowStatus = 'RUNNING' and r.processId = ?1")
22+
List<FlowRecordEntity> findTodoFlowRecordByProcessId(String processId);
2123

2224
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' order by r.id desc")
2325
Page<FlowRecordEntity> findTodoByOperatorId(long operatorId,PageRequest pageRequest);
@@ -34,6 +36,5 @@ public interface FlowRecordEntityRepository extends FastRepository<FlowRecordEnt
3436
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' and r.postponedCount > 0 order by r.id desc")
3537
Page<FlowRecordEntity> findPostponedTodoByOperatorId(long operatorId, PageRequest pageRequest);
3638

37-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' order by r.id desc")
38-
List<FlowRecordEntity> findTodoFlowRecordByProcessId(String processId);
39+
3940
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/domain/FlowNode.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ public List<? extends IFlowOperator> loadFlowNodeOperator(FlowContent flowConten
185185
* @param createOperator 流程操作者
186186
* @param currentOperator 当前操作者
187187
* @param snapshot 快照数据
188-
* @param flowSourceDirection 流程方式
189188
* @return 流程记录
190189
*/
191190
public FlowRecord createRecord(long workId,
@@ -194,8 +193,8 @@ public FlowRecord createRecord(long workId,
194193
String title,
195194
IFlowOperator createOperator,
196195
IFlowOperator currentOperator,
197-
BindDataSnapshot snapshot,
198-
FlowSourceDirection flowSourceDirection) {
196+
BindDataSnapshot snapshot
197+
) {
199198

200199
// 当前操作者存在委托人时,才需要寻找委托人
201200
IFlowOperator flowOperator = currentOperator;
@@ -216,7 +215,6 @@ public FlowRecord createRecord(long workId,
216215
record.setCurrentOperatorId(flowOperator.getUserId());
217216
record.setPreId(preId);
218217
record.setTitle(title);
219-
record.setFlowSourceDirection(flowSourceDirection);
220218
record.setTimeoutTime(this.loadTimeoutTime());
221219
record.setFlowType(FlowType.TODO);
222220
record.setErrMessage(null);

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/record/FlowRecord.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,26 @@ public boolean isPass() {
317317
return this.opinion != null && this.opinion.isSuccess() && isDone();
318318
}
319319

320+
/**
321+
* 匹配操作者
322+
* @param currentOperator 当前操作者
323+
*/
320324
public void matcherOperator(IFlowOperator currentOperator) {
321-
if (currentOperator.getUserId() != this.currentOperatorId) {
325+
if (!isOperator(currentOperator)) {
322326
throw new IllegalArgumentException("current operator is not match");
323327
}
324328
}
325329

330+
/**
331+
* 是否是当前操作者
332+
* @param operator 操作者
333+
* @return 是否是当前操作者
334+
*/
335+
public boolean isOperator(IFlowOperator operator) {
336+
return this.currentOperatorId == operator.getUserId();
337+
}
338+
339+
326340
/**
327341
* 撤回流程
328342
*/

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/FlowRecordService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public List<FlowRecord> createRecord(long preId, FlowNode currentNode) {
8686
String recordTitle = currentNode.generateTitle(flowContent);
8787
List<FlowRecord> recordList = new ArrayList<>();
8888
for (IFlowOperator operator : operators) {
89-
FlowRecord record = currentNode.createRecord(workId, processId, preId, recordTitle, createOperator, operator, snapshot, flowSourceDirection);
89+
FlowRecord record = currentNode.createRecord(workId, processId, preId, recordTitle, createOperator, operator, snapshot);
9090
recordList.add(record);
9191
}
9292
return recordList;
@@ -146,7 +146,7 @@ private List<FlowRecord> errMatcher(FlowNode currentNode, long preId, IFlowOpera
146146
for (IFlowOperator operator : operators) {
147147
FlowContent content = new FlowContent(flowWork, currentNode, createOperator, operator, snapshot.toBindData(), opinion, historyRecords);
148148
String recordTitle = currentNode.generateTitle(content);
149-
FlowRecord record = currentNode.createRecord(flowWork.getId(), processId, preId, recordTitle, createOperator, operator, snapshot, flowSourceDirection);
149+
FlowRecord record = currentNode.createRecord(flowWork.getId(), processId, preId, recordTitle, createOperator, operator, snapshot);
150150
recordList.add(record);
151151
}
152152
return recordList;
@@ -164,7 +164,7 @@ private List<FlowRecord> errMatcher(FlowNode currentNode, long preId, IFlowOpera
164164
if (!matcherOperators.isEmpty()) {
165165
for (IFlowOperator matcherOperator : matcherOperators) {
166166
String recordTitle = node.generateTitle(content);
167-
FlowRecord record = node.createRecord(flowWork.getId(), processId, preId, recordTitle, createOperator, matcherOperator, snapshot, flowSourceDirection);
167+
FlowRecord record = node.createRecord(flowWork.getId(), processId, preId, recordTitle, createOperator, matcherOperator, snapshot);
168168
recordList.add(record);
169169
}
170170
}

0 commit comments

Comments
 (0)