From 8a7eac7d9b3d198f20bae7ce1f81a3dbf067b8de Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 07 十月 2024 10:41:35 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/MissionController.java    |    7 +++
 zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/MissionService.java          |    3 +
 zy-acs-flow/src/page/mission/MissionResend.jsx                                               |   45 ++++++++++++++++------
 zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/MissionServiceImpl.java |    9 ++++
 4 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/zy-acs-flow/src/page/mission/MissionResend.jsx b/zy-acs-flow/src/page/mission/MissionResend.jsx
index 10b1a43..5c74ef3 100644
--- a/zy-acs-flow/src/page/mission/MissionResend.jsx
+++ b/zy-acs-flow/src/page/mission/MissionResend.jsx
@@ -36,6 +36,7 @@
 import DialogCloseButton from "../components/DialogCloseButton";
 import { format } from 'date-fns';
 import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew';
+import request from '@/utils/request';
 
 const MissionResend = ({ open, id }) => {
     const redirect = useRedirect();
@@ -136,8 +137,7 @@
                             </Box>
                         )}
 
-                        <ActionTable actionIds={record?.actionIds} />
-
+                        <ActionTable actionIds={record?.actionIds} currCode={record.currCode} handleClose={handleClose} />
                     </Box>
                 </Box>
             </Stack>
@@ -178,9 +178,10 @@
     },
 ];
 
-const ActionTable = ({ actionIds }) => {
+const ActionTable = ({ actionIds, currCode, handleClose }) => {
     const dataProvider = useDataProvider();
     const translate = useTranslate();
+    const notify = useNotify();
     const [actions, setActions] = useState([]);
     const [selected, setSelected] = React.useState([]);
 
@@ -189,6 +190,13 @@
             dataProvider.getMany('action', { ids: actionIds }).then(res => {
                 if (res.data?.length > 0) {
                     setActions(res.data);
+
+                    // init selected
+                    const indexOfCurrCode = res.data.findIndex(item => item.code === currCode);
+                    if (indexOfCurrCode !== -1) {
+                        const selectedIds = res.data.slice(indexOfCurrCode).map(item => item.id);
+                        setSelected(selectedIds);
+                    }
                 }
             })
         }
@@ -222,6 +230,21 @@
         setSelected(newSelected);
     };
 
+    const resendSubmit = () => {
+        if (!!selected?.length) {
+            request.post("/mission/resend", selected.map(id => ({ id }))).then(res => {
+                const { code, msg, data } = res.data;
+                if (code === 200) {
+                    notify(msg || 'common.response.success', { type: 'success', messageArgs: { _: msg } });
+                    handleClose();
+                } else {
+                    notify(msg || 'common.response.fail', { type: 'error', messageArgs: { _: msg } });
+                }
+            }).catch(error => {
+                notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } });
+            })
+        }
+    }
 
     return (
         <>
@@ -263,16 +286,12 @@
                             </Typography>
                         )}
                         {selected.length > 0 && (
-                            <Tooltip title="Delete">
-                                <IconButton>
-                                    <Button
-                                        onClick={() => {
-                                            alert('clicked');
-                                        }}
-                                    >
-                                        ss
-                                    </Button>
-                                </IconButton>
+                            <Tooltip title="Resend">
+                                <Button
+                                    onClick={resendSubmit}
+                                >
+                                    {translate('ra.action.confirm')}
+                                </Button>
                             </Tooltip>
                         )}
                     </Toolbar>
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/MissionController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/MissionController.java
index 942c48a..c4c6da2 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/MissionController.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/MissionController.java
@@ -3,6 +3,7 @@
 import com.zy.acs.framework.common.Cools;
 import com.zy.acs.framework.common.R;
 import com.zy.acs.manager.core.domain.TaskPosDto;
+import com.zy.acs.manager.manager.entity.Action;
 import com.zy.acs.manager.manager.entity.Segment;
 import com.zy.acs.manager.manager.service.MissionService;
 import com.zy.acs.manager.manager.service.SegmentService;
@@ -58,4 +59,10 @@
         return R.ok().add(missionService.generateVoMoreInfo(segment.getGroupId()));
     }
 
+    @PreAuthorize("hasAuthority('manager:mission:update')")
+    @PostMapping("/mission/resend")
+    public R resend(@RequestBody List<Action> actionList) {
+        return missionService.resend(actionList) ? R.ok("Resend Success") : R.error("Resend Fail");
+    }
+
 }
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/MissionService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/MissionService.java
index 5cd8ba7..9ff3513 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/MissionService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/MissionService.java
@@ -1,6 +1,7 @@
 package com.zy.acs.manager.manager.service;
 
 import com.zy.acs.manager.manager.controller.result.MissionVo;
+import com.zy.acs.manager.manager.entity.Action;
 
 import java.util.List;
 
@@ -12,4 +13,6 @@
 
     MissionVo generateVoMoreInfo(String groupNo);
 
+    Boolean resend(List<Action> actionList);
+
 }
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/MissionServiceImpl.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/MissionServiceImpl.java
index 65656a3..5a69ed7 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/MissionServiceImpl.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/MissionServiceImpl.java
@@ -112,6 +112,15 @@
         return vo;
     }
 
+    @Override
+    public Boolean resend(List<Action> actionList) {
+        if (Cools.isEmpty(actionList)) {
+            return Boolean.FALSE;
+        }
+
+        return Boolean.TRUE;
+    }
+
     public Double calcProgress(String currCode, List<Action> actionList) {
         double progress = 0D;
         if (Cools.isEmpty(actionList, currCode)) {

--
Gitblit v1.9.1