| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.OpenInventoryVo; |
| | | import com.zy.asrs.entity.result.OpenOrderCompeteResult; |
| | | import com.zy.asrs.entity.result.OpenSummaryVo; |
| | | import com.zy.asrs.entity.result.StockVo; |
| | | import com.zy.asrs.mapper.TagMapper; |
| | | import com.zy.asrs.service.*; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Override |
| | | @Transactional |
| | | public void syncMat(MatSyncParam param) { |
| | | if (Cools.isEmpty(param.getMatDetails()) || param.getMatDetails().size() <= 0) { |
| | | if (Cools.isEmpty(param.getMatDetails()) || param.getMatDetails().size() <=0 ) { |
| | | throw new CoolException("商品数据为空"); |
| | | } |
| | | |
| | | for (MatSyncParam.MatParam matParam : param.getMatDetails()) { |
| | | if (Cools.isEmpty(matParam.getMatnr())) { |
| | | for(MatSyncParam.MatParam matParam : param.getMatDetails()){ |
| | | if(Cools.isEmpty(matParam.getMatnr())){ |
| | | throw new CoolException("商品编码不能为空"); |
| | | } |
| | | |
| | |
| | | } else { |
| | | tagId = tagService.getTop().getId(); |
| | | } |
| | | mat.sync(param); |
| | | mat.sync(matParam); |
| | | // mat.setMatnr(param.getMatnr()); |
| | | // mat.setMaktx(param.getMaktx()); |
| | | // mat.setSpecs(param.getSpecs()); |
| | |
| | | log.info("同步新物料[商品编号:{}]", mat.getMatnr()); |
| | | } |
| | | } else { |
| | | mat.sync(param); |
| | | if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr", matParam.getMatnr()))) { |
| | | mat.sync(matParam); |
| | | if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr",matParam.getMatnr()))) { |
| | | throw new CoolException("更新已存在商品信息失败,请联系管理员"); |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void orderCreate(OpenOrderParam param) { |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if (!Cools.isEmpty(order)){ |
| | | throw new CoolException(param.getOrderNo() + "订单已存在,请勿重复创建"); |
| | | } |
| | | Date now = new Date(); |
| | | order = new Order( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | param.getOrderNo(), // 订单编码[非空] |
| | | DateUtils.convert(now), //单据日期 |
| | | param.getOrderType(), //订单类型 |
| | | null, //项目编号 |
| | | null, //项目名称 客户PO号 |
| | | null, //调拨项目编号 |
| | | null, //初始票据号 |
| | | null, //票据号 |
| | | null, //客户编号 |
| | | null, //客户 |
| | | param.getOrderInternalCode(), //单据内码 |
| | | param.getWkType(), //业务类型 |
| | | null, //合计金额 |
| | | null, //优惠率 |
| | | null, //优惠金额 |
| | | null, //销售或采购费用合计 |
| | | null, //实付金额 |
| | | null, //付款类型 1: 现金 2: 记账 |
| | | null, //业务员 |
| | | null, //结算天数 |
| | | null, //邮费支付类型 1: 在线支付 2: 货到付款 |
| | | null, //邮费 |
| | | param.getBusinessTime(), //业务日期 |
| | | param.getCreateTime(), //创建日期 |
| | | null, //物流名称 |
| | | null, //物流单号 |
| | | 1L, //订单状态 |
| | | 1, //状态 1: 正常 0: 禁用 |
| | | 9527L, //添加人员 |
| | | now, //添加时间 |
| | | 9527L, //修改人员 |
| | | now, //修改时间 |
| | | param.getStationId(), //入/出库接驳站点 |
| | | param.getOperateType() // 操作类型 1.新增 2.修改 3.取消 |
| | | ); |
| | | if (!orderService.insert(order)){ |
| | | throw new CoolException("保存订单主档失败,请联系管理员!"+order); |
| | | } |
| | | List<OpenOrderParam.OrderItem> list = new ArrayList<>(); |
| | | List<OpenOrderParam.OrderItem> orderItems = param.getOrderItems(); |
| | | for (OpenOrderParam.OrderItem item : orderItems){ |
| | | OpenOrderParam.OrderItem orderItem = new OpenOrderParam.OrderItem( |
| | | item.getLineId(), |
| | | item.getMatNr(), |
| | | item.getMakTx(), |
| | | item.getAnfme(), |
| | | item.getSpec(), |
| | | item.getModel(), |
| | | item.getUnit(), |
| | | item.getBatch(), |
| | | item.getPalletId(), |
| | | item.getPlanNo(), |
| | | item.getTargetWareHouseId(), |
| | | item.getSourceWareHouseId() |
| | | ); |
| | | if (OpenOrderParam.OrderItem.hasLineNumber(list,orderItem)){ |
| | | OpenOrderParam.OrderItem oi = OpenOrderParam.OrderItem.findLineNumber( |
| | | list, |
| | | item.getLineId(), |
| | | item.getMatNr(), |
| | | item.getMakTx(), |
| | | item.getAnfme(), |
| | | item.getSpec(), |
| | | item.getModel(), |
| | | item.getUnit(), |
| | | item.getBatch(), |
| | | item.getPalletId(), |
| | | item.getPlanNo(), |
| | | item.getTargetWareHouseId(), |
| | | item.getSourceWareHouseId() |
| | | ); |
| | | assert oi != null; |
| | | oi.setAnfme(oi.getAnfme() + orderItem.getAnfme()); |
| | | } else { |
| | | list.add(orderItem); |
| | | } |
| | | } |
| | | for (OpenOrderParam.OrderItem orderItem : list) { |
| | | Mat mat = matService.selectByMatnr(orderItem.getMatNr()); |
| | | if (Cools.isEmpty(mat)){ |
| | | throw new CoolException("订单明细中的商品编号不存在:" + orderItem.getMatNr()); |
| | | } |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.sync(mat); |
| | | orderDetl.setOrderNo(order.getOrderNo()); // 订单编号 |
| | | orderDetl.setOrderId(order.getId()); // 订单内码 |
| | | orderDetl.setStandby1(order.getTel()); // 行内码 唯一标识 |
| | | orderDetl.setAnfme(orderItem.getAnfme()); // 订单数量 |
| | | orderDetl.setBarcode(orderItem.getBatch()); // 批次 |
| | | orderDetl.setStandby2(orderItem.getPalletId()); // 托盘码 |
| | | orderDetl.setStandby3(orderItem.getPlanNo()); // 计划跟踪号 |
| | | orderDetl.setBoxType1(orderItem.getSourceWareHouseId()); // 建议入库仓库 |
| | | orderDetl.setBoxType2(orderItem.getTargetWareHouseId()); // 建议出库仓库 |
| | | orderDetl.setCreateBy(9527L); |
| | | orderDetl.setCreateTime(now); |
| | | orderDetl.setUpdateBy(9527L); |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | // orderDetl.setPakinPakoutStatus(1); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("保存订单明细失败,请联系管理员!"+orderDetl); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public OpenInventoryVo queryInventoryDetails(OpenInventoryParam param) { |
| | | List<LocDetl> locDetlList = locDetlService.queryInventoryDetails(param.getLocId(), param.getMatNr(), param.getOrderNo(), param.getPlanNo(), param.getBatch()); |
| | | if (Cools.isEmpty(locDetlList)){ |
| | | return new OpenInventoryVo(); |
| | | } |
| | | return new OpenInventoryVo(locDetlList); |
| | | } |
| | | |
| | | @Override |
| | | public OpenSummaryVo queryInventorySummary(OpenSummaryParam param) { |
| | | String matNr = param.getMatNr(); |
| | | String[] split = matNr.split(","); |
| | | List<OpenSummaryVo.OpenSummary> openSummaryList = new ArrayList<>(); |
| | | for (String s : split) { |
| | | OpenSummaryVo.OpenSummary openSummary = new OpenSummaryVo.OpenSummary(); |
| | | Double summary = locDetlService.queryInventorySummary(param.getWareHouseId(), s); |
| | | openSummary.setWareHouseId(param.getWareHouseId()); // 仓库编码 |
| | | openSummary.setMatNr(s); // 物料编码 |
| | | openSummary.setAnfme(summary); // 数量 |
| | | openSummaryList.add(openSummary); |
| | | } |
| | | return new OpenSummaryVo(openSummaryList); |
| | | } |
| | | } |