skyouc
2025-05-05 1e7849282875b5bcd237d93f7b496aecb6ede4b6
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/MobileServiceImpl.java
@@ -47,6 +47,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
@@ -197,7 +198,7 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R receiptToWarehouse(Map<String, Object> params, Long loginUserId) {
    public synchronized R receiptToWarehouse(Map<String, Object> params, Long loginUserId) {
        if (Objects.isNull(params)) {
            throw new CoolException("参数不能为空!!");
        }
@@ -267,6 +268,7 @@
            Double itemRcptQty = dto.getReceiptQty() + orderItem.getQty();
            orderItem.setQty(itemRcptQty)
                    .setSplrBatch(dto.getSplrBatch())
                    .setUpdateBy(loginUserId)
                    .setStockUnit(dto.getStockUnit())
                    .setProdTime(dto.getProdTime());
@@ -331,23 +333,17 @@
            if (!warehouseAreasItemService.saveOrUpdate(item)) {
                throw new CoolException("收货失败!!");
            }
        }
//        if (!warehouseAreasItemService.saveBatch(allOrders)) {
//            throw new CoolException("收货失败!!");
//        }
//        //获取采购数量
//        double purQty = receipts.stream().mapToDouble(ReceiptDetlsDto::getPurQty).sum();
//
//        BigDecimal subtract = BigDecimal.valueOf(receiptQty).subtract(BigDecimal.valueOf(purQty));
//        //判断已收货数量是否小于等于采购数量
//        if (subtract.compareTo(new BigDecimal("0.0")) <= 0) {
//            asnOrder.setRleStatus(Short.valueOf("1"));
//            //日志表操作
//            operateOrderLogs(asnOrder);
//        }
        return R.ok(asnOrder);
        AsnOrder order = asnOrderMapper.getOne(new LambdaQueryWrapper<AsnOrder>().eq(AsnOrder::getCode, asnCode));
        if (order.getQty().compareTo(order.getAnfme()) >= 0.00) {
            order.setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_RECEIPT_DONE.val).setRleStatus(Short.valueOf("1"));
            if (!asnOrderMapper.updateById(order)) {
                throw new CoolException("订单状态修改失败!!");
            }
        }
        return R.ok("收货成功!!");
    }
    /**
@@ -428,7 +424,7 @@
    public R getDeltByCode(String code) {
        //TODO 后续需根据策略配置,获取组拖数据。如:混装,按批次混装等
        LambdaQueryWrapper<WarehouseAreasItem> queryWrapper = new QueryWrapper<WarehouseAreasItem>()
                .select("SUM(anfme) as anfme, track_code, asn_code, id, splr_batch, ispt_result, plat_item_id, batch, qty, work_qty, matnr_code, matnr_id, maktx").lambda()
                .select("SUM(anfme) as anfme, track_code, asn_code, id, splr_batch, ispt_result, plat_item_id, batch,unit, stock_unit,  qty, work_qty, matnr_code, matnr_id, maktx").lambda()
                .eq(WarehouseAreasItem::getTrackCode, code)
                .groupBy(WarehouseAreasItem::getSplrBatch, WarehouseAreasItem::getAsnId, WarehouseAreasItem::getAreaId, WarehouseAreasItem::getMatnrId);
        return R.ok(warehouseAreasItemService.getOne(queryWrapper));
@@ -641,7 +637,7 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R publicToStock(PublicToStockParams params, Long loginUserId) {
    public synchronized R publicToStock(PublicToStockParams params, Long loginUserId) {
        if (Objects.isNull(params.getLocCode()) || StringUtils.isBlank(params.getLocCode())) {
            throw new CoolException("库位不能为空!!");
        }
@@ -773,7 +769,7 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R taskGetLocs(String code) throws Exception {
    public synchronized R taskGetLocs(String code) throws Exception {
        if (StringUtils.isBlank(code)) {
            throw new CoolException("拖盘码不能为空!!");
        }
@@ -911,7 +907,7 @@
     * @description 生成任务列表
     */
    @Override
    public R generateTask(Map<String, Object> map, Long loginUserId) {
    public synchronized R generateTask(Map<String, Object> map, Long loginUserId) {
        String barcode = map.get("barcode").toString();
        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, barcode));
        if (waitPakins.isEmpty()) {
@@ -938,6 +934,8 @@
                    .setFieldsIndex(asnOrderItem.getFieldsIndex())
                    .setBarcode(asnOrderItem.getTrackCode())
                    .setQty(asnOrderItem.getQty())
                    .setStockUnit(asnOrderItem.getStockUnit())
                    .setPurUnit(asnOrderItem.getPurUnit())
                    .setPoCode(asnOrderItem.getPoCode())
                    .setAnfme(asnOrderItem.getAnfme())
                    .setPurQty(asnOrderItem.getPurQty())
@@ -949,8 +947,7 @@
            }
            //SET 物料最大存放数量
            detlsDto.setMaxQty(matnr.getMaxQty())
                    .setMatnrId(matnr.getId())
                    .setStockUnit(matnr.getStockUnit());
                    .setMatnrId(matnr.getId());
            QlyInspect inspect = qlyInspectMapper.selectOne(new LambdaQueryWrapper<QlyInspect>()
                    .eq(QlyInspect::getAsnId, asnOrderItem.getAsnId()));
            if (!Objects.isNull(inspect)) {
@@ -961,7 +958,7 @@
            LocItem stockItem = locItemService.getOne(new LambdaQueryWrapper<LocItem>()
//                    .eq(LocItem::getOrderItemId, asnOrderItem.getId())
                    .eq(LocItem::getFieldsIndex, asnOrderItem.getFieldsIndex())
                    .eq(LocItem::getBatch, asnOrderItem.getBatch())
                    .eq(LocItem::getBatch, asnOrderItem.getSplrBatch())
                    .eq(LocItem::getMatnrId, asnOrderItem.getMatnrId()));
            //SET 当前库存数量
            if (Objects.isNull(stockItem)) {