Merge remote-tracking branch 'origin/feature/sap-interface-0804' into feature/sap-interface-0804
This commit is contained in:
@@ -18,6 +18,9 @@ public class SapConstant {
|
||||
/** 接口编号:委外交货确认 */
|
||||
public static final String INTF_MM064 = "MM064";
|
||||
|
||||
/** 接口编号:部门领料出库单同步(SAP → WMS) */
|
||||
public static final String INTF_PP113 = "PP113";
|
||||
|
||||
/** 接口编号:委外出库倒冲 */
|
||||
public static final String INTF_MM065 = "MM065";
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ public enum SourceBillTypeEnum {
|
||||
SAP_MATERIAL("sap_material","SAP物料凭证"),
|
||||
SAP_OUTBOUND_DELIVERY("sapOutboundDelivery","SAP委外单-出库"),
|
||||
SAP_SALES_RETURN_OUT("sapSalesReturnOut","SAP销售退货出库"),
|
||||
SAP_DEPT_PICKING("sapDeptPicking","SAP部门领料出库"),
|
||||
UNDEFINE("","未定义"),
|
||||
;
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.DeptPickingService;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dto.DeptPickingQuery;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* SAP部门领料出库单
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/sapDeptPicking")
|
||||
@Slf4j
|
||||
public class DeptPickingController {
|
||||
|
||||
private final DeptPickingService deptPickingService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询SAP部门领料出库单")
|
||||
public ResponseEntity<Object> queryAll(DeptPickingQuery query, PageQuery page) {
|
||||
return ResponseData.build(deptPickingService.queryPage(query, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getDetail")
|
||||
@Log("查询SAP部门领料出库单明细")
|
||||
public ResponseEntity<Object> getDetail(@RequestParam String orderNo) {
|
||||
return ResponseData.build(deptPickingService.getDetailByOrderNo(orderNo), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Log("查询SAP部门领料出库单详情")
|
||||
public ResponseEntity<Object> getById(@PathVariable Long id) {
|
||||
return ResponseData.build(deptPickingService.getDetail(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除SAP部门领料出库单")
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
deptPickingService.deleteByIds(Arrays.asList(ids));
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/outPush")
|
||||
@Log("下推SAP部门领料出库单")
|
||||
public ResponseEntity<Object> outPush(@RequestBody JSONObject dto) {
|
||||
deptPickingService.pushOut(dto.getLong("id"));
|
||||
return ResponseData.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.enums;
|
||||
|
||||
/**
|
||||
* SAP部门领料出库单状态
|
||||
*/
|
||||
public enum DeptPickingStatus {
|
||||
|
||||
CREATED("CREATED", "已创建"),
|
||||
POSTED("POSTED", "已下发"),
|
||||
COMPLETED("COMPLETED", "已完成"),
|
||||
CANCELED("CANCELED", "已取消");
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
DeptPickingStatus(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dao.DeptPickingItem;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dao.DeptPickingOrder;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dto.DeptPickingOrderDto;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dto.DeptPickingQuery;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dto.DeptPickingSyncDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SAP部门领料出库单(PP113)
|
||||
*/
|
||||
public interface DeptPickingService {
|
||||
|
||||
/**
|
||||
* SAP推送部门领料出库单(接口 /insertSapLld)
|
||||
*/
|
||||
JSONObject insertSapLld(DeptPickingSyncDTO dto);
|
||||
|
||||
IPage<DeptPickingOrder> queryPage(DeptPickingQuery query, PageQuery page);
|
||||
|
||||
DeptPickingOrderDto getDetail(Long id);
|
||||
|
||||
DeptPickingOrderDto getDetailByOrderNo(String orderNo);
|
||||
|
||||
void deleteByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 下推生成WMS出库单,完成后按PP055回传SAP
|
||||
*/
|
||||
void pushOut(Long id);
|
||||
|
||||
List<DeptPickingItem> listItems(Long headerId);
|
||||
|
||||
DeptPickingItem getItem(Long itemId);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* SAP部门领料出库单明细(PP113 行项目)
|
||||
*/
|
||||
@Data
|
||||
@TableName("sap_dept_picking_item")
|
||||
public class DeptPickingItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long header_id;
|
||||
|
||||
private String order_no;
|
||||
|
||||
/** 预留号 */
|
||||
private String rsnum;
|
||||
|
||||
/** 预留行项目 */
|
||||
private String rspos;
|
||||
|
||||
/** 创建日期 */
|
||||
private String erdat;
|
||||
|
||||
/** 创建人 */
|
||||
private String ernam;
|
||||
|
||||
/** 成本中心 */
|
||||
private String kostl;
|
||||
|
||||
/** 生产/工单号,201成本中心领料时为空 */
|
||||
private String aufnr;
|
||||
|
||||
private String matnr;
|
||||
|
||||
/** 物料描述 */
|
||||
private String maktx;
|
||||
|
||||
/** 数量 */
|
||||
private BigDecimal bdmng;
|
||||
|
||||
private String werks;
|
||||
|
||||
/** 库存地点 */
|
||||
private String lgort;
|
||||
|
||||
private String meins;
|
||||
|
||||
/** 移动类型:261工单领料 / 201成本中心领料 */
|
||||
private String bwart;
|
||||
|
||||
/** 收货方/领料人 */
|
||||
private String wempf;
|
||||
|
||||
private String backup1;
|
||||
|
||||
private String backup2;
|
||||
|
||||
private String backup3;
|
||||
|
||||
private String backup4;
|
||||
|
||||
private String created_at;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* SAP部门领料出库单(PP113)
|
||||
*/
|
||||
@Data
|
||||
@TableName("sap_dept_picking")
|
||||
public class DeptPickingOrder implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 单据号:header.src_msgid,为空时系统生成 */
|
||||
private String order_no;
|
||||
|
||||
private String intf_id;
|
||||
|
||||
private String src_system;
|
||||
|
||||
private String dest_system;
|
||||
|
||||
private String src_msgid;
|
||||
|
||||
private String request_time;
|
||||
|
||||
private String backup1;
|
||||
|
||||
private String backup2;
|
||||
|
||||
/** 存储地点,取明细第一条 */
|
||||
private String lgort;
|
||||
|
||||
private Integer item_count;
|
||||
|
||||
/** 状态:CREATED/POSTED/COMPLETED/CANCELED */
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String created_at;
|
||||
|
||||
private String updated_at;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dao.DeptPickingItem;
|
||||
|
||||
@Mapper
|
||||
public interface DeptPickingItemMapper extends BaseMapper<DeptPickingItem> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dao.DeptPickingOrder;
|
||||
|
||||
@Mapper
|
||||
public interface DeptPickingOrderMapper extends BaseMapper<DeptPickingOrder> {
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 部门领料出库明细(页面展示/回传取数)
|
||||
*/
|
||||
@Data
|
||||
public class DeptPickingItemDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long header_id;
|
||||
|
||||
private String rsnum;
|
||||
|
||||
private String rspos;
|
||||
|
||||
private String erdat;
|
||||
|
||||
private String ernam;
|
||||
|
||||
private String kostl;
|
||||
|
||||
private String aufnr;
|
||||
|
||||
private String matnr;
|
||||
|
||||
private String maktx;
|
||||
|
||||
private BigDecimal bdmng;
|
||||
|
||||
private String werks;
|
||||
|
||||
private String lgort;
|
||||
|
||||
private String meins;
|
||||
|
||||
private String bwart;
|
||||
|
||||
private String wempf;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门领料出库单(含明细)
|
||||
*/
|
||||
@Data
|
||||
public class DeptPickingOrderDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String order_no;
|
||||
|
||||
private String intf_id;
|
||||
|
||||
private String src_system;
|
||||
|
||||
private String dest_system;
|
||||
|
||||
private String src_msgid;
|
||||
|
||||
private String request_time;
|
||||
|
||||
private String lgort;
|
||||
|
||||
private Integer item_count;
|
||||
|
||||
private String status;
|
||||
|
||||
private String statusName;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String created_at;
|
||||
|
||||
private String updated_at;
|
||||
|
||||
private List<DeptPickingItemDto> items;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 部门领料出库单查询条件
|
||||
*/
|
||||
@Data
|
||||
public class DeptPickingQuery {
|
||||
|
||||
/** 单据号 */
|
||||
private String orderNo;
|
||||
|
||||
/** 工单号 */
|
||||
private String aufnr;
|
||||
|
||||
/** 物料号 */
|
||||
private String matnr;
|
||||
|
||||
/** 移动类型 */
|
||||
private String bwart;
|
||||
|
||||
private String status;
|
||||
|
||||
private String startTime;
|
||||
|
||||
private String endTime;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PP113 部门领料出库同步报文
|
||||
* <pre>
|
||||
* {
|
||||
* "header": { "intf_id": "PP113", "src_system": "SAP", "dest_system": "MES3", ... },
|
||||
* "body": [ { "rsnum": "...", "rspos": "1", "matnr": "...", "bdmng": "1", ... } ]
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DeptPickingSyncDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@JsonProperty("header")
|
||||
private DeptPickingSyncHeader header;
|
||||
|
||||
@JsonProperty("body")
|
||||
private List<DeptPickingSyncItem> body;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* PP113 同步报文头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DeptPickingSyncHeader implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@JsonProperty("intf_id")
|
||||
private String intfId;
|
||||
|
||||
@JsonProperty("src_system")
|
||||
private String srcSystem;
|
||||
|
||||
@JsonProperty("dest_system")
|
||||
private String destSystem;
|
||||
|
||||
@JsonProperty("src_msgid")
|
||||
private String srcMsgid;
|
||||
|
||||
@JsonProperty("requesttime")
|
||||
private String requesttime;
|
||||
|
||||
@JsonProperty("backup1")
|
||||
private String backup1;
|
||||
|
||||
@JsonProperty("backup2")
|
||||
private String backup2;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* PP113 同步报文行项目(部门领料出库)
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DeptPickingSyncItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 预留号 */
|
||||
@JsonProperty("rsnum")
|
||||
private String rsnum;
|
||||
|
||||
/** 预留行项目 */
|
||||
@JsonProperty("rspos")
|
||||
private String rspos;
|
||||
|
||||
/** 创建日期 */
|
||||
@JsonProperty("erdat")
|
||||
private String erdat;
|
||||
|
||||
/** 创建人 */
|
||||
@JsonProperty("ernam")
|
||||
private String ernam;
|
||||
|
||||
/** 成本中心 */
|
||||
@JsonProperty("kostl")
|
||||
private String kostl;
|
||||
|
||||
/** 生产/工单号 */
|
||||
@JsonProperty("aufnr")
|
||||
private String aufnr;
|
||||
|
||||
@JsonProperty("matnr")
|
||||
private String matnr;
|
||||
|
||||
/** 物料描述 */
|
||||
@JsonProperty("maktx")
|
||||
private String maktx;
|
||||
|
||||
/** 数量 */
|
||||
@JsonProperty("bdmng")
|
||||
private BigDecimal bdmng;
|
||||
|
||||
@JsonProperty("werks")
|
||||
private String werks;
|
||||
|
||||
/** 库存地点 */
|
||||
@JsonProperty("lgort")
|
||||
private String lgort;
|
||||
|
||||
@JsonProperty("meins")
|
||||
private String meins;
|
||||
|
||||
/** 移动类型:261工单领料 / 201成本中心领料 */
|
||||
@JsonProperty("bwart")
|
||||
private String bwart;
|
||||
|
||||
/** 收货方/领料人 */
|
||||
@JsonProperty("wempf")
|
||||
private String wempf;
|
||||
|
||||
@JsonProperty("backup1")
|
||||
private String backup1;
|
||||
|
||||
@JsonProperty("backup2")
|
||||
private String backup2;
|
||||
|
||||
@JsonProperty("backup3")
|
||||
private String backup3;
|
||||
|
||||
@JsonProperty("backup4")
|
||||
private String backup4;
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
package org.nl.wms.pm_manage.sap.deptPicking.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.ext_manage.sap.enums.SapConstant;
|
||||
import org.nl.wms.pm_manage.SourceBillTypeEnum;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.enums.DeptPickingStatus;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.DeptPickingService;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dao.DeptPickingItem;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dao.DeptPickingOrder;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dao.mapper.DeptPickingItemMapper;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dao.mapper.DeptPickingOrderMapper;
|
||||
import org.nl.wms.pm_manage.sap.deptPicking.service.dto.*;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.IOutBillService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* SAP部门领料出库单(PP113):SAP推送落库 → 下推WMS出库单 → 出库完成按PP055回传SAP
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeptPickingServiceImpl implements DeptPickingService {
|
||||
|
||||
/** 下推生成的WMS出库单类型 */
|
||||
private static final String WMS_BILL_TYPE_NAME = "生产出库";
|
||||
|
||||
private static final String CALLBACK_STRATEGY = "sapDeptPickingOut";
|
||||
|
||||
private final DeptPickingOrderMapper orderMapper;
|
||||
private final DeptPickingItemMapper itemMapper;
|
||||
private final IOutBillService outBillService;
|
||||
private final IMdMeMaterialbaseService materialbaseService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject insertSapLld(DeptPickingSyncDTO dto) {
|
||||
if (dto == null || CollectionUtils.isEmpty(dto.getBody())) {
|
||||
throw new BadRequestException("SAP部门领料出库同步失败:body为空");
|
||||
}
|
||||
DeptPickingSyncHeader header = dto.getHeader();
|
||||
String orderNo = header == null ? null : StrUtil.trim(header.getSrcMsgid());
|
||||
if (StrUtil.isBlank(orderNo)) {
|
||||
orderNo = "RKD" + DateUtil.format(DateUtil.date(), "yyyyMMddHHmmssSSS");
|
||||
}
|
||||
if (orderMapper.selectOne(new LambdaQueryWrapper<DeptPickingOrder>()
|
||||
.eq(DeptPickingOrder::getOrder_no, orderNo)) != null) {
|
||||
throw new BadRequestException("SAP部门领料出库同步失败:单据" + orderNo + "已经存在");
|
||||
}
|
||||
|
||||
String now = DateUtil.now();
|
||||
DeptPickingOrder order = new DeptPickingOrder();
|
||||
order.setOrder_no(orderNo);
|
||||
order.setIntf_id(header == null ? SapConstant.INTF_PP113 : StrUtil.blankToDefault(header.getIntfId(), SapConstant.INTF_PP113));
|
||||
order.setSrc_system(header == null ? "SAP" : StrUtil.blankToDefault(header.getSrcSystem(), "SAP"));
|
||||
order.setDest_system(header == null ? "MES3" : StrUtil.blankToDefault(header.getDestSystem(), "MES3"));
|
||||
order.setSrc_msgid(header == null ? null : header.getSrcMsgid());
|
||||
order.setRequest_time(header == null ? null : header.getRequesttime());
|
||||
order.setBackup1(header == null ? null : header.getBackup1());
|
||||
order.setBackup2(header == null ? null : header.getBackup2());
|
||||
order.setLgort(StrUtil.trim(dto.getBody().get(0).getLgort()));
|
||||
order.setItem_count(dto.getBody().size());
|
||||
order.setStatus(DeptPickingStatus.CREATED.getCode());
|
||||
order.setCreated_at(now);
|
||||
order.setUpdated_at(now);
|
||||
orderMapper.insert(order);
|
||||
|
||||
for (DeptPickingSyncItem syncItem : dto.getBody()) {
|
||||
saveSyncItem(order, syncItem, now);
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("respCode", 0);
|
||||
result.put("respMsg", "部门领料出库同步成功");
|
||||
result.put("orderNo", orderNo);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void saveSyncItem(DeptPickingOrder order, DeptPickingSyncItem syncItem, String now) {
|
||||
if (syncItem == null) {
|
||||
throw new BadRequestException("SAP部门领料出库同步失败:存在空行项目");
|
||||
}
|
||||
if (StrUtil.isBlank(syncItem.getMatnr())) {
|
||||
throw new BadRequestException("SAP部门领料出库同步失败:物料号不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(syncItem.getLgort())) {
|
||||
throw new BadRequestException("SAP部门领料出库同步失败:物料" + syncItem.getMatnr() + "的库存地点不能为空");
|
||||
}
|
||||
if (syncItem.getBdmng() == null || syncItem.getBdmng().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new BadRequestException("SAP部门领料出库同步失败:物料" + syncItem.getMatnr() + "的数量必须大于0");
|
||||
}
|
||||
DeptPickingItem item = new DeptPickingItem();
|
||||
item.setHeader_id(order.getId());
|
||||
item.setOrder_no(order.getOrder_no());
|
||||
item.setRsnum(syncItem.getRsnum());
|
||||
item.setRspos(syncItem.getRspos());
|
||||
item.setErdat(syncItem.getErdat());
|
||||
item.setErnam(syncItem.getErnam());
|
||||
item.setKostl(syncItem.getKostl());
|
||||
item.setAufnr(syncItem.getAufnr());
|
||||
item.setMatnr(StrUtil.trim(syncItem.getMatnr()));
|
||||
item.setMaktx(syncItem.getMaktx());
|
||||
item.setBdmng(syncItem.getBdmng());
|
||||
item.setWerks(syncItem.getWerks());
|
||||
item.setLgort(StrUtil.trim(syncItem.getLgort()));
|
||||
item.setMeins(syncItem.getMeins());
|
||||
item.setBwart(syncItem.getBwart());
|
||||
item.setWempf(syncItem.getWempf());
|
||||
item.setBackup1(syncItem.getBackup1());
|
||||
item.setBackup2(syncItem.getBackup2());
|
||||
item.setBackup3(syncItem.getBackup3());
|
||||
item.setBackup4(syncItem.getBackup4());
|
||||
item.setCreated_at(now);
|
||||
itemMapper.insert(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<DeptPickingOrder> queryPage(DeptPickingQuery query, PageQuery page) {
|
||||
LambdaQueryWrapper<DeptPickingOrder> wrapper = new LambdaQueryWrapper<>();
|
||||
if (query != null) {
|
||||
if (StrUtil.isNotBlank(query.getOrderNo())) {
|
||||
wrapper.like(DeptPickingOrder::getOrder_no, query.getOrderNo().trim());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getStatus())) {
|
||||
wrapper.eq(DeptPickingOrder::getStatus, query.getStatus());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getStartTime())) {
|
||||
wrapper.ge(DeptPickingOrder::getCreated_at, query.getStartTime());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getEndTime())) {
|
||||
wrapper.le(DeptPickingOrder::getCreated_at, query.getEndTime());
|
||||
}
|
||||
// 工单号/物料/移动类型在明细上,按明细命中的单据过滤
|
||||
if (StrUtil.isNotBlank(query.getAufnr()) || StrUtil.isNotBlank(query.getMatnr())
|
||||
|| StrUtil.isNotBlank(query.getBwart())) {
|
||||
List<Long> headerIds = queryHeaderIdsByItem(query);
|
||||
if (headerIds.isEmpty()) {
|
||||
return new Page<>(1, 10);
|
||||
}
|
||||
wrapper.in(DeptPickingOrder::getId, headerIds);
|
||||
}
|
||||
}
|
||||
wrapper.orderByDesc(DeptPickingOrder::getId);
|
||||
int pageNum = page == null || page.getPage() == null ? 0 : page.getPage();
|
||||
int pageSize = page == null || page.getSize() == null ? 10 : page.getSize();
|
||||
return orderMapper.selectPage(new Page<>(pageNum + 1, pageSize), wrapper);
|
||||
}
|
||||
|
||||
private List<Long> queryHeaderIdsByItem(DeptPickingQuery query) {
|
||||
LambdaQueryWrapper<DeptPickingItem> wrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(query.getAufnr())) {
|
||||
wrapper.like(DeptPickingItem::getAufnr, query.getAufnr().trim());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getMatnr())) {
|
||||
wrapper.like(DeptPickingItem::getMatnr, query.getMatnr().trim());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getBwart())) {
|
||||
wrapper.eq(DeptPickingItem::getBwart, query.getBwart().trim());
|
||||
}
|
||||
wrapper.select(DeptPickingItem::getHeader_id);
|
||||
return itemMapper.selectList(wrapper).stream()
|
||||
.map(DeptPickingItem::getHeader_id)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeptPickingOrderDto getDetail(Long id) {
|
||||
DeptPickingOrder order = orderMapper.selectById(id);
|
||||
if (order == null) {
|
||||
throw new BadRequestException("部门领料出库单不存在");
|
||||
}
|
||||
return toOrderDto(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeptPickingOrderDto getDetailByOrderNo(String orderNo) {
|
||||
DeptPickingOrder order = orderMapper.selectOne(new LambdaQueryWrapper<DeptPickingOrder>()
|
||||
.eq(DeptPickingOrder::getOrder_no, StrUtil.trim(orderNo)));
|
||||
if (order == null) {
|
||||
throw new BadRequestException("单据" + orderNo + "不存在");
|
||||
}
|
||||
return toOrderDto(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByIds(List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
throw new BadRequestException("删除失败:未选择单据");
|
||||
}
|
||||
for (Long id : ids) {
|
||||
DeptPickingOrder order = orderMapper.selectById(id);
|
||||
if (order == null) {
|
||||
continue;
|
||||
}
|
||||
if (!DeptPickingStatus.CREATED.getCode().equals(order.getStatus())
|
||||
&& !DeptPickingStatus.CANCELED.getCode().equals(order.getStatus())) {
|
||||
throw new BadRequestException("删除失败:单据" + order.getOrder_no() + "已下发或已完成");
|
||||
}
|
||||
itemMapper.delete(new LambdaQueryWrapper<DeptPickingItem>()
|
||||
.eq(DeptPickingItem::getHeader_id, order.getId()));
|
||||
orderMapper.deleteById(order.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void pushOut(Long id) {
|
||||
if (id == null) {
|
||||
throw new BadRequestException("下推失败:未选择单据");
|
||||
}
|
||||
DeptPickingOrder order = orderMapper.selectById(id);
|
||||
if (order == null) {
|
||||
throw new BadRequestException("下推失败:单据不存在");
|
||||
}
|
||||
if (!DeptPickingStatus.CREATED.getCode().equals(order.getStatus())) {
|
||||
throw new BadRequestException("下推失败:单据" + order.getOrder_no() + "不是已创建状态");
|
||||
}
|
||||
List<DeptPickingItem> items = listItems(order.getId());
|
||||
if (CollectionUtils.isEmpty(items)) {
|
||||
throw new BadRequestException("下推失败:单据明细不存在");
|
||||
}
|
||||
Map<String, List<DeptPickingItem>> grouped = items.stream()
|
||||
.peek(item -> {
|
||||
if (StrUtil.isBlank(item.getLgort())) {
|
||||
throw new BadRequestException("下推失败:物料" + item.getMatnr() + "的库存地点不能为空");
|
||||
}
|
||||
})
|
||||
.collect(Collectors.groupingBy(DeptPickingItem::getLgort));
|
||||
for (Map.Entry<String, List<DeptPickingItem>> entry : grouped.entrySet()) {
|
||||
outBillService.saveBill(convertToOutBill(order, entry.getKey(), entry.getValue()));
|
||||
}
|
||||
order.setStatus(DeptPickingStatus.POSTED.getCode());
|
||||
order.setUpdated_at(DateUtil.now());
|
||||
orderMapper.updateById(order);
|
||||
}
|
||||
|
||||
private JSONObject convertToOutBill(DeptPickingOrder order, String houseCode, List<DeptPickingItem> items) {
|
||||
List<String> materialCodes = items.stream()
|
||||
.map(DeptPickingItem::getMatnr)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<MdMeMaterialbase> materials = materialbaseService.list(new LambdaQueryWrapper<MdMeMaterialbase>()
|
||||
.in(MdMeMaterialbase::getMaterial_code, materialCodes)
|
||||
.select(MdMeMaterialbase::getMaterial_id, MdMeMaterialbase::getMaterial_code,
|
||||
MdMeMaterialbase::getQty_unit_id));
|
||||
Map<String, MdMeMaterialbase> materialsByCode = materials.stream()
|
||||
.collect(Collectors.toMap(MdMeMaterialbase::getMaterial_code, Function.identity(), (a, b) -> a));
|
||||
List<JSONObject> tableData = new ArrayList<>();
|
||||
for (DeptPickingItem item : items) {
|
||||
MdMeMaterialbase material = materialsByCode.get(item.getMatnr());
|
||||
if (material == null) {
|
||||
throw new BadRequestException("下推失败:物料" + item.getMatnr() + "在WMS中不存在");
|
||||
}
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("material_id", material.getMaterial_id());
|
||||
row.put("material_code", item.getMatnr());
|
||||
row.put("qty_unit_id", material.getQty_unit_id());
|
||||
row.put("qty_unit_name", StrUtil.blankToDefault(item.getMeins(), ""));
|
||||
row.put("qty", item.getBdmng());
|
||||
row.put("source_bill_code", order.getOrder_no());
|
||||
row.put("source_bill_type", SourceBillTypeEnum.SAP_DEPT_PICKING.getBillType());
|
||||
// 明细主键传给回传策略,用于取预留号/工单号回传PP055
|
||||
row.put("source_billdtl_id", String.valueOf(item.getId()));
|
||||
row.put("callback_strategy", CALLBACK_STRATEGY);
|
||||
row.put("remark", "SAP部门领料出库下推:" + order.getOrder_no());
|
||||
tableData.add(row);
|
||||
}
|
||||
JSONObject billParam = new JSONObject();
|
||||
billParam.put("stor_code", houseCode);
|
||||
billParam.put("biz_date", DateUtil.today());
|
||||
billParam.put("bill_type", IOSEnum.BILL_TYPE.code(WMS_BILL_TYPE_NAME));
|
||||
billParam.put("remark", "SAP部门领料出库下推,单据:" + order.getOrder_no());
|
||||
billParam.put("tableData", tableData);
|
||||
return billParam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptPickingItem> listItems(Long headerId) {
|
||||
return itemMapper.selectList(new LambdaQueryWrapper<DeptPickingItem>()
|
||||
.eq(DeptPickingItem::getHeader_id, headerId)
|
||||
.orderByAsc(DeptPickingItem::getId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeptPickingItem getItem(Long itemId) {
|
||||
return itemId == null ? null : itemMapper.selectById(itemId);
|
||||
}
|
||||
|
||||
private DeptPickingOrderDto toOrderDto(DeptPickingOrder order) {
|
||||
DeptPickingOrderDto dto = new DeptPickingOrderDto();
|
||||
dto.setId(order.getId());
|
||||
dto.setOrder_no(order.getOrder_no());
|
||||
dto.setIntf_id(order.getIntf_id());
|
||||
dto.setSrc_system(order.getSrc_system());
|
||||
dto.setDest_system(order.getDest_system());
|
||||
dto.setSrc_msgid(order.getSrc_msgid());
|
||||
dto.setRequest_time(order.getRequest_time());
|
||||
dto.setLgort(order.getLgort());
|
||||
dto.setItem_count(order.getItem_count());
|
||||
dto.setStatus(order.getStatus());
|
||||
dto.setStatusName(resolveStatusName(order.getStatus()));
|
||||
dto.setRemark(order.getRemark());
|
||||
dto.setCreated_at(order.getCreated_at());
|
||||
dto.setUpdated_at(order.getUpdated_at());
|
||||
dto.setItems(listItems(order.getId()).stream().map(this::toItemDto).collect(Collectors.toList()));
|
||||
return dto;
|
||||
}
|
||||
|
||||
private DeptPickingItemDto toItemDto(DeptPickingItem item) {
|
||||
DeptPickingItemDto dto = new DeptPickingItemDto();
|
||||
dto.setId(item.getId());
|
||||
dto.setHeader_id(item.getHeader_id());
|
||||
dto.setRsnum(item.getRsnum());
|
||||
dto.setRspos(item.getRspos());
|
||||
dto.setErdat(item.getErdat());
|
||||
dto.setErnam(item.getErnam());
|
||||
dto.setKostl(item.getKostl());
|
||||
dto.setAufnr(item.getAufnr());
|
||||
dto.setMatnr(item.getMatnr());
|
||||
dto.setMaktx(item.getMaktx());
|
||||
dto.setBdmng(item.getBdmng());
|
||||
dto.setWerks(item.getWerks());
|
||||
dto.setLgort(item.getLgort());
|
||||
dto.setMeins(item.getMeins());
|
||||
dto.setBwart(item.getBwart());
|
||||
dto.setWempf(item.getWempf());
|
||||
return dto;
|
||||
}
|
||||
|
||||
private String resolveStatusName(String status) {
|
||||
for (DeptPickingStatus value : DeptPickingStatus.values()) {
|
||||
if (value.getCode().equals(status)) {
|
||||
return value.getName();
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,8 @@ public class SapProduct2X001MM057 implements CallbackStrategy {
|
||||
List<IOStorInvDisDto> disSet = ioStorInvDisMapper.queryOutBillDisDtl(
|
||||
MapOf.of("iostorinvdtl_id", param.getIostorinvdtl_id()));
|
||||
IOStorInv storInv = loadStorInv(param);
|
||||
MaterialTransferRequest request = buildMaterialTransferRequest(param, storInv, storCode, disSet);
|
||||
//XX001对应SAPX001
|
||||
MaterialTransferRequest request = buildMaterialTransferRequest(param, storInv, "X001", disSet);
|
||||
PmStockReturn stockReturn = new PmStockReturn();
|
||||
stockReturn.setRequest_Id(param.getIostorinv_id());
|
||||
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨"));
|
||||
|
||||
Reference in New Issue
Block a user