自动化立体仓库 - WMS系统
chen.llin
昨天 12067f657bc3dc169a7a466e433374368e8daf73
src/main/java/com/zy/asrs/controller/OrderPakinController.java
@@ -13,6 +13,7 @@
import com.zy.asrs.service.*;
import com.zy.common.model.DetlDto;
import com.zy.common.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -20,6 +21,7 @@
import java.util.*;
@Slf4j
@RestController
@RequestMapping("order/pakin")
public class OrderPakinController extends BaseController {
@@ -42,6 +44,29 @@
    private WrkMastService wrkMastService;
    @Autowired
    private WrkMastLogService wrkMastLogService;
    @Autowired
    private ClientService clientService;
    @Autowired
    private CrossDockService crossDockService;
    @RequestMapping(value = "/order/list/pda/page/auth")
    @ManagerAuth
    public R pdaPageList(@RequestParam(required = true)Long tagId,
                         @RequestParam(defaultValue = "1")Integer curr,
                         @RequestParam(defaultValue = "10")Integer limit){
        List<DocType> docTypes = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakin", 1));
        ArrayList<Integer> arrayList = new ArrayList<>();
        docTypes.forEach(docType -> {
            arrayList.add(docType.getDocId().intValue());
        });
        EntityWrapper<OrderPakin> wrapper = new EntityWrapper<>();
//        wrapper.eq("tag_id", tagId);
        wrapper.in("doc_type", arrayList);
        wrapper.in("settle",1,2);
        wrapper.orderBy("create_time", false);
        Page<OrderPakin> orderPage = orderService.selectPage(new Page<>(curr, limit), wrapper);
        return R.ok().add(orderPage);
    }
    @RequestMapping(value = "/order/nav/list/auth")
    @ManagerAuth
@@ -112,19 +137,23 @@
        if (order != null) {
            return R.error("单据编号已存在");
        }
        Client client = clientService.selectOne(new EntityWrapper<Client>().eq("name", param.getCstmrName()));
        if (null == client){
            return R.error("客户不存在");
        }
        Date now = new Date();
        order = new OrderPakin(
                String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                param.getOrderNo(),    // 订单编号
                DateUtils.convert(now),    // 单据日期
                param.getOrderTime(),    // 单据日期
                param.getDocType(),    // 单据类型
                null,    // 项目编号
                null,    //
                null,    // 调拨项目编号
                null,    // 初始票据号
                null,    // 票据号
                null,    // 客户编号
                null,    // 客户
                client.getCode(),    // 客户编号
                client.getName(),    // 客户
                null,    // 联系方式
                null,    // 操作人员
                null,    // 合计金额
@@ -181,6 +210,29 @@
                }
            }
        }
        // 越库功能:如果勾选了越库订单,无论什么类型的订单都按照越库逻辑处理
        Boolean isCrossDock = param.getIsCrossDock();
        log.info("检查越库订单标识,isCrossDock:{},类型:{},订单号:{}",
                isCrossDock, isCrossDock != null ? isCrossDock.getClass().getName() : "null", order.getOrderNo());
        // 判断是否为越库订单(支持 Boolean.TRUE 或 true 字符串)
        boolean shouldProcessCrossDock = Boolean.TRUE.equals(isCrossDock) ||
                (isCrossDock != null && isCrossDock.toString().equalsIgnoreCase("true"));
        if (shouldProcessCrossDock) {
            log.info("开始处理越库订单,订单号:{},订单ID:{}", order.getOrderNo(), order.getId());
            String outOrderNo = crossDockService.processCrossDockInbound(order, param, getUserId());
            // 重新查询订单,确保状态已更新
            OrderPakin finalOrder = orderService.selectById(order.getId());
            if (finalOrder != null) {
                log.info("越库订单处理完成,订单号:{},最终状态:{}", finalOrder.getOrderNo(), finalOrder.getSettle());
            }
            return R.ok("越库入库单创建成功,已自动生成越库出库单:" + outOrderNo);
        } else {
            log.info("非越库订单,订单号:{},状态保持为:{}", order.getOrderNo(), order.getSettle());
        }
        return R.ok("订单添加成功");
    }
@@ -194,14 +246,23 @@
        }
        Date now = new Date();
        Long userId = getUserId();
        Client client = clientService.selectOne(new EntityWrapper<Client>().eq("name", param.getCstmrName()));
        if (null == client){
            return R.error("客户不存在");
        }
        order.setCstmr(client.getCode());
        order.setCstmrName(client.getName());
        // 修改主档
        if (!param.getDocType().equals(order.getDocType())) {
        if (!param.getDocType().equals(order.getDocType()) || !param.getOrderTime().equals(order.getOrderTime())) {
            order.setDocType(param.getDocType());
            order.setUpdateBy(userId);
            order.setUpdateTime(now);
            if (!orderService.updateById(order)) {
                throw new CoolException("修改订单类型失败");
            }
            order.setOrderTime(param.getOrderTime());
        }
        order.setUpdateBy(userId);
        order.setUpdateTime(now);
        if (!orderService.updateById(order)) {
            throw new CoolException("修改订单类型失败");
        }
        // 修改明细档
//        List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId());
@@ -310,7 +371,7 @@
                .add("list", wrkTraceVos)
                .add("orderNo", order.getOrderNo())
                .add("totalQty", totalQty)
                .add("wrkQty", wrkQty + endQty)
                .add("wrkQty", wrkQty)
                .add("lackQty", lackQty)
                .add("endQty", endQty)
        );