| | |
| | | @Override |
| | | @Transactional |
| | | public void pakinOrderCreate(OpenOrderPakinParam param) { |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | String orderNo = param.getOrderNo(); |
| | | String orderType = param.getOrderType(); |
| | | String optType = param.getOptType(); |
| | | |
| | | Order order = orderService.selectByNo(orderNo); |
| | | if (optType.equals("add")) { |
| | | if (!Cools.isEmpty(order)) { |
| | | throw new CoolException(param.getOrderNo() + "单据已存在,请勿重复提交"); |
| | | throw new CoolException(orderNo + "单据已存在,请勿重复提交"); |
| | | } |
| | | DocType docType = docTypeService.selectOrAdd(param.getOrderType(), Boolean.TRUE); |
| | | |
| | | DocType docType = docTypeService.selectOrAdd(orderType, Boolean.TRUE); |
| | | Date now = new Date(); |
| | | // 单据主档 |
| | | order = new Order( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | param.getOrderNo(), // 订单编号 |
| | | orderNo, // 订单编号 |
| | | DateUtils.convert(now), // 单据日期 |
| | | docType.getDocId(), // 单据类型 |
| | | null, // 项目编号 |
| | |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("生成单据主档失败,请联系管理员"); |
| | | throw new CoolException("生成单据主档失败,orderNo:" + orderNo); |
| | | } |
| | | // 单据明细档 |
| | | |
| | | // 合并单据明细档 |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | List<DetlDto> orderDetails = param.getOrderDetails(); |
| | | for (DetlDto detail : orderDetails) { |
| | |
| | | list.add(dto); |
| | | } |
| | | } |
| | | |
| | | // 插入明细 |
| | | for (DetlDto detlDto : list) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | |
| | | orderDetl.setAnfme(detlDto.getAnfme()); |
| | | orderDetl.setOrderId(order.getId()); |
| | | orderDetl.setOrderNo(order.getOrderNo()); |
| | | orderDetl.setSku(detlDto.getSku()); // 单行号,u8明细id,上报需要 |
| | | orderDetl.setCreateBy(9527L); |
| | | orderDetl.setCreateTime(now); |
| | | orderDetl.setUpdateBy(9527L); |
| | |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("生成单据明细失败,请联系管理员"); |
| | | throw new CoolException(orderNo+":生成单据明细失败:" + detlDto.getMatnr()); |
| | | } |
| | | } |
| | | } else if (optType.equals("delete")) { |
| | | if (Cools.isEmpty(order)) { |
| | | throw new CoolException(orderNo + "单据不存在!"); |
| | | } |
| | | |
| | | // 订单状态 |
| | | Long settle = order.getSettle(); |
| | | if (settle == 1) { |
| | | // 删除订单明细 |
| | | orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", order.getId())); |
| | | // 删除订单主表 |
| | | orderService.delete(new EntityWrapper<Order>().eq("id", order.getId())); |
| | | |
| | | } else { |
| | | throw new CoolException(orderNo + ":订单已处理,无法取消"); |
| | | } |
| | | } else { |
| | | throw new CoolException(orderNo + ",操作类型不存在:" + optType); |
| | | } |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Transactional |
| | | public void pakoutOrderCreate(OpenOrderPakoutParam param) { |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | // 如果单据不存在则添加;如果单据存在,作业中无法修改,反之则修改单据 |
| | | if (!Cools.isEmpty(order)) { |
| | | if (order.getSettle() > 1L) { |
| | | throw new CoolException(param.getOrderNo() + "正在出库,无法修改单据"); |
| | | } |
| | | orderService.remove(order.getId()); |
| | | } |
| | | DocType docType = docTypeService.selectOrAdd(param.getOrderType(), Boolean.FALSE); |
| | | String orderNo = param.getOrderNo(); |
| | | String optType = param.getOptType(); |
| | | String orderType = param.getOrderType(); |
| | | Order order = orderService.selectByNo(orderNo); |
| | | |
| | | if (optType.equals("add")) { |
| | | DocType docType = docTypeService.selectOrAdd(orderType, Boolean.FALSE); |
| | | Date now = new Date(); |
| | | // 单据主档 |
| | | order = new Order( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | param.getOrderNo(), // 订单编号 |
| | | orderNo, // 订单编号 |
| | | DateUtils.convert(now), // 单据日期 |
| | | docType.getDocId(), // 单据类型 |
| | | null, // 项目编号 |
| | |
| | | null // 备注 |
| | | ); |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("生成单据主档失败,请联系管理员"); |
| | | throw new CoolException("生成单据主档失败,orderNo:" + orderNo); |
| | | } |
| | | // 单据明细档 |
| | | List<DetlDto> list = new ArrayList<>(); |
| | |
| | | orderDetl.setAnfme(detlDto.getAnfme()); |
| | | orderDetl.setOrderId(order.getId()); |
| | | orderDetl.setOrderNo(order.getOrderNo()); |
| | | orderDetl.setSku(detlDto.getSku()); // 单行号,u8明细id,上报需要 |
| | | orderDetl.setCreateBy(9527L); |
| | | orderDetl.setCreateTime(now); |
| | | orderDetl.setUpdateBy(9527L); |
| | |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("生成单据明细失败,请联系管理员"); |
| | | throw new CoolException(orderNo + ":生成单据明细失败:" + detlDto.getMatnr()); |
| | | } |
| | | } |
| | | } else if (optType.equals("delete")) { |
| | | if (Cools.isEmpty(order)) { |
| | | throw new CoolException(orderNo + "单据不存在!"); |
| | | } |
| | | // 订单状态 |
| | | Long settle = order.getSettle(); |
| | | if (settle == 1) { |
| | | // 删除订单明细 |
| | | orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", order.getId())); |
| | | // 删除订单主表 |
| | | orderService.delete(new EntityWrapper<Order>().eq("id", order.getId())); |
| | | } else { |
| | | throw new CoolException(orderNo + ":订单已处理,无法取消"); |
| | | } |
| | | } else { |
| | | throw new CoolException(orderNo + ",操作类型不存在:" + optType); |
| | | } |
| | | } |
| | | |
| | |
| | | if (Cools.isEmpty(param.getMatDetails()) || param.getMatDetails().size() <=0 ) { |
| | | throw new CoolException("商品数据为空"); |
| | | } |
| | | |
| | | for(MatSyncParam.MatParam matParam : param.getMatDetails()){ |
| | | if(Cools.isEmpty(matParam.getMatnr())){ |
| | | throw new CoolException("商品编码不能为空"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | for (MatSyncParam.MatParam matParam : param.getMatDetails()) { |
| | | String logInfo = "optType:" + matParam.getOptType() + ",matnr:" + matParam.getMatnr() + ",maktx:" + matParam.getMaktx() + ",specs:" + matParam.getSpecs(); |
| | | if (Cools.isEmpty(matParam.getOptType(), matParam.getMatnr(), matParam.getMaktx())) { |
| | | throw new CoolException("商品信息不能为空[" + logInfo + "]"); |
| | | } |
| | | Mat mat = matService.selectByMatnr(matParam.getMatnr()); |
| | | if (mat == null) { |
| | | switch (matParam.getOptType()) { |
| | | case "add": |
| | | if (mat != null) { |
| | | throw new CoolException("商品信息已经存在[" + logInfo + "]"); |
| | | } |
| | | mat = new Mat(); |
| | | // 分类 |
| | | Long tagId; |
| | |
| | | } else { |
| | | tagId = tagService.getTop().getId(); |
| | | } |
| | | mat.sync(param); |
| | | // mat.setMatnr(param.getMatnr()); |
| | | // mat.setMaktx(param.getMaktx()); |
| | | // mat.setSpecs(param.getSpecs()); |
| | | // mat.setModel(param.getModel()); |
| | | |
| | | mat.sync(matParam); |
| | | mat.setTagId(tagId); |
| | | mat.setStatus(1); |
| | | mat.setCreateTime(now); |
| | | mat.setUpdateTime(now); |
| | | if (!matService.insert(mat)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | throw new CoolException("同步新物料错误[" + logInfo + "]"); |
| | | } else { |
| | | log.info("同步新物料[商品编号:{}]", mat.getMatnr()); |
| | | log.info("同步新物料[{}]", logInfo); |
| | | } |
| | | break; |
| | | case "delete": |
| | | if (mat == null) { |
| | | throw new CoolException("商品信息不存在[" + logInfo + "]"); |
| | | } |
| | | if (matService.delete(new EntityWrapper<Mat>().eq("matnr", matParam.getMatnr()))) { |
| | | log.info("删除物料[{}]", logInfo); |
| | | } else { |
| | | mat.sync(param); |
| | | throw new CoolException("删除已存在商品信息失败[" + logInfo + "]"); |
| | | } |
| | | break; |
| | | case "update": |
| | | if (mat == null) { |
| | | throw new CoolException("商品信息不存在[" + logInfo + "]"); |
| | | } |
| | | mat.sync(matParam); |
| | | if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr",matParam.getMatnr()))) { |
| | | throw new CoolException("更新已存在商品信息失败,请联系管理员"); |
| | | throw new CoolException("更新已存在商品信息失败[" + logInfo + "]"); |
| | | } else { |
| | | log.info("更新物料[:{}]", logInfo); |
| | | } |
| | | break; |
| | | default: |
| | | throw new CoolException("商品信息操作类型不存在[" + logInfo + "]"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |