From ca36e3b92acaa53f042fd8af1920930af782efc6 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期四, 25 十二月 2025 12:43:16 +0800
Subject: [PATCH] Merge branch 'devlop_org' into devlop-phyz

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java        |  399 ++++++++++++++++++++++++++------
 rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseStockController.java |   20 +
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java     |    2 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java        |   35 ++
 rsf-admin/src/page/basicInfo/loc/LocItemList.jsx                                                 |  132 ++++++----
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/ReviseLogServiceImpl.java   |    2 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java                 |   64 +++--
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/TaskService.java                 |    9 
 rsf-admin/src/page/statistics/stockManage/WarehouseStockList.jsx                                 |   28 -
 9 files changed, 494 insertions(+), 197 deletions(-)

diff --git a/rsf-admin/src/page/basicInfo/loc/LocItemList.jsx b/rsf-admin/src/page/basicInfo/loc/LocItemList.jsx
index 6e2d6b2..ae6d901 100644
--- a/rsf-admin/src/page/basicInfo/loc/LocItemList.jsx
+++ b/rsf-admin/src/page/basicInfo/loc/LocItemList.jsx
@@ -8,37 +8,27 @@
     SelectColumnsButton,
     EditButton,
     FilterButton,
-    CreateButton,
-    ExportButton,
-    BulkDeleteButton,
     WrapperField,
-    useRecordContext,
     useTranslate,
     useNotify,
     useListContext,
-    FunctionField,
     TextField,
     NumberField,
     DateField,
     BooleanField,
     ReferenceField,
     TextInput,
-    DateTimeInput,
     DateInput,
     SelectInput,
-    NumberInput,
-    ReferenceInput,
-    ReferenceArrayInput,
-    AutocompleteInput,
     DeleteButton,
+    NumberInput,
+    useRefresh,
     useGetRecordId,
 } from 'react-admin';
-import { Box, Typography, Card, Stack } from '@mui/material';
+import { Box, Typography, Card, Stack, LinearProgress } from '@mui/material';
 import { styled } from '@mui/material/styles';
 import LocItemCreate from "./LocItemCreate";
-import EmptyData from "../../components/EmptyData";
-import MyCreateButton from "../../components/MyCreateButton";
-import MyExportButton from '../../components/MyExportButton';
+import request from '@/utils/request';
 import PageDrawer from "../../components/PageDrawer";
 import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_ITEM_PAGE_SIZE } from '@/config/setting';
 
@@ -119,42 +109,7 @@
                 )}
                 perPage={DEFAULT_ITEM_PAGE_SIZE}
             >
-                <StyledDatagrid
-                    preferenceKey='locItem'
-                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
-                    rowClick={(id, resource, record) => false}
-                    expand={false}
-                    expandSingle={true}
-                    omit={['id', 'locId', 'orderId', 'orderItemId', 'matnrId', 'statusBool','trackCode', 'createTime', 'fieldsIndex','splrBatch', 'createBy', 'spec', 'model', 'memo']}
-                >
-                    <NumberField source="id" />
-                    <NumberField source="locId" label="table.field.locItem.locId" />
-                    <NumberField source="orderId" label="table.field.locItem.orderId" />
-                    <TextField source="type$" label="table.field.locItem.type" />
-                    <NumberField source="orderItemId" label="table.field.locItem.orderItemId" />
-                    <NumberField source="wkType$" label="table.field.locItem.wkType" />
-                    <NumberField source="matnrId" label="table.field.locItem.matnrId" />
-                    <TextField source="matnrCode" label="table.field.locItem.matnrCode" />
-                    <TextField source="maktx" label="table.field.locItem.maktx" />
-                    <TextField source="batch" label="table.field.locItem.batch" />
-                    <TextField source="trackCode" label="table.field.locItem.trackCode" />
-                    <NumberField source="anfme" label="table.field.locItem.anfme" />
-                    <TextField source="unit" label="table.field.locItem.unit" />
-                    <TextField source="splrBatch" label="table.field.locItem.splrBatch" />
-                    <TextField source="spec" label="table.field.locItem.spec" />
-                    <TextField source="model" label="table.field.locItem.model" />
-                    <TextField source="fieldsIndex" label="table.field.locItem.fieldsIndex" />
-                    <TextField source="updateBy$" label="common.field.updateBy" />
-                    <DateField source="updateTime" label="common.field.updateTime" showTime />
-                    <TextField source="createBy$" label="common.field.createBy" />
-                    <DateField source="createTime" label="common.field.createTime" showTime />
-                    <BooleanField source="statusBool" label="common.field.status" sortable={false} />
-                    <TextField source="memo" label="common.field.memo" sortable={false} />
-                    <WrapperField cellClassName="opt" label="common.field.opt">
-                        <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} />
-                        <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} redirect={false}/>
-                    </WrapperField>
-                </StyledDatagrid>
+                <DynamicFields />
             </List>
             <LocItemCreate
                 open={createDialog}
@@ -170,4 +125,81 @@
     )
 }
 
+
 export default LocItemList;
+
+
+const DynamicFields = (props) => {
+    const translate = useTranslate();
+    const notify = useNotify();
+    const [columns, setColumns] = useState([]);
+    const { isLoading } = useListContext();
+    const refresh = useRefresh();
+    useEffect(() => {
+        getDynamicFields();
+    }, []);
+
+    const getDynamicFields = async () => {
+        const { data: { code, data, msg }, } = await request.get("/fields/enable/list");
+        if (code == 200) {
+            const arr = [
+                <NumberField source="id" />,
+                <NumberField source="locId" label="table.field.locItem.locId" />,
+                <NumberField source="orderId" label="table.field.locItem.orderId" />,
+                <TextField source="type$" label="table.field.locItem.type" />,
+                <NumberField source="orderItemId" label="table.field.locItem.orderItemId" />,
+                <NumberField source="wkType$" label="table.field.locItem.wkType" />,
+                <NumberField source="matnrId" label="table.field.locItem.matnrId" />,
+                <TextField source="matnrCode" label="table.field.locItem.matnrCode" />,
+                <TextField source="maktx" label="table.field.locItem.maktx" />,
+                <TextField source="batch" label="table.field.locItem.batch" />,
+                <TextField source="trackCode" label="table.field.locItem.trackCode" />,
+                <NumberField source="anfme" label="table.field.locItem.anfme" />,
+                <TextField source="unit" label="table.field.locItem.unit" />,
+                <TextField source="splrBatch" label="table.field.locItem.splrBatch" />,
+                <TextField source="spec" label="table.field.locItem.spec" />,
+                <TextField source="model" label="table.field.locItem.model" />,
+                <TextField source="fieldsIndex" label="table.field.locItem.fieldsIndex" />,
+                <BooleanField source="statusBool" label="common.field.status" sortable={false} />,
+            ]
+            const fields = data.map(el => <TextField key={el.fields} source={`extendFields.[${el.fields}]`} label={el.fieldsAlise} />)
+            const lastArr = [
+                <TextField source="updateBy$" label="common.field.updateBy" />,
+                <DateField source="updateTime" label="common.field.updateTime" showTime />,
+                <TextField source="createBy$" label="common.field.createBy" />,
+                <DateField source="createTime" label="common.field.createTime" showTime />,
+                <TextField source="memo" label="common.field.memo" sortable={false} />,
+            ]
+            setColumns([...arr, ...fields, ...lastArr]);
+        } else {
+            notify(msg);
+        }
+    }
+
+    return (
+        <Box sx={{ position: 'relative', minHeight: "60vh", }}>
+            {isLoading && (
+                <LinearProgress
+                    sx={{
+                        height: "2px",
+                        position: 'absolute',
+                        top: 0,
+                        left: 0,
+                        right: 0,
+                    }}
+                />
+            )}
+            {columns.length > 0 &&
+                <StyledDatagrid
+                    preferenceKey='locItem'
+                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
+                    rowClick={(id, resource, record) => false}
+                    expand={false}
+                    expandSingle={true}
+                    omit={['id', 'locId', 'orderId', 'orderItemId', 'matnrId', 'statusBool', 'trackCode', 'createTime', 'fieldsIndex', 'splrBatch', 'createBy', 'spec', 'model', 'memo']}
+                >
+                    {columns.map((column) => column)}
+                </StyledDatagrid>}
+        </Box>
+    )
+}
diff --git a/rsf-admin/src/page/statistics/stockManage/WarehouseStockList.jsx b/rsf-admin/src/page/statistics/stockManage/WarehouseStockList.jsx
index 94fb604..113b44b 100644
--- a/rsf-admin/src/page/statistics/stockManage/WarehouseStockList.jsx
+++ b/rsf-admin/src/page/statistics/stockManage/WarehouseStockList.jsx
@@ -53,19 +53,19 @@
         cursor: 'auto'
     },
     '& .MuiTableCell-root': {
-    whiteSpace: 'nowrap',
-    overflow: 'visible',
-    textOverflow: 'unset'
+        whiteSpace: 'nowrap',
+        overflow: 'visible',
+        textOverflow: 'unset'
     },
     '& .opt': {
         width: 180,
         whiteSpace: 'normal',
     },
-    '& .column-maktx': {        
+    '& .column-maktx': {
         maxWidth: '15em',
         overflow: 'hidden',
         textOverflow: 'ellipsis',
-        whiteSpace: 'nowrap',    
+        whiteSpace: 'nowrap',
     },
 }));
 
@@ -77,23 +77,11 @@
     const translate = useTranslate();
     const [createDialog, setCreateDialog] = useState(false);
     const [filters, setFilters] = useState([
-        <SearchInput source="condition" alwaysOn />,
-        <NumberInput source="locId" label="table.field.locItem.locId" />,
-        <TextInput source="locCode" label="table.field.locItem.locCode" />,
-        <TextInput source="type" label="table.field.locItem.type" />,
         <AutocompleteInput choices={dict} optionText='label' optionValue="value" source="aggType" label="table.field.locItem.aggType" />,
-        <NumberInput source="orderItemId" label="table.field.locItem.orderItemId" />,
-        <NumberInput source="wkType" label="table.field.locItem.wkType" />,
-        <NumberInput source="matnrId" label="table.field.locItem.matnrId" />,
+        <TextInput source="matnrCode" label="table.field.warehouseStock.matnrCode" alwaysOn/>,
         <TextInput source="maktx" label="table.field.locItem.maktx" />,
-        <TextInput source="unit" label="table.field.locItem.unit" />,
-        <NumberInput source="anfme" label="table.field.locItem.anfme" />,
-        <NumberInput source="workQty" label="table.field.locItem.workQty" />,
         <TextInput source="batch" label="table.field.locItem.batch" />,
-        <TextInput source="spec" label="table.field.locItem.spec" />,
-        <TextInput source="model" label="table.field.locItem.model" />,
-        <TextInput source="fieldsIndex" label="table.field.locItem.fieldsIndex" />,
-        <TextInput label="common.field.memo" source="memo" />,]);
+        ]);
     const [select, setSelect] = useState({});
     const [drawerVal, setDrawerVal] = useState(false);
 
@@ -242,7 +230,7 @@
                     rowClick={false}
                     expand={false}
                     expandSingle={true}
-                    omit={['id', 'createTime', 'locId', 'spec', 'model', 'locCode', 'orderId', 'orderItemId', 'matnrId', 'splrBatch', 'createBy', 'memo', 'fieldsIndex','updateBy$']}
+                    omit={['id', 'createTime', 'locId', 'spec', 'model', 'locCode', 'orderId', 'orderItemId', 'matnrId', 'splrBatch', 'createBy', 'memo', 'fieldsIndex', 'updateBy$']}
                 >
                     {columns.map((column) => column)}
                 </StyledDatagrid>}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseStockController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseStockController.java
index aa8edf6..a4c74da 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseStockController.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseStockController.java
@@ -59,17 +59,22 @@
         } else {
             wrapper.groupBy("matnr_id");
         }
+        wrapper.eq(!Objects.isNull(param.get("matnrCode")), "matnr_code", param.get("matnrCode"));
 
         FieldsUtils.setFieldsFilters(wrapper, pageParam, ViewStockManage.class);
 
+
         IPage<ViewStockManage> pageResult = warehouseStockService.pageByStock(pageParam, wrapper);
+
+
         List<ViewStockManage> records = pageResult.getRecords();
-        for (ViewStockManage record : records) {
+
+        records.forEach(record -> {
             if (!Objects.isNull(record.getFieldsIndex())) {
                 Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex());
                 record.setExtendFields(fields);
             }
-        }
+        });
         pageResult.setRecords(records);
 
         return R.ok(pageResult);
@@ -145,8 +150,17 @@
         } else {
             wrapper.eq(ViewStockManage::getMatnrCode, stock.getMatnrCode());
        }
+        PageParam<ViewStockManage, BaseParam> result = warehouseStockService.page(pageParam, wrapper);
+        List<ViewStockManage> records = result.getRecords();
+        records.forEach(record -> {
+            if (!Objects.isNull(record.getFieldsIndex())) {
+                Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex());
+                record.setExtendFields(fields);
+            }
+        });
+        result.setRecords(records);
 
-        return R.ok(warehouseStockService.page(pageParam, wrapper));
+        return R.ok(result);
     }
 
 }
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/TaskService.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/TaskService.java
index c67e035..8aaa36a 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/TaskService.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/TaskService.java
@@ -3,8 +3,7 @@
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.vincent.rsf.framework.common.R;
 import com.vincent.rsf.server.manager.controller.params.GenerateTaskParams;
-import com.vincent.rsf.server.manager.entity.Task;
-import com.vincent.rsf.server.manager.entity.WaitPakin;
+import com.vincent.rsf.server.manager.entity.*;
 
 import java.util.List;
 
@@ -29,4 +28,10 @@
     Task operateComplete(Long id, Long loginUserId);
 
     void moveToDeep(Long loginUserId, String curLoc) throws Exception;
+
+    void pubTaskToWcs(List<Task> tasks);
+
+    R menualExceTask(List<Long> ids);
+
+    void saveOutStockItem(List<TaskItem> taskItems, WkOrderItem orderItem, WaveItem waveItem, WkOrderItem diffItem, Long loginUserId) throws Exception;
 }
\ No newline at end of file
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
index 7a9e21e..fb68257 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
@@ -65,7 +65,7 @@
     @Override
     @Synchronized
     @Transactional(rollbackFor = Exception.class)
-    public void generateTask(Short resouce, LocToTaskParams map, Long loginUserId) throws Exception {
+    public synchronized void generateTask(Short resouce, LocToTaskParams map, Long loginUserId) throws Exception {
         if (Objects.isNull(map.getSiteNo())) {
             throw new CoolException("绔欑偣涓嶈兘涓虹┖锛�");
         }
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/ReviseLogServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/ReviseLogServiceImpl.java
index ba1f45c..cf0dc60 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/ReviseLogServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/ReviseLogServiceImpl.java
@@ -129,7 +129,7 @@
                 throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�");
             }
             List<LocItem> list = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
-            if (!list.isEmpty()) {
+            if (list.isEmpty()) {
                 throw new CoolException("搴撲綅:" + loc.getCode() + ", 璋冩暣淇℃伅涓虹┖锛侊紒");
             }
             locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
index 82a7389..90e474e 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -1,10 +1,21 @@
 package com.vincent.rsf.server.manager.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.cfg.CoercionAction;
+import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
 import com.vincent.rsf.framework.common.Cools;
+import com.vincent.rsf.framework.common.DateUtils;
+import com.vincent.rsf.server.api.config.RemotesInfoProperties;
 import com.vincent.rsf.server.api.controller.erp.params.TaskInParam;
+import com.vincent.rsf.server.api.entity.CommonResponse;
+import com.vincent.rsf.server.api.entity.constant.RcsConstant;
 import com.vincent.rsf.server.api.entity.dto.InTaskMsgDto;
+import com.vincent.rsf.server.api.entity.params.TaskItemParam;
+import com.vincent.rsf.server.api.entity.params.WcsTaskParams;
 import com.vincent.rsf.server.api.service.WcsService;
 import com.vincent.rsf.server.common.constant.Constants;
 import com.vincent.rsf.server.manager.controller.params.LocToTaskParams;
@@ -18,8 +29,12 @@
 import com.vincent.rsf.server.manager.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.vincent.rsf.server.manager.utils.LocManageUtil;
+import com.vincent.rsf.server.system.constant.GlobalConfigCode;
 import com.vincent.rsf.server.system.constant.SerialRuleCode;
 import com.vincent.rsf.server.manager.enums.LocStsType;
+import com.vincent.rsf.server.system.entity.Config;
+import com.vincent.rsf.server.system.service.ConfigService;
+import com.vincent.rsf.server.system.service.impl.ConfigServiceImpl;
 import com.vincent.rsf.server.system.utils.SerialRuleUtils;
 import com.vincent.rsf.server.system.utils.SystemAuthUtils;
 import lombok.Synchronized;
@@ -29,10 +44,16 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.client.RestTemplate;
 
 import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -95,6 +116,12 @@
     private CheckDiffItemService checkDiffItemService;
     @Autowired
     private BasContainerService basContainerService;
+    @Autowired
+    private ConfigService configService;
+    @Autowired
+    private RestTemplate restTemplate;
+    @Autowired
+    private RemotesInfoProperties.RcsApi rcsApi;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -309,6 +336,9 @@
         waitPakins.forEach(pakin -> {
             BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>()
                     .eq(BasContainer::getCode, pakin.getBarcode()));
+            if (Objects.isNull(container)) {
+                throw new CoolException("瀹瑰櫒鏈淮鎶ゅ叆搴擄紝璇风淮鎶ゅ悗鍐嶆搷浣滐紒锛�");
+            }
             /**鑾峰彇搴撲綅*/
             String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), container.getContainerType());
             if (Cools.isEmpty(targetLoc)) {
@@ -422,12 +452,12 @@
      * @param tasks
      * @throws Exception
      */
-    @Synchronized
     @Override
-    public void complateInTask(List<Task> tasks) throws Exception {
-        Long loginUserId = SystemAuthUtils.getLoginUserId();
-        for (Task task : tasks) {
-            try {
+    public void complateInTask(List<Task> tasks) {
+        AtomicBoolean success = new AtomicBoolean(false);
+        if (success.compareAndSet(false, true)) {
+            Long loginUserId = SystemAuthUtils.getLoginUserId();
+            for (Task task : tasks) {
                 if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
                     //1.鍏ュ簱
                     complateInstock(task, loginUserId);
@@ -439,8 +469,6 @@
                     //绉诲簱
                     moveInStock(task, loginUserId);
                 }
-            } catch (Exception ex) {
-                log.error(ex.getMessage(), ex);
             }
         }
     }
@@ -675,7 +703,7 @@
      * @param loginUserId
      */
     @Transactional(rollbackFor = Exception.class)
-    public void pickComplateInStock(Task task, Long loginUserId) throws Exception {
+    public void pickComplateInStock(Task task, Long loginUserId) {
         if (Objects.isNull(task)) {
             return;
         }
@@ -683,10 +711,9 @@
         if (Objects.isNull(loc)) {
             throw new CoolException("搴撳瓨涓嶅瓨鍦紒锛�");
         }
-        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) {
-            throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害锛屼笉鍙墽琛屽叆搴撴搷浣滐紒");
-        }
-
+//        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) {
+//            throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害锛屼笉鍙墽琛屽叆搴撴搷浣滐紒");
+//        }
         loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
                 .setBarcode(task.getBarcode())
                 .setUpdateBy(loginUserId).setUpdateTime(new Date());
@@ -705,16 +732,17 @@
             LocItem locItem = new LocItem();
             LocItemWorking locWorking = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>()
                     .eq(LocItemWorking::getTaskId, taskItem.getTaskId())
-                    .eq(StringUtils.isNotBlank(taskItem.getBatch()), LocItemWorking::getBatch, taskItem.getBatch())
+                    .eq(LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex())
+                    .eq(StringUtils.isNotEmpty(taskItem.getBatch()), LocItemWorking::getBatch, taskItem.getBatch())
                     .eq(LocItemWorking::getMatnrId, taskItem.getMatnrId()));
             if (Objects.isNull(locWorking)) {
-                throw new CoolException("鏁版嵁閿欒锛屼綔涓氫腑搴撳瓨鏁版嵁涓㈠け锛侊紒");
+               continue;
             }
             if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
                 locWorking.setAnfme(taskItem.getAnfme());
             }
             BeanUtils.copyProperties(locWorking, locItem);
-            locItem.setWorkQty(0.0).setLocCode(loc.getCode()).setLocId(loc.getId()).setId(null).setUpdateBy(loginUserId).setUpdateTime(new Date());
+            locItem.setWorkQty(0.0).setQty(0.0).setLocCode(loc.getCode()).setLocId(loc.getId()).setId(null).setUpdateBy(loginUserId).setUpdateTime(new Date());
             items.add(locItem);
         }
 
@@ -724,7 +752,7 @@
 
         TaskItem taskItem = taskItems.stream().findFirst().get();
         //淇濆瓨鍏ュ嚭搴撴祦姘�
-        saveStockItems(taskItems, task, null, null, taskItem.getWkType(), taskItem.getOrderType(), loginUserId);
+        saveStockItems(taskItems, task, null, null, taskItem.getWkType(), OrderType.ORDER_IN.type, loginUserId);
 
         locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()));
 
