| | |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.api.entity.OrderParams; |
| | | import com.zy.api.entity.ReportOrderParam; |
| | | import com.zy.api.entity.PubOrderParams; |
| | | import com.zy.api.entity.ReportOrderParam; |
| | | import com.zy.api.entity.SyncMatParmas; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | |
| | |
| | | } catch (Exception e) { |
| | | return R.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /* */ |
| | | /** |
| | | * 备货指示派工单下发 |
| | | * @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("参数不能为空!!"); |
| | | } |
| | | // 校验参数 |
| | | 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不能为空!!"); |
| | | } |
| | | |
| | | addOrUpdateOrders(params, "add"); |
| | | |
| | | return R.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("订单类型不能为空!!"); |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | 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)) { |
| | |
| | | // 删除旧订单明细 |
| | | if (!orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", order.getId()))) { |
| | | throw new CoolException("订单明细删除失败!!"); |
| | | }; |
| | | } |
| | | |
| | | if (!orderService.deleteById(order.getId())) { |
| | | throw new CoolException("原单据删除失败!!"); |
| | | } |
| | |
| | | if (OrderType.ORDER_IN.type.equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | // 入库 |
| | | newOrder.setPakinPakoutStatus(1); |
| | | newOrder.setDocType(Long.parseLong(params.getType())); |
| | | newOrder.setOrderNo(params.getInv_no()); |
| | | } else if (OrderType.ORDER_OUT.type.equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | // 出库 |
| | | newOrder.setPakinPakoutStatus(2); |
| | | newOrder.setDocType(5L); |
| | | newOrder.setOrderNo(params.getDispatch_no()); |
| | | } |
| | | newOrder.setDocType(Long.parseLong(params.getType())); |
| | | newOrder.setOrderNo(params.getInv_no()); |
| | | newOrder.setUuid(generateUUID(params)); |
| | | // 流水号(唯一) |
| | | newOrder.setDefNumber(params.getKopen_id()); |
| | |
| | | BeanUtils.copyProperties(matnr, orderItem); |
| | | orderItem.setOrderId(newOrder.getId()); |
| | | orderItem.setOrderNo(newOrder.getOrderNo()); |
| | | orderItem.setAnfme(Math.round(item.getInv_qty() * 10000) / 10000.0); |
| | | |
| | | if (OrderType.ORDER_IN.type.equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | // 入库 |
| | | 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); |
| | | } |
| | | orderItem.setMatnr(matnr.getMatnr()); |
| | | orderItem.setMaktx(matnr.getMaktx()); |
| | | orderItem.setBrand(matnr.getBrand()); |