#
luxiaotao1123
2021-03-23 0f007b4fb175c29b916cbd3c3a640bddce86447b
src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java
@@ -9,9 +9,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import zy.cloud.wms.common.model.BillDto;
import zy.cloud.wms.common.model.OrderStoDto;
import zy.cloud.wms.common.service.MainService;
import zy.cloud.wms.common.service.asrs.AsrsService;
import zy.cloud.wms.common.service.erp.ErpService;
import zy.cloud.wms.common.utils.VersionUtils;
import zy.cloud.wms.manager.entity.*;
import zy.cloud.wms.manager.entity.param.*;
@@ -46,6 +48,8 @@
    private MatService matService;
    @Autowired
    private AsrsService asrsService;
    @Autowired
    private ErpService erpService;
    @Override
    @Transactional
@@ -59,6 +63,17 @@
            return R.error("物料不存在");
        }
        Date now = new Date();
        String docNum = String.valueOf(snowflakeIdWorker.nextId());
        switch (param.getDocType()) {
            case 34:    // 采购单
                docNum = "PU-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15);
                break;
            case 45:    // 销售退货单
                docNum = "SR-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15);
                break;
            default:
                break;
        }
        for (Comb comb : combs) {
            // 改变组托档状态
            comb.setIoStatus(4);
@@ -77,6 +92,8 @@
                locDetl.setZpallet(param.getZpallet());
                locDetl.setAnfme(comb.getAnfme());
                VersionUtils.setLocDetl(locDetl, comb);
                locDetl.setDocId(param.getDocType().longValue());
                locDetl.setDocNum(docNum);
                locDetl.setStatus(1);
                locDetl.setCreateBy(userId);
                locDetl.setCreateTime(now);
@@ -94,6 +111,19 @@
            }
        }
        // 上报给erp
        List<BillDto> dtos = new ArrayList<>();
        for (Comb comb : combs) {
            BillDto billDto = new BillDto();
            billDto.setMatnr(comb.getMatnr());
            billDto.setQty(comb.getAnfme());
            dtos.add(billDto);
        }
        if (!erpService.uploadBill(dtos, param.getDocType(), docNum)) {
            throw new CoolException("无法上报至erp");
        }
        return R.ok();
    }
@@ -174,6 +204,21 @@
        // 修改单据状态
        if (!custOrderService.updateStatus(param.getNumber(), 4)) {
            throw new CoolException("修改单据状态失败");
        }
        // 采购退货单
        if (param.getNumber().startsWith("PR-")) {
            List<BillDto> dtos = new ArrayList<>();
            for (Pakout pakout : pakouts) {
                BillDto billDto = new BillDto();
                billDto.setMatnr(pakout.getMatnr());
                billDto.setQty(pakout.getAnfme());
                dtos.add(billDto);
            }
            // erp单据上传 -- 采购退货单
            if (!erpService.uploadBill(dtos, 6, pakouts.get(0).getDocNum())) {
                throw new CoolException("无法上报至erp");
            }
        }
        return R.ok();
    }
@@ -352,17 +397,17 @@
            }
        }
        if (asrs) {
            if (asrsService.stockTransfer(params)) {
                for (StockTransferParam param : params) {
                    // 修改销售订单待出数量
                    if (!custOrderService.updateQty(number, param.getMatnr(), param.getAnfme())) {
                        throw new CoolException("修改销售订单待出数量失败");
                    }
                }
                return R.ok("库存调拨成功");
            } else {
                return R.error("立库调拨失败,请联系管理员");
            }
//            if (asrsService.stockTransfer(params)) {
//                for (StockTransferParam param : params) {
//                    // 修改销售订单待出数量
//                    if (!custOrderService.updateQty(number, param.getMatnr(), param.getAnfme())) {
//                        throw new CoolException("修改销售订单待出数量失败");
//                    }
//                }
//                return R.ok("库存调拨成功");
//            } else {
//                return R.error("立库调拨失败,请联系管理员");
//            }
        }
        return R.error("暂不缺货,不需要立库调拨");
    }