26个文件已修改
1个文件已添加
6个文件已删除
1092 ■■■■■ 已修改文件
rsf-admin/src/page/basicInfo/companys/CompanysList.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/page/basicInfo/matnr/BatchModal.jsx 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/page/task/TaskList.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/api/service/MobileService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/MobileServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/api/utils/LocUtils.java 286 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/common/config/ConfigProperties.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/BasDeviceController.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/TaskController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/BasDevice.java 162 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/WaitPakinItemLog.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/PakinIOStatus.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/WarehType.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/BasDeviceMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/ScheduleJobs.java 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/BasDeviceService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/LocItemService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/BasDeviceServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/DeviceSiteServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OutStockServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/QlyIsptItemServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java 138 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/system/utils/SystemAuthUtils.java 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/resources/application.yml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/resources/mapper/manager/BasDeviceMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/page/basicInfo/companys/CompanysList.jsx
@@ -74,7 +74,7 @@
            { id: 'customer', name: 'common.field.customer' },
            { id: 'supplier', name: 'common.field.supplier' },
            { id: 'partners', name: 'common.field.partners' }
        ]} />,
        ]} alwaysOn />,
    <TextInput source="contact" label="table.field.companys.contact" />,
    <TextInput source="tel" label="table.field.companys.tel" />,
    <TextInput source="email" label="table.field.companys.email" />,
rsf-admin/src/page/basicInfo/matnr/BatchModal.jsx
@@ -182,6 +182,7 @@
                                        onChange={(e) => handleChange(e.target.value, 'flagCheck')}
                                        label="table.field.matnr.flagCheck"
                                        source="flagCheck"
                                        defaultValue={1}
                                        choices={[
                                            { id: 0, name: ' 否' },
                                            { id: 1, name: ' 是' },
rsf-admin/src/page/task/TaskList.jsx
@@ -286,7 +286,7 @@
        }
    }
    return (
        (record.taskStatus == 1 || record.taskStatus == 101) && (record.taskType == 1 || record.taskType == 101 || record.taskType == 10 || record.taskType == 104) ?
        (record.taskStatus == 1 || record.taskStatus == 101) && (record.taskType == 1 || record.taskType == 101 || record.taskType == 10 || record.taskType == 103 || record.taskType == 11 ) ?
            <Button
                onClick={clickCancel}
                label="toolbar.cancel">
rsf-server/src/main/java/com/vincent/rsf/server/api/service/MobileService.java
@@ -40,7 +40,6 @@
    WaitPakin mergeItems(WaitPakinParam waitPakin, Long userId);
    WaitPakin unBind(WaitPakinParam param);
    R inspect(String code, Long loginUserId);
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/MobileServiceImpl.java
@@ -237,7 +237,7 @@
            throw new CoolException("数据错误:主单不存在!!");
        }
        //TODO /**收货数量累加,1. 会出超收情况 2. 会有收货不足情况*/
        Double rcptedQty = asnOrder.getQty() + receiptQty;
        Double rcptedQty = Math.round((asnOrder.getQty() + receiptQty) * 10000) / 10000.0;
        asnOrder.setQty(rcptedQty).setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_EXCE_ING.val);
        if (!asnOrderMapper.updateById(asnOrder)) {
@@ -288,7 +288,7 @@
                throw new CoolException("请输入正确的时间格式!!");
            }
            Double itemRcptQty = dto.getReceiptQty() + orderItem.getQty();
            Double itemRcptQty = Math.round((dto.getReceiptQty() + orderItem.getQty()) * 10000) / 10000.0;
            Boolean allowOver = false;
            if (!Objects.isNull(config)) {
                if (Boolean.parseBoolean(config.getVal())) {
@@ -401,7 +401,8 @@
        if (!Objects.isNull(serviceOne)) {
            item.setId(serviceOne.getId());
            item.setAnfme(item.getAnfme() + serviceOne.getAnfme());
            Double anfme = Math.round((item.getAnfme() + serviceOne.getAnfme()) * 10000) / 10000.0;
            item.setAnfme(anfme);
        }
        //未质检
@@ -1094,7 +1095,8 @@
            if (Objects.isNull(stockItem)) {
                detlsDto.setStockQty(0.0);
            } else {
                detlsDto.setStockQty(stockItem.getAnfme() + stockItem.getWorkQty());
                Double anfme = Math.round((stockItem.getAnfme() + stockItem.getWorkQty()) * 10000) / 10000.0;
                detlsDto.setStockQty(anfme);
            }
            if (!Objects.isNull(asnOrderItem.getPoDetlId())) {
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
@@ -144,7 +144,7 @@
    private WaitPakin validateWaitPakin(String barcode) {
        WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
                .eq(WaitPakin::getBarcode, barcode)
                .eq(WaitPakin::getIoStatus, Short.parseShort(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)));
                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
        if (Cools.isEmpty(waitPakin)) {
            throw new CoolException("请检查组拖状态是否完成!!");
@@ -172,7 +172,7 @@
        task.setTaskCode(ruleCode)
                .setTaskStatus(TaskStsType.GENERATE_IN.id)
                .setTaskType(TaskType.TASK_TYPE_IN.type)
                .setWarehType(WarehType.WAREHOUSE_TYPE_CRN.id)
                .setWarehType(WarehType.WAREHOUSE_TYPE_CRN.val)
                .setTargLoc(targetLoc)
                .setBarcode(barcode)
                .setTargSite(targetSite)
@@ -194,7 +194,6 @@
                .eq(Loc::getCode, locCode)
                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
                .set(Loc::getBarcode, barcode));
        if (!updated) {
            throw new CoolException("库位预约失败!!");
        }
@@ -204,9 +203,7 @@
     * 获取并验证组拖明细
     */
    private List<WaitPakinItem> getWaitPakinItems(Long pakinId) {
        List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(
                new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakinId));
        List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakinId));
        if (waitPakinItems.isEmpty()) {
            throw new CoolException("数据错误:组拖明细不存在");
        }
@@ -334,7 +331,7 @@
//        return locNo;
//    }
    @Override
    public InTaskMsgDto getLocNo(TaskInParam param) throws Exception{
    public InTaskMsgDto getLocNo(TaskInParam param) throws Exception {
        String matnr = null;
        String batch = null;
        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, param.getBarcode()));
@@ -361,18 +358,16 @@
        }
        LocTypeDto locTypeDto = new LocTypeDto(param);
        InTaskMsgDto dto = null;
        switch (warehouseArea.getType()) {
            case "CRN": //堆垛机
                dto = getLocNoCrn(deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType());
                break;
            case "SXC": //四向库
                break;
            case "CTU": //ctu
                dto = getLocNoCtu(deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType());
                break;
            default:
                dto = getLocNoCtu(deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType());
                break;
        //根据立库类型获取获取库位
        if (warehouseArea.getType().equals(WarehType.WAREHOUSE_TYPE_CRN.val)) {
            //堆垛机
            dto = getLocNoCrn(deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType());
        } else if (warehouseArea.getType().equals(WarehType.WAREHOUSE_TYPE_FOUR_DIRECTIONS.val)) {
            //四向库
        }  else {
            //CTU 库以及其它
            dto = getLocNoCtu(deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType());
        }
        return dto;
    }
@@ -419,10 +414,10 @@
                List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getMatnrCode, matnr));
                for (LocItem locItem : locItems) {
                    Loc loc1 = locService.getById(locItem.getLocId());
                    if (LocUtils.isShallowLoc(slaveProperties, loc1.getCode())) {
                    if (LocUtils.isShallowLoc(loc1.getCode())) {
                        continue;
                    }
                    String shallowLocNo = LocUtils.getShallowLoc(slaveProperties, loc1.getCode());
                    String shallowLocNo = LocUtils.getShallowLoc(loc1.getCode());
                    // 检测目标库位是否为空库位
                    Loc shallowLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLocNo));
                    if (shallowLoc != null && shallowLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
@@ -430,7 +425,6 @@
                            loc = shallowLoc;
                            channel = shallowLoc.getChannel();
                            break;
                        }
                    }
                }
@@ -494,7 +488,7 @@
                if (!LocUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                    continue;
                }
                String shallowLoc = LocUtils.getDeepLoc(slaveProperties, locMast1.getCode());
                String shallowLoc = LocUtils.getDeepLoc(locMast1.getCode());
                if ((ioType == 1 && deviceBind.getBeSimilar().equals("1"))) {
                    //相似物料打开,判断深库位有没有货,没货就放深库位,有货就不操作
                    Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
@@ -535,7 +529,7 @@
                        continue;
                    }
                    if (deviceBind.getBeSimilar().equals("1")) {
                        String shallowLoc = LocUtils.getDeepLoc(slaveProperties, locMast1.getCode());
                        String shallowLoc = LocUtils.getDeepLoc(locMast1.getCode());
                        Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                                .eq(Loc::getCode, shallowLoc)
                                .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
rsf-server/src/main/java/com/vincent/rsf/server/api/utils/LocUtils.java
@@ -10,26 +10,47 @@
import com.vincent.rsf.server.api.entity.dto.LocTypeDto;
import com.vincent.rsf.server.manager.entity.*;
import com.vincent.rsf.server.manager.enums.LocStsType;
import com.vincent.rsf.server.manager.enums.TaskStsType;
import com.vincent.rsf.server.manager.enums.TaskType;
import com.vincent.rsf.server.manager.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.RegEx;
import javax.annotation.Resource;
import java.util.List;
@Component
public class LocUtils {
    public static final Logger logger = LoggerFactory.getLogger(LocUtils.class);
    private static List<Integer>  doubleLocs;
    private static Boolean isDoubleDeep;
    @Autowired
    private SlaveProperties slavePropertie;
    @PostConstruct
    public void init() {
        doubleLocs = slavePropertie.getDoubleLocs();
        isDoubleDeep = slavePropertie.isDoubleDeep();
    }
    /**
     * 获取 浅库位对应的深库位号
     */
    public static String getDeepLoc(SlaveProperties slaveProperties, String shallowLoc) {
    public static String getDeepLoc(String shallowLoc) {
        LocService locService = SpringUtils.getBean(LocService.class);
        Loc shaLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc));
        int row = shaLoc.getRow()-1;
        boolean contains = slaveProperties.getDoubleLocs().contains(row);
        boolean contains = doubleLocs.contains(row);
        Loc deepLoc = null;
        if (contains) {
            deepLoc = locService.getOne(new LambdaQueryWrapper<Loc>()
@@ -52,7 +73,7 @@
    /**
     * 获取 深库位对应的浅库位号
     */
    public static String getShallowLoc(SlaveProperties slaveProperties, String deepLoc) {
    public static String getShallowLoc(String deepLoc) {
        LocService locService = SpringUtils.getBean(LocService.class);
        Loc depLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, deepLoc));
        int row;
@@ -61,7 +82,7 @@
        } else {
            row = depLoc.getRow();
        }
        boolean contains = slaveProperties.getDoubleLocs().contains(row);
        boolean contains = doubleLocs.contains(row);
        Loc shallowLoc = null;
        if (!contains) {
            shallowLoc = locService.getOne(new LambdaQueryWrapper<Loc>()
@@ -84,10 +105,10 @@
    /**
     * 判断是否为浅库位
     */
    public static boolean isShallowLoc(SlaveProperties slaveProperties, String locNo) {
        if (slaveProperties.isDoubleDeep()) {
    public static boolean isShallowLoc(String locNo) {
        if (isDoubleDeep) {
            int row = getRow(locNo);
            return !slaveProperties.getDoubleLocs().contains(row);
            return !doubleLocs.contains(row);
        } else {
            return false;
        }
@@ -113,7 +134,7 @@
      return LocNecessaryParametersDoubleExtension(curRow, crnNumber); //已完善
    }
    //经典双伸库位
    //经典双伸库位,  获取双深排
    public static int[] LocNecessaryParametersDoubleExtension( Integer curRow, Integer crnNumber) {
        int[] necessaryParameters = new int[]{0, 0, 0, 0};
@@ -192,6 +213,14 @@
        return dto.getLocType1().equals(Integer.parseInt(loc.getType()));
    }
    public static String  getCrnLoc() {
//        SlaveProperties bean = SpringUtils.getBean(SlaveProperties.class);
        System.out.println(doubleLocs);
        return null;
    }
    public static String zerofill(String msg, Integer count) {
        if (msg.length() == count) {
            return msg;
@@ -205,4 +234,245 @@
            return msgBuilder.toString();
        }
    }
    /**
     * 获取堆垛机库位信息
     * @param deviceBind
     * @param area
     * @param sourceStaNo
     * @param matnr
     * @param batch
     * @param locTypeDto
     * @param times
     * @param ioType 作业类型(*必传参数)
     * @return
     */
    public static InTaskMsgDto getLocNoCrn(DeviceBind deviceBind, Long area, Integer sourceStaNo, String matnr, String batch, LocTypeDto locTypeDto, int times, Integer ioType) {
        DeviceBindService deviceBindService = SpringUtils.getBean(DeviceBindService.class);
        DeviceSiteService deviceSiteService = SpringUtils.getBean(DeviceSiteService.class);
        LocService locService = SpringUtils.getBean(LocService.class);
        LocItemService locItemService = SpringUtils.getBean(LocItemService.class);
        if (Cools.isEmpty(matnr)) {  //物料号
            matnr = "";
        }
        if (Cools.isEmpty(batch)) {  //批次
            batch = "";
        }
        // 初始化参数
        int channel = 0;      //堆垛机号
        int nearRow = 0;    //最浅库位排
        int curRow = 0;     //最深库位排
        int rowCount = 0;   //轮询轮次
        Loc loc = null;     // 目标库位
        InTaskMsgDto inTaskMsgDto = new InTaskMsgDto();
        int sRow = deviceBind.getStartRow();
        int eRow = deviceBind.getEndRow();
        int deviceQty = deviceBind.getDeviceQty();
        // ===============>>>> 开始执行
        curRow = deviceBind.getCurrentRow();
        //此程序用于优化堆垛机异常时的运行时间
        for (int i = times; i <= deviceQty * 2; i++) {
            int[] locNecessaryParameters = LocUtils.LocNecessaryParameters(deviceBind, curRow, deviceQty);
            curRow = locNecessaryParameters[1];
            channel = locNecessaryParameters[2];
            rowCount = locNecessaryParameters[0];
            nearRow = locNecessaryParameters[3];
            break;
        }
        if (nearRow == 0) {
            throw new CoolException("无可用堆垛机");
        }
        //入库靠近摆放
        if (ioType == 1 && deviceBind.getBeSimilar().equals("1") && !Cools.isEmpty(matnr)) {
            if (nearRow != curRow) {
                List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getMatnrCode, matnr));
                for (LocItem locItem : locItems) {
                    Loc loc1 = locService.getById(locItem.getLocId());
                    if (LocUtils.isShallowLoc(loc1.getCode())) {
                        continue;
                    }
                    String shallowLocNo = LocUtils.getShallowLoc(loc1.getCode());
                    // 检测目标库位是否为空库位
                    Loc shallowLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLocNo));
                    if (shallowLoc != null && shallowLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
                        if (LocUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) {
                            loc = shallowLoc;
                            channel = shallowLoc.getChannel();
                            break;
                        }
                    }
                }
            }
        }
//        // 靠近摆放规则 --- 空托 //互通版
//        if (ioType == 10 && deviceBind.getEmptySimilar().equals("1")) {
//            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
//                    .eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("whs_type", rowLastnoType.getType().longValue()));
//            if (!locMasts.isEmpty()) {
//                for (LocMast loc : locMasts) {
//                    if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) {
//                        continue;
//                    }
//                    String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo());
//                    // 检测目标库位是否为空库位
//                    LocMast shallowLoc = locMastService.selectById(shallowLocNo);
//                    if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) {
//                        if (VersionUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) {
//                            if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) {
//                                locMast = shallowLoc;
//                                crnNo = locMast.getCrnNo();
//                                break;
//                            }
//                        }
//                    }
//                }
//            }
//        }
        //查找路径
        DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                .eq(DeviceSite::getType, ioType)
                .eq(DeviceSite::getSite, sourceStaNo)
                .eq(DeviceSite::getChannel, channel)
        );
        if (Cools.isEmpty(deviceSite)) {
            channel = 0;
        } else {
            inTaskMsgDto.setStaNo(Integer.parseInt(deviceSite.getDeviceSite()));
        }
        //更新当前排
        deviceBind.setCurrentRow(curRow);
        deviceBindService.updateById(deviceBind);
        // 开始查找库位 ==============================>>
        // 1.按规则查找库位
        if (Cools.isEmpty(loc) && channel != 0) {
            List<Loc> locMasts = null;
            locMasts = locService.list(new LambdaQueryWrapper<Loc>()
                    .eq(Loc::getRow, nearRow)
                    .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                    .eq(Loc::getType, locTypeDto.getLocType1())
                    .eq(Loc::getAreaId, area)
                    .orderByAsc(Loc::getLev)
                    .orderByAsc(Loc::getCol)
            );
            for (Loc locMast1 : locMasts) {
                if (!LocUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                    continue;
                }
                String shallowLoc = LocUtils.getDeepLoc(locMast1.getCode());
                if ((ioType == TaskStsType.GENERATE_IN.id && deviceBind.getBeSimilar().equals("1"))) {
                    //相似物料打开,判断深库位有没有货,没货就放深库位,有货就不操作
                    Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                            .eq(Loc::getCode, shallowLoc)
                            .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                            .eq(Loc::getAreaId, area)
                    );
                    if (!Cools.isEmpty(locMast2)) {
                        loc = locMast2;
                        break;
                    }
                } else {
                    //相似物料关闭,判断深库位有没有货,有货就放浅库位,无货就不操作
                    Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                            .eq(Loc::getCode, shallowLoc)
                            .in(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type, LocStsType.LOC_STS_TYPE_F.type)
                            .eq(Loc::getAreaId, area)
                    );
                    if (!Cools.isEmpty(locMast2)) {
                        loc = locMast1;
                        break;
                    } else {
                        locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                                .eq(Loc::getCode, shallowLoc)
                                .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                                .eq(Loc::getAreaId, area)
                        );
                        if (!Cools.isEmpty(locMast2)) {
                            loc = locMast2;
                            break;
                        }
                    }
                }
            }
            if (Cools.isEmpty(loc) && deviceBind.getBeSimilar().equals("1")) {
                for (Loc locMast1 : locMasts) {
                    if (!LocUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                        continue;
                    }
                    if (deviceBind.getBeSimilar().equals("1")) {
                        String shallowLoc = LocUtils.getDeepLoc(locMast1.getCode());
                        Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                                .eq(Loc::getCode, shallowLoc)
                                .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                                .eq(Loc::getAreaId, area)
                        );
                        if (!Cools.isEmpty(locMast2)) {
                            loc = locMast2;
                            break;
                        } else {
                            locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>()
                                    .eq(Loc::getCode, shallowLoc)
                                    .in(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type, LocStsType.LOC_STS_TYPE_D.type)
                                    .eq(Loc::getAreaId, area)
                            );
                            if (!Cools.isEmpty(locMast2)) {
                                loc = locMast1;
                                break;
                            }
                        }
                    } else {
                        if (!Cools.isEmpty(locMast1)) {
                            loc = locMast1;
                            break;
                        }
                    }
                }
            }
        }
        //查询当前库位类型空库位 小于5个则locmast = null
        List<Loc> locTypeLocMasts = locService.list(new LambdaQueryWrapper<Loc>()
                .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                .eq(Loc::getChannel, channel)
                .eq(Loc::getType, locTypeDto.getLocType1())
                .eq(Loc::getAreaId, area)
        );
        if (null != locTypeLocMasts && locTypeLocMasts.size() <= 5) {
            loc = null;
        }
        // 递归查询
        if (Cools.isEmpty(loc) || !loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归
            if (times < rowCount * 2) {
                times = times + 1;
                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(deviceBind, area, sourceStaNo, matnr, batch, locTypeDto, 0, ioType);
            }
            throw new CoolException("没有空库位");
        }
        String locNo = loc.getCode();
        // 返回dto
        inTaskMsgDto.setDeviceNo(channel);
        inTaskMsgDto.setSourceStaNo(sourceStaNo);
//        inTaskMsgDto.setStaNo();
        inTaskMsgDto.setLocNo(locNo);
        return inTaskMsgDto;
    }
}
rsf-server/src/main/java/com/vincent/rsf/server/common/config/ConfigProperties.java
@@ -70,6 +70,11 @@
     */
    private String securityCode;
    private String userName;
    private String password;
    public List<String> getSuperUserList() {
        return Arrays.stream(superUsername.split(",")).collect(Collectors.toList());
    }
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/BasDeviceController.java
File was deleted
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocController.java
@@ -165,7 +165,7 @@
        if (Objects.isNull(map.get("ids"))) {
            locs = locService.list();
        } else {
            locs = locService.list(new LambdaQueryWrapper<Loc>().in(Loc::getId , map.get("ids")).eq(Loc::getStatus, 1));
            locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getStatus, 1));
        }
        ExcelUtil.build(ExcelUtil.create(locs, Loc.class), response);
    }
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemController.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.server.api.utils.LocUtils;
import com.vincent.rsf.server.common.constant.Constants;
import com.vincent.rsf.server.common.utils.ExcelUtil;
import com.vincent.rsf.server.common.annotation.OperationLog;
@@ -96,7 +97,7 @@
        }
        param.setType(Constants.TASK_TYPE_OUT_STOCK);
        return locItemService.generateTask(param);
        return locItemService.generateTask(param, getLoginUserId());
    }
    /**
@@ -111,7 +112,7 @@
        if (Objects.isNull(map)) {
            return R.error("参数不能为空!!");
        }
        return R.ok("任务生成成功").add(locItemService.genMoveTask(map));
        return R.ok("任务生成成功").add(locItemService.genMoveTask(map, getLoginUserId()));
    }
    /**
@@ -127,7 +128,8 @@
            return R.error("参数不能为空!!");
        }
        map.setType(Constants.TASK_TYPE_OUT_CHECK);
        return R.ok("任务生成成功").add(locItemService.generateTask(map));
        return R.ok("任务生成成功").add(locItemService.generateTask(map, getLoginUserId()));
    }
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/TaskController.java
@@ -141,7 +141,7 @@
        for (Task task : tasks) {
            if (StringUtils.isNotBlank(task.getParentId() + "")) {
                Task task1 = taskService.getById(task.getParentId());
                if (!Objects.isNull(task1)) {
                if (!Objects.isNull(task1) && task1.getTaskType().equals(TaskStsType.UPDATED_IN.id)) {
                    throw new CoolException("父任务:" + task1.getTaskCode() + "未执行完成!");
                }
            }
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/BasDevice.java
File was deleted
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java
@@ -9,6 +9,7 @@
import com.vincent.rsf.server.system.entity.DictData;
import com.vincent.rsf.server.system.service.DictDataService;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -31,6 +32,7 @@
import com.vincent.rsf.server.system.entity.User;
import java.io.Serializable;
import java.util.Date;
import java.util.stream.Collectors;
@Data
@Accessors(chain = true)
@@ -60,7 +62,7 @@
    private Long parentId;
    @ApiModelProperty("仓库类型")
    private Integer warehType;
    private String warehType;
    /**
     * 任务类型
@@ -259,6 +261,18 @@
        return dictDatas.getValue() + "." + dictDatas.getLabel();
    }
    public String getWarehType$(){
        if (null == this.warehType){ return null; }
        DictDataService dictDataService = SpringUtils.getBean(DictDataService.class);
        DictData dictDatas = dictDataService.getOne(new LambdaQueryWrapper<DictData>()
                .eq(DictData::getDictTypeCode, DictTypeCode.DICT_SYS_DEVICE_TYPE)
                .eq(DictData::getValue, warehType));
        if (Objects.isNull(dictDatas)) {
            return null;
        }
        return dictDatas.getLabel();
    }
    public String getTaskType$() {
        if (Cools.isEmpty(this.taskType)) {
            return null;
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/WaitPakinItemLog.java
@@ -40,6 +40,9 @@
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @ApiModelProperty("日志主单ID")
    private Long logId;
    /**
     * 主单ID
     */
rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/PakinIOStatus.java
@@ -17,11 +17,11 @@
            ;
    PakinIOStatus(String val, String desc) {
        this.val = val;
        this.val = Short.parseShort(val);
        this.desc = desc;
    }
    public String val;
    public Short val;
    public String desc;
}
rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/WarehType.java
@@ -3,18 +3,18 @@
public enum WarehType {
    //仓库类型
    WAREHOUSE_TYPE_FOUR_DIRECTIONS("1", "四向库"),
    WAREHOUSE_TYPE_AGV("2", "AGV库"),
    WAREHOUSE_TYPE_CTU("3", "CTU库"),
    WAREHOUSE_TYPE_PLAT("4", "平库"),
    WAREHOUSE_TYPE_CRN("5", "堆垛机库"),
    WAREHOUSE_TYPE_FOUR_DIRECTIONS("SXC", "四向库"),
    WAREHOUSE_TYPE_AGV("AGV", "AGV库"),
    WAREHOUSE_TYPE_CTU("CTU", "CTU库"),
    WAREHOUSE_TYPE_PLAT("PLAT", "平库"),
    WAREHOUSE_TYPE_CRN("CRN", "堆垛机库"),
    ;
    public Integer id;
    public String val;
    public String desc;
    WarehType(String id, String desc) {
        this.id = Integer.parseInt(id);
    WarehType(String val, String desc) {
        this.val = val;
        this.desc = desc;
    }
rsf-server/src/main/java/com/vincent/rsf/server/manager/mapper/BasDeviceMapper.java
File was deleted
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/ScheduleJobs.java
@@ -190,7 +190,8 @@
        WarehouseAreasItem serviceOne = warehouseAreasItemService.getOne(queryWrapper);
        if (!Objects.isNull(serviceOne)) {
            item.setId(serviceOne.getId());
            item.setAnfme(item.getAnfme() + serviceOne.getAnfme());
            Double anfme = Math.round((item.getAnfme() + serviceOne.getAnfme()) * 10000) / 10000.0;
            item.setAnfme(anfme);
        }
        //未质检
        if (!warehouseAreasItemService.saveOrUpdate(item)) {
@@ -329,7 +330,7 @@
    @Transactional(rollbackFor = Exception.class)
    public void pakinLog() {
        List<WaitPakin> pakinIds = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                .eq(WaitPakin::getIoStatus, Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val))
                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val)
                .select(WaitPakin::getId));
        if (pakinIds.isEmpty()) {
            return;
@@ -339,32 +340,36 @@
        if (pakins.isEmpty()) {
            throw new CoolException("组拖单为空!!");
        }
        List<WaitPakinLog> pakinLogs = new ArrayList<>();
        pakins.forEach(pakin -> {
            WaitPakinLog log = new WaitPakinLog();
            BeanUtils.copyProperties(pakin, log);
            log.setPakinId(pakin.getId()).setIoStatus(Short.parseShort("2"));
            pakinLogs.add(log);
        });
        if (!waitPakinLogService.saveBatch(pakinLogs)) {
            throw new CoolException("历史档保存失败!!");
        }
        List<WaitPakinItemLog> itemLogs = new ArrayList<>();
        List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().in(WaitPakinItem::getPakinId, list));
        if (pakinItems.isEmpty()) {
            throw new CoolException("组拖明细为空!!");
        }
        pakinItems.forEach(item -> {
            WaitPakinItemLog itemLog = new WaitPakinItemLog();
            BeanUtils.copyProperties(item, itemLog);
            itemLog.setPakinItemId(item.getId())
                    .setPakinId(item.getPakinId());
            itemLogs.add(itemLog);
            log.setPakinId(pakin.getId()).setIoStatus(PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val);
            if (!waitPakinLogService.save(log)) {
                throw new CoolException("组托日志保存失败!!");
            }
            List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().in(WaitPakinItem::getPakinId, pakin.getId()));
            if (pakinItems.isEmpty()) {
                throw new CoolException("组拖明细为空!!");
            }
            List<WaitPakinItemLog> itemLogs = new ArrayList<>();
            pakinItems.forEach(item -> {
                WaitPakinItemLog itemLog = new WaitPakinItemLog();
                BeanUtils.copyProperties(item, itemLog);
                itemLog.setPakinItemId(item.getId())
                        .setLogId(log.getId())
                        .setQty(item.getWorkQty())
                        .setWorkQty(0.0)
                        .setPakinId(item.getPakinId());
                itemLogs.add(itemLog);
            });
            if (!waitPakinItemLogService.saveBatch(itemLogs)) {
                throw new CoolException("历史明细档保存失败!!");
            }
        });
        if (!waitPakinItemLogService.saveBatch(itemLogs)) {
            throw new CoolException("历史明细档保存失败!!");
        }
        if (!waitPakinService.removeByIds(list)) {
            throw new CoolException("原单据删除失败!!");
        }
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
@@ -8,6 +8,9 @@
import com.vincent.rsf.server.system.constant.GlobalConfigCode;
import com.vincent.rsf.server.system.entity.Config;
import com.vincent.rsf.server.system.service.ConfigService;
import com.vincent.rsf.server.system.utils.SystemAuthUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
@@ -27,6 +30,8 @@
@Component
public class TaskSchedules {
    public static Logger logger = LoggerFactory.getLogger(TaskSchedules.class);
    @Autowired
    private TaskService taskService;
    @Autowired
@@ -35,18 +40,6 @@
    private TaskLogService taskLogService;
    @Autowired
    private TaskItemLogService taskItemLogService;
    @Autowired
    private StockItemService stockItemService;
    @Autowired
    private PurchaseService purchaseService;
    @Autowired
    private AsnOrderService asnOrderService;
    @Autowired
    private AsnOrderItemService asnOrderItemService;
    @Autowired
    private StockService stockService;
    @Autowired
    private LocService locService;
    @Autowired
    private ConfigService configService;
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/BasDeviceService.java
File was deleted
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/LocItemService.java
@@ -6,12 +6,10 @@
import com.vincent.rsf.server.manager.entity.LocItem;
import com.vincent.rsf.server.manager.entity.Task;
import java.util.Map;
public interface LocItemService extends IService<LocItem> {
    R generateTask(LocToTaskParams map);
    R generateTask(LocToTaskParams map, Long loginUserId);
    Task genMoveTask(LocToTaskParams map);
    Task genMoveTask(LocToTaskParams map, Long loginUserId);
}
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderServiceImpl.java
@@ -290,7 +290,7 @@
            }
            PurchaseItem service = purchaseItemService.getById(item.getId());
            Double qty = service.getQty() + item.getAnfme();
            Double qty = Math.round((service.getQty() + item.getAnfme()) * 10000) / 10000.0;
            if (qty.compareTo(service.getAnfme()) > 0) {
                throw new CoolException("新建单据数量不能大于计划数量!!");
            }
@@ -316,7 +316,9 @@
            if (Objects.isNull(purchaseItem)) {
                throw new CoolException("单据不存在!!");
            }
            purchaseItem.setQty(purchaseItem.getQty() +  item.getAnfme());
            Double toQty = Math.round((purchaseItem.getQty() + item.getAnfme()) * 10000) / 10000.0;
            purchaseItem.setQty(toQty);
            if (!purchaseItemService.updateById(purchaseItem)) {
                throw new CoolException("PO单明细修改失败!!");
            }
@@ -328,7 +330,8 @@
            throw new CoolException(("Asn单据明细保存失败!!"));
        }
        //任务执行完成,修改已完成数量和PO单执行状态
        purchase.setQty(sum + purchase.getQty())
        Double qty = Math.round((sum + purchase.getQty()) * 10000) / 10000.0;
        purchase.setQty(qty)
                .setExceStatus(POExceStatus.PO_EXCE_STATUS_EXCE_ING.val);
        if (!purchaseService.saveOrUpdate(purchase)) {
@@ -361,7 +364,8 @@
            list.forEach(item -> {
                PurchaseItem purchaseItem = purchaseItemService.getById(item.getPoDetlId());
                if (!Objects.isNull(purchaseItem)) {
                    purchaseItem.setQty(purchaseItem.getQty() - item.getAnfme());
                    Double minusQty = Math.round((purchaseItem.getQty() - item.getAnfme()) * 10000) / 10000.0;
                    purchaseItem.setQty(minusQty);
                    if (!purchaseItemService.updateById(purchaseItem)) {
                        throw new CoolException("PO单明细更新失败!!");
                    }
@@ -373,7 +377,8 @@
            Purchase purchase = purchaseService.getOne(new LambdaQueryWrapper<Purchase>()
                    .eq(Purchase::getCode, list.stream().findFirst().get().getPoCode()));
            if (!Objects.isNull(purchase)) {
                purchase.setQty(purchase.getQty() - sum)
                Double qty = Math.round((purchase.getQty() - sum) * 10000) / 10000.0;
                purchase.setQty(qty)
                        .setExceStatus(POExceStatus.PO_EXCE_STATUS_EXCE_ING.val);
                if (!purchaseService.updateById(purchase)) {
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/BasDeviceServiceImpl.java
File was deleted
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/DeviceSiteServiceImpl.java
@@ -1,10 +1,8 @@
package com.vincent.rsf.server.manager.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.manager.controller.params.DeviceSiteParame;
import com.vincent.rsf.server.manager.entity.BasDevice;
import com.vincent.rsf.server.manager.entity.BasStation;
import com.vincent.rsf.server.manager.mapper.DeviceSiteMapper;
import com.vincent.rsf.server.manager.entity.DeviceSite;
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
@@ -1,7 +1,5 @@
package com.vincent.rsf.server.manager.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.framework.exception.CoolException;
@@ -14,7 +12,6 @@
import com.vincent.rsf.server.manager.controller.params.LocToTaskParams;
import com.vincent.rsf.server.manager.entity.*;
import com.vincent.rsf.server.manager.enums.*;
import com.vincent.rsf.server.manager.enums.LocType;
import com.vincent.rsf.server.manager.mapper.LocItemMapper;
import com.vincent.rsf.server.manager.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -27,7 +24,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Array;
import java.util.*;
import java.util.stream.Collectors;
@@ -55,12 +51,13 @@
     * type: check 盘点, stock: 库存出库
     *
     * @param map
     * @param loginUserId
     * @return
     */
    @Override
    @Synchronized
    @Transactional(rollbackFor = Exception.class)
    public R generateTask(LocToTaskParams map) {
    public R generateTask(LocToTaskParams map, Long loginUserId) {
        if (Objects.isNull(map.getSiteNo())) {
            throw new CoolException("站点不能为空!");
        }
@@ -84,9 +81,9 @@
            }
            Task moveTask = new Task();
            if (!LocUtils.isShallowLoc(slaveProperties, loc.getCode())) {
            if (!LocUtils.isShallowLoc(loc.getCode())) {
                //获取深库位对应浅库位
                String shallowLoc = LocUtils.getShallowLoc(slaveProperties, loc.getCode());
                String shallowLoc = LocUtils.getShallowLoc(loc.getCode());
                Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc));
                if (Objects.isNull(one)) {
                    throw new CoolException("对应库位不存在!!");
@@ -94,7 +91,7 @@
                map.setOrgLoc(one.getCode());
                //优先生成移库任务
                if (!one.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
                    moveTask = genMoveTask(map);
                    moveTask = genMoveTask(map, loginUserId);
                }
            }
@@ -103,6 +100,10 @@
                    .setTaskCode(ruleCode)
                    .setParentId(moveTask.getId())
                    .setTargSite(siteNo)
                    .setUpdateBy(loginUserId)
                    .setCreateBy(loginUserId)
                    .setCreateTime(new Date())
                    .setUpdateTime(new Date())
                    .setTaskStatus(TaskStsType.GENERATE_OUT.id)
                    .setBarcode(loc.getBarcode());
@@ -125,7 +126,6 @@
                Double useQty = Math.round((outQty + workQty) * 10000) / 10000.0;
                if (orgQty.compareTo(useQty) > 0) {
                    //拣料出库
                    task.setTaskType(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type);
                    DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                            .eq(DeviceSite::getSite, siteNo)
@@ -134,19 +134,21 @@
                    if (Objects.isNull(deviceSite)) {
                        throw new CoolException("站点不支持拣料出库!!");
                    }
                    task.setTaskType(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type).setWarehType(deviceSite.getDevice());
                } else {
                    //全板出库
                    task.setTaskType(TaskType.TASK_TYPE_OUT.type);
                    DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                            .eq(DeviceSite::getChannel, loc.getChannel())
                            .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_OUT.type));
                    if (Objects.isNull(deviceSite)) {
                        throw new CoolException("站点不支持全板出库!!");
                    }
                    task.setTaskType(TaskType.TASK_TYPE_OUT.type).setWarehType(deviceSite.getDevice());
                }
            } else if (map.getType().equals(Constants.TASK_TYPE_OUT_CHECK)) {
                //盘点出库
                task.setTaskType(TaskType.TASK_TYPE_CHECK_OUT.type);
                DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                        .eq(DeviceSite::getChannel, loc.getChannel())
                        .eq(DeviceSite::getSite, siteNo)
@@ -154,6 +156,9 @@
                if (Objects.isNull(deviceSite)) {
                    throw new CoolException("当前站点不支持盘点出库!!");
                }
                task.setTaskType(TaskType.TASK_TYPE_CHECK_OUT.type).setWarehType(deviceSite.getDevice());
            }
            if (!taskService.save(task)) {
@@ -166,6 +171,10 @@
                taskItem.setTaskId(task.getId())
                        .setAnfme(item.getOutQty())
                        .setBatch(item.getBatch())
                        .setUpdateBy(loginUserId)
                        .setCreateBy(loginUserId)
                        .setCreateTime(new Date())
                        .setUpdateTime(new Date())
                        .setOrderType(OrderType.ORDER_OUT.type)
                        .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type));
                taskItems.add(taskItem);
@@ -186,6 +195,8 @@
                } else {
                    item.setWorkQty(qty);
                }
                item.setUpdateBy(loginUserId).setUpdateTime(new Date());
                if (!locItemService.updateById(item)) {
                    throw new CoolException("库存信息修改失败!!");
                }
@@ -203,11 +214,12 @@
     * 生成移库任务
     *
     * @param map
     * @param loginUserId
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Task genMoveTask(LocToTaskParams map) {
    public Task genMoveTask(LocToTaskParams map, Long loginUserId) {
        if (Objects.isNull(map.getOrgLoc()) || StringUtils.isBlank(map.getOrgLoc())) {
            throw new CoolException("源库位不能为空!");
        }
@@ -270,6 +282,8 @@
                .setTaskCode(ruleCode)
                .setTaskType(TaskType.TASK_TYPE_LOC_MOVE.type)
                .setTargLoc(targetLoc.getCode())
                .setUpdateBy(loginUserId)
                .setUpdateTime(new Date())
                .setTaskStatus(TaskStsType.GENERATE_IN.id)
                .setBarcode(orgLoc.getBarcode());
@@ -286,6 +300,8 @@
                taskItem.setTaskId(task.getId())
                        .setAnfme(item.getAnfme())
                        .setBatch(item.getBatch())
                        .setUpdateBy(loginUserId)
                        .setUpdateTime(new Date())
                        .setOrderType(OrderType.ORDER_IN.type)
                        .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_OTHER_IN.type));
                taskItems.add(taskItem);
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OutStockServiceImpl.java
@@ -366,7 +366,7 @@
                        p1.getUnit(),
                        p1.getTrackCode(),
                        p1.getFieldsIndex(),
                        p1.getAnfme() + p2.getAnfme(),
                        Math.round((p1.getAnfme() + p2.getAnfme()) * 10000) / 10000.0,
                        p1.getWorkQty(),
                        p1.getTenantId(),
                        p1.getStatus(),
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/QlyIsptItemServiceImpl.java
@@ -190,7 +190,8 @@
                }
            }
        } else {
            orderItem.setAnfme(orderItem.getAnfme() - sum);
            Double anfme = Math.round((orderItem.getAnfme() - sum) * 10000) / 10000.0;
            orderItem.setAnfme(anfme);
            if (!warehouseAreasItemService.updateById(orderItem)) {
                throw new CoolException("收货区库存明细更新失败!!");
            }
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -13,7 +13,6 @@
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.LocType;
import com.vincent.rsf.server.manager.mapper.TaskMapper;
import com.vincent.rsf.server.manager.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -21,8 +20,11 @@
import com.vincent.rsf.server.system.constant.SerialRuleCode;
import com.vincent.rsf.server.manager.enums.LocStsType;
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import com.vincent.rsf.server.system.utils.SystemAuthUtils;
import lombok.Synchronized;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -33,6 +35,8 @@
@Service("taskService")
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
    public static final Logger logger = LoggerFactory.getLogger(TaskServiceImpl.class);
    @Autowired
    private WaitPakinService waitPakinService;
@@ -82,10 +86,9 @@
            throw new CoolException("参数不能为空!!");
        }
        /**获取组拖*/
//        List<Long> ids = pakins.stream().map(WaitPakin::getId).collect(Collectors.toList());
        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                .in(WaitPakin::getId, pakins.getId())
                .eq(WaitPakin::getIoStatus, Short.parseShort(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)));
                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
        if (waitPakins.isEmpty()) {
            throw new CoolException("请检查组托状态是否完成!!");
        }
@@ -105,7 +108,7 @@
            task.setTaskCode(ruleCode)
                    .setTaskStatus(TaskStsType.GENERATE_IN.id)
                    .setTaskType(TaskType.TASK_TYPE_IN.type)
                    .setWarehType(WarehType.WAREHOUSE_TYPE_AGV.id)
                    .setWarehType(WarehType.WAREHOUSE_TYPE_AGV.val)
                    .setTargLoc(targetLoc)
                    .setOrgSite(orgSta)
                    .setBarcode(pakin.getBarcode())
@@ -170,7 +173,7 @@
        /**获取组拖*/
        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                .in(WaitPakin::getId, pakins.getId())
                .eq(WaitPakin::getIoStatus, Short.parseShort(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)));
                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
        if (waitPakins.isEmpty()) {
            throw new CoolException("请检查组托状态是否完成!!");
        }
@@ -190,7 +193,7 @@
            task.setTaskCode(ruleCode)
                    .setTaskStatus(TaskStsType.COMPLETE_IN.id)
                    .setTaskType(TaskType.TASK_TYPE_IN.type)
                    .setWarehType(WarehType.WAREHOUSE_TYPE_PLAT.id)
                    .setWarehType(WarehType.WAREHOUSE_TYPE_PLAT.val)
                    .setTargLoc(targetLoc)
                    .setBarcode(pakin.getBarcode())
                    .setCreateBy(loginUserId)
@@ -277,7 +280,7 @@
        List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList());
        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                .in(WaitPakin::getId, ids)
                .eq(WaitPakin::getIoStatus, Short.parseShort(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)));
                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
        if (waitPakins.isEmpty()) {
            throw new CoolException("请检查组拖状态是否完成!!");
        }
@@ -386,23 +389,24 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void complateInTask(List<Task> tasks) throws Exception {
        Long loginUserId = SystemAuthUtils.getLoginUserId();
        for (Task task : tasks) {
            if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
                //1.入库
                complateInstock(task);
                complateInstock(task, loginUserId);
            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
                //53.拣料再入库
                //57.盘点再入库
                pickComplateInStock(task);
                pickComplateInStock(task, loginUserId);
            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
                //移库
                moveInStock(task);
                moveInStock(task, loginUserId);
            }
        }
    }
    @Transactional(rollbackFor = Exception.class)
    public void moveInStock(Task task) {
    public void moveInStock(Task task, Long loginUserId) {
        if (Objects.isNull(task)) {
            return;
        }
@@ -431,7 +435,7 @@
            //移库有可能是空板
            try {
                //更新库位明细
                saveLocItem(taskItems, task.getId());
                saveLocItem(taskItems, task.getId(), loginUserId);
            } catch (Exception e) {
                throw new CoolException("库位明细更新失败!!");
            }
@@ -445,19 +449,26 @@
        /**修改库位状态为F.在库*/
        if (!locService.update(new LambdaUpdateWrapper<Loc>()
                        .set(Loc::getBarcode, task.getBarcode())
                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type)
                .eq(Loc::getCode, task.getTargLoc()))) {
                        .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type)
                        .set(Loc::getUpdateBy, loginUserId)
                        .set(Loc::getUpdateTime, new Date())
                        .eq(Loc::getCode, task.getTargLoc()))) {
            throw new CoolException("库位状态修改失败!!");
        }
        if (!locService.update(new LambdaUpdateWrapper<Loc>()
                        .set(Loc::getBarcode, null)
                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type).eq(Loc::getCode, task.getOrgLoc()))) {
                        .set(Loc::getUpdateBy, loginUserId)
                        .set(Loc::getUpdateTime, new Date())
                        .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                .eq(Loc::getCode, task.getOrgLoc()))) {
            throw new CoolException("库位状态修改失败!!");
        }
        if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
        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_IN.id))) {
            throw new CoolException("任务状态修改失败!!");
        }
@@ -474,17 +485,18 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void completeTask(List<Task> tasks) throws Exception {
        Long loginUserId = SystemAuthUtils.getLoginUserId();
        for (Task task : tasks) {
            //出库任务
            if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) {
                //全托出库
                complateOutStock(task);
                complateOutStock(task, loginUserId);
            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) {
                //拣料出库
                complateOutStock(task);
                complateOutStock(task, loginUserId);
            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
                //盘点出库
                complateOutStock(task);
                complateOutStock(task, loginUserId);
            }
        }
    }
@@ -493,9 +505,10 @@
     * 拣料再入库
     *
     * @param task
     * @param loginUserId
     */
    @Transactional(rollbackFor = Exception.class)
    public void pickComplateInStock(Task task) throws Exception {
    public void pickComplateInStock(Task task, Long loginUserId) throws Exception {
        if (Objects.isNull(task)) {
            return;
        }
@@ -507,7 +520,9 @@
            throw new CoolException("当前库位状态不处于S.入库预约,不可执行入库操作!");
        }
        loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type).setBarcode(task.getBarcode());
        loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
                .setBarcode(task.getBarcode())
                .setUpdateBy(loginUserId).setUpdateTime(new Date());
        if (!locService.updateById(loc)) {
            throw new CoolException("库位信息更新失败!!");
@@ -532,7 +547,7 @@
                locWorking.setAnfme(taskItem.getAnfme());
            }
            BeanUtils.copyProperties(locWorking, locItem);
            locItem.setWorkQty(0.0).setLocCode(loc.getCode()).setLocId(loc.getId()).setId(null);
            locItem.setWorkQty(0.0).setLocCode(loc.getCode()).setLocId(loc.getId()).setId(null).setUpdateBy(loginUserId).setUpdateTime(new Date());
            items.add(locItem);
        }
@@ -542,13 +557,13 @@
        TaskItem taskItem = taskItems.stream().findFirst().get();
        //保存入出库流水
        saveStockItems(taskItems, task, null, null, taskItem.getWkType(), taskItem.getOrderType());
        saveStockItems(taskItems, task, null, null, taskItem.getWkType(), taskItem.getOrderType(), loginUserId);
        if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) {
            throw new CoolException("作业中库存删除失败!!");
        }
        task.setTaskStatus(TaskStsType.UPDATED_IN.id).setUpdateTime(null);
        task.setTaskStatus(TaskStsType.UPDATED_IN.id).setUpdateTime(new Date()).setUpdateBy(loginUserId);
        if (!taskService.updateById(task)) {
            throw new CoolException("任务状态修改失败!!");
        }
@@ -578,22 +593,20 @@
                    .eq(WaitPakin::getBarcode, task.getBarcode())
            );
            if (null != waitPakin) {
                waitPakin.setIoStatus(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
                waitPakin.setIoStatus(PakinIOStatus.PAKIN_IO_STATUS_DONE.val);
                if (!waitPakinService.updateById(waitPakin)) {
                    throw new CoolException("更新组托状态失败!!");
                }
            }
            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 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);
                if (!locService.updateById(loc)) {
                    throw new CoolException("更新库位状态失败!!");
                }
            }
            if (!Objects.isNull(task.getWarehType()) && task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.id)) {
            if (!Objects.isNull(task.getWarehType()) && task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.val)) {
                BasStation basStation = null;
                if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
                    basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
@@ -608,8 +621,7 @@
                ) {
                    basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                            .eq(BasStation::getStationName, task.getTargLoc())
                            .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type)
                    );
                            .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type));
                }
                if (null == basStation) {
                    throw new CoolException("站点状态错误!!");
@@ -618,6 +630,10 @@
                if (!basStationService.updateById(basStation)) {
                    throw new CoolException("更新站点状态失败!!");
                }
            }
            if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()))) {
                throw new CoolException("任务明细删除失败!!");
            }
        }
        if (!this.removeByIds(Arrays.asList(ids))) {
@@ -736,11 +752,10 @@
     */
    @Synchronized
    @Transactional(rollbackFor = Exception.class)
    public void complateOutStock(Task task) throws Exception {
    public void complateOutStock(Task task, Long loginUserId) throws Exception {
        if (Objects.isNull(task)) {
            throw new CoolException("参数不能为空!!");
        }
        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc()));
        if (Objects.isNull(loc)) {
            throw new CoolException("库位不存在!!");
@@ -763,7 +778,11 @@
        for (LocItem item : locItems) {
            LocItemWorking working = new LocItemWorking();
            BeanUtils.copyProperties(item, working);
            working.setId(null).setTaskId(task.getId()).setLocItemId(item.getId());
            working.setId(null)
                    .setTaskId(task.getId())
                    .setLocItemId(item.getId())
                    .setUpdateBy(loginUserId)
                    .setUpdateTime(new Date());
            workings.add(working);
        }
@@ -775,7 +794,7 @@
            //更新库位明细
            subtractLocItem(loc);
        } catch (Exception e) {
            log.error("<UNK>", e);
            logger.error("<UNK>", e);
            throw new CoolException(e.getMessage());
        }
@@ -794,14 +813,14 @@
                    throw new CoolException("波次明细不存在!!");
                }
                try {
                    saveOutStockItem(maps.get(key), waveItem);
                    saveOutStockItem(maps.get(key), waveItem, loginUserId);
                } catch (Exception e) {
                    throw new CoolException(e.getMessage());
                }
            });
        } else {
            try {
                saveOutStockItem(taskItems, null);
                saveOutStockItem(taskItems, null, loginUserId);
            } catch (Exception e) {
                throw new CoolException(e.getMessage());
            }
@@ -811,6 +830,8 @@
        if (!locService.update(new LambdaUpdateWrapper<Loc>()
                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                .set(Loc::getBarcode, null)
                        .set(Loc::getUpdateBy, loginUserId)
                        .set(Loc::getUpdateTime, new Date())
                .eq(Loc::getId, loc.getId()))) {
            throw new CoolException("库位状态修改失败!!");
        }
@@ -818,21 +839,23 @@
        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("临时库存清除失败!!");
            }
        }
    }
@@ -844,7 +867,7 @@
     * @version 1.0
     */
    @Transactional(rollbackFor = Exception.class)
    public void saveOutStockItem(List<TaskItem> taskItems, WaveItem waveItem) throws Exception {
    public void saveOutStockItem(List<TaskItem> taskItems, WaveItem waveItem, Long loginUserId) throws Exception {
        Stock stock = new Stock();
        String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null);
        if (StringUtils.isBlank(ruleCode)) {
@@ -852,6 +875,8 @@
        }
        Double sum = taskItems.stream().mapToDouble(TaskItem::getAnfme).sum();
        stock.setCode(ruleCode)
                .setUpdateBy(loginUserId)
                .setUpdateTime(new Date())
                .setAnfme(sum);
        if (Objects.isNull(waveItem)) {
            stock.setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type))
@@ -870,6 +895,8 @@
            StockItem stockItem = new StockItem();
            BeanUtils.copyProperties(item, stockItem);
            stockItem.setSourceItemId(item.getOrderItemId())
                    .setUpdateBy(loginUserId)
                    .setUpdateTime(new Date())
                    .setStockCode(stock.getCode())
                    .setId(null)
                    .setStockId(stock.getId());
@@ -901,7 +928,7 @@
     * @version 1.0
     */
    @Transactional(rollbackFor = Exception.class)
    public void complateInstock(Task task) {
    public void complateInstock(Task task, Long loginUserId) {
        if (Objects.isNull(task)) {
            return;
        }
@@ -921,7 +948,7 @@
        }
        try {
            //更新库位明细
            saveLocItem(taskItems, task.getId());
            saveLocItem(taskItems, task.getId(), loginUserId);
        } catch (Exception e) {
            throw new CoolException("库位明细更新失败!!");
        }
@@ -936,10 +963,11 @@
            List<TaskItem> items = orderMap.get(key);
            try {
                //保存库存明细
                saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType());
                saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType(), loginUserId);
                //移出收货区库存, 修改组托状态
                removeReceiptStock(pakinItem);
                removeReceiptStock(pakinItem, loginUserId);
            } catch (Exception e) {
                logger.error("<UNK>", e);
                throw new CoolException(e.getMessage());
            }
        });
@@ -954,24 +982,26 @@
    /**
     * @param
     * @param loginUserId
     * @return
     * @author Ryan
     * @description 移除收货区库存
     * @time 2025/4/30 16:32
     */
    @Transactional(rollbackFor = Exception.class)
    public void removeReceiptStock(WaitPakinItem pakinItem) {
    public 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 = itemServiceOne.getWorkQty() - pakinItem.getAnfme();
        Double qty = itemServiceOne.getQty() + pakinItem.getAnfme();
        Double workQty = Math.round((itemServiceOne.getWorkQty() - pakinItem.getAnfme()) * 10000) / 10000.0;
        Double qty = Math.round((itemServiceOne.getQty() + pakinItem.getAnfme()) * 10000) / 10000.0;
        itemServiceOne.setWorkQty(workQty).setQty(qty);
        if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
                .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val)
                        .set(WaitPakin::getUpdateBy, loginUserId)
                .eq(WaitPakin::getId, pakinItem.getPakinId()))) {
            throw new CoolException("组拖状态修改失败!!");
        }
@@ -981,6 +1011,7 @@
                throw new CoolException("收货区物料删除失败!!");
            }
        } else {
            itemServiceOne.setUpdateBy(loginUserId).setUpdateTime(null);
            if (!warehouseAreasItemService.updateById(itemServiceOne)) {
                throw new CoolException("收货区库完成数量修改失败!!");
            }
@@ -989,13 +1020,14 @@
    /**
     * @param
     * @param loginUserId
     * @return
     * @author Ryan
     * @description 更新库位明细
     * @time 2025/4/15 15:28
     */
    @Transactional(rollbackFor = Exception.class)
    public void saveLocItem(List<TaskItem> items, Long taskId) throws Exception {
    public void saveLocItem(List<TaskItem> items, Long taskId, Long loginUserId) throws Exception {
        Task task = this.getById(taskId);
        if (Objects.isNull(task)) {
            throw new CoolException("任务不存在!!");
@@ -1008,6 +1040,7 @@
            BeanUtils.copyProperties(taskItem, item);
            item.setLocCode(loc.getCode()).setId(null)
                    .setLocId(loc.getId())
                    .setUpdateBy(loginUserId)
                    .setWkType(taskItem.getWkType())
                    .setType(taskItem.getOrderType());
            locItems.add(item);
@@ -1021,10 +1054,11 @@
     * 生成入库库存明细
     *
     * @param items
     * @param loginUserId
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public void saveStockItems(List<TaskItem> items, Task task, Long id, String code, Short wkType, String type) throws
    public void saveStockItems(List<TaskItem> items, Task task, Long id, String code, Short wkType, String type, Long loginUserId) throws
            Exception {
        Stock stock = new Stock();
        String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null);
@@ -1038,6 +1072,7 @@
                .setAnfme(sum)
                .setWkType(wkType)
                .setBarcode(task.getBarcode())
                .setUpdateBy(loginUserId)
                .setType(type);
        if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) ||
                task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type) ||
@@ -1061,6 +1096,7 @@
                    .setStockCode(stock.getCode())
                    .setBarcode(task.getBarcode())
                    .setSourceItemId(item.getOrderItemId())
                    .setUpdateBy(loginUserId)
                    .setId(null)
                    .setStockId(stock.getId());
            stockItems.add(stockItem);
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java
@@ -63,7 +63,7 @@
        if (StringUtils.isBlank(waitPakin.getBarcode())) {
            throw new CoolException("参数错误:托盘码为空!!");
        }
        List<Short> asList = Arrays.asList(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val), Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
//        List<Short> asList = Arrays.asList(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val), Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
        WaitPakin pakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
                .eq(WaitPakin::getBarcode, waitPakin.getBarcode()));
        if (!Objects.isNull(pakin)) {
@@ -84,7 +84,7 @@
        }
        waitPakin1.setCode(ruleCode)
                //状态修改为入库中
                .setIoStatus(Short.parseShort(PakinIOStatus.PAKIN_IO_STATUS_DONE.val))
                .setIoStatus(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)
                .setAnfme(sum)
                .setUpdateBy(userId)
                .setCreateBy(userId)
@@ -149,7 +149,7 @@
        }
        double sum1 = items.stream().mapToDouble(WaitPakinItem::getAnfme).sum();
        Double sum1 = items.stream().mapToDouble(WaitPakinItem::getAnfme).sum();
        if (!waitPakinItemService.saveBatch(items)) {
            throw new CoolException("组托明细保存失败!!");
@@ -161,9 +161,10 @@
            if (Objects.isNull(one)) {
                throw new CoolException("收货区数据错误!!");
            }
//            one.setAnfme(one.getAnfme() - pakinItem.getAnfme())
            one.setWorkQty(one.getWorkQty() + pakinItem.getAnfme() + one.getQty());
            if (one.getWorkQty() > one.getAnfme()) {
            Double workQty = Math.round((one.getWorkQty() + pakinItem.getAnfme()) * 10000) / 10000.0;
            Double qty = Math.round((workQty + one.getQty()) * 10000) / 10000.0;
            one.setWorkQty(workQty);
            if (qty.compareTo(one.getAnfme()) > 0) {
                throw new CoolException("组托数量不能大于收货数量!!");
            }
            if (!warehouseAreasItemService.saveOrUpdate(one)) {
@@ -175,9 +176,6 @@
        if (!this.updateById(waitPakin1)) {
            throw new CoolException("组托数量修改失败!!");
        }
        //TODO 组托完成后,扣减收货区库存
        return pakin;
    }
@@ -222,10 +220,13 @@
                            if (item.getReceiptQty().compareTo(0.00) == 0) {
                                throw new CoolException("解绑数量不能为零!!");
                            }
                            if (item.getReceiptQty().compareTo(pakinItems.get(i1).getAnfme() - pakinItems.get(i1).getWorkQty() - pakinItems.get(i1).getQty()) > 0) {
                            Double reslt = Math.round((pakinItems.get(i1).getAnfme() - pakinItems.get(i1).getWorkQty() - pakinItems.get(i1).getQty()) * 10000) / 10000.0;
                            if (item.getReceiptQty().compareTo(reslt) > 0) {
                                throw new CoolException("解绑数量不能大于剩余可执行数!!");
                            }
                           pakinItems.get(i1).setAnfme(pakinItems.get(i1).getAnfme() - item.getReceiptQty());
                            Double anfme = Math.round((pakinItems.get(i1).getAnfme() - item.getReceiptQty()) * 10000) / 10000.0;
                           pakinItems.get(i1).setAnfme(anfme);
                           if (!waitPakinItemService.updateById(pakinItems.get(i1))) {
                               throw new CoolException("组托明细数量修改失败!!");
                           }
@@ -236,7 +237,7 @@
                        }
                        for (int i = 0; i < warehouseAreasItems.size(); i++) {
                            if (warehouseAreasItems.get(i).getId().equals(pakinItems.get(i1).getSource())) {
                                double v = warehouseAreasItems.get(i).getWorkQty() - item.getReceiptQty();
                                double v = Math.round((warehouseAreasItems.get(i).getWorkQty() - item.getReceiptQty()) * 10000) / 10000.0;
                                warehouseAreasItems.get(i).setWorkQty(v);
                                if (!warehouseAreasItemService.updateById(warehouseAreasItems.get(i))) {
                                    throw new CoolException("收货区数量修改失败!!");
@@ -254,7 +255,8 @@
                    throw new CoolException("组托删除失败!!");
                }
            } else {
                waitPakins.setAnfme(waitPakins.getAnfme() - anfmes);
                Double anfme = Math.round((waitPakins.getAnfme() - anfmes) * 10000) / 10000.0;
                waitPakins.setAnfme(anfme);
                if (!waitPakinService.updateById(waitPakins)) {
                    throw new CoolException("组托数据修改失败!!");
                }
@@ -298,7 +300,8 @@
                    continue;
                }
                double sum = pakin.stream().mapToDouble(WaitPakinItem::getAnfme).sum();
                item.setWorkQty(item.getWorkQty() - sum);
                Double workQty = Math.round((item.getWorkQty() - sum) * 10000) / 10000.0;
                item.setWorkQty(workQty);
                if (!warehouseAreasItemService.updateById(item)) {
                    throw new CoolException("收货区数据回滚失败!!");
                }
rsf-server/src/main/java/com/vincent/rsf/server/system/utils/SystemAuthUtils.java
New file
@@ -0,0 +1,75 @@
package com.vincent.rsf.server.system.utils;
import com.vincent.rsf.common.enums.SystemModeType;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.framework.common.SpringUtils;
import com.vincent.rsf.server.common.config.ConfigProperties;
import com.vincent.rsf.server.common.domain.BusinessRes;
import com.vincent.rsf.server.common.security.JwtSubject;
import com.vincent.rsf.server.common.utils.JwtUtil;
import com.vincent.rsf.server.system.entity.Tenant;
import com.vincent.rsf.server.system.entity.User;
import com.vincent.rsf.server.system.entity.UserLogin;
import com.vincent.rsf.server.system.service.TenantService;
import com.vincent.rsf.server.system.service.UserLoginService;
import com.vincent.rsf.server.system.service.UserService;
import org.checkerframework.checker.units.qual.C;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import javax.annotation.PostConstruct;
import java.util.Objects;
@Component
public class SystemAuthUtils {
    public static Logger logger = LoggerFactory.getLogger(SystemAuthUtils.class);
    private static String username;
    private static String password;
    private static String tokenKey;
    private static Long tokenExpireTime;
    private static SystemModeType systemMode;
    @Autowired
    private ConfigProperties configProperties;
    @PostConstruct
    public void init() {
        username = configProperties.getUserName();
        password = configProperties.getPassword();
    }
    public static User getLoginUser() {
        try {
            Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
            if (authentication != null) {
                Object object = authentication.getPrincipal();
                if (object instanceof User) {
                    return (User) object;
                }
            } else {
                UserService userService = SpringUtils.getBean(UserService.class);
                return userService.getByUsername(username, null);
            }
        } catch (Exception e) {
            logger.error("<UNK>", e);
        }
        return null;
    }
    public static Long getLoginUserId() {
        User loginUser = getLoginUser();
        return loginUser == null ? null : loginUser.getId();
    }
}
rsf-server/src/main/resources/application.yml
@@ -11,6 +11,8 @@
  code-length: 6
  code-time: 300
  security-code: 951123
  username: super
  password: 123456
eureka:
  client:
@@ -37,6 +39,7 @@
super:
  pwd: xltys1995
logging:
  file:
    path: logs/@pom.artifactId@
rsf-server/src/main/resources/mapper/manager/BasDeviceMapper.xml
File was deleted