| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.R; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.api.controller.params.PageRequestParams; |
| | | import com.zy.api.entity.OrderItemsParam; |
| | | import com.zy.api.entity.OrderParams; |
| | | import com.zy.api.entity.OutOrderParams; |
| | | import com.zy.api.entity.PubOrderParams; |
| | | import com.zy.api.entity.ReportOrderParam; |
| | | import com.zy.api.entity.StockAdjustParams; |
| | | import com.zy.api.entity.StockUpOrderParams; |
| | | import com.zy.api.entity.SyncMatParmas; |
| | | import com.zy.api.entity.dto.XSR; |
| | | import com.zy.api.enums.MatLocType; |
| | | import com.zy.api.enums.OrderType; |
| | | import com.zy.api.enums.OrderWkType; |
| | | import com.zy.api.service.KopenApiService; |
| | | import com.zy.asrs.entity.CheckOrder; |
| | | import com.zy.asrs.entity.CheckOrderDetl; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.Mat; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.enums.CommonEnum; |
| | | import com.zy.asrs.enums.OrderSettle; |
| | | import com.zy.asrs.enums.OrderTypeEnum; |
| | | import com.zy.asrs.service.CheckOrderDetlService; |
| | | import com.zy.asrs.service.CheckOrderService; |
| | | import com.zy.asrs.service.LocDetlService; |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @Service("kopenApiServiceImpl") |
| | |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private CheckOrderService checkOrderService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private CheckOrderDetlService checkOrderDetlService; |
| | | |
| | | /** |
| | | * 接收下发订单信息 |
| | | * |
| | | * @param orderParams |
| | | * @return com.core.common.R |
| | | * @author Ryan |
| | | * @date 2025/11/24 14:49 |
| | | * @param params |
| | | * @return com.core.common.R |
| | | */ |
| | | @Override |
| | | public R receiveOrders(PubOrderParams params) { |
| | | if (params.getType().equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | return R.error("当前类型不是上架派工单!!"); |
| | | } |
| | | addOrUpdateOrders(params, "add"); |
| | | return R.ok("单据下发成功!!"); |
| | | public XSR receiveOrders(List<PubOrderParams> orderParams) { |
| | | orderParams.forEach(params -> { |
| | | if (params.getType().equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | throw new CoolException("当前类型不是上架派工单!!"); |
| | | } |
| | | addOrUpdateOrders(params, "add"); |
| | | }); |
| | | |
| | | return XSR.ok("单据下发成功!!"); |
| | | } |
| | | |
| | | /** |
| | | * 上架派工单反馈 |
| | | * |
| | | * |
| | | * @author Ryan |
| | | * @date 2025/11/24 15:33 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R getInDispatchResult(ReportOrderParam params) { |
| | | public XSR getInDispatchResult(List<ReportOrderParam> params) { |
| | | if (Objects.isNull(params)) { |
| | | return R.error("参数不能为空!!"); |
| | | return XSR.error("参数不能为空!!"); |
| | | } |
| | | String response = null; |
| | | try { |
| | |
| | | .build() |
| | | .doPost(); |
| | | if (Objects.isNull(response) || response.trim().isEmpty()) { |
| | | return R.error("外网接口无响应!!"); |
| | | return XSR.error("外网接口无响应!!"); |
| | | } |
| | | JSONObject jsonObject = JSONObject.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (!Objects.isNull(code) && code.equals(1)) { |
| | | return R.ok("入库单上报完成!!"); |
| | | return XSR.ok("入库单上报完成!!"); |
| | | } else { |
| | | String msg = jsonObject.getString("message"); |
| | | return R.error(Objects.isNull(msg) ? "上报失败!!" : msg); |
| | | return XSR.error(Objects.isNull(msg) ? "上报失败!!" : msg); |
| | | } |
| | | } catch (Exception e) { |
| | | return R.error(e.getMessage()); |
| | | return XSR.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /* */ |
| | | |
| | | /** |
| | | * 备货指示派工单下发 |
| | | * |
| | | * |
| | | * @param pubOrderParams |
| | | * @return com.core.common.R |
| | | * @author Ryan |
| | | * @date 2025/11/24 15:21 |
| | | * @param params |
| | | * @return com.core.common.R |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R sendOutDispatch(PubOrderParams params) { |
| | | if (Objects.isNull(params)) { |
| | | return R.error("参数不能为空!!"); |
| | | public XSR sendOutDispatch(List<PubOrderParams> pubOrderParams) { |
| | | if (Objects.isNull(pubOrderParams) || pubOrderParams.isEmpty()) { |
| | | return XSR.error("参数不能为空!!"); |
| | | } |
| | | // 校验参数 |
| | | if (Objects.isNull(params.getDispatch_no())) { |
| | | return R.error("派工单编号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getKopen_id())) { |
| | | return R.error("流水号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getCompany_id())) { |
| | | return R.error("公司ID不能为空!!"); |
| | | } |
| | | pubOrderParams.forEach(params -> { |
| | | // 校验参数 |
| | | if (Objects.isNull(params.getDispatch_no())) { |
| | | throw new CoolException("派工单编号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getKopen_id())) { |
| | | throw new CoolException("流水号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getCompany_id())) { |
| | | throw new CoolException("公司ID不能为空!!"); |
| | | } |
| | | |
| | | addOrUpdateOrders(params, "add"); |
| | | addOrUpdateOrders(params, "add"); |
| | | }); |
| | | |
| | | return R.ok("备货指示派工单下发成功!!"); |
| | | return XSR.ok("备货指示派工单下发成功!!"); |
| | | } |
| | | |
| | | /** |
| | | * 备货指示派工单 |
| | | * |
| | | * @author Ryan |
| | | * @date 2025/12/16 9:15 |
| | | * @param params |
| | | */ |
| | | private void outOrderAddAndUpdate(PubOrderParams params, String type) { |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getType())) { |
| | | throw new CoolException("订单类型不能为空!!"); |
| | | } |
| | | // /** |
| | | // * 备货指示派工单 |
| | | // * |
| | | // * @author Ryan |
| | | // * @date 2025/12/16 9:15 |
| | | // * @param params |
| | | // */ |
| | | // private void outOrderAddAndUpdate(PubOrderParams params, String type) { |
| | | // if (Objects.isNull(params)) { |
| | | // throw new CoolException("参数不能为空!!"); |
| | | // } |
| | | // if (Objects.isNull(params.getType())) { |
| | | // throw new CoolException("订单类型不能为空!!"); |
| | | // } |
| | | |
| | | OrderParams orderParams = JSONObject.parseObject(JSONObject.toJSONString(params), OrderParams.class); |
| | | Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderParams.getInv_no())); |
| | | if (type.equals("add") && !Objects.isNull(order)) { |
| | | throw new CoolException("单据已存在, 不可重复添加!!"); |
| | | } |
| | | // 判断订单是否存在 |
| | | if (Objects.isNull(order)) { |
| | | /** 不存在,新增订单 */ |
| | | generateOrders(params); |
| | | } else { |
| | | /** 存在,删除老订单,更新插入新订单 */ |
| | | // 删除旧订单明细 |
| | | if (!orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", order.getId()))) { |
| | | throw new CoolException("订单明细删除失败!!"); |
| | | } |
| | | ; |
| | | if (!orderService.deleteById(order.getId())) { |
| | | throw new CoolException("原单据删除失败!!"); |
| | | } |
| | | generateOrders(params); |
| | | } |
| | | // OrderParams orderParams = |
| | | // JSONObject.parseObject(JSONObject.toJSONString(params), OrderParams.class); |
| | | // Order order = orderService.selectOne(new |
| | | // EntityWrapper<Order>().eq("order_no", orderParams.getInv_no())); |
| | | // if (type.equals("add") && !Objects.isNull(order)) { |
| | | // throw new CoolException("单据已存在, 不可重复添加!!"); |
| | | // } |
| | | // // 判断订单是否存在 |
| | | // if (Objects.isNull(order)) { |
| | | // /** 不存在,新增订单 */ |
| | | // generateOrders(params); |
| | | // } else { |
| | | // /** 存在,删除老订单,更新插入新订单 */ |
| | | // // 删除旧订单明细 |
| | | // if (!orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", |
| | | // order.getId()))) { |
| | | // throw new CoolException("订单明细删除失败!!"); |
| | | // } |
| | | // ; |
| | | // if (!orderService.deleteById(order.getId())) { |
| | | // throw new CoolException("原单据删除失败!!"); |
| | | // } |
| | | // generateOrders(params); |
| | | // } |
| | | |
| | | } |
| | | // } |
| | | |
| | | /** |
| | | * 基础零件变更 |
| | | * |
| | | * @author Ryan |
| | | * @date 2025/11/24 15:05 |
| | | * @param params |
| | | * @return com.core.common.R |
| | | * @author Ryan |
| | | * @date 2025/11/24 15:05 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public synchronized R basMatupdate(SyncMatParmas params) { |
| | | if (Objects.isNull(params.getPro_komcode())) { |
| | | return R.error("零件编码不能为空!!"); |
| | | public synchronized XSR basMatupdate(List<SyncMatParmas> params) { |
| | | if (Objects.isNull(params) || params.isEmpty()) { |
| | | return XSR.error("参数不能为空!!"); |
| | | } |
| | | Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", params.getPro_komcode())); |
| | | if (!Objects.isNull(matnr)) { |
| | | // 订单时间 |
| | | if (Utils.isValidFormat(params.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) { |
| | | Date date1 = Utils.getFormateDate(params.getUpdate_time()); |
| | | matnr.setUpdateTime(date1); |
| | | params.forEach(mats -> { |
| | | if (Objects.isNull(mats)) { |
| | | throw new CoolException("物料编码不能为空!!"); |
| | | } |
| | | matnr.setMaktx(params.getPro_name()); |
| | | matnr.setSpecs(params.getPro_size()); |
| | | matnr.setWeight(Double.parseDouble(params.getPro_wet())); |
| | | matnr.setSuppCode(params.getPro_id()); |
| | | matnr.setTagId(MatLocType.getTag(params.getPro_type())); |
| | | matnr.setManu(params.getCompany_id()); |
| | | if (!matService.updateById(matnr)) { |
| | | throw new CoolException("物料更新失败或无需更新!!"); |
| | | Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", mats.getPro_komcode())); |
| | | if (!Objects.isNull(matnr)) { |
| | | // 订单时间 |
| | | if (Utils.isValidFormat(mats.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) { |
| | | Date date1 = Utils.getFormateDate(mats.getUpdate_time()); |
| | | matnr.setUpdateTime(date1); |
| | | } |
| | | matnr.setMaktx(mats.getPro_name()); |
| | | matnr.setSpecs(mats.getPro_size()); |
| | | matnr.setWeight(Double.parseDouble(mats.getPro_wet())); |
| | | matnr.setSuppCode(mats.getPro_id()); |
| | | matnr.setTagId(MatLocType.getTag(mats.getPro_type())); |
| | | matnr.setLocType(MatLocType.getTag(mats.getPro_type())); |
| | | matnr.setManu(mats.getCompany_id()); |
| | | if (!matService.updateById(matnr)) { |
| | | throw new CoolException("物料更新失败或无需更新!!"); |
| | | } |
| | | } else { |
| | | if (Objects.isNull(matnr)) { |
| | | matnr = new Mat(); |
| | | } |
| | | // 订单时间 |
| | | if (Utils.isValidFormat(mats.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) { |
| | | Date date1 = Utils.getFormateDate(mats.getUpdate_time()); |
| | | matnr.setUpdateTime(date1); |
| | | } |
| | | matnr.setMaktx(mats.getPro_name()); |
| | | matnr.setMatnr(mats.getPro_komcode()); |
| | | matnr.setSpecs(mats.getPro_size()); |
| | | matnr.setWeight(Double.parseDouble(mats.getPro_wet())); |
| | | matnr.setSuppCode(mats.getPro_id()); |
| | | matnr.setTagId(MatLocType.getTag(mats.getPro_type())); |
| | | matnr.setLocType(MatLocType.getTag(mats.getPro_type())); |
| | | matnr.setManu(mats.getCompany_id()); |
| | | if (!matService.insert(matnr)) { |
| | | throw new CoolException("物料更新失败!!"); |
| | | } |
| | | } |
| | | } else { |
| | | if (Objects.isNull(matnr)) { |
| | | matnr = new Mat(); |
| | | } |
| | | // 订单时间 |
| | | if (Utils.isValidFormat(params.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) { |
| | | Date date1 = Utils.getFormateDate(params.getUpdate_time()); |
| | | matnr.setUpdateTime(date1); |
| | | } |
| | | matnr.setMaktx(params.getPro_name()); |
| | | matnr.setMatnr(params.getPro_komcode()); |
| | | matnr.setSpecs(params.getPro_size()); |
| | | matnr.setWeight(Double.parseDouble(params.getPro_wet())); |
| | | matnr.setSuppCode(params.getPro_id()); |
| | | matnr.setTagId(MatLocType.getTag(params.getPro_type())); |
| | | matnr.setManu(params.getCompany_id()); |
| | | if (!matService.insert(matnr)) { |
| | | throw new CoolException("物料更新失败!!"); |
| | | } |
| | | } |
| | | return R.ok("保存成功!!"); |
| | | }); |
| | | |
| | | return XSR.ok("保存成功!!"); |
| | | } |
| | | |
| | | /** |
| | |
| | | throw new CoolException("订单类型不能为空!!"); |
| | | } |
| | | OrderParams orderParams = JSONObject.parseObject(JSONObject.toJSONString(params), OrderParams.class); |
| | | Order order = new Order(); |
| | | // Order order = orderService.selectOne(new |
| | | // EntityWrapper<Order>().eq("order_no", orderParams.getDispatch_no())); |
| | | Order order = null; |
| | | if (OrderType.ORDER_IN.type.equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | // 入库 |
| | | order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderParams.getInv_no())); |
| | | order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", |
| | | orderParams.getDispatch_no())); |
| | | } else if (OrderType.ORDER_OUT.type.equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | // 出库 |
| | | order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderParams.getDispatch_no())); |
| | | if (OrderWkType.ORDER_WK_ORDER_OUT.val.equals(params.getType())) { |
| | | // 备货单出库 |
| | | order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", |
| | | orderParams.getPick_no())); |
| | | } else if (OrderWkType.ORDER_WK_ORDER_OUT_EO.val.equals(params.getType()) |
| | | || OrderWkType.ORDER_WK_ORDER_OUT_SO.val.equals(params.getType())) { |
| | | // 备货指示派工单(EO/SO)出库 |
| | | order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", |
| | | orderParams.getDispatch_no())); |
| | | } |
| | | } |
| | | // 出库 |
| | | if (type.equals("add") && !Objects.isNull(order)) { |
| | | throw new CoolException("单据已存在, 不可重复添加!!"); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 生成订单信息 |
| | | * |
| | | * |
| | | * @param params |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateOrders(PubOrderParams params) { |
| | | // 将数据当新订单插入 |
| | | Order newOrder = new Order(); |
| | | // 派工单号 |
| | | newOrder.setOrderNo(params.getDispatch_no()); |
| | | if (OrderType.ORDER_IN.type.equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | // 入库 |
| | | newOrder.setPakinPakoutStatus(1); |
| | | newOrder.setDocType(Long.parseLong(params.getType())); |
| | | newOrder.setOrderNo(params.getInv_no()); |
| | | newOrder.setNumber(params.getInv_no()); |
| | | } else if (OrderType.ORDER_OUT.type.equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | // 出库 |
| | | if (OrderWkType.ORDER_WK_ORDER_OUT.val.equals(params.getType())) { |
| | | // 备货单出库 |
| | | newOrder.setOrderNo(params.getPick_no()); |
| | | newOrder.setNumber(params.getDispatch_no()); |
| | | newOrder.setShipCode(params.getOrder_no()); |
| | | newOrder.setCstmrName(params.getCus_id()); |
| | | newOrder.setTel(params.getCus_address()); |
| | | newOrder.setDocType(Long.parseLong(OrderTypeEnum.STOCK.type + "")); |
| | | } else if (OrderWkType.ORDER_WK_ORDER_OUT_EO.val.equals(params.getType()) |
| | | || OrderWkType.ORDER_WK_ORDER_OUT_SO.val.equals(params.getType())) { |
| | | // 备货指示派工单(EO/SO)出库 |
| | | newOrder.setDocType(Long.parseLong(OrderTypeEnum.TRANSFER.type + "")); |
| | | } |
| | | newOrder.setPakinPakoutStatus(2); |
| | | newOrder.setDocType(5L); |
| | | newOrder.setOrderNo(params.getDispatch_no()); |
| | | } |
| | | |
| | | newOrder.setUuid(generateUUID(params)); |
| | | // 流水号(唯一) |
| | | newOrder.setDefNumber(params.getKopen_id()); |
| | | // 派工单号 |
| | | newOrder.setNumber(params.getDispatch_no()); |
| | | newOrder.setTargetLocation(params.getTarget_location()); |
| | | // 箱号 |
| | | newOrder.setItemName(params.getPm_tktid()); |
| | | newOrder.setSettle(OrderSettle.ORDER_SETTLE_HOLDING.type); |
| | |
| | | orderItem.setAnfme(Math.round(item.getInv_qty() * 10000) / 10000.0); |
| | | } else if (OrderType.ORDER_OUT.type.equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | // 出库 |
| | | newOrder.setPakinPakoutStatus(2); |
| | | orderItem.setAnfme(Math.round(item.getOrder_qty() * 10000) / 10000.0); |
| | | if (OrderWkType.ORDER_WK_ORDER_OUT.val.equals(params.getType())) { |
| | | // 备货单出库 |
| | | orderItem.setAnfme(Math.round(item.getPick_qty() * 10000) / 10000.0); |
| | | } else if (OrderWkType.ORDER_WK_ORDER_OUT_EO.val.equals(params.getType()) |
| | | || OrderWkType.ORDER_WK_ORDER_OUT_SO.val.equals(params.getType())) { |
| | | // 备货指示派工单(EO/SO)出库 |
| | | orderItem.setAnfme(Math.round(item.getOrder_qty() * 10000) / 10000.0); |
| | | } |
| | | } |
| | | orderItem.setMatnr(matnr.getMatnr()); |
| | | orderItem.setMaktx(matnr.getMaktx()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 备货单下发 |
| | | * |
| | | * @param stockUpParams |
| | | * @return com.core.common.R |
| | | * @author Ryan |
| | | * @date 2025/11/24 15:40 |
| | | */ |
| | | @Override |
| | | public XSR getOutDetails(List<StockUpOrderParams> stockUpParams) { |
| | | if (Objects.isNull(stockUpParams)) { |
| | | return XSR.error("参数不能为空!!"); |
| | | } |
| | | stockUpParams.forEach(params -> { |
| | | if (Objects.isNull(params.getDispatch_no())) { |
| | | throw new CoolException("派工单编号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getKopen_id())) { |
| | | throw new CoolException("流水号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getCompany_id())) { |
| | | throw new CoolException("公司ID不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getDetails()) || params.getDetails().isEmpty()) { |
| | | throw new CoolException("订单明细不能为空!!"); |
| | | } |
| | | List<OrderItemsParam> items = new ArrayList<>(); |
| | | if (params.getDetails() != null) { |
| | | for (OutOrderParams detail : params.getDetails()) { |
| | | if (detail.getPartList() != null) { |
| | | items.addAll(detail.getPartList()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | params.getDetails().forEach(item -> { |
| | | PubOrderParams pubOrderParams = new PubOrderParams(); |
| | | BeanUtils.copyProperties(params, pubOrderParams); |
| | | pubOrderParams.setType(item.getType()) |
| | | .setPick_no(item.getPick_no()) |
| | | .setCus_address(item.getCus_address()) |
| | | .setOrder_no(item.getOrder_no()) |
| | | .setUpdate_time(params.getUpdate_time()) |
| | | .setCus_id(item.getCus_id()); |
| | | pubOrderParams.setDetails(item.getPartList()); |
| | | addOrUpdateOrders(pubOrderParams, "add"); |
| | | }); |
| | | }); |
| | | |
| | | return XSR.ok("备货单下发成功!!"); |
| | | } |
| | | |
| | | /** |
| | | * 查询WMS库存信息 |
| | | * |
| | | * @param params |
| | | * @return com.core.common.R |
| | | */ |
| | | @Override |
| | | public XSR getStockInfo(PageRequestParams params) { |
| | | EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); |
| | | if (!Objects.isNull(params.getPro_id())) { |
| | | wrapper.eq("supp_code", params.getPro_id()); |
| | | } |
| | | if (!Objects.isNull(params.getPro_komcode())) { |
| | | wrapper.eq("matnr", params.getPro_komcode()); |
| | | } |
| | | |
| | | Page<LocDetl> locDetls = locDetlService.selectPage(new Page<>(params.getCurr(), params.getLimit()), wrapper); |
| | | |
| | | return XSR.ok(locDetls.getRecords()); |
| | | } |
| | | |
| | | /** |
| | | * 零件损溢单下发 |
| | | * |
| | | * @author Ryan |
| | | * @date 2025/11/24 15:22 |
| | | * @param params |
| | | * @return com.core.common.R |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public XSR sendStockAdjust(List<StockAdjustParams> params, Long userId) { |
| | | if (Objects.isNull(params)) { |
| | | return XSR.error("参数不能为空!!"); |
| | | } |
| | | params.forEach(param -> { |
| | | gentCheckOrders(param, userId); |
| | | }); |
| | | |
| | | return XSR.ok("零件损溢单下发成功!!"); |
| | | } |
| | | |
| | | /** 生成新的零件损溢单 |
| | | * @param userId */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void gentCheckOrders(StockAdjustParams params, Long userId) { |
| | | if (Objects.isNull(params.getDetails()) || params.getDetails().isEmpty()) { |
| | | throw new CoolException("订单明细不能为空!!"); |
| | | } |
| | | // 校验参数 |
| | | if (Objects.isNull(params.getBsby_no())) { |
| | | throw new CoolException("损溢单编号不能为空!!"); |
| | | } |
| | | |
| | | CheckOrder checkOrder = checkOrderService |
| | | .selectOne(new EntityWrapper<CheckOrder>().eq("order_no", params.getBsby_no())); |
| | | if (!Objects.isNull(checkOrder)) { |
| | | throw new CoolException("损溢单已存在!!"); |
| | | } |
| | | |
| | | CheckOrder order = new CheckOrder(); |
| | | order.setOrderNo(params.getBsby_no()); |
| | | order.setCstmrName(params.getCompany_id()); |
| | | order.setDefNumber(params.getKopen_id()); |
| | | order.setDocType(4L); |
| | | order.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | | order.setSettle(Long.valueOf(CommonEnum.COMMON_ENUM_Y.type + "")); |
| | | order.setStatus(CommonEnum.COMMON_ENUM_Y.type); |
| | | order.setOrderTime(params.getUpdate_time()); |
| | | order.setMemo(params.getResason()); |
| | | order.setShipName(params.getReason_name()); |
| | | order.setCreateTime(new Date()); |
| | | order.setUpdateTime(new Date()); |
| | | |
| | | if (!checkOrderService.insert(order)) { |
| | | throw new CoolException("损溢单新增失败!!"); |
| | | } |
| | | |
| | | if (Objects.isNull(params.getDetails()) || params.getDetails().isEmpty()) { |
| | | throw new CoolException("订单明细不能为空!!"); |
| | | } |
| | | |
| | | params.getDetails().forEach(item -> { |
| | | CheckOrderDetl checkOrderDetl = new CheckOrderDetl(); |
| | | //通过托盘, 物料编码, 供应商编码查询库存明细 |
| | | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>() |
| | | .eq("matnr", item.getPro_komcode()) |
| | | .eq("zpallet", item.getLocation_no()) |
| | | .eq("supp_code", item.getPro_id())); |
| | | if (Objects.isNull(locDetl)) { |
| | | throw new CoolException("库存不存在!!"); |
| | | } |
| | | BeanUtils.copyProperties(locDetl, checkOrderDetl); |
| | | checkOrderDetl.setLocDetlId(locDetl.getId()); |
| | | checkOrderDetl.setOrderId(order.getId()); |
| | | checkOrderDetl.setOrderNo(order.getOrderNo()); |
| | | checkOrderDetl.setMatnr(locDetl.getMatnr()); |
| | | checkOrderDetl.setMaktx(locDetl.getMaktx()); |
| | | checkOrderDetl.setBatch(locDetl.getBatch()); |
| | | checkOrderDetl.setSpecs(locDetl.getSpecs()); |
| | | checkOrderDetl.setThreeCode(locDetl.getThreeCode()); |
| | | checkOrderDetl.setSuppCode(locDetl.getSuppCode()); |
| | | checkOrderDetl.setStandby1(locDetl.getSuppCode()); |
| | | checkOrderDetl.setAnfme(new BigDecimal(locDetl.getAnfme().toString())); |
| | | checkOrderDetl.setDiffQty(BigDecimal.ZERO); |
| | | checkOrderDetl.setWorkQty(BigDecimal.ZERO); |
| | | checkOrderDetl.setStatus(1); |
| | | checkOrderDetl.setZpallet(locDetl.getZpallet()); |
| | | checkOrderDetl.setCreateBy(userId); |
| | | checkOrderDetl.setCreateTime(new Date()); |
| | | checkOrderDetl.setUpdateBy(userId); |
| | | checkOrderDetl.setUpdateTime(new Date()); |
| | | |
| | | if (!checkOrderDetlService.insert(checkOrderDetl)) { |
| | | throw new CoolException("保存盘点单明细失败"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |