cl
9 小时以前 8943a4e9f5ee1455c56ac4af60d941fa23731051
重量
14个文件已修改
219 ■■■■ 已修改文件
rsf-open-api/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/params/LocationAllocateParams.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/impl/WmsRcsServiceImpl.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/api/controller/WcsController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/TaskInParam.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/api/service/WcsService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java 75 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Stock.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockItem.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/RcsTestServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java 68 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-open-api/pom.xml
@@ -59,6 +59,11 @@
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-crypto</artifactId>
        </dependency>
        <!-- 电视机报警:RCS 回调写入与 zy-monitor-admin 相同的 Redis 键 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
    </dependencies>
    <build>
        <finalName>rsf-open-api</finalName>
rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/params/LocationAllocateParams.java
@@ -6,6 +6,7 @@
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@Accessors(chain = true)
@@ -24,4 +25,7 @@
    @ApiModelProperty(value = "入库类型", required = true)
    private Integer type;
    @ApiModelProperty(value = "重量,4位小数")
    private BigDecimal weight;
}
rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/impl/WmsRcsServiceImpl.java
@@ -426,7 +426,7 @@
    @Transactional(rollbackFor = Exception.class)
    public R allocateLocation(LocationAllocateParams params) {
        log.info("========== 开始申请入库任务,分配库位 ==========");
        log.info("料箱码:{},入库站点:{},入库类型:{}", params.getBarcode(), params.getStaNo(), params.getType());
        log.info("料箱码:{},入库站点:{},入库类型:{},重量:{}", params.getBarcode(), params.getStaNo(), params.getType(), params.getWeight());
        
        // 调用WMS server内部接口进行库位分配
        String wmsUrl = getWmsBaseUrl() + "/rsf-server/wcs/allocate/location";
@@ -438,6 +438,9 @@
        requestParams.put("staNo", params.getStaNo());
        requestParams.put("type", params.getType());
        requestParams.put("full", params.getFull());
        if (params.getWeight() != null) {
            requestParams.put("weight", params.getWeight());
        }
        log.info("请求参数:{}", requestParams.toJSONString());
        
        HttpHeaders headers = new HttpHeaders();
rsf-server/src/main/java/com/vincent/rsf/server/api/controller/WcsController.java
@@ -28,6 +28,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.Map;
@RestController
@@ -172,6 +173,7 @@
                full = Boolean.parseBoolean(params.get("full").toString());
            }
        }
        BigDecimal weight = parseAllocateWeight(params.get("weight"));
        if (Cools.isEmpty(barcode)) {
            return R.error("料箱码不能为空!!");
        }
@@ -181,7 +183,24 @@
        if (type == null) {
            return R.error("入库类型不能为空!!");
        }
        return wcsService.allocateLocation(barcode, staNo, type, full);
        return wcsService.allocateLocation(barcode, staNo, type, full, weight);
    }
    private static BigDecimal parseAllocateWeight(Object raw) {
        if (raw == null) {
            return null;
        }
        if (raw instanceof BigDecimal) {
            return (BigDecimal) raw;
        }
        if (raw instanceof Number) {
            return new BigDecimal(raw.toString());
        }
        String s = raw.toString().trim();
        if (s.isEmpty()) {
            return null;
        }
        return new BigDecimal(s);
    }
    @ApiOperation("空板出库:从指定空板库位生成出库任务至目标站点")
rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/TaskInParam.java
@@ -5,6 +5,8 @@
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
@Data
@Accessors(chain = true)
@ApiModel(value = "TaskInParam", description = "WCS调度参数")
@@ -31,6 +33,9 @@
    private Long user;
    private String orgLoc;
    @ApiModelProperty("重量,4位小数")
    private BigDecimal weight;
//    private Integer locType2; //库位类型
//    private Integer locType3; //库位类型
}
rsf-server/src/main/java/com/vincent/rsf/server/api/service/WcsService.java
@@ -3,6 +3,8 @@
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.server.api.entity.dto.InTaskMsgDto;
import com.vincent.rsf.server.api.controller.erp.params.TaskInParam;
import java.math.BigDecimal;
import com.vincent.rsf.server.api.entity.params.ExMsgParams;
import com.vincent.rsf.server.api.entity.params.WcsTaskParams;
@@ -19,5 +21,5 @@
    R pubWcsTask(WcsTaskParams params);
    R allocateLocation(String barcode, String staNo, Integer type, Boolean full);
    R allocateLocation(String barcode, String staNo, Integer type, Boolean full, BigDecimal weight);
}
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
@@ -51,6 +51,8 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -143,7 +145,7 @@
        // 空板入库:与非空板同一入口,仅不校验组托,只做分配库位、建任务、更新库位
        if (param.getIoType() != null && param.getIoType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
            return createInTaskForEmptyPallet(param.getBarcode(), param.getSourceStaNo(), param.getLocType1());
            return createInTaskForEmptyPallet(param);
        }
        // 提前定义 waitPakin / waitPakinItems,供后续其他入库逻辑使用
@@ -262,6 +264,12 @@
                    log.warn("更新拣料入库任务的入库站点失败 - 任务编码:{}", pickInTask.getTaskCode());
                }
            }
            if (param.getWeight() != null) {
                pickInTask.setWeight(param.getWeight());
                if (!taskService.updateById(pickInTask)) {
                    log.warn("更新拣料入库任务重量失败 - 任务编码:{}", pickInTask.getTaskCode());
                }
            }
            // 返回拣料入库任务的信息
            InTaskMsgDto msgDto = new InTaskMsgDto();
@@ -313,6 +321,12 @@
                checkInTask.setOrgSite(param.getSourceStaNo());
                if (!taskService.updateById(checkInTask)) {
                    log.warn("更新盘点入库任务的入库站点失败 - 任务编码:{}", checkInTask.getTaskCode());
                }
            }
            if (param.getWeight() != null) {
                checkInTask.setWeight(param.getWeight());
                if (!taskService.updateById(checkInTask)) {
                    log.warn("更新盘点入库任务重量失败 - 任务编码:{}", checkInTask.getTaskCode());
                }
            }
@@ -395,6 +409,12 @@
                    log.warn("更新入库任务的入库站点失败 - 任务编码:{}", existingInTask.getTaskCode());
                }
            }
            if (param.getWeight() != null) {
                existingInTask.setWeight(param.getWeight());
                if (!taskService.updateById(existingInTask)) {
                    log.warn("更新入库任务重量失败 - 任务编码:{}", existingInTask.getTaskCode());
                }
            }
            // 直接返回已有任务信息,不再新建任务
            InTaskMsgDto msgDto = new InTaskMsgDto();
@@ -424,10 +444,11 @@
        }
        // 创建并保存任务
        Task task = createTask(ruleCode, locNo.getLocNo(), waitPakin.getBarcode(),
                deviceSite.getDeviceSite(), param.getSourceStaNo().toString(), param.getUser());
                deviceSite.getDeviceSite(), param.getSourceStaNo().toString(), param.getUser(),
                TaskType.TASK_TYPE_IN.type, param.getWeight());
        // 更新库位状态
        updateLocStatus(task.getTargLoc(), waitPakin.getBarcode());
        updateLocStatus(task.getTargLoc(), waitPakin.getBarcode(), param.getWeight());
        // 获取并验证组拖明细
        waitPakinItems = getWaitPakinItems(waitPakin.getId());
@@ -584,16 +605,16 @@
    /**
     * 创建并保存任务
     */
    private Task createTask(String ruleCode, String targetLoc, String barcode,
                            String targetSite, String sourceSiteNo, Long loginUserId) {
        return createTask(ruleCode, targetLoc, barcode, targetSite, sourceSiteNo, loginUserId, TaskType.TASK_TYPE_IN.type);
    }
//    private Task createTask(String ruleCode, String targetLoc, String barcode,
//                            String targetSite, String sourceSiteNo, Long loginUserId) {
//        return createTask(ruleCode, targetLoc, barcode, targetSite, sourceSiteNo, loginUserId, TaskType.TASK_TYPE_IN.type, null);
//    }
    /**
     * 创建并保存任务(支持指定任务类型,如空板入库)
     */
    private Task createTask(String ruleCode, String targetLoc, String barcode,
                            String targetSite, String sourceSiteNo, Long loginUserId, Integer taskType) {
                            String targetSite, String sourceSiteNo, Long loginUserId, Integer taskType, BigDecimal weight) {
        Task task = new Task();
        task.setTaskCode(ruleCode)
                .setTaskStatus(TaskStsType.GENERATE_IN.id)
@@ -605,6 +626,9 @@
                .setCreateBy(loginUserId)
                .setUpdateBy(loginUserId)
                .setOrgSite(sourceSiteNo);
        if (weight != null) {
            task.setWeight(weight);
        }
        if (!taskService.save(task)) {
            throw new CoolException("任务保存失败!!");
@@ -615,11 +639,13 @@
    /**
     * 更新库位状态
     */
    private void updateLocStatus(String locCode, String barcode) {
        boolean updated = locService.update(new LambdaUpdateWrapper<Loc>()
    private void updateLocStatus(String locCode, String barcode, BigDecimal weight) {
        LambdaUpdateWrapper<Loc> uw = new LambdaUpdateWrapper<Loc>()
                .eq(Loc::getCode, locCode)
                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
                .set(Loc::getBarcode, barcode));
                .set(Loc::getBarcode, barcode)
                .set(Loc::getWeight, weight);
        boolean updated = locService.update(uw);
        if (!updated) {
            throw new CoolException("库位预约失败!!");
        }
@@ -629,13 +655,16 @@
     * 空板入库:与非空板同一流程(校验站点、分配库位、建任务、更新库位),仅不校验组托、不写任务明细、不更新组托状态。
     * 由 createInTask 在 ioType=空板时调用;需在设备站点中配置 type=10(空板入库)的站点路径。
     */
    private InTaskMsgDto createInTaskForEmptyPallet(String barcode, String staNo, Integer type) {
    private InTaskMsgDto createInTaskForEmptyPallet(TaskInParam sourceParam) {
        TaskInParam param = new TaskInParam();
        String barcode = sourceParam.getBarcode();
        String staNo = sourceParam.getSourceStaNo();
        param.setBarcode(barcode);
        param.setSourceStaNo(staNo);
        param.setLocType1(type != null ? type : 1);
        param.setLocType1(sourceParam.getLocType1() != null ? sourceParam.getLocType1() : 1);
        param.setIoType(TaskType.TASK_TYPE_EMPITY_IN.type);
        param.setUser(1L);
        param.setUser(sourceParam.getUser() != null ? sourceParam.getUser() : 1L);
        param.setWeight(sourceParam.getWeight());
        // 校验设备站点(需配置 type=10 空板入库的站点)
        DeviceSite deviceSite = validateDeviceSite(param);
@@ -650,6 +679,10 @@
            log.info("找到该托盘号已有空板入库任务,复用 - 任务编码:{},箱号:{}", existingInTask.getTaskCode(), barcode);
            if (StringUtils.isNotBlank(staNo) && !staNo.equals(existingInTask.getOrgSite())) {
                existingInTask.setOrgSite(staNo);
                taskService.updateById(existingInTask);
            }
            if (param.getWeight() != null) {
                existingInTask.setWeight(param.getWeight());
                taskService.updateById(existingInTask);
            }
            InTaskMsgDto msgDto = new InTaskMsgDto();
@@ -686,8 +719,8 @@
        }
        String ruleCode = generateTaskCode();
        String targetSite = StringUtils.isNotBlank(deviceSite.getDeviceSite()) ? deviceSite.getDeviceSite() : staNo;
        Task task = createTask(ruleCode, locNo.getLocNo(), barcode, targetSite, staNo, param.getUser(), TaskType.TASK_TYPE_EMPITY_IN.type);
        updateLocStatus(task.getTargLoc(), barcode);
        Task task = createTask(ruleCode, locNo.getLocNo(), barcode, targetSite, staNo, param.getUser(), TaskType.TASK_TYPE_EMPITY_IN.type, param.getWeight());
        updateLocStatus(task.getTargLoc(), barcode, param.getWeight());
        locNo.setWorkNo(ruleCode);
        locNo.setTaskId(task.getId());
        log.info("[空板入库] 已创建任务: {}, 库位: {}, 料箱: {}", ruleCode, locNo.getLocNo(), barcode);
@@ -1561,9 +1594,14 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R allocateLocation(String barcode, String staNo, Integer type, Boolean full) {
    public R allocateLocation(String barcode, String staNo, Integer type, Boolean full, BigDecimal weight) {
        log.info("========== 开始申请入库任务,分配库位 ==========");
        log.info("料箱码:{},入库站点:{},入库类型:{},空板:{}", barcode, staNo, type, full);
        log.info("料箱码:{},入库站点:{},入库类型:{},空板:{},重量:{}", barcode, staNo, type, full, weight);
        BigDecimal weightScaled = null;
        if (weight != null) {
            weightScaled = weight.setScale(4, RoundingMode.HALF_UP);
        }
        // 统一走 createInTask:空板(full=true)仅不校验组托,仍校验站点、分配库位、建任务;非空板需组托
        TaskInParam param = new TaskInParam();
@@ -1572,6 +1610,7 @@
        param.setLocType1(type != null ? type : 1);
        param.setUser(1L);
        param.setIoType(Boolean.TRUE.equals(full) ? TaskType.TASK_TYPE_EMPITY_IN.type : TaskType.TASK_TYPE_IN.type);
        param.setWeight(weightScaled);
        InTaskMsgDto msgDto = createInTask(param);
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java
@@ -18,6 +18,7 @@
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
@@ -86,6 +87,9 @@
    @ApiModelProperty(value= "容器编码")
    private String barcode;
    @ApiModelProperty(value= "重量")
    private BigDecimal weight;
    /**
     * 存放单位
     */
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Stock.java
@@ -28,6 +28,7 @@
import com.vincent.rsf.server.system.service.UserService;
import com.vincent.rsf.server.system.entity.User;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
@@ -79,6 +80,9 @@
    @ApiModelProperty(value= "库存数量")
    private Double anfme;
    @ApiModelProperty(value= "重量")
    private BigDecimal weight;
    @ApiModelProperty(value= "条形码")
    private String barcode;
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockItem.java
@@ -22,6 +22,7 @@
import com.vincent.rsf.server.system.service.UserService;
import com.vincent.rsf.server.system.entity.User;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Map;
@Data
@@ -80,6 +81,9 @@
    @ApiModelProperty(value= "送货数量")
    private Double anfme;
    @ApiModelProperty(value= "重量")
    private BigDecimal weight;
    /**
     * 库存单位
     */
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java
@@ -32,6 +32,7 @@
import com.vincent.rsf.server.system.service.UserService;
import com.vincent.rsf.server.system.entity.User;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.stream.Collectors;
@@ -107,6 +108,9 @@
    @ApiModelProperty(value= "料箱码")
    private String barcode;
    @ApiModelProperty(value= "重量")
    private BigDecimal weight;
    /**
     * 机器人编码
     */
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
@@ -207,8 +207,15 @@
            if (barcodeToUse == null && !existTasks.isEmpty()) {
                barcodeToUse = existTasks.get(0).getBarcode();
                if (StringUtils.isNotBlank(barcodeToUse)) {
                    locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getId, loc.getId())
                            .set(Loc::getBarcode, barcodeToUse).set(Loc::getUpdateBy, loginUserId).set(Loc::getUpdateTime, new Date()));
                    Task refTask = existTasks.get(0);
                    LambdaUpdateWrapper<Loc> locUw = new LambdaUpdateWrapper<Loc>().eq(Loc::getId, loc.getId())
                            .set(Loc::getBarcode, barcodeToUse)
                            .set(Loc::getUpdateBy, loginUserId)
                            .set(Loc::getUpdateTime, new Date());
                    if (refTask.getWeight() != null) {
                        locUw.set(Loc::getWeight, refTask.getWeight());
                    }
                    locService.update(locUw);
                }
            }
            if (barcodeToUse == null) {
@@ -456,7 +463,8 @@
            throw new CoolException("目标库位不存在!!");
        }
        targetLoc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
        targetLoc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type)
                .setWeight(orgLoc.getWeight());
        if (!locService.updateById(targetLoc)) {
            throw new CoolException("目标库位预约失败!!");
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/RcsTestServiceImpl.java
@@ -222,7 +222,7 @@
                
                if ("location_allocate".equals(params.getInboundApiType())) {
                    // 使用 location_allocate 接口(内部调用createInTask);full=null 表示普通入库
                    R allocateResult = wcsService.allocateLocation(barcode, inboundStation, 1, null);
                    R allocateResult = wcsService.allocateLocation(barcode, inboundStation, 1, null, null);
                    if (allocateResult != null) {
                        Object dataObj = allocateResult.get("data");
                        if (dataObj != null) {
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -58,6 +58,8 @@
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@@ -175,7 +177,9 @@
                throw new CoolException("任务保存失败!!");
            }
            if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
                    .set(Loc::getBarcode, pakin.getBarcode())
                    .set(Loc::getWeight, task.getWeight()))) {
                throw new CoolException("库位预约失败!!");
            }
            /**获取组拖明细**/
@@ -264,7 +268,8 @@
                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
                    .set(Loc::getUpdateBy, loginUserId)
                    .set(Loc::getUpdateTime, new Date())
                    .set(Loc::getBarcode, pakin.getBarcode()))) {
                    .set(Loc::getBarcode, pakin.getBarcode())
                    .set(Loc::getWeight, task.getWeight()))) {
                throw new CoolException("库位预约失败!!");
            }
            /**获取组拖明细**/
@@ -406,7 +411,9 @@
            if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
                    .set(Loc::getBarcode, pakin.getBarcode())
                    .set(Loc::getWeight, task.getWeight()))) {
                throw new CoolException("库位预约失败!!");
            }
            /**获取组拖明细**/
@@ -643,6 +650,7 @@
        // 将库位状态设为空(O状态)
        if (!locService.update(new LambdaUpdateWrapper<Loc>()
                .set(Loc::getBarcode, null)
                .set(Loc::getWeight, null)
                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                .set(Loc::getUpdateBy, loginUserId)
                .set(Loc::getUpdateTime, new Date())
@@ -802,6 +810,7 @@
        /**修改库位状态为F.在库*/
        if (!locService.update(new LambdaUpdateWrapper<Loc>()
                .set(Loc::getBarcode, task.getBarcode())
                .set(Loc::getWeight, task.getWeight())
                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type)
                .set(Loc::getUpdateBy, loginUserId)
                .set(Loc::getUpdateTime, new Date())
@@ -811,6 +820,7 @@
        if (!locService.update(new LambdaUpdateWrapper<Loc>()
                .set(Loc::getBarcode, null)
                .set(Loc::getWeight, null)
                .set(Loc::getUpdateBy, loginUserId)
                .set(Loc::getUpdateTime, new Date())
                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
@@ -873,6 +883,7 @@
//        }
        loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
                .setBarcode(task.getBarcode())
                .setWeight(task.getWeight())
                .setUpdateBy(loginUserId).setUpdateTime(new Date());
        if (!locService.updateById(loc)) {
@@ -1104,7 +1115,9 @@
                }
                if (!locService.update(new LambdaUpdateWrapper<Loc>()
                        .eq(Loc::getCode, task.getTargLoc())
                        .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type))) {
                        .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                        .set(Loc::getBarcode, null)
                        .set(Loc::getWeight, null))) {
                    throw new CoolException("移库目标库位状态修改失败!!");
                }
@@ -1192,6 +1205,7 @@
                        }
                        loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
                                .setBarcode(task.getBarcode())
                                .setWeight(task.getWeight())
                                .setUpdateBy(loginUserId)
                                .setUpdateTime(new Date());
                        if (!locService.updateById(loc)) {
@@ -1266,7 +1280,9 @@
                        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTaskType() < TaskStsType.UPDATED_IN.id ? task.getTargLoc() : task.getOrgLoc()));
                        if (null != loc && (loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)
                                || loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type))) {
                            loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
                            loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type)
                                    .setBarcode(null)
                                    .setWeight(null);
                            if (!locService.updateById(loc)) {
                                throw new CoolException("更新库位状态失败!!");
                            }
@@ -1505,7 +1521,8 @@
                throw new CoolException("临时库存更新失败!!");
            }
        }
        loc1.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
        loc1.setUseStatus(LocStsType.LOC_STS_TYPE_S.type)
                .setWeight(task.getWeight());
        locService.updateById(loc1);
//        if (!locService.updateById(loc1)) {
//            throw new CoolException("库位预约入库失败!!");
@@ -1630,11 +1647,13 @@
            if (!workings.isEmpty()) {
                locItemWorkingService.saveBatch(workings);
            }
            loc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
            loc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type)
                    .setWeight(first.getWeight());
            locService.updateById(loc);
        } else {
            loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
            loc.setBarcode(null);
            loc.setWeight(null);
            loc.setUpdateBy(loginUserId);
            loc.setUpdateTime(new Date());
            locService.updateById(loc);
@@ -1673,6 +1692,7 @@
                        .eq(Loc::getId, loc.getId())
                        .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                        .set(Loc::getBarcode, null)
                        .set(Loc::getWeight, null)
                        .set(Loc::getUpdateBy, loginUserId)
                        .set(Loc::getUpdateTime, new Date()))) {
                    throw new CoolException("空板出库库位状态更新失败!!");
@@ -1815,6 +1835,7 @@
            if (!locService.update(new LambdaUpdateWrapper<Loc>()
                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                    .set(Loc::getBarcode, null)
                    .set(Loc::getWeight, null)
                    .set(Loc::getUpdateBy, loginUserId)
                    .set(Loc::getUpdateTime, new Date())
                    .eq(Loc::getId, loc.getId()))) {
@@ -2459,6 +2480,7 @@
        if (TaskType.TASK_TYPE_EMPITY_IN.type.equals(task.getTaskType())) {
            if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type)
                    .set(Loc::getWeight, task.getWeight())
                    .set(Loc::getUpdateBy, loginUserId)
                    .set(Loc::getUpdateTime, new Date()))) {
                throw new CoolException("空板入库库位状态修改失败!!");
@@ -2545,7 +2567,10 @@
        }
        /**修改库位状态为F.在库*/
        if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).eq(Loc::getCode, task.getTargLoc()))) {
        if (!locService.update(new LambdaUpdateWrapper<Loc>()
                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type)
                .set(Loc::getWeight, task.getWeight())
                .eq(Loc::getCode, task.getTargLoc()))) {
            throw new CoolException("库位状态修改失败!!");
        }
        if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
@@ -2690,12 +2715,27 @@
        } else {
            stock.setLocCode(task.getOrgLoc());
        }
        BigDecimal trayWeight = task.getWeight();
        BigDecimal groupWeight = null;
        if (trayWeight != null && sum > 0) {
            List<TaskItem> allLines = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
            double totalQty = allLines.stream().mapToDouble(t -> t.getAnfme() != null ? t.getAnfme() : 0.0).sum();
            if (totalQty > 0) {
                groupWeight = trayWeight.multiply(BigDecimal.valueOf(sum)).divide(BigDecimal.valueOf(totalQty), 4, RoundingMode.HALF_UP);
            } else {
                groupWeight = trayWeight;
            }
            stock.setWeight(groupWeight);
        }
        if (!stockService.save(stock)) {
            throw new CoolException("库存保存失败!!");
        }
        List<StockItem> stockItems = new ArrayList<>();
        for (TaskItem item : items) {
        BigDecimal allocatedWeight = BigDecimal.ZERO;
        BigDecimal sumBd = sum > 0 ? BigDecimal.valueOf(sum) : null;
        for (int i = 0; i < items.size(); i++) {
            TaskItem item = items.get(i);
            /**通过任务明细中的taskId查询,获取TASK的目标库位信息*/
            StockItem stockItem = new StockItem();
            BeanUtils.copyProperties(item, stockItem);
@@ -2706,6 +2746,16 @@
                    .setUpdateBy(loginUserId)
                    .setId(null)
                    .setStockId(stock.getId());
            if (groupWeight != null && sumBd != null) {
                if (i == items.size() - 1) {
                    stockItem.setWeight(groupWeight.subtract(allocatedWeight));
                } else {
                    double lineQty = item.getAnfme() != null ? item.getAnfme() : 0.0;
                    BigDecimal lineW = groupWeight.multiply(BigDecimal.valueOf(lineQty)).divide(sumBd, 4, RoundingMode.HALF_UP);
                    stockItem.setWeight(lineW);
                    allocatedWeight = allocatedWeight.add(lineW);
                }
            }
            stockItems.add(stockItem);
        }
        if (!stockItemService.saveBatch(stockItems)) {