自动化立体仓库 - WMS系统
luxiaotao1123
2022-03-24 9b42fa92ac328405850bea678a811d983871bc90
src/main/java/com/zy/asrs/controller/OrderController.java
@@ -6,10 +6,8 @@
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.common.*;
import com.core.exception.CoolException;
import com.zy.asrs.entity.Order;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.entity.param.InitOrderParam;
@@ -17,12 +15,10 @@
import com.zy.asrs.service.OrderService;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@RestController
public class OrderController extends BaseController {
@@ -31,6 +27,8 @@
    private OrderService orderService;
    @Autowired
    private OrderDetlService orderDetlService;
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    @RequestMapping(value = "/order/head/page/auth")
    @ManagerAuth
@@ -42,7 +40,9 @@
        EntityWrapper<Order> wrapper = new EntityWrapper<>();
        excludeTrash(param);
        convert(param, wrapper);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else {
            wrapper.orderBy("create_time", false);
        }
        return R.ok(orderService.selectPage(new Page<>(curr, limit), wrapper));
    }
@@ -54,9 +54,64 @@
    @RequestMapping(value = "/order/form/add/auth")
    @ManagerAuth
    @Transactional
    public R formAdd(@RequestBody InitOrderParam param){
        System.out.println(JSON.toJSONString(param));
        return R.ok();
        Order order = orderService.selectByNo(param.getOrderNo());
        if (order != null) {
            return R.error("单据编号已存在");
        }
        Date now = new Date();
        order = new Order(
                String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                param.getOrderNo(),    // 订单编号
                DateUtils.convert(now),    // 单据日期
                param.getDocType(),    // 单据类型
                null,    // 项目编号
                null,    //
                null,    // 调拨项目编号
                null,    // 初始票据号
                null,    // 票据号
                null,    // 客户编号
                null,    // 客户
                null,    // 联系方式
                null,    // 操作人员
                null,    // 合计金额
                null,    // 优惠率
                null,    // 优惠金额
                null,    // 销售或采购费用合计
                null,    // 实付金额
                null,    // 付款类型
                null,    // 业务员
                null,    // 结算天数
                null,    // 邮费支付类型
                null,    // 邮费
                null,    // 付款时间
                null,    // 发货时间
                null,    // 物流名称
                null,    // 物流单号
                1L,    // 订单状态
                1,    // 状态
                getUserId(),    // 添加人员
                now,    // 添加时间
                getUserId(),    // 修改人员
                now,    // 修改时间
                null    // 备注
        );
        if (!orderService.insert(order)) {
            throw new CoolException("保存订单主档失败");
        }
        for (OrderDetl orderDetl : param.getOrderDetlList()) {
            orderDetl.setOrderId(order.getId());
            orderDetl.setCreateBy(getUserId());
            orderDetl.setCreateTime(now);
            orderDetl.setUpdateBy(getUserId());
            orderDetl.setUpdateTime(now);
            orderDetl.setStatus(1);
            if (!orderDetlService.insert(orderDetl)) {
                throw new CoolException("保存订单明细档失败");
            }
        }
        return R.ok("订单添加成功");
    }
    @RequestMapping(value = "/order/form/modify/auth")