| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | 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.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; |
| | |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private CheckOrderService checkOrderService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private CheckOrderDetlService checkOrderDetlService; |
| | | |
| | | /** |
| | | * 接收下发订单信息 |
| | | * |
| | | * @param params |
| | | * @param orderParams |
| | | * @return com.core.common.R |
| | | * @author Ryan |
| | | * @date 2025/11/24 14:49 |
| | | */ |
| | | @Override |
| | | public XSR receiveOrders(PubOrderParams params) { |
| | | if (params.getType().equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | return XSR.error("当前类型不是上架派工单!!"); |
| | | } |
| | | addOrUpdateOrders(params, "add"); |
| | | 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("单据下发成功!!"); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public XSR getInDispatchResult(ReportOrderParam params) { |
| | | public XSR getInDispatchResult(List<ReportOrderParam> params) { |
| | | if (Objects.isNull(params)) { |
| | | return XSR.error("参数不能为空!!"); |
| | | } |
| | |
| | | /** |
| | | * 备货指示派工单下发 |
| | | * |
| | | * @param params |
| | | * @param pubOrderParams |
| | | * @return com.core.common.R |
| | | * @author Ryan |
| | | * @date 2025/11/24 15:21 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public XSR sendOutDispatch(PubOrderParams params) { |
| | | if (Objects.isNull(params)) { |
| | | public XSR sendOutDispatch(List<PubOrderParams> pubOrderParams) { |
| | | if (Objects.isNull(pubOrderParams) || pubOrderParams.isEmpty()) { |
| | | return XSR.error("参数不能为空!!"); |
| | | } |
| | | // 校验参数 |
| | | if (Objects.isNull(params.getDispatch_no())) { |
| | | return XSR.error("派工单编号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getKopen_id())) { |
| | | return XSR.error("流水号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getCompany_id())) { |
| | | return XSR.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 XSR.ok("备货指示派工单下发成功!!"); |
| | | } |
| | |
| | | /** |
| | | * 备货单下发 |
| | | * |
| | | * @param params |
| | | * @param stockUpParams |
| | | * @return com.core.common.R |
| | | * @author Ryan |
| | | * @date 2025/11/24 15:40 |
| | | */ |
| | | @Override |
| | | public XSR getOutDetails(StockUpOrderParams params) { |
| | | if (Objects.isNull(params)) { |
| | | public XSR getOutDetails(List<StockUpOrderParams> stockUpParams) { |
| | | if (Objects.isNull(stockUpParams)) { |
| | | return XSR.error("参数不能为空!!"); |
| | | } |
| | | // 校验参数 |
| | | if (Objects.isNull(params.getDispatch_no())) { |
| | | return XSR.error("派工单编号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getKopen_id())) { |
| | | return XSR.error("流水号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getCompany_id())) { |
| | | return XSR.error("公司ID不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getDetails()) || params.getDetails().isEmpty()) { |
| | | return XSR.error("订单明细不能为空!!"); |
| | | } |
| | | |
| | | List<OrderItemsParam> items = new ArrayList<>(); |
| | | if (params.getDetails() != null) { |
| | | for (OutOrderParams detail : params.getDetails()) { |
| | | if (detail.getPartList() != null) { |
| | | items.addAll(detail.getPartList()); |
| | | 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"); |
| | | 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("保存盘点单明细失败"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |