From 5604c2dd5bb8bce148aaed0367e0cc84a09aedcc Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期一, 28 四月 2025 17:41:10 +0800
Subject: [PATCH] Merge branch 'devlop' of http://47.97.1.152:5880/r/wms-master into devlop

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java |   63 ++++++++++-----
 /dev/null                                                                                 |   18 ----
 rsf-admin/src/page/waitPakin/SelectSiteModel.jsx                                          |   38 ++++++---
 rsf-admin/src/page/deviceBind/DeviceBindEdit.jsx                                          |    7 -
 rsf-server/src/main/java/com/vincent/rsf/server/api/controller/params/TaskInParam.java    |    1 
 rsf-admin/src/page/deviceBind/DeviceBindCreate.jsx                                        |    9 +-
 rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java          |    7 +
 rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java      |   55 ++++++-------
 8 files changed, 103 insertions(+), 95 deletions(-)

diff --git a/rsf-admin/src/page/deviceBind/DeviceBindCreate.jsx b/rsf-admin/src/page/deviceBind/DeviceBindCreate.jsx
index 101d8d4..c8e60f9 100644
--- a/rsf-admin/src/page/deviceBind/DeviceBindCreate.jsx
+++ b/rsf-admin/src/page/deviceBind/DeviceBindCreate.jsx
@@ -128,11 +128,10 @@
                                         parse={v => v}
                                     />
                                 </Grid>
-                                <Grid item xs={6} display="flex" gap={1}>
-                                    <NumberInput
-                                        label="table.field.deviceBind.typeId"
-                                        source="typeId"
-                                    />
+                                <Grid item xs={6} display="flex" gap={1}>                                    
+                                    <ReferenceInput source="typeId" label="table.field.deviceBind.typeId" reference="warehouseAreas" filter={{}}>
+                                        <AutocompleteInput optionValue="id" optionText="name" label="table.field.deviceBind.typeId" />
+                                    </ReferenceInput>
                                 </Grid>
                                 <Grid item xs={6} display="flex" gap={1}>
                                     <TextInput
diff --git a/rsf-admin/src/page/deviceBind/DeviceBindEdit.jsx b/rsf-admin/src/page/deviceBind/DeviceBindEdit.jsx
index 9bd771b..f93e7fd 100644
--- a/rsf-admin/src/page/deviceBind/DeviceBindEdit.jsx
+++ b/rsf-admin/src/page/deviceBind/DeviceBindEdit.jsx
@@ -108,10 +108,9 @@
                             />
                         </Stack>
                         <Stack direction='row' gap={2}>
-                            <NumberInput
-                                label="table.field.deviceBind.typeId"
-                                source="typeId"
-                            />
+                            <ReferenceInput source="typeId" label="table.field.deviceBind.typeId" reference="warehouseAreas" filter={{}}>
+                                <AutocompleteInput optionValue="id" optionText="name" label="table.field.deviceBind.typeId" />
+                            </ReferenceInput>
                         </Stack>
                         <Stack direction='row' gap={2}>
                             <TextInput
diff --git a/rsf-admin/src/page/waitPakin/SelectSiteModel.jsx b/rsf-admin/src/page/waitPakin/SelectSiteModel.jsx
index 26ed4ed..3c828af 100644
--- a/rsf-admin/src/page/waitPakin/SelectSiteModel.jsx
+++ b/rsf-admin/src/page/waitPakin/SelectSiteModel.jsx
@@ -19,6 +19,27 @@
     },
 }));
 
+const SelectSiteButton = (props) => {
+    const { source, setOpen, refresh, notify } = props;
+    const record = useRecordContext();
+    
+    const handleClick = async () => {
+        setOpen(false);
+        const id = record.id;
+        const res = await request.post(`/waitPakin/merge`, {waitPakins: source, siteId: id});
+        if (res?.data?.code === 200) {
+            refresh();
+            notify(res.data.msg);
+        } else {
+            notify(res.data.msg);
+        }
+    };
+    
+    return (
+        <Button label="toolbar.selectSite" onClick={handleClick} />
+    );
+};
+
 const SelectSiteModel = (props) => {
     const { open, setOpen, source } = props;
     const translate = useTranslate();
@@ -47,6 +68,7 @@
                 <DialogContent>
                     <List
                         resource='deviceSite'
+                        filter={{type : 1}}
                         sx={{
                             flexGrow: 1,
                             transition: (theme) =>
@@ -68,17 +90,7 @@
                         <StyledDatagrid
                             preferenceKey='deviceSite'
                             bulkActionButtons={false}
-                            rowClick='toggleSelection'
-                            onToggleItem={async (id)=>{
-                                setOpen(false);
-                                const res = await request.post(`/waitPakin/merge`, {waitPakins: source, siteId: id});
-                                if (res?.data?.code === 200) {
-                                    refresh();
-                                    notify(res.data.msg);
-                                } else {
-                                    notify(res.data.msg);
-                                }
-                            }}
+                            rowClick={false}                            
                             omit={['id','name', 'createTime','label', 'createBy', 'memo', 'updateBy$', 'createBy$', 'createTime', 'updateTime']}
                         >
                             <NumberField source="id" />
@@ -97,9 +109,7 @@
                             <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">
-                                <Button label="toolbar.selectSite" onClick={(event)=>{ 
-                                    setOpen(false)
-                                 }}/>
+                            <SelectSiteButton source={source} setOpen={setOpen} refresh={refresh} notify={notify} />
                             </WrapperField>
                         </StyledDatagrid>
                     </List>
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/params/TaskInParam.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/params/TaskInParam.java
index ecb50ac..aee0ee6 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/params/TaskInParam.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/params/TaskInParam.java
@@ -9,7 +9,6 @@
     private Integer sourceStaNo; //浣滀笟绔欑偣 or 鏉ユ簮绔欑偣
     private String barcode; //瀹瑰櫒鏉$爜
     private Integer locType1; //搴撲綅绫诲瀷
-    private Integer area;
 //    private Integer locType2; //搴撲綅绫诲瀷
 //    private Integer locType3; //搴撲綅绫诲瀷
 }
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/enums/LocUseStatusType.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/enums/LocUseStatusType.java
deleted file mode 100644
index dfb4da7..0000000
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/entity/enums/LocUseStatusType.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.vincent.rsf.server.api.entity.enums;
-
-public enum LocUseStatusType {
-    Empty_Slot("O","绌哄簱浣�"),
-    In_Stock("F","鍦ㄥ簱"),
-    Empty_Pallet("D","绌烘墭鐩�")
-    ;
-
-
-
-    LocUseStatusType(String type, String desc) {
-        this.type = type;
-        this.desc = desc;
-    }
-
-    public String type;
-    public String desc;
-}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
index 57b3e1f..269072b 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
@@ -7,7 +7,6 @@
 import com.vincent.rsf.server.api.entity.dto.InTaskMsgDto;
 import com.vincent.rsf.server.api.entity.dto.LocTypeDto;
 import com.vincent.rsf.server.api.controller.params.TaskInParam;
-import com.vincent.rsf.server.api.entity.enums.LocUseStatusType;
 import com.vincent.rsf.server.api.entity.enums.OrderType;
 import com.vincent.rsf.server.api.entity.enums.TaskStsType;
 import com.vincent.rsf.server.api.entity.enums.TaskType;
@@ -316,7 +315,11 @@
         if (Cools.isEmpty(deviceSites)) {
             throw new CoolException("鏈壘鍒扮珯鐐硅矾寰勪俊鎭�");
         }
-        WarehouseAreas warehouseArea = warehouseAreasService.getById(param.getArea());
+        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(param.getSourceStaNo()));
+        if (Cools.isEmpty(deviceBind)) {
+            throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�===>搴撲綅瑙勫垯鏈煡");
+        }
+        WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
         if (Cools.isEmpty(warehouseArea)) {
             throw new CoolException("鏈壘鍒版墍灞炲簱鍖轰俊鎭�");
         }
@@ -324,18 +327,18 @@
         InTaskMsgDto dto = null;
         switch (warehouseArea.getType()) {
             case "CRN": //鍫嗗灈鏈�
-                dto = getLocNoCrn(param.getArea(), param.getSourceStaNo(), matnr,batch, locTypeDto, 0, param.getIoType());
+                dto = getLocNoCrn(deviceBind,warehouseArea.getId(), param.getSourceStaNo(), matnr,batch, locTypeDto, 0, param.getIoType());
                 break;
             case "SXC": //鍥涘悜搴�
                 break;
             case "CTU": //ctu
-                dto = getLocNoCtu(param.getArea(), param.getSourceStaNo(), matnr,batch, locTypeDto, 0, param.getIoType());
+                dto = getLocNoCtu(deviceBind,warehouseArea.getId(), param.getSourceStaNo(), matnr,batch, locTypeDto, 0, param.getIoType());
                 break;
         }
         return dto;
     }
 
-    private InTaskMsgDto getLocNoCrn(Integer area,Integer sourceStaNo, String matnr, String batch,LocTypeDto locTypeDto, int times,Integer ioType){
+    private InTaskMsgDto getLocNoCrn(DeviceBind deviceBind,Long area,Integer sourceStaNo, String matnr, String batch,LocTypeDto locTypeDto, int times,Integer ioType){
         if (Cools.isEmpty(matnr)) {  //鐗╂枡鍙�
             matnr = "";
         }
@@ -350,10 +353,7 @@
         Loc loc = null;     // 鐩爣搴撲綅
 
         InTaskMsgDto inTaskMsgDto = new InTaskMsgDto();
-        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(sourceStaNo));
-        if (Cools.isEmpty(deviceBind)) {
-            throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�===>搴撲綅瑙勫垯鏈煡");
-        }
+
         int sRow = deviceBind.getStartRow();
         int eRow = deviceBind.getEndRow();
         int deviceQty = deviceBind.getDeviceQty();
@@ -386,7 +386,7 @@
                     String shallowLocNo = LocUtils.getShallowLoc(slaveProperties, loc1.getCode());
                     // 妫�娴嬬洰鏍囧簱浣嶆槸鍚︿负绌哄簱浣�
                     Loc shallowLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode,shallowLocNo));
-                    if (shallowLoc != null && shallowLoc.getUseStatus().equals(LocUseStatusType.Empty_Slot.type)) {
+                    if (shallowLoc != null && shallowLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
                         if (LocUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) {
                                 loc = shallowLoc;
                                 deviceNo = shallowLoc.getDeviceNo();
@@ -445,7 +445,7 @@
             List<Loc> locMasts = null;
             locMasts = locService.list(new LambdaQueryWrapper<Loc>()
                     .eq(Loc::getRow, nearRow)
-                    .eq(Loc::getUseStatus, LocUseStatusType.Empty_Slot.type)
+                    .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                     .eq(Loc::getType, locTypeDto.getLocType1())
                     .eq(Loc::getAreaId,area)
                     .orderByAsc(Loc::getLev)
@@ -460,7 +460,7 @@
                     //鐩镐技鐗╂枡鎵撳紑锛屽垽鏂繁搴撲綅鏈夋病鏈夎揣锛屾病璐у氨鏀炬繁搴撲綅锛屾湁璐у氨涓嶆搷浣�
                     Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                             .eq(Loc::getRow, shallowLoc)
-                            .eq(Loc::getUseStatus, LocUseStatusType.Empty_Slot.type)
+                            .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                             .eq(Loc::getAreaId,area)
                     );
                     if (!Cools.isEmpty(locMast2)) {
@@ -471,7 +471,7 @@
                     //鐩镐技鐗╂枡鍏抽棴锛屽垽鏂繁搴撲綅鏈夋病鏈夎揣锛屾湁璐у氨鏀炬祬搴撲綅锛屾棤璐у氨涓嶆搷浣�
                     Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                             .eq(Loc::getCode, shallowLoc)
-                            .in(Loc::getUseStatus, LocUseStatusType.Empty_Pallet.type,LocUseStatusType.In_Stock.type)
+                            .in(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type,LocStsType.LOC_STS_TYPE_F.type)
                             .eq(Loc::getAreaId,area)
                     );
                     if (!Cools.isEmpty(locMast2)) {
@@ -480,7 +480,7 @@
                     }else{
                         locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                                 .eq(Loc::getCode, shallowLoc)
-                                .eq(Loc::getUseStatus, LocUseStatusType.Empty_Slot.type)
+                                .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                                 .eq(Loc::getAreaId,area)
                         );
                         if (!Cools.isEmpty(locMast2)) {
@@ -499,7 +499,7 @@
                         String shallowLoc = LocUtils.getDeepLoc(slaveProperties, locMast1.getCode());
                         Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                                 .eq(Loc::getCode, shallowLoc)
-                                .eq(Loc::getUseStatus, "O")
+                                .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                                 .eq(Loc::getAreaId,area)
                         );
                         if (!Cools.isEmpty(locMast2)) {
@@ -508,7 +508,7 @@
                         } else {
                             locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                                     .eq(Loc::getCode, shallowLoc)
-                                    .in(Loc::getUseStatus, LocUseStatusType.Empty_Pallet.type,LocUseStatusType.In_Stock.type)
+                                    .in(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type,LocStsType.LOC_STS_TYPE_D.type)
                                     .eq(Loc::getAreaId,area)
                             );
                             if (!Cools.isEmpty(locMast2)) {
@@ -527,7 +527,7 @@
         }
         //鏌ヨ褰撳墠搴撲綅绫诲瀷绌哄簱浣� 灏忎簬5涓垯locmast = null
         List<Loc> locTypeLocMasts = locService.list(new LambdaQueryWrapper<Loc>()
-                .eq(Loc::getUseStatus, LocUseStatusType.Empty_Slot.type)
+                .eq(Loc::getUseStatus,LocStsType.LOC_STS_TYPE_O.type)
                 .eq(Loc::getDeviceNo, deviceNo)
                 .eq(Loc::getType, locTypeDto.getLocType1())
                 .eq(Loc::getAreaId,area)
@@ -536,18 +536,18 @@
             loc = null;
         }
         // 閫掑綊鏌ヨ
-        if (Cools.isEmpty(loc) || !loc.getUseStatus().equals(LocUseStatusType.Empty_Slot.type)) {
+        if (Cools.isEmpty(loc) || !loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
             // 褰撳墠宸烽亾鏃犵┖搴撲綅鏃讹紝閫掑綊璋冩暣鑷充笅涓�宸烽亾锛屾绱㈠叏閮ㄥ贩閬撴棤鏋滃悗锛岃烦鍑洪�掑綊
             if (times < rowCount * 2) {
                 times = times + 1;
-                return getLocNoCrn(area,sourceStaNo,matnr,batch,locTypeDto,times, ioType);
+                return getLocNoCrn(deviceBind,area,sourceStaNo,matnr,batch,locTypeDto,times, ioType);
 
             }
             // 2.搴撲綅褰撳墠鎵�灞炲昂瀵告棤绌哄簱浣嶆椂锛岃皟鏁村昂瀵稿弬鏁帮紝鍚戜笂鍏煎妫�绱㈠簱浣�
             if (locTypeDto.getLocType1() < 3) {
                 int i = locTypeDto.getLocType1() + 1;
                 locTypeDto.setLocType1(i);
-                return getLocNoCrn(area,sourceStaNo,matnr,batch,locTypeDto,0, ioType);
+                return getLocNoCrn(deviceBind,area,sourceStaNo,matnr,batch,locTypeDto,0, ioType);
             }
             throw new CoolException("娌℃湁绌哄簱浣�");
         }
@@ -561,7 +561,7 @@
         return inTaskMsgDto;
     }
 
-    private InTaskMsgDto getLocNoCtu(Integer area,Integer sourceStaNo, String matnr, String batch,LocTypeDto locTypeDto, int times,Integer ioType){
+    private InTaskMsgDto getLocNoCtu(DeviceBind deviceBind,Long area,Integer sourceStaNo, String matnr, String batch,LocTypeDto locTypeDto, int times,Integer ioType){
         if (Cools.isEmpty(matnr)) {  //鐗╂枡鍙�
             matnr = "";
         }
@@ -571,14 +571,9 @@
         int deviceNo = 0;
         Loc loc = new Loc();
         InTaskMsgDto inTaskMsgDto = new InTaskMsgDto();
-        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(sourceStaNo));
-        if (Cools.isEmpty(deviceBind)) {
-            throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�===>搴撲綅瑙勫垯鏈煡");
-        }
-
         List<Loc> loc1 = locService.list(new LambdaQueryWrapper<Loc>()
                 .eq(Loc::getAreaId, area)
-                .eq(Loc::getUseStatus, LocUseStatusType.Empty_Slot.type)
+                .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                 .eq(Loc::getType, locTypeDto.getLocType1())
                 .orderByAsc(Loc::getRow)
                 .orderByAsc(Loc::getCol)
@@ -604,18 +599,18 @@
             inTaskMsgDto.setStaNo(Integer.parseInt(deviceSite.getDeviceSite()));
         }
         // 閫掑綊鏌ヨ
-        if (Cools.isEmpty(loc) || !loc.getUseStatus().equals(LocUseStatusType.Empty_Slot.type)) {
+        if (Cools.isEmpty(loc) || !loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
             // 褰撳墠宸烽亾鏃犵┖搴撲綅鏃讹紝閫掑綊璋冩暣鑷充笅涓�宸烽亾锛屾绱㈠叏閮ㄥ贩閬撴棤鏋滃悗锛岃烦鍑洪�掑綊
             if (times < 5) {
                 times = times + 1;
-                return getLocNoCrn(area,sourceStaNo,matnr,batch,locTypeDto,times, ioType);
+                return getLocNoCtu(deviceBind,area,sourceStaNo,matnr,batch,locTypeDto,times, ioType);
 
             }
             // 2.搴撲綅褰撳墠鎵�灞炲昂瀵告棤绌哄簱浣嶆椂锛岃皟鏁村昂瀵稿弬鏁帮紝鍚戜笂鍏煎妫�绱㈠簱浣�
             if (locTypeDto.getLocType1() < 3) {
                 int i = locTypeDto.getLocType1() + 1;
                 locTypeDto.setLocType1(i);
-                return getLocNoCrn(area,sourceStaNo,matnr,batch,locTypeDto,0, ioType);
+                return getLocNoCtu(deviceBind,area,sourceStaNo,matnr,batch,locTypeDto,0, ioType);
             }
             throw new CoolException("娌℃湁绌哄簱浣�");
         }
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 3943f40..d4b4f22 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
@@ -2,11 +2,13 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.vincent.rsf.framework.common.Cools;
 import com.vincent.rsf.server.api.entity.enums.OrderType;
 import com.vincent.rsf.server.api.entity.enums.TaskStsType;
 import com.vincent.rsf.framework.common.R;
 import com.vincent.rsf.framework.exception.CoolException;
 import com.vincent.rsf.server.api.entity.enums.TaskType;
+import com.vincent.rsf.server.api.utils.LocUtils;
 import com.vincent.rsf.server.manager.controller.params.GenerateTaskParams;
 import com.vincent.rsf.server.manager.entity.*;
 import com.vincent.rsf.server.manager.enums.PakinIOStatus;
@@ -62,6 +64,11 @@
     @Autowired
     private LocItemService locItemService;
 
+    @Autowired
+    private DeviceBindService deviceBindService;
+    @Autowired
+    private WarehouseAreasService warehouseAreasService;
+
 
     /**
      * @param
@@ -82,6 +89,20 @@
         if (Objects.isNull(deviceSite)) {
             throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
         }
+        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(Integer.valueOf(deviceSite.getSite())));
+        if (Cools.isEmpty(deviceBind)) {
+            throw new CoolException("搴撲綅瑙勫垯鏈煡");
+        }
+        WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
+        if (Cools.isEmpty(warehouseArea)) {
+            throw new CoolException("鏈壘鍒版墍灞炲簱鍖轰俊鎭�");
+        }
+
+        /**鑾峰彇搴撲綅*/
+        String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId());
+        if (Cools.isEmpty(targetLoc)) {
+            throw new CoolException("璇ョ珯鐐瑰搴斿簱鍖烘湭鎵惧埌搴撲綅");
+        }
         /**鑾峰彇缁勬嫋*/
         List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList());
         List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
@@ -100,28 +121,28 @@
             task.setTaskCode(ruleCode)
                     .setTaskStatus(TaskStsType.GENERATE_IN.id.shortValue())
                     .setTaskType(TaskType.TASK_TYPE_IN.type.shortValue())
-                    .setTargLoc(LocManageUtil.getTargetLoc())
+                    .setTargLoc(targetLoc)
                     .setBarcode(pakin.getBarcode())
-                    .setTargSite(deviceSite.getDeviceCode())
+                    .setOrgSite(deviceSite.getSite())
+                    .setTargSite(deviceSite.getDeviceSite())
                     .setCreateBy(loginUserId)
                     .setUpdateBy(loginUserId);
-
-            if (!Objects.isNull(waitPakin.getSiteId()) && waitPakin.getSiteId() > 0) {
-                DeviceSite site = deviceSiteService.getById(waitPakin.getSiteId());
-                task.setTargSite(site.getSite() + "");
-            } else {
-                task.setTargSite(LocManageUtil.getTargetSite());
-            }
-            if (!Objects.isNull(waitPakin.getLocCode()) && StringUtils.isNotBlank(waitPakin.getLocCode())) {
-                List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, waitPakin.getLocCode()));
-//                if (!locs.isEmpty()) {
-//                    throw new CoolException("搴撲綅閿欒锛氱浉鍚屽簱浣嶅簲鍙竴鏉�")
-//                }
-                Loc loc = locs.stream().findFirst().get();
-                task.setTargSite(loc.getCode());
-            } else {
-                task.setTargSite(LocManageUtil.getTargetSite());
-            }
+//            if (!Objects.isNull(waitPakin.getSiteId()) && waitPakin.getSiteId() > 0) {
+//                DeviceSite site = deviceSiteService.getById(waitPakin.getSiteId());
+//                task.setTargSite(site.getSite() + "");
+//            } else {
+//                task.setTargSite(LocManageUtil.getTargetSite());
+//            }
+//            if (!Objects.isNull(waitPakin.getLocCode()) && StringUtils.isNotBlank(waitPakin.getLocCode())) {
+//                List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, waitPakin.getLocCode()));
+////                if (!locs.isEmpty()) {
+////                    throw new CoolException("搴撲綅閿欒锛氱浉鍚屽簱浣嶅簲鍙竴鏉�")
+////                }
+//                Loc loc = locs.stream().findFirst().get();
+//                task.setTargSite(loc.getCode());
+//            } else {
+//                task.setTargSite(LocManageUtil.getTargetSite());
+//            }
 
             if (!this.save(task)) {
                 throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
@@ -231,7 +252,7 @@
      * @time 2025/4/15 15:28
      */
     @Transactional(rollbackFor = Exception.class)
-    void saveLocItem(List<TaskItem> items, Long taskId) throws Exception {
+    public void saveLocItem(List<TaskItem> items, Long taskId) throws Exception {
         Task task = this.getById(taskId);
         if (Objects.isNull(task)) {
             throw new CoolException("浠诲姟涓嶅瓨鍦�!!");
@@ -255,7 +276,7 @@
      * @return
      */
     @Transactional(rollbackFor = Exception.class)
-    void saveStockItems(List<TaskItem> items, WaitPakinItem order) throws Exception {
+    public void saveStockItems(List<TaskItem> items, WaitPakinItem order) throws Exception {
         Stock stock = new Stock();
 //        if (!Objects.isNull(order.getPoCode()) && StringUtils.isNotBlank(order.getPoCode())) {
 //            Purchase purchase = purchaseService.getOne(new LambdaQueryWrapper<Purchase>().eq(Purchase::getCode, order.getPoCode()));
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 49a869f..07f3f46 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
@@ -21,11 +21,14 @@
      * @return
      * @time 2025/3/31 08:50
      */
-    public static String getTargetLoc() {
+    public static String getTargetLoc(Long areaId) {
         //TODO 搴撲綅绛栫暐鍚庣画鎺掓湡
         LocService locService = SpringUtils.getBean(LocService.class);
 
-        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type), false);
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>()
+                .eq(Loc::getAreaId, areaId)
+                .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type), false
+        );
 
         return !Objects.isNull(loc) ? loc.getCode() : null;
     }

--
Gitblit v1.9.1