@@ -788,7 +816,6 @@
             } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
                 List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, Arrays.asList(ids)));
                 if (!taskItems.isEmpty()) {
-
                     taskItems.forEach(taskItem -> {
                         if (!checkOrderItemService.update(new LambdaUpdateWrapper<WkOrderItem>()
                                 .eq(WkOrderItem::getId, taskItem.getOrderItemId())
@@ -868,7 +895,7 @@
                             if (Objects.isNull(waveItem)) {
                                 throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�");
                             }
-                            Double workQty = Math.round((waveItem.getWorkQty() - item.getAnfme()) * 10000) / 10000.0;
+                            Double workQty = Math.round((waveItem.getWorkQty() - item.getAnfme()) * 1000000) / 1000000.0;
                             waveItem.setWorkQty(workQty).setExceStatus(WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val);
                             if (!waveItemService.updateById(waveItem)) {
                                 throw new CoolException("娉㈡鏄庣粏鏇存柊澶辫触锛侊紒");
@@ -892,7 +919,7 @@
                             if (Objects.isNull(wkOrder)) {
                                 throw new CoolException("鏁版嵁閿欒锛氬崟鎹凡涓嶅瓨鍦紒锛�");
                             }
-                            Double workQty = Math.round((wkOrder.getWorkQty() - item.getAnfme()) * 10000) / 10000.0;
+                            Double workQty = Math.round((wkOrder.getWorkQty() - item.getAnfme()) * 1000000) / 1000000.0;
 
                             wkOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_INIT.val)
                                     .setWorkQty(workQty.compareTo(0.00) > 0 ? workQty : 0.00)
@@ -907,7 +934,7 @@
                                 throw new CoolException("鏁版嵁閿欒锛氬崟鎹槑缁嗗凡涓嶅瓨鍦紒锛�");
                             }
 
-                            Double workItmQty = Math.round((orderItem.getWorkQty() - item.getAnfme()) * 10000) / 10000.0;
+                            Double workItmQty = Math.round((orderItem.getWorkQty() - item.getAnfme()) * 1000000) / 1000000.0;
                             orderItem.setWorkQty(workItmQty);
 
                             if (!outStockItemService.updateById(orderItem)) {
@@ -1017,37 +1044,37 @@
 
         tempLocs.forEach(working -> {
             taskItems.forEach(taskItem -> {
-                if (taskItem.getMatnrId().equals(working.getMatnrId())) {
+                if (taskItem.getFieldsIndex().equals(working.getFieldsIndex())) {
                     Double minQty = taskItem.getAnfme();
                     if (!task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
-                        minQty = Math.round((working.getAnfme() - taskItem.getAnfme()) * 10000) / 10000.0;
+                        minQty = Math.round((working.getAnfme() - taskItem.getQty()) * 1000000) / 1000000.0;
                     }
-                    if (minQty.compareTo(0.0) > 0) {
+                    if (minQty.compareTo(0.0) >= 0) {
                         taskItem.setAnfme(minQty);
                         if (!taskItemService.updateById(taskItem)) {
                             throw new CoolException("浠诲姟鏄庣粏淇敼澶辫触锛侊紒");
                         }
                     } else {
                         if (!taskItemService.removeById(taskItem)) {
-                            throw new CoolException("浠诲姟鏄庣粏淇敼澶辫触锛侊紒");
+                            log.error("浠诲姟鏄庣粏淇敼澶辫触锛侊紒");
                         }
                     }
                 }
             });
         });
-        List<Long> matnrIds = taskItems.stream().map(TaskItem::getMatnrId).collect(Collectors.toList());
+        List<String> matnrIds = taskItems.stream().map(TaskItem::getFieldsIndex).collect(Collectors.toList());
         //鍒犻櫎涓庝换鍔℃槑缁嗛噸澶嶇殑搴撳瓨淇℃伅锛屼互浠诲姟鏄庣粏涓哄噯
         List<LocItemWorking> itemWorkings = tempLocs.stream()
-                .filter(working -> !matnrIds.contains(working.getMatnrId()))
+                .filter(working -> !matnrIds.contains(working.getFieldsIndex()))
                 .collect(Collectors.toList());
         itemWorkings.forEach(working -> {
             TaskItem taskItem = taskItems.stream().findFirst().get();
             taskItem.setMatnrId(working.getMatnrId())
                     .setMaktx(working.getMaktx())
-                    .setMatnrId(working.getMatnrId())
                     .setMatnrCode(working.getMatnrCode())
                     .setSpec(working.getSpec())
                     .setAnfme(working.getAnfme())
+                    .setQty(0.0)
                     .setBatch(working.getBatch())
                     .setFieldsIndex(working.getFieldsIndex())
                     .setUnit(working.getUnit())
@@ -1072,6 +1099,7 @@
                 LocItemWorking itemWorking = new LocItemWorking();
                 BeanUtils.copyProperties(taskItem, itemWorking);
                 itemWorking.setTaskId(task.getId())
+                        .setQty(0.0)
                         .setLocId(loc1.getId())
                         .setLocCode(loc1.getCode());
                 workings.add(itemWorking);
@@ -1159,11 +1187,11 @@
                     if (Objects.isNull(waveItem)) {
                         throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�");
                     }
-                    try {
-                        saveOutStockItem(maps.get(key), null, waveItem, null, loginUserId);
-                    } catch (Exception e) {
-                        throw new CoolException(e.getMessage());
-                    }
+//                    try {
+//                        saveOutStockItem(maps.get(key), null, waveItem, null, loginUserId);
+//                    } catch (Exception e) {
+//                        throw new CoolException(e.getMessage());
+//                    }
                 } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) {
                     WkOrderItem orderItem = asnOrderItemService.getById(key);
                     if (Objects.isNull(orderItem)) {
@@ -1206,27 +1234,35 @@
             throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
         }
 
-        if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
-            if (!this.update(new LambdaUpdateWrapper<Task>()
-                    .eq(Task::getId, task.getId())
-                    .set(Task::getUpdateBy, loginUserId)
-                    .set(Task::getUpdateTime, new Date())
-                    .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
-                throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
-            }
-        } else {
-            if (!this.update(new LambdaUpdateWrapper<Task>()
-                    .eq(Task::getId, task.getId())
-                    .set(Task::getUpdateBy, loginUserId)
-                    .set(Task::getUpdateTime, new Date())
-                    .set(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id))) {
-                throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
-            }
-            //鍏ㄦ澘鍑哄簱锛屽垹闄や复鏃跺簱瀛�
-            if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) {
-                throw new CoolException("涓存椂搴撳瓨娓呴櫎澶辫触锛侊紒");
-            }
+        if (!this.update(new LambdaUpdateWrapper<Task>()
+                .eq(Task::getId, task.getId())
+                .set(Task::getUpdateBy, loginUserId)
+                .set(Task::getUpdateTime, new Date())
+                .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
+            throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
         }
+
+//        if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
+//            if (!this.update(new LambdaUpdateWrapper<Task>()
+//                    .eq(Task::getId, task.getId())
+//                    .set(Task::getUpdateBy, loginUserId)
+//                    .set(Task::getUpdateTime, new Date())
+//                    .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
+//                throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+//            }
+//        } else {
+//            if (!this.update(new LambdaUpdateWrapper<Task>()
+//                    .eq(Task::getId, task.getId())
+//                    .set(Task::getUpdateBy, loginUserId)
+//                    .set(Task::getUpdateTime, new Date())
+//                    .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
+//                throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+//            }
+////            //鍏ㄦ澘鍑哄簱锛屽垹闄や复鏃跺簱瀛�
+////            if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) {
+////                throw new CoolException("涓存椂搴撳瓨娓呴櫎澶辫触锛侊紒");
+////            }
+//        }
 
     }
 
@@ -1251,6 +1287,7 @@
      * @description: 鍑哄簱淇℃伅淇濆瓨鑷冲簱瀛樻槑缁嗚〃
      * @version 1.0
      */
+    @Override
     @Transactional(rollbackFor = Exception.class)
     public void saveOutStockItem(List<TaskItem> taskItems, WkOrderItem orderItem, WaveItem waveItem, WkOrderItem diffItem, Long loginUserId) throws Exception {
         Stock stock = new Stock();
@@ -1268,7 +1305,7 @@
             stock.setSourceId(waveItem.getId()).setType(OrderType.ORDER_OUT.type);
         } else if (!Objects.isNull(orderItem) && StringUtils.isNotBlank(orderItem.getId() + "")) {
             WkOrder wkOrder = asnOrderService.getById(orderItem.getOrderId());
-            Double qty = Math.round((wkOrder.getQty() + sum) * 10000) / 10000.0;
+            Double qty = Math.round((wkOrder.getQty() + sum) * 1000000) / 1000000.0;
             wkOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val)
                     .setQty(qty);
             if (!asnOrderService.updateById(wkOrder)) {
@@ -1305,6 +1342,206 @@
         }
     }
 
+
+    /**
+     * 鎵嬪姩涓嬪彂鎵ц浠诲姟
+     * @author Ryan
+     * @date 2025/11/22 13:45
+     * @param ids
+     * @return com.vincent.rsf.framework.common.R
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R menualExceTask(List<Long> ids) {
+        if (Objects.isNull(ids) || ids.isEmpty()) {
+            return R.error("浠诲姟缂栫爜涓嶈兘涓虹┖锛侊紒");
+        }
+        List<Integer> integers = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id);
+        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>()
+                .in(Task::getId, ids)
+                .in(Task::getTaskStatus, integers)
+                .orderByDesc(Task::getSort));
+        if (tasks.isEmpty()) {
+            return R.error("浠诲姟宸插湪鎵ц涓紒锛�");
+        }
+        Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.AUTO_RUN_CHECK_ORDERS));
+        if (!Objects.isNull(config) && !Objects.isNull(config.getVal())) {
+            if (Boolean.parseBoolean(config.getVal())) {
+                return R.error("鑷姩鐢熸垚浠诲姟宸插紑鍚紝鏃犻渶鎵嬪姩涓嬪彂锛侊紒");
+            }
+        }
+
+        taskService.pubTaskToWcs(tasks);
+
+        return R.ok();
+    }
+
+
+    /**
+     * 涓嬪彂浠诲姟鑷砏CS
+     *
+     * @param tasks
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void pubTaskToWcs(List<Task> tasks) {
+        WcsTaskParams taskParams = new WcsTaskParams();
+        List<TaskItemParam> items = new ArrayList<>();
+        tasks.forEach(task -> {
+            TaskItemParam itemParam = new TaskItemParam();
+            //浠诲姟绫诲瀷锛屼换鍔$紪鐮�
+            itemParam.setTaskType(RcsTaskType.getTypeDesc(task.getTaskType()))
+                    .setSeqNum(task.getTaskCode());
+            //涓诲弬鏁�
+            taskParams.setBatch(task.getBarcode());
+            BasStation station = null;
+            if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+                station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
+                if (Objects.isNull(station)) {
+                    throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+                }
+            }
+
+            /**鍒ゆ柇鏄惁鍏夌數绔欑偣锛岄潪鍏夊簵绔欑偣闇�绠℃帶绔欑偣鐘舵��*/
+            if (!Objects.isNull(station) && station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+                if (task.getTaskType() <= TaskType.TASK_TYPE_CHECK_IN.type && !task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+                    station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+                    if (!basStationService.updateById(station)) {
+                        throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
+                    }
+                } else if (task.getTaskType() >= TaskType.TASK_TYPE_OUT.type) {
+                    station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+                    if (!basStationService.updateById(station)) {
+                        throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
+                    }
+                }
+            }
+
+            /**绉诲簱鍙傛暟*/
+            if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+                itemParam.setOriLoc(task.getOrgLoc()).setDestLoc(task.getTargLoc());
+            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
+                    || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
+                    || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
+                /**鍏ㄦ澘鍏ュ簱鍙傛暟*/
+                itemParam.setDestLoc(task.getTargLoc())
+                        .setOriSta(task.getOrgSite());
+            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) {
+                /**鎷f枡/鐩樼偣鍏ュ簱鍙傛暟*/
+                itemParam.setDestLoc(task.getTargLoc())
+                        .setOriSta(task.getTargSite());
+            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
+                    || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
+                    || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
+                    || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
+                    || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)) {
+                /**鍑哄簱鍙傛暟*/
+                itemParam.setOriLoc(task.getOrgLoc())
+                        .setDestSta(task.getTargSite());
+            } else {
+                /**绔欑偣闂寸Щ搴撳弬鏁�*/
+                itemParam.setOriSta(task.getOrgSite()).setDestSta(task.getTargSite());
+
+                BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
+                if (Objects.isNull(curSta)) {
+                    throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+                }
+                if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+                    if (!curSta.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
+                        throw new CoolException("褰撳墠绔欑偣涓嶆槸F.鍦ㄥ簱鐘舵�侊紒锛�");
+                    }
+                }
+                if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+                    if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+                        throw new CoolException("鐩爣绔欑偣涓嶆槸O.绌洪棽鐘舵�侊紒锛�");
+                    }
+                }
+            }
+            items.add(itemParam);
+        });
+        taskParams.setTaskList(items);
+        /**浠诲姟涓嬪彂鎺ュ彛*/
+        String pubTakUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.pubTask;
+        /**RCS鍩虹閰嶇疆閾炬帴*/
+        log.info("浠诲姟涓嬪彂锛岃姹傚湴鍧�锛� {}锛� 璇锋眰鍙傛暟锛� {}", pubTakUrl, JSONObject.toJSONString(taskParams));
+        HttpHeaders headers = new HttpHeaders();
+        headers.add("Content-Type", "application/json");
+        headers.add("api-version", "v2.0");
+        HttpEntity httpEntity = new HttpEntity(taskParams, headers);
+        ResponseEntity<String> exchange = restTemplate.exchange(pubTakUrl, HttpMethod.POST, httpEntity, String.class);
+        log.info("浠诲姟涓嬪彂鍚庯紝鍝嶅簲缁撴灉锛� {}", exchange);
+        if (Objects.isNull(exchange.getBody())) {
+            throw new CoolException("浠诲姟涓嬪彂澶辫触锛侊紒");
+        } else {
+            try {
+                ObjectMapper objectMapper = new ObjectMapper();
+                objectMapper.coercionConfigDefaults()
+                        .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty);
+                CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class);
+                if (result.getCode() == 200) {
+                    tasks.forEach(task -> {
+
+                        if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+
+                            BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
+                            if (Objects.isNull(curSta)) {
+                                throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+                            }
+
+                            if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
+                                    .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_IN.id))) {
+                                throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+                            }
+                            /**鎺掗櫎绉诲簱鍔熻兘*/
+                            if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+                                /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍑哄簱棰勭害*/
+                                if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+                                    curSta.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+                                    if (!basStationService.updateById(curSta)) {
+                                        throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
+                                    }
+                                }
+                            }
+                        } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) {
+                            BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
+                            if (Objects.isNull(curSta)) {
+                                throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+                            }
+
+                            if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
+                                    .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_OUT.id))) {
+                                throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+                            }
+                            /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍏ュ簱棰勭害*/
+                            if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+                                curSta.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+                                if (!basStationService.updateById(curSta)) {
+                                    throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
+                                }
+                            }
+                        }
+                    });
+                } else {
+                    log.error(JSONObject.toJSONString(result));
+//                    throw new CoolException("浠诲姟涓嬪彂澶辫触锛侊紒");
+                }
+            } catch (JsonProcessingException e) {
+                throw new CoolException(e.getMessage());
+            }
+        }
+
+    }/**
+
+
     /**
      * @author Ryan
      * @date 2025/5/20
@@ -1325,7 +1562,7 @@
      * @version 1.0
      */
     @Transactional(rollbackFor = Exception.class)
-    public void complateInstock(Task task, Long loginUserId) {
+    public synchronized void complateInstock(Task task, Long loginUserId) {
         if (Objects.isNull(task)) {
             return;
         }
@@ -1343,12 +1580,9 @@
         if (taskItems.isEmpty()) {
             throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦紒锛�");
         }
-        try {
-            //鏇存柊搴撲綅鏄庣粏
-            saveLocItem(taskItems, task.getId(), loginUserId);
-        } catch (Exception e) {
-            throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
-        }
+
+        //鏇存柊搴撲綅鏄庣粏
+        saveLocItem(taskItems, task.getId(), loginUserId);
 
         /**瀵逛换鍔℃槑缁嗘寜缁勬嫋鏄庣粏杩涜鍒嗙粍*/
         Map<Long, List<TaskItem>> orderMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource));
@@ -1358,15 +1592,10 @@
                 throw new CoolException("鏁版嵁閿欒锛氱粍鎷栨暟鎹笉瀛樺湪锛岃鑱旂郴绠$悊鍛橈紒锛�");
             }
             List<TaskItem> items = orderMap.get(key);
-            try {
-                //淇濆瓨搴撳瓨鏄庣粏
-                saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType(), loginUserId);
-                //绉诲嚭鏀惰揣鍖哄簱瀛橈紝 淇敼缁勬墭鐘舵��
-                removeReceiptStock(pakinItem, loginUserId);
-            } catch (Exception e) {
-                logger.error("<UNK>", e);
-                throw new CoolException(e.getMessage());
-            }
+            //淇濆瓨鍏ュ嚭搴撴槑缁�
+            saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType(), loginUserId);
+            //绉诲嚭鏀惰揣鍖哄簱瀛橈紝 淇敼缁勬墭鐘舵��
+            removeReceiptStock(pakinItem, loginUserId);
         });
         /**淇敼搴撲綅鐘舵�佷负F.鍦ㄥ簱*/
         if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).eq(Loc::getCode, task.getTargLoc()))) {
@@ -1386,14 +1615,14 @@
      * @time 2025/4/30 16:32
      */
     @Transactional(rollbackFor = Exception.class)
-    public void removeReceiptStock(WaitPakinItem pakinItem, Long loginUserId) {
+    public synchronized void removeReceiptStock(WaitPakinItem pakinItem, Long loginUserId) {
         WarehouseAreasItem itemServiceOne = warehouseAreasItemService.getOne(new LambdaQueryWrapper<WarehouseAreasItem>()
                 .eq(WarehouseAreasItem::getId, pakinItem.getSource()));
         if (Objects.isNull(itemServiceOne)) {
             throw new CoolException("鏁版嵁閿欒锛氳鏌ョ湅璇疯揣鍖哄簱瀛樻槸鍚﹀瓨鍦紒锛�");
         }
-        Double workQty = Math.round((itemServiceOne.getWorkQty() - pakinItem.getAnfme()) * 10000) / 10000.0;
-        Double qty = Math.round((itemServiceOne.getQty() + pakinItem.getAnfme()) * 10000) / 10000.0;
+        Double workQty = Math.round((itemServiceOne.getWorkQty() - pakinItem.getAnfme()) * 1000000) / 1000000.0;
+        Double qty = Math.round((itemServiceOne.getQty() + pakinItem.getAnfme()) * 1000000) / 1000000.0;
         itemServiceOne.setWorkQty(workQty).setQty(qty);
 
         if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
@@ -1424,7 +1653,7 @@
      * @time 2025/4/15 15:28
      */
     @Transactional(rollbackFor = Exception.class)
-    public void saveLocItem(List<TaskItem> items, Long taskId, Long loginUserId) throws Exception {
+    public synchronized void saveLocItem(List<TaskItem> items, Long taskId, Long loginUserId) {
         Task task = this.getById(taskId);
         if (Objects.isNull(task)) {
             throw new CoolException("浠诲姟涓嶅瓨鍦�!!");
@@ -1440,8 +1669,8 @@
             LocItem locItem = locItemService.getOne(new LambdaQueryWrapper<LocItem>()
                     .eq(LocItem::getMatnrId, taskItem.getMatnrId())
                     .eq(LocItem::getLocId, loc.getId())
-                    .eq(StringUtils.isNoneBlank(taskItem.getBatch()), LocItem::getBatch, taskItem.getBatch())
-                    .eq(StringUtils.isNoneBlank(taskItem.getFieldsIndex()), LocItem::getFieldsIndex, taskItem.getFieldsIndex()));
+                    .eq(StringUtils.isNotBlank(taskItem.getBatch()), LocItem::getBatch, taskItem.getBatch())
+                    .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItem::getFieldsIndex, taskItem.getFieldsIndex()));
             if (Objects.isNull(locItem)) {
                 BeanUtils.copyProperties(taskItem, item);
                 item.setLocCode(loc.getCode())
@@ -1450,16 +1679,20 @@
                         .setUpdateBy(loginUserId)
                         .setWkType(taskItem.getWkType())
                         .setType(taskItem.getOrderType());
-                locItems.add(item);
+                if (!locItemService.saveOrUpdate(item)) {
+                    throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
+                }
             } else {
-                locItem.setAnfme(Math.round((locItem.getAnfme() + taskItem.getAnfme()) * 10000) / 10000.0)
-                        .setUpdateTime(new Date());
-                locItems.add(locItem);
+                logger.error("褰撳墠绁ㄥ彿:"  + locItem.getFieldsIndex()  + " 宸插湪搴撳唴锛岃妫�鏌ュ悗鍐嶆搷浣滐紒锛�");
+//                throw new CoolException("褰撳墠绁ㄥ彿宸插湪搴撳唴锛岃妫�鏌ュ悗鍐嶆搷浣滐紒锛�");
+//                locItem.setAnfme(Math.round((locItem.getAnfme() + taskItem.getAnfme()) * 1000000) / 1000000.0)
+//                        .setUpdateTime(new Date());
+//                if (!locItemService.saveOrUpdate(locItem)) {
+//                    throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
+//                }
             }
         });
-        if (!locItemService.saveBatch(locItems)) {
-            throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
-        }
+
     }
 
     /**
@@ -1470,7 +1703,7 @@
      * @return
      */
     @Transactional(rollbackFor = Exception.class)
-    public void saveStockItems(List<TaskItem> items, Task task, Long id, String code, Short wkType, String type, Long loginUserId) {
+    public synchronized void saveStockItems(List<TaskItem> items, Task task, Long id, String code, Short wkType, String type, Long loginUserId) {
         Stock stock = new Stock();
         String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null);
         if (StringUtils.isBlank(ruleCode)) {
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java
index 44b88bf..f76a019 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java
@@ -133,7 +133,9 @@
                 throw new CoolException("褰撳墠鐘舵�佹棤娉曚笅鍙戞墽琛岋紒锛�");
             }
 
-            List<WaveItem> items = waveItemService.list(new LambdaQueryWrapper<WaveItem>().eq(WaveItem::getWaveId, wave.getId()));
+            List<WaveItem> items = waveItemService.list(new LambdaQueryWrapper<WaveItem>()
+                    .le(WaveItem::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_EXCING.val)
+                    .eq(WaveItem::getWaveId, wave.getId()));
             if (items.isEmpty()) {
                 throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�");
             }
@@ -203,14 +205,29 @@
                     throw new CoolException("涓嬪彂鎵ц寮傚父锛岃绋嶅�欓噸璇曪紒");
                 }
             }
-            if (!waveService.update(new LambdaUpdateWrapper<Wave>()
-                    .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_TASK.val)
-                    .set(Wave::getWorkQty, taskItems.stream().mapToDouble(TaskItem::getAnfme).sum())
-                    .set(Wave::getUpdateBy, loginUserId)
-                    .set(Wave::getMemo, null)
-                    .set(Wave::getUpdateTime, new Date())
-                    .eq(Wave::getId, wave.getId()))) {
-                throw new CoolException("娉㈡鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+
+            Double sum = taskItems.stream().mapToDouble(TaskItem::getAnfme).sum();
+            Double v = Math.round((wave.getWorkQty() + sum) * 1000000) / 1000000.0;
+            if (wave.getAnfme().compareTo(v) == 0) {
+                if (!waveService.update(new LambdaUpdateWrapper<Wave>()
+                        .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_TASK.val)
+                        .set(Wave::getWorkQty, v)
+                        .set(Wave::getUpdateBy, loginUserId)
+                        .set(Wave::getMemo, null)
+                        .set(Wave::getUpdateTime, new Date())
+                        .eq(Wave::getId, wave.getId()))) {
+                    throw new CoolException("娉㈡鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+                }
+            } else {
+                if (!waveService.update(new LambdaUpdateWrapper<Wave>()
+                        .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_EXCING.val)
+                        .set(Wave::getWorkQty, v)
+                        .set(Wave::getUpdateBy, loginUserId)
+                        .set(Wave::getMemo, null)
+                        .set(Wave::getUpdateTime, new Date())
+                        .eq(Wave::getId, wave.getId()))) {
+                    throw new CoolException("娉㈡鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+                }
             }
         }
 
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
index aa46ba7..cfc5abf 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
@@ -8,15 +8,12 @@
 import com.vincent.rsf.server.manager.controller.dto.OrderOutItemDto;
 import com.vincent.rsf.server.manager.controller.params.WaveToLocParams;
 import com.vincent.rsf.server.manager.entity.*;
-import com.vincent.rsf.server.manager.enums.ContainerType;
 import com.vincent.rsf.server.manager.enums.TaskType;
 import com.vincent.rsf.server.manager.enums.WaveRuleType;
 import com.vincent.rsf.server.manager.service.*;
 import com.vincent.rsf.server.manager.enums.LocStsType;
-import io.swagger.models.auth.In;
 import org.apache.commons.lang3.StringUtils;
 
-import javax.swing.*;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -38,24 +35,24 @@
 
     public static String getTargetLoc(Long areaId, Long containerType) {
         Long locType = null;
-        if (!Objects.isNull(containerType)) {
-            LocTypeService locService = SpringUtils.getBean(LocTypeService.class);
-            if (containerType.equals(ContainerType.CONTAINER_TYPE_NORMAL.val)) {
-                LocType low = locService.getOne(new LambdaQueryWrapper<LocType>()
-                        .eq(LocType::getCode, "L"));
-                if (Objects.isNull(low)) {
-                    throw new CoolException("搴綅椤炲瀷涓嶅瓨鍦紒锛�");
-                }
-                locType = low.getId();
-            } else {
-                LocType low = locService.getOne(new LambdaQueryWrapper<LocType>()
-                        .eq(LocType::getCode, "H"));
-                if (Objects.isNull(low)) {
-                    throw new CoolException("搴綅椤炲瀷涓嶅瓨鍦紒锛�");
-                }
-                locType = low.getId();
-            }
-        }
+//        if (!Objects.isNull(containerType)) {
+//            LocTypeService locService = SpringUtils.getBean(LocTypeService.class);
+//            if (containerType.equals(ContainerType.CONTAINER_TYPE_NORMAL.val)) {
+//                LocType low = locService.getOne(new LambdaQueryWrapper<LocType>()
+//                        .eq(LocType::getCode, "L"));
+//                if (Objects.isNull(low)) {
+//                    throw new CoolException("搴綅椤炲瀷涓嶅瓨鍦紒锛�");
+//                }
+//                locType = low.getId();
+//            } else {
+//                LocType low = locService.getOne(new LambdaQueryWrapper<LocType>()
+//                        .eq(LocType::getCode, "H"));
+//                if (Objects.isNull(low)) {
+//                    throw new CoolException("搴綅椤炲瀷涓嶅瓨鍦紒锛�");
+//                }
+//                locType = low.getId();
+//            }
+//        }
         //TODO 搴撲綅绛栫暐鍚庣画鎺掓湡
         LocService locService = SpringUtils.getBean(LocService.class);
         Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>()
@@ -129,7 +126,12 @@
         LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>();
         locItemQueryWrapper.eq(LocItem::getMatnrCode, matnrCode);
         locItemQueryWrapper.eq(StringUtils.isNotEmpty(splrBatch), LocItem::getBatch, splrBatch);
-        locItemQueryWrapper.orderByAsc(LocItem::getCreateTime);
+        //濡傛灉鎵规涓嶄负绌猴紝鎸夋壒娆″厛鍚庡嚭搴�
+        if (StringUtils.isNotBlank(splrBatch)) {
+            locItemQueryWrapper.orderByAsc(LocItem::getBatch);
+        } else {
+            locItemQueryWrapper.orderByAsc(LocItem::getCreateTime);
+        }
         String applySql = String.format(
                 "EXISTS (SELECT 1 FROM man_loc ml " +
                         "WHERE ml.use_status = '%s'" +
@@ -156,6 +158,8 @@
         DeviceSiteService deviceSiteService = SpringUtils.getBean(DeviceSiteService.class);
 
         List<OrderOutItemDto> list = new ArrayList<>();
+        //涓嶈绔欑偣閲嶅浣跨敤闂
+        List<BasStation> stations = new ArrayList<>();
         Set<ExistDto> existDtos = new HashSet<>();
         for (WaveToLocParams item : params) {
             BigDecimal issued = new BigDecimal(item.getAnfme().toString())
@@ -175,7 +179,6 @@
                     locItems = LocManageUtil.getFirstInFirstOutItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme());
                 }
             }
-
             for (LocItem locItem : locItems) {
                 Loc loc = locService.getById(locItem.getLocId());
                 List<LocItem> itemList = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, locItem.getLocCode()));
@@ -184,8 +187,8 @@
                     if (existDtos.add(existDto)) {
                         locItem.setOutQty(issued.doubleValue() >= locItem.getAnfme() ? locItem.getAnfme() : issued.doubleValue());
                         locItem.setBarcode(loc.getBarcode())
-                                .setSourceId(item.getWaveId())
-                                .setSource(item.getItemId());
+                                .setSourceId(item.getWaveId())//娉㈡ID
+                                .setSource(item.getItemId());//娉㈡鏄庣粏ID
                         OrderOutItemDto orderOutItemDto = new OrderOutItemDto();
                         orderOutItemDto.setLocItem(locItem);
 
@@ -203,12 +206,18 @@
                                 maps.add(staListDto);
                             }
                             orderOutItemDto.setStaNos(maps);
-                            //榛樿鑾峰彇绗竴绔欑偣
-                            DeviceSite deviceSite = deviceSites.stream().findFirst().get();
+                            //鑾峰彇婊¤冻鏉′欢绔欑偣
+                            Set<String> stationSet = deviceSites.stream().map(DeviceSite::getSite).collect(Collectors.toSet());
+                            //宸蹭娇鐢ㄧ珯鐐�
+                            Set<String> stas = stations.stream().map(BasStation::getStationName).collect(Collectors.toSet());
                             BasStationService basStationService = SpringUtils.getBean(BasStationService.class);
                             BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                                     .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
+                                    .in(BasStation::getStationName, stationSet)
+                                    .notIn(!stas.isEmpty(), BasStation::getStationName, stas)
                                     .last("LIMIT 1"));
+                            stations.add(basStation);
+
                             if (Objects.isNull(basStation)) {
                                 throw new CoolException("绔欓粸涓嶅瓨鍦紒锛�");
                             }
@@ -217,7 +226,6 @@
 
                         orderOutItemDto.setSource(item.getItemId())
                                 .setSourceId(item.getWaveId());
-
                         list.add(orderOutItemDto);
 
                         issued = issued.subtract(new BigDecimal(locItem.getAnfme().toString()));

--
Gitblit v1.9.1