add:手工领料出库单
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
- `pm_manage/sap/outBoundDelivery` — SAP 委外交货单
|
||||
- `pm_manage/sap/salesReturnOut` — SAP 销售退货出库
|
||||
- `pm_manage/sap/deptPicking` — SAP 部门领料出库(PP113)
|
||||
- `pm_manage/sap/manualPicking` — SAP 手工领料出库(MM022)
|
||||
|
||||
详细接口文档见各业务模块下的 `READ.MD`。
|
||||
|
||||
@@ -95,6 +96,29 @@ PDA 扫码后调用以下接口收货:
|
||||
> 先按 `material_document.mblnr` 找入库方向(`MaterialDocumentIo.IN`)的物料凭证,再按 `outbound_delivery.vbeln`
|
||||
> 找收货类交货单(`OutboundDeliveryBillType.isStorageOnly()`)。
|
||||
|
||||
## SAP 成本中心查询(MDG019,WMS 主动拉取)
|
||||
|
||||
| 接口 | 说明 | 实现 |
|
||||
|------|------|------|
|
||||
| `SapApi#costCenterQuery()` | 查询成本中心列表(表名固定 `CSKS`) | `ManualPickingServiceImpl#listCostCenters` |
|
||||
|
||||
- 请求:`header.intf_id=MDG019`、`src_system=WMS5`、`dest_system=SAP`;`body[0].TABLENAME="CSKS"`。
|
||||
- 响应:`body` 为对象 `{status, message, csks:[{kostl,bukrs,ktext}]}`,走 `postQuery`,不走写入类接口的 S/E 数组校验。
|
||||
- 前端下拉接口:`GET /api/sapManualPicking/costCenters`,服务端 5 分钟缓存。
|
||||
|
||||
## SAP 手工领料出库(WMS 新建 → MM022)
|
||||
|
||||
- 页面 `wms/pm_manage/sap/manualPicking/index`:选择仓库、建单日期、逐行录入物料/数量/成本中心(下拉来自 MDG019),
|
||||
单据号 `SLL+yyyyMMddHHmmssSSS`,落 `sap_manual_picking` / `sap_manual_picking_item`。
|
||||
- 下推:`POST /api/sapManualPicking/outPush`,按仓库生成一张 WMS 出库单(类型:生产出库),
|
||||
明细 `callback_strategy = sapManualPickingOut`、`source_billdtl_id = 领料明细ID`,出库单号回写 `out_bill_code`。
|
||||
- 回传:出库单全部明细完成 → `SapManualPickingOut` 组装 **MM022**:
|
||||
`mblnr`=WMS 出库单号、`bldat`=建单日期、`budat`=过账当天、`bwart`=201,
|
||||
`item[]`:`posnr`=领料行号、`werks`=领料行工厂(默认 1060)、`lgort`=出库仓库、`lfimg`=实际出库数量、
|
||||
`meins`=单位、`sobkz`=空、`matnr`=物料、`kostl`=成本中心。
|
||||
结果落 `pm_stock_return`(类型=SAP手工领料出库),同一出库单成功过账一次,成功后将单据置为已完成。
|
||||
- PDA 拣选:此类出库单走普通出库流程(`STOutTask`),无需部门领料的专属任务。
|
||||
|
||||
### SAP 部门领料出库(PP113 → PP055)
|
||||
|
||||
- 同步:`POST /wms/sap_services/maintain/insertSapLld`,报文为 `header + body[]`(行项目扁平列表),
|
||||
|
||||
@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.ext_manage.sap.enums.SapConstant;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.MaterialTransferRequest;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.ManualPickingRequest;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.ProductionInboundRequest;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.ProductionOutboundRequest;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.ReceiptConfirmRequest;
|
||||
@@ -94,6 +95,41 @@ public class SapApi {
|
||||
return postInbound("SAP生产入库", request);
|
||||
}
|
||||
|
||||
/**
|
||||
* MM022 手工领料出库过账
|
||||
*/
|
||||
public JSONObject manualPickingOut(ManualPickingRequest request) {
|
||||
return postInbound("SAP手工领料出库[" + SapConstant.INTF_MM022 + "]", request);
|
||||
}
|
||||
|
||||
/**
|
||||
* MDG019 成本中心主数据查询(表名固定 CSKS)
|
||||
* <p>
|
||||
* 查询类接口,响应体 body 为对象:{@code {"status":"S","message":"查询成功","csks":[{...}]}},
|
||||
* 与写入类接口的 body 数组不同,故走 postQuery。
|
||||
*/
|
||||
public JSONObject costCenterQuery() {
|
||||
JSONObject header = new JSONObject();
|
||||
header.put("intf_id", SapConstant.INTF_MDG019);
|
||||
header.put("src_system", SapConstant.SRC_SYSTEM);
|
||||
header.put("dest_system", SapConstant.DEST_SYSTEM);
|
||||
header.put("src_msgid", "");
|
||||
header.put("requesttime", "");
|
||||
header.put("backup1", "1");
|
||||
header.put("backup2", "2");
|
||||
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("TABLENAME", SapConstant.MDG019_TABLE_CSKS);
|
||||
|
||||
JSONArray body = new JSONArray();
|
||||
body.add(item);
|
||||
|
||||
JSONObject request = new JSONObject();
|
||||
request.put("header", header);
|
||||
request.put("body", body);
|
||||
return postQuery("SAP成本中心查询[" + SapConstant.INTF_MDG019 + "]", request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按已落库的 SAP 请求 JSON 直接回传(手动回传)
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.nl.wms.ext_manage.sap.api.dto;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MM022 手工领料出库过账 - 凭证体
|
||||
*/
|
||||
@Data
|
||||
public class ManualPickingBody {
|
||||
|
||||
/** 过账日期 yyyyMMdd */
|
||||
@JSONField(name = "budat")
|
||||
@JsonProperty("budat")
|
||||
private String budat;
|
||||
|
||||
/** 单据编号(WMS 出库单号) */
|
||||
@JSONField(name = "mblnr")
|
||||
@JsonProperty("mblnr")
|
||||
private String mblnr;
|
||||
|
||||
/** 建单日期 yyyyMMdd */
|
||||
@JSONField(name = "bldat")
|
||||
@JsonProperty("bldat")
|
||||
private String bldat;
|
||||
|
||||
/** 移动类型,固定 201 */
|
||||
@JSONField(name = "bwart")
|
||||
@JsonProperty("bwart")
|
||||
private String bwart;
|
||||
|
||||
/** 行项目,接口字段名为 item(单数) */
|
||||
@JSONField(name = "item")
|
||||
@JsonProperty("item")
|
||||
private List<ManualPickingItem> items;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.nl.wms.ext_manage.sap.api.dto;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* MM022 手工领料出库过账 - 报文头
|
||||
*/
|
||||
@Data
|
||||
public class ManualPickingHeader {
|
||||
|
||||
@JSONField(name = "intf_id")
|
||||
@JsonProperty("intf_id")
|
||||
private String intfId;
|
||||
|
||||
@JSONField(name = "src_system")
|
||||
@JsonProperty("src_system")
|
||||
private String srcSystem;
|
||||
|
||||
@JSONField(name = "dest_system")
|
||||
@JsonProperty("dest_system")
|
||||
private String destSystem;
|
||||
|
||||
@JSONField(name = "src_msgid")
|
||||
@JsonProperty("src_msgid")
|
||||
private String srcMsgid;
|
||||
|
||||
@JSONField(name = "requesttime")
|
||||
@JsonProperty("requesttime")
|
||||
private String requesttime;
|
||||
|
||||
@JSONField(name = "backup1")
|
||||
@JsonProperty("backup1")
|
||||
private String backup1;
|
||||
|
||||
@JSONField(name = "backup2")
|
||||
@JsonProperty("backup2")
|
||||
private String backup2;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.nl.wms.ext_manage.sap.api.dto;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* MM022 手工领料出库过账 - 行项目
|
||||
*/
|
||||
@Data
|
||||
public class ManualPickingItem {
|
||||
|
||||
/** 行项目号 */
|
||||
@JSONField(name = "posnr")
|
||||
@JsonProperty("posnr")
|
||||
private String posnr;
|
||||
|
||||
/** 工厂 */
|
||||
@JSONField(name = "werks")
|
||||
@JsonProperty("werks")
|
||||
private String werks;
|
||||
|
||||
/** 库存地点(仓库编码) */
|
||||
@JSONField(name = "lgort")
|
||||
@JsonProperty("lgort")
|
||||
private String lgort;
|
||||
|
||||
/** 数量 */
|
||||
@JSONField(name = "lfimg")
|
||||
@JsonProperty("lfimg")
|
||||
private Double lfimg;
|
||||
|
||||
/** 计量单位 */
|
||||
@JSONField(name = "meins")
|
||||
@JsonProperty("meins")
|
||||
private String meins;
|
||||
|
||||
/** 特殊库存标识,手工领料固定空 */
|
||||
@JSONField(name = "sobkz")
|
||||
@JsonProperty("sobkz")
|
||||
private String sobkz;
|
||||
|
||||
/** 物料号 */
|
||||
@JSONField(name = "matnr")
|
||||
@JsonProperty("matnr")
|
||||
private String matnr;
|
||||
|
||||
/** 成本中心 */
|
||||
@JSONField(name = "kostl")
|
||||
@JsonProperty("kostl")
|
||||
private String kostl;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.wms.ext_manage.sap.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MM022 手工领料出库过账请求
|
||||
*/
|
||||
@Data
|
||||
public class ManualPickingRequest {
|
||||
|
||||
private ManualPickingHeader header;
|
||||
|
||||
private List<ManualPickingBody> body;
|
||||
}
|
||||
@@ -48,6 +48,15 @@ public class SapConstant {
|
||||
/** 接口编号:供应商主数据查询(按供应商编码查名称) */
|
||||
public static final String INTF_MDG004 = "MDG004";
|
||||
|
||||
/** 接口编号:成本中心主数据查询(MDG019,表名固定 CSKS) */
|
||||
public static final String INTF_MDG019 = "MDG019";
|
||||
|
||||
/** 接口编号:手工领料出库过账 */
|
||||
public static final String INTF_MM022 = "MM022";
|
||||
|
||||
/** MDG019 查询表名(成本中心主数据) */
|
||||
public static final String MDG019_TABLE_CSKS = "CSKS";
|
||||
|
||||
/** 物料查询同步来源系统 */
|
||||
public static final String MATERIAL_QUERY_SRC_SYSTEM = "WMS";
|
||||
|
||||
@@ -74,6 +83,9 @@ public class SapConstant {
|
||||
/** 移动类型:采购退货出库 */
|
||||
public static final String BWART_RETURN_OUT = "161";
|
||||
|
||||
/** 移动类型:成本中心领料出库(手工领料 MM022) */
|
||||
public static final String BWART_COST_CENTER_ISSUE = "201";
|
||||
|
||||
/**
|
||||
* 工单BOM控制码:ZP02 表示该物料不需要回传生产入库(PP066)
|
||||
* 取工单BOM的 steus 字段,非 ZP02 才回传
|
||||
|
||||
@@ -18,6 +18,7 @@ public enum SourceBillTypeEnum {
|
||||
SAP_OUTBOUND_DELIVERY("sapOutboundDelivery","SAP委外单-出库"),
|
||||
SAP_SALES_RETURN_OUT("sapSalesReturnOut","SAP销售退货出库"),
|
||||
SAP_DEPT_PICKING("sapDeptPicking","SAP部门领料出库"),
|
||||
SAP_MANUAL_PICKING("sapManualPicking","SAP手工领料出库"),
|
||||
UNDEFINE("","未定义"),
|
||||
;
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.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.manualPicking.service.ManualPickingService;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingOrderDto;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingQuery;
|
||||
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.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* SAP手工领料出库单:WMS 新建 → 下推出库 → 出库完成按 MM022 回传 SAP
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/sapManualPicking")
|
||||
@Slf4j
|
||||
public class ManualPickingController {
|
||||
|
||||
private final ManualPickingService manualPickingService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询SAP手工领料出库单")
|
||||
public ResponseEntity<Object> queryAll(ManualPickingQuery query, PageQuery page) {
|
||||
return ResponseData.build(manualPickingService.queryPage(query, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Log("查询SAP手工领料出库单详情")
|
||||
public ResponseEntity<Object> getById(@PathVariable Long id) {
|
||||
return ResponseData.build(manualPickingService.getDetail(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增SAP手工领料出库单")
|
||||
public ResponseEntity<Object> create(@RequestBody ManualPickingOrderDto dto) {
|
||||
Long id = manualPickingService.create(dto);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("id", id);
|
||||
return ResponseData.build(result);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改SAP手工领料出库单")
|
||||
public ResponseEntity<Object> update(@RequestBody ManualPickingOrderDto dto) {
|
||||
manualPickingService.update(dto);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除SAP手工领料出库单")
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
manualPickingService.deleteByIds(Arrays.asList(ids));
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/outPush")
|
||||
@Log("下推SAP手工领料出库单生成出库单")
|
||||
public ResponseEntity<Object> outPush(@RequestBody JSONObject dto) {
|
||||
String billCode = manualPickingService.pushOut(dto.getLong("id"));
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("billCode", billCode);
|
||||
return ResponseData.build(result);
|
||||
}
|
||||
|
||||
@GetMapping("/costCenters")
|
||||
@Log("查询成本中心列表(MDG019)")
|
||||
public ResponseEntity<Object> costCenters() {
|
||||
return ResponseData.build(manualPickingService.listCostCenters(), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.enums;
|
||||
|
||||
/**
|
||||
* SAP手工领料出库单状态
|
||||
*/
|
||||
public enum ManualPickingStatus {
|
||||
|
||||
CREATED("CREATED", "已创建"),
|
||||
POSTED("POSTED", "已下发"),
|
||||
COMPLETED("COMPLETED", "已完成"),
|
||||
CANCELED("CANCELED", "已取消");
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
ManualPickingStatus(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static ManualPickingStatus ofCode(String code) {
|
||||
for (ManualPickingStatus value : values()) {
|
||||
if (value.code.equals(code)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingItem;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingOrder;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.CostCenterVo;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingOrderDto;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SAP手工领料出库单:WMS 新建 → 下推WMS出库单 → 出库完成后按 MM022 回传 SAP
|
||||
*/
|
||||
public interface ManualPickingService {
|
||||
|
||||
IPage<ManualPickingOrder> queryPage(ManualPickingQuery query, PageQuery page);
|
||||
|
||||
ManualPickingOrderDto getDetail(Long id);
|
||||
|
||||
/**
|
||||
* 新建手工领料单
|
||||
*/
|
||||
Long create(ManualPickingOrderDto dto);
|
||||
|
||||
/**
|
||||
* 修改手工领料单(仅已创建状态)
|
||||
*/
|
||||
void update(ManualPickingOrderDto dto);
|
||||
|
||||
void deleteByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 下推生成WMS出库单,出库完成后按 MM022 回传 SAP
|
||||
*/
|
||||
String pushOut(Long id);
|
||||
|
||||
List<ManualPickingItem> listItems(Long headerId);
|
||||
|
||||
ManualPickingItem getItem(Long itemId);
|
||||
|
||||
/**
|
||||
* MDG019 成本中心列表
|
||||
*/
|
||||
List<CostCenterVo> listCostCenters();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.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手工领料出库单明细
|
||||
*/
|
||||
@Data
|
||||
@TableName("sap_manual_picking_item")
|
||||
public class ManualPickingItem 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;
|
||||
|
||||
/** 行项目号,回传 MM022 时使用 */
|
||||
private Integer posnr;
|
||||
|
||||
private String matnr;
|
||||
|
||||
/** 物料描述 */
|
||||
private String maktx;
|
||||
|
||||
/** 数量 */
|
||||
private BigDecimal menge;
|
||||
|
||||
private String meins;
|
||||
|
||||
/** 成本中心 */
|
||||
private String kostl;
|
||||
|
||||
/** 成本中心名称 */
|
||||
private String kostl_name;
|
||||
|
||||
private String werks;
|
||||
|
||||
/** 库存地点:取单据仓库编码 */
|
||||
private String lgort;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.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手工领料出库单(WMS 新建 → 下推出库 → 完成后按 MM022 回传 SAP)
|
||||
*/
|
||||
@Data
|
||||
@TableName("sap_manual_picking")
|
||||
public class ManualPickingOrder implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 单据号:SLL + yyyyMMddHHmmssSSS */
|
||||
private String order_no;
|
||||
|
||||
/** 仓库编码(WMS 仓库,同时作为 MM022 的 lgort) */
|
||||
private String stor_code;
|
||||
|
||||
private String stor_name;
|
||||
|
||||
/** 建单日期 yyyyMMdd */
|
||||
private String bldat;
|
||||
|
||||
/** 明细行数 */
|
||||
private Integer item_count;
|
||||
|
||||
/** 总数量 */
|
||||
private BigDecimal total_qty;
|
||||
|
||||
/** 状态:CREATED/POSTED/COMPLETED/CANCELED */
|
||||
private String status;
|
||||
|
||||
/** 下推生成的 WMS 出库单号,作为 MM022 的 mblnr */
|
||||
private String out_bill_code;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String create_id;
|
||||
|
||||
private String create_name;
|
||||
|
||||
private String create_time;
|
||||
|
||||
private String update_id;
|
||||
|
||||
private String update_name;
|
||||
|
||||
private String update_time;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingItem;
|
||||
|
||||
@Mapper
|
||||
public interface ManualPickingItemMapper extends BaseMapper<ManualPickingItem> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingOrder;
|
||||
|
||||
@Mapper
|
||||
public interface ManualPickingOrderMapper extends BaseMapper<ManualPickingOrder> {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* MDG019 成本中心(CSKS)
|
||||
*/
|
||||
@Data
|
||||
public class CostCenterVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 成本中心编码 */
|
||||
private String kostl;
|
||||
|
||||
/** 公司代码 */
|
||||
private String bukrs;
|
||||
|
||||
/** 成本中心名称 */
|
||||
private String ktext;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* SAP手工领料出库单明细DTO
|
||||
*/
|
||||
@Data
|
||||
public class ManualPickingItemDto {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long header_id;
|
||||
|
||||
private String order_no;
|
||||
|
||||
/** 行项目号 */
|
||||
private Integer posnr;
|
||||
|
||||
private String matnr;
|
||||
|
||||
private String maktx;
|
||||
|
||||
private BigDecimal menge;
|
||||
|
||||
private String meins;
|
||||
|
||||
private String kostl;
|
||||
|
||||
private String kostl_name;
|
||||
|
||||
private String werks;
|
||||
|
||||
private String lgort;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SAP手工领料出库单DTO(同时用于新增/修改入参)
|
||||
*/
|
||||
@Data
|
||||
public class ManualPickingOrderDto {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String order_no;
|
||||
|
||||
private String stor_code;
|
||||
|
||||
private String stor_name;
|
||||
|
||||
/** 建单日期 yyyyMMdd */
|
||||
private String bldat;
|
||||
|
||||
private Integer item_count;
|
||||
|
||||
private BigDecimal total_qty;
|
||||
|
||||
private String status;
|
||||
|
||||
private String statusName;
|
||||
|
||||
/** 下推生成的WMS出库单号 */
|
||||
private String out_bill_code;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String create_id;
|
||||
|
||||
private String create_name;
|
||||
|
||||
private String create_time;
|
||||
|
||||
private String update_id;
|
||||
|
||||
private String update_name;
|
||||
|
||||
private String update_time;
|
||||
|
||||
private List<ManualPickingItemDto> items;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* SAP手工领料出库单查询条件
|
||||
*/
|
||||
@Data
|
||||
public class ManualPickingQuery {
|
||||
|
||||
/** 单据号 */
|
||||
private String orderNo;
|
||||
|
||||
/** 仓库编码 */
|
||||
private String storCode;
|
||||
|
||||
/** 物料号(明细) */
|
||||
private String matnr;
|
||||
|
||||
private String status;
|
||||
|
||||
private String startTime;
|
||||
|
||||
private String endTime;
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
package org.nl.wms.pm_manage.sap.manualPicking.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
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.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata_manage.service.IBsrealStorattrService;
|
||||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.basedata_manage.service.dao.BsrealStorattr;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.ext_manage.sap.api.SapApi;
|
||||
import org.nl.wms.ext_manage.sap.enums.SapConstant;
|
||||
import org.nl.wms.pm_manage.SourceBillTypeEnum;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.enums.ManualPickingStatus;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.ManualPickingService;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingItem;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingOrder;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.mapper.ManualPickingItemMapper;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.mapper.ManualPickingOrderMapper;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.CostCenterVo;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingItemDto;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingOrderDto;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dto.ManualPickingQuery;
|
||||
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.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* SAP手工领料出库单(WMS 新建 → 下推出库 → MM022 回传)
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ManualPickingServiceImpl implements ManualPickingService {
|
||||
|
||||
/** 下推生成的WMS出库单类型 */
|
||||
private static final String WMS_BILL_TYPE_NAME = "生产出库";
|
||||
|
||||
/** 出库明细完成后的回传策略(MM022) */
|
||||
private static final String CALLBACK_STRATEGY = "sapManualPickingOut";
|
||||
|
||||
/** 成本中心缓存时间:5分钟 */
|
||||
private static final long COST_CENTER_CACHE_MILLIS = 5 * 60 * 1000L;
|
||||
|
||||
private static volatile List<CostCenterVo> costCenterCache = Collections.emptyList();
|
||||
private static volatile long costCenterCacheTime = 0L;
|
||||
|
||||
private final ManualPickingOrderMapper orderMapper;
|
||||
private final ManualPickingItemMapper itemMapper;
|
||||
private final IOutBillService outBillService;
|
||||
private final IMdMeMaterialbaseService materialbaseService;
|
||||
private final IBsrealStorattrService bsrealStorattrService;
|
||||
private final SapApi sapApi;
|
||||
|
||||
@Override
|
||||
public IPage<ManualPickingOrder> queryPage(ManualPickingQuery query, PageQuery page) {
|
||||
LambdaQueryWrapper<ManualPickingOrder> wrapper = new LambdaQueryWrapper<>();
|
||||
if (query != null) {
|
||||
if (StrUtil.isNotBlank(query.getOrderNo())) {
|
||||
wrapper.like(ManualPickingOrder::getOrder_no, query.getOrderNo().trim());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getStorCode())) {
|
||||
wrapper.like(ManualPickingOrder::getStor_code, query.getStorCode().trim());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getStatus())) {
|
||||
wrapper.eq(ManualPickingOrder::getStatus, query.getStatus());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getStartTime())) {
|
||||
wrapper.ge(ManualPickingOrder::getCreate_time, query.getStartTime());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getEndTime())) {
|
||||
wrapper.le(ManualPickingOrder::getCreate_time, query.getEndTime());
|
||||
}
|
||||
// 物料号在明细上,按明细命中的单据过滤
|
||||
if (StrUtil.isNotBlank(query.getMatnr())) {
|
||||
List<Long> headerIds = queryHeaderIdsByMaterial(query.getMatnr());
|
||||
if (headerIds.isEmpty()) {
|
||||
return new Page<>(1, 10);
|
||||
}
|
||||
wrapper.in(ManualPickingOrder::getId, headerIds);
|
||||
}
|
||||
}
|
||||
wrapper.orderByDesc(ManualPickingOrder::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> queryHeaderIdsByMaterial(String matnr) {
|
||||
List<ManualPickingItem> items = itemMapper.selectList(new LambdaQueryWrapper<ManualPickingItem>()
|
||||
.like(ManualPickingItem::getMatnr, matnr.trim())
|
||||
.select(ManualPickingItem::getHeader_id));
|
||||
return items.stream()
|
||||
.map(ManualPickingItem::getHeader_id)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManualPickingOrderDto getDetail(Long id) {
|
||||
ManualPickingOrder order = orderMapper.selectById(id);
|
||||
if (order == null) {
|
||||
throw new BadRequestException("手工领料单不存在");
|
||||
}
|
||||
return toOrderDto(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long create(ManualPickingOrderDto dto) {
|
||||
if (dto == null) {
|
||||
throw new BadRequestException("新增失败:参数为空");
|
||||
}
|
||||
BsrealStorattr stor = requireStor(dto.getStor_code());
|
||||
List<ManualPickingItemDto> items = validateItems(dto.getItems());
|
||||
String operatorId = SecurityUtils.getCurrentUserId();
|
||||
String operatorName = StrUtil.blankToDefault(SecurityUtils.getCurrentNickName(), SecurityUtils.getCurrentUsername());
|
||||
String now = DateUtil.now();
|
||||
|
||||
ManualPickingOrder order = new ManualPickingOrder();
|
||||
order.setOrder_no("SLL" + DateUtil.format(DateUtil.date(), "yyyyMMddHHmmssSSS"));
|
||||
order.setStor_code(stor.getStor_code());
|
||||
order.setStor_name(stor.getStor_name());
|
||||
order.setBldat(StrUtil.blankToDefault(StrUtil.trim(dto.getBldat()), DateUtil.format(DateUtil.date(), "yyyyMMdd")));
|
||||
order.setItem_count(items.size());
|
||||
order.setTotal_qty(sumQty(items));
|
||||
order.setStatus(ManualPickingStatus.CREATED.getCode());
|
||||
order.setRemark(dto.getRemark());
|
||||
order.setCreate_id(operatorId);
|
||||
order.setCreate_name(operatorName);
|
||||
order.setCreate_time(now);
|
||||
order.setUpdate_id(operatorId);
|
||||
order.setUpdate_name(operatorName);
|
||||
order.setUpdate_time(now);
|
||||
orderMapper.insert(order);
|
||||
saveItems(order, items);
|
||||
return order.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(ManualPickingOrderDto dto) {
|
||||
if (dto == null || dto.getId() == null) {
|
||||
throw new BadRequestException("修改失败:主键为空");
|
||||
}
|
||||
ManualPickingOrder order = orderMapper.selectById(dto.getId());
|
||||
if (order == null) {
|
||||
throw new BadRequestException("修改失败:手工领料单不存在");
|
||||
}
|
||||
if (!ManualPickingStatus.CREATED.getCode().equals(order.getStatus())) {
|
||||
throw new BadRequestException("修改失败:单据" + order.getOrder_no() + "已下发或已完成");
|
||||
}
|
||||
BsrealStorattr stor = requireStor(dto.getStor_code());
|
||||
List<ManualPickingItemDto> items = validateItems(dto.getItems());
|
||||
|
||||
order.setStor_code(stor.getStor_code());
|
||||
order.setStor_name(stor.getStor_name());
|
||||
order.setBldat(StrUtil.blankToDefault(StrUtil.trim(dto.getBldat()), order.getBldat()));
|
||||
order.setItem_count(items.size());
|
||||
order.setTotal_qty(sumQty(items));
|
||||
order.setRemark(dto.getRemark());
|
||||
order.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
order.setUpdate_name(StrUtil.blankToDefault(SecurityUtils.getCurrentNickName(), SecurityUtils.getCurrentUsername()));
|
||||
order.setUpdate_time(DateUtil.now());
|
||||
orderMapper.updateById(order);
|
||||
|
||||
itemMapper.delete(new LambdaQueryWrapper<ManualPickingItem>()
|
||||
.eq(ManualPickingItem::getHeader_id, order.getId()));
|
||||
saveItems(order, items);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByIds(List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
throw new BadRequestException("删除失败:未选择单据");
|
||||
}
|
||||
for (Long id : ids) {
|
||||
ManualPickingOrder order = orderMapper.selectById(id);
|
||||
if (order == null) {
|
||||
continue;
|
||||
}
|
||||
if (!ManualPickingStatus.CREATED.getCode().equals(order.getStatus())
|
||||
&& !ManualPickingStatus.CANCELED.getCode().equals(order.getStatus())) {
|
||||
throw new BadRequestException("删除失败:单据" + order.getOrder_no() + "已下发或已完成");
|
||||
}
|
||||
itemMapper.delete(new LambdaQueryWrapper<ManualPickingItem>()
|
||||
.eq(ManualPickingItem::getHeader_id, order.getId()));
|
||||
orderMapper.deleteById(order.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String pushOut(Long id) {
|
||||
if (id == null) {
|
||||
throw new BadRequestException("下推失败:未选择单据");
|
||||
}
|
||||
ManualPickingOrder order = orderMapper.selectById(id);
|
||||
if (order == null) {
|
||||
throw new BadRequestException("下推失败:单据不存在");
|
||||
}
|
||||
if (!ManualPickingStatus.CREATED.getCode().equals(order.getStatus())) {
|
||||
throw new BadRequestException("下推失败:单据" + order.getOrder_no() + "不是已创建状态");
|
||||
}
|
||||
List<ManualPickingItem> items = listItems(order.getId());
|
||||
if (CollectionUtils.isEmpty(items)) {
|
||||
throw new BadRequestException("下推失败:单据明细不存在");
|
||||
}
|
||||
String billCode = outBillService.saveBill(convertToOutBill(order, items));
|
||||
order.setOut_bill_code(billCode);
|
||||
order.setStatus(ManualPickingStatus.POSTED.getCode());
|
||||
order.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
order.setUpdate_name(StrUtil.blankToDefault(SecurityUtils.getCurrentNickName(), SecurityUtils.getCurrentUsername()));
|
||||
order.setUpdate_time(DateUtil.now());
|
||||
orderMapper.updateById(order);
|
||||
return billCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一个领料单只有一个仓库,直接生成一张出库单;明细回调策略为 MM022
|
||||
*/
|
||||
private JSONObject convertToOutBill(ManualPickingOrder order, List<ManualPickingItem> items) {
|
||||
List<String> materialCodes = items.stream()
|
||||
.map(ManualPickingItem::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 (ManualPickingItem 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.getMenge());
|
||||
row.put("source_bill_code", order.getOrder_no());
|
||||
row.put("source_bill_type", SourceBillTypeEnum.SAP_MANUAL_PICKING.getBillType());
|
||||
// 明细主键传给回传策略,用于取成本中心等信息组装 MM022
|
||||
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", order.getStor_code());
|
||||
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<ManualPickingItem> listItems(Long headerId) {
|
||||
return itemMapper.selectList(new LambdaQueryWrapper<ManualPickingItem>()
|
||||
.eq(ManualPickingItem::getHeader_id, headerId)
|
||||
.orderByAsc(ManualPickingItem::getPosnr)
|
||||
.orderByAsc(ManualPickingItem::getId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManualPickingItem getItem(Long itemId) {
|
||||
return itemId == null ? null : itemMapper.selectById(itemId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CostCenterVo> listCostCenters() {
|
||||
long now = System.currentTimeMillis();
|
||||
if (!costCenterCache.isEmpty() && now - costCenterCacheTime < COST_CENTER_CACHE_MILLIS) {
|
||||
return costCenterCache;
|
||||
}
|
||||
JSONObject result = sapApi.costCenterQuery();
|
||||
List<CostCenterVo> costCenters = parseCostCenters(result);
|
||||
if (!costCenters.isEmpty()) {
|
||||
costCenterCache = costCenters;
|
||||
costCenterCacheTime = now;
|
||||
}
|
||||
return costCenters;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 MDG019 响应:body.csks[],兼容 body 为对象/数组两种形态
|
||||
*/
|
||||
private List<CostCenterVo> parseCostCenters(JSONObject result) {
|
||||
if (result == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Object bodyValue = result.get("body");
|
||||
JSONObject body = null;
|
||||
if (bodyValue instanceof JSONObject) {
|
||||
body = (JSONObject) bodyValue;
|
||||
} else if (bodyValue instanceof JSONArray && !((JSONArray) bodyValue).isEmpty()) {
|
||||
body = ((JSONArray) bodyValue).getJSONObject(0);
|
||||
}
|
||||
if (body == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String status = StrUtil.trim(body.getString("status"));
|
||||
if ("E".equalsIgnoreCase(status)) {
|
||||
throw new BadRequestException("成本中心查询失败:"
|
||||
+ StrUtil.blankToDefault(body.getString("message"), "SAP返回错误"));
|
||||
}
|
||||
JSONArray csks = body.getJSONArray("csks");
|
||||
if (csks == null || csks.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<CostCenterVo> list = new ArrayList<>();
|
||||
for (int i = 0; i < csks.size(); i++) {
|
||||
JSONObject one = csks.getJSONObject(i);
|
||||
if (one == null || StrUtil.isBlank(one.getString("kostl"))) {
|
||||
continue;
|
||||
}
|
||||
CostCenterVo vo = new CostCenterVo();
|
||||
vo.setKostl(one.getString("kostl").trim());
|
||||
vo.setBukrs(StrUtil.trim(one.getString("bukrs")));
|
||||
vo.setKtext(StrUtil.trim(one.getString("ktext")));
|
||||
list.add(vo);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private BsrealStorattr requireStor(String storCode) {
|
||||
if (StrUtil.isBlank(storCode)) {
|
||||
throw new BadRequestException("仓库不能为空");
|
||||
}
|
||||
BsrealStorattr stor = bsrealStorattrService.findByCode(storCode.trim());
|
||||
if (stor == null) {
|
||||
throw new BadRequestException("仓库" + storCode + "不存在");
|
||||
}
|
||||
return stor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验收货明细:物料、数量、成本中心必填,物料不存在直接报错
|
||||
*/
|
||||
private List<ManualPickingItemDto> validateItems(List<ManualPickingItemDto> items) {
|
||||
if (CollectionUtils.isEmpty(items)) {
|
||||
throw new BadRequestException("明细不能为空");
|
||||
}
|
||||
int posnr = 1;
|
||||
for (ManualPickingItemDto item : items) {
|
||||
if (StrUtil.isBlank(item.getMatnr())) {
|
||||
throw new BadRequestException("第" + posnr + "行物料编码不能为空");
|
||||
}
|
||||
if (item.getMenge() == null || item.getMenge().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new BadRequestException("物料" + item.getMatnr() + "的数量必须大于0");
|
||||
}
|
||||
if (StrUtil.isBlank(item.getKostl())) {
|
||||
throw new BadRequestException("物料" + item.getMatnr() + "的成本中心不能为空");
|
||||
}
|
||||
MdMeMaterialbase material = materialbaseService.getByCode(item.getMatnr().trim());
|
||||
if (material == null) {
|
||||
throw new BadRequestException("物料" + item.getMatnr() + "在WMS中不存在");
|
||||
}
|
||||
item.setMatnr(item.getMatnr().trim());
|
||||
item.setPosnr(posnr++);
|
||||
if (StrUtil.isBlank(item.getMaktx())) {
|
||||
item.setMaktx(material.getMaterial_name());
|
||||
}
|
||||
if (StrUtil.isBlank(item.getMeins())) {
|
||||
item.setMeins(material.getQty_unit_name());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private BigDecimal sumQty(List<ManualPickingItemDto> items) {
|
||||
return items.stream()
|
||||
.map(ManualPickingItemDto::getMenge)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
private void saveItems(ManualPickingOrder order, List<ManualPickingItemDto> items) {
|
||||
for (ManualPickingItemDto dto : items) {
|
||||
ManualPickingItem item = new ManualPickingItem();
|
||||
item.setHeader_id(order.getId());
|
||||
item.setOrder_no(order.getOrder_no());
|
||||
item.setPosnr(dto.getPosnr());
|
||||
item.setMatnr(dto.getMatnr());
|
||||
item.setMaktx(dto.getMaktx());
|
||||
item.setMenge(dto.getMenge());
|
||||
item.setMeins(dto.getMeins());
|
||||
item.setKostl(dto.getKostl());
|
||||
item.setKostl_name(dto.getKostl_name());
|
||||
item.setWerks(StrUtil.blankToDefault(StrUtil.trim(dto.getWerks()), SapConstant.WERKS));
|
||||
item.setLgort(order.getStor_code());
|
||||
item.setRemark(dto.getRemark());
|
||||
itemMapper.insert(item);
|
||||
}
|
||||
}
|
||||
|
||||
private ManualPickingOrderDto toOrderDto(ManualPickingOrder order) {
|
||||
ManualPickingOrderDto dto = new ManualPickingOrderDto();
|
||||
dto.setId(order.getId());
|
||||
dto.setOrder_no(order.getOrder_no());
|
||||
dto.setStor_code(order.getStor_code());
|
||||
dto.setStor_name(order.getStor_name());
|
||||
dto.setBldat(order.getBldat());
|
||||
dto.setItem_count(order.getItem_count());
|
||||
dto.setTotal_qty(order.getTotal_qty());
|
||||
dto.setStatus(order.getStatus());
|
||||
ManualPickingStatus status = ManualPickingStatus.ofCode(order.getStatus());
|
||||
dto.setStatusName(status == null ? order.getStatus() : status.getName());
|
||||
dto.setOut_bill_code(order.getOut_bill_code());
|
||||
dto.setRemark(order.getRemark());
|
||||
dto.setCreate_id(order.getCreate_id());
|
||||
dto.setCreate_name(order.getCreate_name());
|
||||
dto.setCreate_time(order.getCreate_time());
|
||||
dto.setUpdate_id(order.getUpdate_id());
|
||||
dto.setUpdate_name(order.getUpdate_name());
|
||||
dto.setUpdate_time(order.getUpdate_time());
|
||||
dto.setItems(listItems(order.getId()).stream().map(this::toItemDto).collect(Collectors.toList()));
|
||||
return dto;
|
||||
}
|
||||
|
||||
private ManualPickingItemDto toItemDto(ManualPickingItem item) {
|
||||
ManualPickingItemDto dto = new ManualPickingItemDto();
|
||||
dto.setId(item.getId());
|
||||
dto.setHeader_id(item.getHeader_id());
|
||||
dto.setOrder_no(item.getOrder_no());
|
||||
dto.setPosnr(item.getPosnr());
|
||||
dto.setMatnr(item.getMatnr());
|
||||
dto.setMaktx(item.getMaktx());
|
||||
dto.setMenge(item.getMenge());
|
||||
dto.setMeins(item.getMeins());
|
||||
dto.setKostl(item.getKostl());
|
||||
dto.setKostl_name(item.getKostl_name());
|
||||
dto.setWerks(item.getWerks());
|
||||
dto.setLgort(item.getLgort());
|
||||
dto.setRemark(item.getRemark());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.nl.wms.warehouse_manage.stockReturn.service.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -10,6 +11,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.ext_manage.sap.api.SapApi;
|
||||
import org.nl.wms.pm_manage.SourceBillTypeEnum;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.enums.ManualPickingStatus;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingOrder;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.mapper.ManualPickingOrderMapper;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
|
||||
@@ -31,6 +36,8 @@ public class PmStockReturnServiceImpl extends ServiceImpl<PmStockReturnMapper, P
|
||||
|
||||
@Resource
|
||||
private SapApi sapApi;
|
||||
@Resource
|
||||
private ManualPickingOrderMapper manualPickingOrderMapper;
|
||||
|
||||
@Override
|
||||
public IPage<PmStockReturn> queryAll(Map whereJson, PageQuery page) {
|
||||
@@ -108,6 +115,7 @@ public class PmStockReturnServiceImpl extends ServiceImpl<PmStockReturnMapper, P
|
||||
stockReturn.setError_msg(null);
|
||||
stockReturn.setProcess_time(DateUtil.now());
|
||||
this.updateById(stockReturn);
|
||||
markManualPickingCompleted(stockReturn);
|
||||
} catch (Exception e) {
|
||||
String errorMsg = e.getMessage();
|
||||
if (errorMsg != null && errorMsg.length() > 255) {
|
||||
@@ -126,6 +134,30 @@ public class PmStockReturnServiceImpl extends ServiceImpl<PmStockReturnMapper, P
|
||||
parseRequestData(requestData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手工领料出库:手动重发回传成功后,把源领料单置为已完成
|
||||
*/
|
||||
private void markManualPickingCompleted(PmStockReturn stockReturn) {
|
||||
if (stockReturn == null
|
||||
|| !SourceBillTypeEnum.SAP_MANUAL_PICKING.getDesc().equals(stockReturn.getRequest_type())) {
|
||||
return;
|
||||
}
|
||||
String billCode = StringUtils.hasText(stockReturn.getBill_code())
|
||||
? stockReturn.getBill_code() : stockReturn.getRequest_Id();
|
||||
if (!StringUtils.hasText(billCode)) {
|
||||
return;
|
||||
}
|
||||
List<ManualPickingOrder> orders = manualPickingOrderMapper.selectList(
|
||||
new LambdaQueryWrapper<ManualPickingOrder>()
|
||||
.eq(ManualPickingOrder::getOut_bill_code, billCode)
|
||||
.ne(ManualPickingOrder::getStatus, ManualPickingStatus.COMPLETED.getCode()));
|
||||
for (ManualPickingOrder order : orders) {
|
||||
order.setStatus(ManualPickingStatus.COMPLETED.getCode());
|
||||
order.setUpdate_time(DateUtil.now());
|
||||
manualPickingOrderMapper.updateById(order);
|
||||
}
|
||||
}
|
||||
|
||||
private String formatQueryTime(Object time, String defaultTime) {
|
||||
String value = String.valueOf(time);
|
||||
if (value.contains("T")) {
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
package org.nl.wms.warehouse_manage.stockReturn.strategy.core.impl.sap;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.ext_manage.sap.api.SapApi;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.ManualPickingBody;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.ManualPickingHeader;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.ManualPickingItem;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.ManualPickingRequest;
|
||||
import org.nl.wms.ext_manage.sap.enums.SapConstant;
|
||||
import org.nl.wms.pm_manage.SourceBillTypeEnum;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.enums.ManualPickingStatus;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingOrder;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.mapper.ManualPickingItemMapper;
|
||||
import org.nl.wms.pm_manage.sap.manualPicking.service.dao.mapper.ManualPickingOrderMapper;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInv;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDtl;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDtlMapper;
|
||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvMapper;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.strategy.core.CallbackStrategy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SAP手工领料出库完成回调:整张出库单完成后按 MM022 回传 SAP 过账(移动类型 201 成本中心领料)。
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("sapManualPickingOut")
|
||||
public class SapManualPickingOut implements CallbackStrategy {
|
||||
|
||||
private static final DateTimeFormatter DATE_BASIC = DateTimeFormatter.BASIC_ISO_DATE;
|
||||
|
||||
@Autowired
|
||||
private ManualPickingOrderMapper orderMapper;
|
||||
@Autowired
|
||||
private ManualPickingItemMapper itemMapper;
|
||||
@Autowired
|
||||
private IOStorInvMapper ioStorInvMapper;
|
||||
@Autowired
|
||||
private IOStorInvDtlMapper ioStorInvDtlMapper;
|
||||
@Autowired
|
||||
private IPmStockReturnService iPmStockReturnService;
|
||||
@Autowired
|
||||
private SapApi sapApi;
|
||||
|
||||
@Override
|
||||
public void buildCallback(IOStorInvDtl param) {
|
||||
if (param == null || StrUtil.isBlank(param.getSource_bill_code())) {
|
||||
throw new BadRequestException("手工领料回传失败:来源单据号为空");
|
||||
}
|
||||
String orderNo = param.getSource_bill_code().trim();
|
||||
ManualPickingOrder order = orderMapper.selectOne(new LambdaQueryWrapper<ManualPickingOrder>()
|
||||
.eq(ManualPickingOrder::getOrder_no, orderNo));
|
||||
if (order == null) {
|
||||
throw new BadRequestException("手工领料回传失败:单据" + orderNo + "不存在");
|
||||
}
|
||||
if (ManualPickingStatus.COMPLETED.getCode().equals(order.getStatus())) {
|
||||
return;
|
||||
}
|
||||
// 整张出库单明细全部完成才回传
|
||||
String finishedStatus = IOSEnum.BILL_STATUS.code("完成");
|
||||
Integer unFinishCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<IOStorInvDtl>()
|
||||
.eq(IOStorInvDtl::getIostorinv_id, param.getIostorinv_id())
|
||||
.ne(IOStorInvDtl::getBill_status, finishedStatus));
|
||||
if (unFinishCount != null && unFinishCount > 0) {
|
||||
return;
|
||||
}
|
||||
List<IOStorInvDtl> billItems = ioStorInvDtlMapper.selectList(new LambdaQueryWrapper<IOStorInvDtl>()
|
||||
.eq(IOStorInvDtl::getIostorinv_id, param.getIostorinv_id())
|
||||
.orderByAsc(IOStorInvDtl::getSeq_no));
|
||||
if (billItems == null || billItems.isEmpty()) {
|
||||
throw new BadRequestException("手工领料回传失败:出库明细不存在");
|
||||
}
|
||||
IOStorInv bill = ioStorInvMapper.selectById(param.getIostorinv_id());
|
||||
String billCode = bill != null && StrUtil.isNotBlank(bill.getBill_code())
|
||||
? bill.getBill_code().trim()
|
||||
: StrUtil.blankToDefault(order.getOut_bill_code(), order.getOrder_no());
|
||||
if (alreadySucceeded(billCode)) {
|
||||
log.info("手工领料单{}的出库单{}已回传过SAP,跳过", orderNo, billCode);
|
||||
markCompleted(order, billCode);
|
||||
return;
|
||||
}
|
||||
|
||||
ManualPickingRequest request = buildRequest(order, bill, billItems, billCode);
|
||||
PmStockReturn stockReturn = new PmStockReturn();
|
||||
stockReturn.setRequest_Id(billCode);
|
||||
stockReturn.setBill_code(billCode);
|
||||
stockReturn.setRequest_type(SourceBillTypeEnum.SAP_MANUAL_PICKING.getDesc());
|
||||
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode());
|
||||
stockReturn.setCreate_time(DateUtil.now());
|
||||
stockReturn.setRequest_data(JSON.toJSONString(request));
|
||||
boolean success = false;
|
||||
try {
|
||||
JSONObject sapResult = sapApi.manualPickingOut(request);
|
||||
stockReturn.setStatus(StockReturnStatusEnum.SUCESS.getCode());
|
||||
stockReturn.setProcess_time(DateUtil.now());
|
||||
JSONObject record = new JSONObject();
|
||||
record.put("request", request);
|
||||
record.put("response", sapResult);
|
||||
stockReturn.setRequest_data(record.toJSONString());
|
||||
success = true;
|
||||
} catch (Exception e) {
|
||||
log.error("手工领料单{}回传SAP失败", orderNo, e);
|
||||
stockReturn.setError_msg(e.getMessage());
|
||||
stockReturn.setStatus(StockReturnStatusEnum.FAIL.getCode());
|
||||
stockReturn.setProcess_time(DateUtil.now());
|
||||
}
|
||||
iPmStockReturnService.save(stockReturn);
|
||||
if (success) {
|
||||
markCompleted(order, billCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回传成功后把领料单置为已完成
|
||||
*/
|
||||
private void markCompleted(ManualPickingOrder order, String billCode) {
|
||||
if (ManualPickingStatus.COMPLETED.getCode().equals(order.getStatus())) {
|
||||
return;
|
||||
}
|
||||
order.setStatus(ManualPickingStatus.COMPLETED.getCode());
|
||||
order.setOut_bill_code(billCode);
|
||||
order.setUpdate_time(DateUtil.now());
|
||||
orderMapper.updateById(order);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一张出库单只成功过账一次
|
||||
*/
|
||||
private boolean alreadySucceeded(String billCode) {
|
||||
return iPmStockReturnService.count(new LambdaQueryWrapper<PmStockReturn>()
|
||||
.eq(PmStockReturn::getRequest_type, SourceBillTypeEnum.SAP_MANUAL_PICKING.getDesc())
|
||||
.eq(PmStockReturn::getBill_code, billCode)
|
||||
.eq(PmStockReturn::getStatus, StockReturnStatusEnum.SUCESS.getCode())) > 0;
|
||||
}
|
||||
|
||||
private ManualPickingRequest buildRequest(ManualPickingOrder order, IOStorInv bill,
|
||||
List<IOStorInvDtl> billItems, String billCode) {
|
||||
String today = LocalDate.now().format(DATE_BASIC);
|
||||
ManualPickingRequest request = new ManualPickingRequest();
|
||||
|
||||
ManualPickingHeader header = new ManualPickingHeader();
|
||||
header.setIntfId(SapConstant.INTF_MM022);
|
||||
header.setSrcSystem(SapConstant.SRC_SYSTEM);
|
||||
header.setDestSystem(SapConstant.DEST_SYSTEM);
|
||||
header.setSrcMsgid("MSG" + System.currentTimeMillis());
|
||||
header.setRequesttime("");
|
||||
header.setBackup1("");
|
||||
header.setBackup2("");
|
||||
request.setHeader(header);
|
||||
|
||||
ManualPickingBody body = new ManualPickingBody();
|
||||
body.setBudat(today);
|
||||
body.setMblnr(billCode);
|
||||
body.setBldat(StrUtil.blankToDefault(StrUtil.trim(order.getBldat()), today));
|
||||
body.setBwart(SapConstant.BWART_COST_CENTER_ISSUE);
|
||||
body.setItems(buildItems(order, bill, billItems));
|
||||
request.setBody(Collections.singletonList(body));
|
||||
return request;
|
||||
}
|
||||
|
||||
private List<ManualPickingItem> buildItems(ManualPickingOrder order, IOStorInv bill, List<IOStorInvDtl> billItems) {
|
||||
String lgort = bill != null && StrUtil.isNotBlank(bill.getStor_code())
|
||||
? bill.getStor_code().trim()
|
||||
: StrUtil.trim(order.getStor_code());
|
||||
List<ManualPickingItem> items = new ArrayList<>();
|
||||
for (IOStorInvDtl dtl : billItems) {
|
||||
org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingItem pickingItem =
|
||||
findPickingItem(dtl.getSource_billdtl_id());
|
||||
ManualPickingItem item = new ManualPickingItem();
|
||||
item.setPosnr(pickingItem != null && pickingItem.getPosnr() != null
|
||||
? String.valueOf(pickingItem.getPosnr())
|
||||
: StrUtil.blankToDefault(dtl.getSeq_no(), "1"));
|
||||
item.setWerks(pickingItem != null && StrUtil.isNotBlank(pickingItem.getWerks())
|
||||
? pickingItem.getWerks().trim() : SapConstant.WERKS);
|
||||
item.setLgort(lgort);
|
||||
item.setLfimg(resolveQty(dtl).doubleValue());
|
||||
item.setMeins(StrUtil.blankToDefault(StrUtil.trim(dtl.getQty_unit_name()),
|
||||
pickingItem == null ? "" : StrUtil.blankToDefault(pickingItem.getMeins(), "")));
|
||||
item.setSobkz("");
|
||||
item.setMatnr(StrUtil.blankToDefault(StrUtil.trim(dtl.getMaterial_code()),
|
||||
pickingItem == null ? "" : StrUtil.blankToDefault(pickingItem.getMatnr(), "")));
|
||||
item.setKostl(pickingItem == null ? "" : StrUtil.blankToDefault(StrUtil.trim(pickingItem.getKostl()), ""));
|
||||
items.add(item);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private org.nl.wms.pm_manage.sap.manualPicking.service.dao.ManualPickingItem findPickingItem(String sourceBilldtlId) {
|
||||
if (StrUtil.isBlank(sourceBilldtlId)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return itemMapper.selectById(Long.valueOf(sourceBilldtlId.trim()));
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 实际出库数量:优先实收数量,其次计划数量
|
||||
*/
|
||||
private BigDecimal resolveQty(IOStorInvDtl dtl) {
|
||||
if (dtl.getReal_qty() != null && dtl.getReal_qty().signum() > 0) {
|
||||
return dtl.getReal_qty().setScale(3, RoundingMode.HALF_UP);
|
||||
}
|
||||
if (dtl.getPlan_qty() != null && dtl.getPlan_qty().signum() > 0) {
|
||||
return dtl.getPlan_qty().setScale(3, RoundingMode.HALF_UP);
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
@@ -366,3 +366,46 @@ INSERT INTO `wms_nlwq`.`sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `syste
|
||||
|
||||
-- ========== 交货单分类页面菜单(已有库请执行独立脚本) ==========
|
||||
-- 文件:sql/outbound_delivery_bill_menu_upgrade.sql
|
||||
|
||||
-- ========== SAP手工领料出库(WMS 新建 → MM022 回传) ==========
|
||||
CREATE TABLE IF NOT EXISTS `sap_manual_picking` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`order_no` varchar(32) NOT NULL COMMENT '单据号(SLL+时间戳)',
|
||||
`stor_code` varchar(20) DEFAULT NULL COMMENT '仓库编码(MM022 lgort)',
|
||||
`stor_name` varchar(100) DEFAULT NULL COMMENT '仓库名称',
|
||||
`bldat` varchar(8) DEFAULT NULL COMMENT '建单日期 yyyyMMdd',
|
||||
`item_count` int DEFAULT 0 COMMENT '明细行数',
|
||||
`total_qty` decimal(18,3) DEFAULT 0.000 COMMENT '总数量',
|
||||
`status` varchar(20) DEFAULT 'CREATED' COMMENT 'CREATED已创建 POSTED已下发 COMPLETED已完成 CANCELED已取消',
|
||||
`out_bill_code` varchar(40) DEFAULT NULL COMMENT '下推生成的WMS出库单号(MM022 mblnr)',
|
||||
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
|
||||
`create_id` varchar(64) DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_name` varchar(50) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` varchar(30) DEFAULT NULL COMMENT '创建时间',
|
||||
`update_id` varchar(64) DEFAULT NULL COMMENT '修改人ID',
|
||||
`update_name` varchar(50) DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` varchar(30) DEFAULT NULL COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_order_no` (`order_no`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_create_time` (`create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SAP手工领料出库单主表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sap_manual_picking_item` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`header_id` bigint NOT NULL COMMENT '主表ID',
|
||||
`order_no` varchar(32) DEFAULT NULL COMMENT '单据号',
|
||||
`posnr` int DEFAULT NULL COMMENT '行项目号',
|
||||
`matnr` varchar(40) DEFAULT NULL COMMENT '物料号',
|
||||
`maktx` varchar(255) DEFAULT NULL COMMENT '物料描述',
|
||||
`menge` decimal(18,3) DEFAULT NULL COMMENT '数量',
|
||||
`meins` varchar(10) DEFAULT NULL COMMENT '计量单位',
|
||||
`kostl` varchar(20) DEFAULT NULL COMMENT '成本中心',
|
||||
`kostl_name` varchar(100) DEFAULT NULL COMMENT '成本中心名称',
|
||||
`werks` varchar(10) DEFAULT NULL COMMENT '工厂',
|
||||
`lgort` varchar(20) DEFAULT NULL COMMENT '库存地点(仓库编码)',
|
||||
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_header_id` (`header_id`),
|
||||
KEY `idx_order_no` (`order_no`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SAP手工领料出库单明细表';
|
||||
|
||||
503
nladmin-ui/src/views/wms/pm_manage/sap/manualPicking/index.vue
Normal file
503
nladmin-ui/src/views/wms/pm_manage/sap/manualPicking/index.vue
Normal file
@@ -0,0 +1,503 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="head-container">
|
||||
<el-form :inline="true" class="demo-form-inline" label-position="right" label-width="90px" label-suffix=":" size="mini">
|
||||
<el-form-item label="单据号">
|
||||
<el-input v-model="query.orderNo" clearable placeholder="请输入单据号" @keyup.enter.native="crud.toQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库">
|
||||
<el-select v-model="query.storCode" clearable filterable placeholder="全部" style="width: 160px;" @change="crud.toQuery">
|
||||
<el-option v-for="stor in storList" :key="stor.stor_code" :label="stor.stor_code + ' ' + stor.stor_name" :value="stor.stor_code" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="物料号">
|
||||
<el-input v-model="query.matnr" clearable placeholder="请输入物料号" @keyup.enter.native="crud.toQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="query.status" clearable placeholder="全部" @change="crud.toQuery">
|
||||
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间">
|
||||
<el-date-picker
|
||||
v-model="query.datepick"
|
||||
type="daterange"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="['00:00:00', '23:59:59']"
|
||||
/>
|
||||
</el-form-item>
|
||||
<rrOperation />
|
||||
</el-form>
|
||||
|
||||
<crudOperation :permission="permission">
|
||||
<el-button slot="right" class="filter-item" type="primary" icon="el-icon-plus" size="mini" @click="openAdd">新增手工领料</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="success"
|
||||
icon="el-icon-s-promotion"
|
||||
size="mini"
|
||||
:loading="pushing"
|
||||
:disabled="isPushDisabled()"
|
||||
@click="handlePush"
|
||||
>下推出库</el-button>
|
||||
</crudOperation>
|
||||
|
||||
<!-- 新增/编辑 -->
|
||||
<el-dialog
|
||||
:visible.sync="dialogVisible"
|
||||
:title="dialogMode === 'add' ? '新增手工领料单' : '修改手工领料单'"
|
||||
width="1100px"
|
||||
:close-on-click-modal="false"
|
||||
@close="closeDialog"
|
||||
>
|
||||
<el-form :model="form" size="mini" label-width="100px" label-suffix=":" style="border: 1px solid #cfe0df; padding: 10px;">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="仓库">
|
||||
<el-select v-model="form.storCode" filterable placeholder="请选择仓库" style="width: 100%;" :disabled="dialogMode === 'edit'">
|
||||
<el-option v-for="stor in storList" :key="stor.stor_code" :label="stor.stor_code + ' ' + stor.stor_name" :value="stor.stor_code" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="建单日期">
|
||||
<el-date-picker v-model="form.bldat" type="date" value-format="yyyyMMdd" placeholder="请选择建单日期" style="width: 100%;" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model.trim="form.remark" placeholder="备注" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<div style="margin: 12px 0 8px; display: flex; justify-content: space-between; align-items: center;">
|
||||
<span style="font-weight: 600;">领料明细</span>
|
||||
<el-button size="mini" type="primary" icon="el-icon-plus" @click="addItem">新增明细</el-button>
|
||||
</div>
|
||||
<el-table :data="form.items" size="mini" border max-height="360">
|
||||
<el-table-column type="index" label="序号" width="55" align="center" />
|
||||
<el-table-column label="物料编码" min-width="140">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model.trim="scope.row.matnr" size="mini" placeholder="物料编码" @blur="loadMaterial(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="物料名称" min-width="170">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model.trim="scope.row.maktx" size="mini" placeholder="物料名称" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" width="130">
|
||||
<template slot-scope="scope">
|
||||
<el-input-number v-model="scope.row.menge" :min="0" :precision="3" :controls="false" size="mini" style="width: 100%;" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" width="90">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model.trim="scope.row.meins" size="mini" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="成本中心" min-width="210">
|
||||
<template slot-scope="scope">
|
||||
<el-select
|
||||
v-model="scope.row.kostl"
|
||||
filterable
|
||||
placeholder="请选择成本中心"
|
||||
size="mini"
|
||||
style="width: 100%;"
|
||||
@change="onCostCenterChange(scope.row)"
|
||||
>
|
||||
<el-option
|
||||
v-for="cc in costCenters"
|
||||
:key="cc.kostl"
|
||||
:label="cc.kostl + ' ' + (cc.ktext || '')"
|
||||
:value="cc.kostl"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" min-width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model.trim="scope.row.remark" size="mini" placeholder="备注" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="70" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click="removeItem(scope.$index)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="closeDialog">取消</el-button>
|
||||
<el-button size="mini" type="primary" :loading="saving" @click="submitForm">保存</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 明细 -->
|
||||
<el-dialog :visible.sync="detailVisible" title="手工领料单明细" width="1150px" :close-on-click-modal="false" @close="closeDetail">
|
||||
<div style="margin-bottom: 10px; color: #606266; font-size: 13px;">
|
||||
单据号:<strong>{{ currentOrder.order_no }}</strong> |
|
||||
仓库:<strong>{{ currentOrder.stor_code }} {{ currentOrder.stor_name }}</strong> |
|
||||
建单日期:<strong>{{ currentOrder.bldat || '-' }}</strong> |
|
||||
出库单号:<strong>{{ currentOrder.out_bill_code || '-' }}</strong> |
|
||||
状态:<strong>{{ statusLabel(currentOrder.status) }}</strong>
|
||||
</div>
|
||||
<el-table v-loading="detailLoading" :data="itemList" size="small" border max-height="480">
|
||||
<el-table-column prop="posnr" label="行号" width="70" align="center" />
|
||||
<el-table-column prop="matnr" label="物料编码" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="maktx" label="物料名称" min-width="170" show-overflow-tooltip />
|
||||
<el-table-column prop="menge" label="数量" width="100" align="right" />
|
||||
<el-table-column prop="meins" label="单位" width="80" align="center" />
|
||||
<el-table-column prop="kostl" label="成本中心" width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="kostl_name" label="成本中心名称" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="werks" label="工厂" width="80" align="center" />
|
||||
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="closeDetail">关闭</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
size="small"
|
||||
border
|
||||
row-key="id"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="order_no" label="单据号" min-width="170" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
<el-link type="primary" @click="openDetail(scope.row)">{{ scope.row.order_no }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="仓库" min-width="180" show-overflow-tooltip>
|
||||
<template slot-scope="scope">{{ scope.row.stor_code }} {{ scope.row.stor_name }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="bldat" label="建单日期" width="100" align="center" />
|
||||
<el-table-column prop="item_count" label="明细行数" width="90" align="center" />
|
||||
<el-table-column prop="total_qty" label="总数量" width="100" align="right" />
|
||||
<el-table-column prop="out_bill_code" label="出库单号" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="status" label="状态" width="90" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="statusTagType(scope.row.status)" size="mini">{{ statusLabel(scope.row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="create_name" label="创建人" width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="create_time" label="创建时间" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" :disabled="!canEdit(scope.row)" @click="openEdit(scope.row)">编辑</el-button>
|
||||
<el-button size="mini" type="text" :disabled="!canEdit(scope.row)" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CRUD, { crud, header, presenter } from '@crud/crud'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import { add, edit, del, get, outPush, getCostCenters, getMaterial } from './manualPicking'
|
||||
import { getStor } from '@/views/wms/basedata/bsrealstorattr/bsrealstorattr'
|
||||
|
||||
const createItem = () => ({
|
||||
matnr: '',
|
||||
maktx: '',
|
||||
menge: undefined,
|
||||
meins: '',
|
||||
kostl: '',
|
||||
kostl_name: '',
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const createForm = () => ({
|
||||
id: null,
|
||||
storCode: '',
|
||||
bldat: '',
|
||||
remark: '',
|
||||
items: []
|
||||
})
|
||||
|
||||
export default {
|
||||
name: 'SapManualPicking',
|
||||
components: { crudOperation, rrOperation, pagination },
|
||||
mixins: [presenter(), header(), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: 'SAP手工领料出库',
|
||||
url: 'api/sapManualPicking',
|
||||
idField: 'id',
|
||||
sort: 'id,desc',
|
||||
crudMethod: { add, edit, del },
|
||||
optShow: { add: false, reset: true }
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
permission: {
|
||||
add: ['admin', 'sapManualPicking:add'],
|
||||
edit: ['admin', 'sapManualPicking:edit'],
|
||||
del: ['admin', 'sapManualPicking:del']
|
||||
},
|
||||
statusOptions: [
|
||||
{ value: 'CREATED', label: '已创建' },
|
||||
{ value: 'POSTED', label: '已下发' },
|
||||
{ value: 'COMPLETED', label: '已完成' },
|
||||
{ value: 'CANCELED', label: '已取消' }
|
||||
],
|
||||
storList: [],
|
||||
costCenters: [],
|
||||
multipleSelection: [],
|
||||
pushing: false,
|
||||
saving: false,
|
||||
dialogVisible: false,
|
||||
dialogMode: 'add',
|
||||
form: createForm(),
|
||||
detailVisible: false,
|
||||
detailLoading: false,
|
||||
currentOrder: {},
|
||||
itemList: []
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.loadStorList()
|
||||
this.loadCostCenters()
|
||||
},
|
||||
methods: {
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
if (this.query.datepick && this.query.datepick.length) {
|
||||
this.query.startTime = this.query.datepick[0]
|
||||
this.query.endTime = this.query.datepick.length > 1 ? this.query.datepick[1] : this.query.datepick[0]
|
||||
} else {
|
||||
this.query.startTime = ''
|
||||
this.query.endTime = ''
|
||||
}
|
||||
},
|
||||
loadStorList() {
|
||||
if (this.storList.length) {
|
||||
return
|
||||
}
|
||||
getStor().then(res => {
|
||||
this.storList = res.data || []
|
||||
}).catch(() => {
|
||||
this.storList = []
|
||||
})
|
||||
},
|
||||
loadCostCenters() {
|
||||
if (this.costCenters.length) {
|
||||
return
|
||||
}
|
||||
getCostCenters().then(res => {
|
||||
this.costCenters = res.data || []
|
||||
}).catch(() => {
|
||||
this.costCenters = []
|
||||
})
|
||||
},
|
||||
statusLabel(status) {
|
||||
const target = this.statusOptions.find(item => item.value === status)
|
||||
return target ? target.label : (status || '-')
|
||||
},
|
||||
statusTagType(status) {
|
||||
const map = { CREATED: 'warning', POSTED: 'primary', COMPLETED: 'success', CANCELED: 'info' }
|
||||
return map[status] || ''
|
||||
},
|
||||
canEdit(row) {
|
||||
return row.status === 'CREATED'
|
||||
},
|
||||
handleSelectionChange(selection) {
|
||||
this.multipleSelection = selection
|
||||
this.crud.selectionChangeHandler(selection)
|
||||
},
|
||||
isPushDisabled() {
|
||||
if (this.multipleSelection.length !== 1) {
|
||||
return true
|
||||
}
|
||||
return this.multipleSelection[0].status !== 'CREATED'
|
||||
},
|
||||
openAdd() {
|
||||
this.loadStorList()
|
||||
this.loadCostCenters()
|
||||
this.dialogMode = 'add'
|
||||
this.form = createForm()
|
||||
this.form.bldat = this.today()
|
||||
this.form.items = [createItem()]
|
||||
this.dialogVisible = true
|
||||
},
|
||||
openEdit(row) {
|
||||
this.loadStorList()
|
||||
this.loadCostCenters()
|
||||
this.dialogMode = 'edit'
|
||||
this.form = createForm()
|
||||
this.dialogVisible = true
|
||||
get(row.id).then(res => {
|
||||
const detail = res.data || {}
|
||||
this.form = {
|
||||
id: detail.id,
|
||||
storCode: detail.stor_code,
|
||||
bldat: detail.bldat,
|
||||
remark: detail.remark,
|
||||
items: (detail.items || []).map(item => ({
|
||||
matnr: item.matnr,
|
||||
maktx: item.maktx,
|
||||
menge: item.menge,
|
||||
meins: item.meins,
|
||||
kostl: item.kostl,
|
||||
kostl_name: item.kostl_name,
|
||||
remark: item.remark
|
||||
}))
|
||||
}
|
||||
})
|
||||
},
|
||||
closeDialog() {
|
||||
this.dialogVisible = false
|
||||
this.form = createForm()
|
||||
},
|
||||
addItem() {
|
||||
this.form.items.push(createItem())
|
||||
},
|
||||
removeItem(index) {
|
||||
this.form.items.splice(index, 1)
|
||||
},
|
||||
onCostCenterChange(row) {
|
||||
const hit = this.costCenters.find(cc => cc.kostl === row.kostl)
|
||||
row.kostl_name = hit ? hit.ktext : ''
|
||||
},
|
||||
loadMaterial(row) {
|
||||
const code = (row.matnr || '').trim()
|
||||
if (!code) {
|
||||
return
|
||||
}
|
||||
getMaterial(code).then(res => {
|
||||
const material = res.data || {}
|
||||
if (material.material_code) {
|
||||
row.maktx = row.maktx || material.material_name
|
||||
row.meins = row.meins || material.qty_unit_name
|
||||
}
|
||||
}).catch(() => {})
|
||||
},
|
||||
submitForm() {
|
||||
if (!this.form.storCode) {
|
||||
this.$message.warning('请选择仓库')
|
||||
return
|
||||
}
|
||||
const items = this.form.items || []
|
||||
if (!items.length) {
|
||||
this.$message.warning('请至少添加一条领料明细')
|
||||
return
|
||||
}
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i]
|
||||
const line = i + 1
|
||||
if (!item.matnr) {
|
||||
this.$message.warning('第' + line + '行物料编码不能为空')
|
||||
return
|
||||
}
|
||||
if (!item.menge || Number(item.menge) <= 0) {
|
||||
this.$message.warning('第' + line + '行数量必须大于0')
|
||||
return
|
||||
}
|
||||
if (!item.kostl) {
|
||||
this.$message.warning('第' + line + '行成本中心不能为空')
|
||||
return
|
||||
}
|
||||
}
|
||||
const payload = {
|
||||
id: this.form.id,
|
||||
stor_code: this.form.storCode,
|
||||
bldat: this.form.bldat,
|
||||
remark: this.form.remark,
|
||||
items: items.map(item => ({
|
||||
matnr: item.matnr,
|
||||
maktx: item.maktx,
|
||||
menge: item.menge,
|
||||
meins: item.meins,
|
||||
kostl: item.kostl,
|
||||
kostl_name: item.kostl_name,
|
||||
remark: item.remark
|
||||
}))
|
||||
}
|
||||
this.saving = true
|
||||
const submitAction = this.dialogMode === 'add' ? add(payload) : edit(payload)
|
||||
submitAction.then(() => {
|
||||
this.$message.success(this.dialogMode === 'add' ? '新增成功' : '修改成功')
|
||||
this.dialogVisible = false
|
||||
this.crud.toQuery()
|
||||
}).finally(() => {
|
||||
this.saving = false
|
||||
})
|
||||
},
|
||||
openDetail(row) {
|
||||
this.currentOrder = { ...row }
|
||||
this.detailVisible = true
|
||||
this.detailLoading = true
|
||||
get(row.id).then(res => {
|
||||
const detail = res.data || {}
|
||||
this.currentOrder = { ...this.currentOrder, ...detail }
|
||||
this.itemList = detail.items || []
|
||||
}).catch(() => {
|
||||
this.itemList = []
|
||||
}).finally(() => {
|
||||
this.detailLoading = false
|
||||
})
|
||||
},
|
||||
closeDetail() {
|
||||
this.detailVisible = false
|
||||
this.currentOrder = {}
|
||||
this.itemList = []
|
||||
},
|
||||
handlePush() {
|
||||
if (this.isPushDisabled()) {
|
||||
this.$message.warning('请勾选一张已创建状态的手工领料单')
|
||||
return
|
||||
}
|
||||
const row = this.multipleSelection[0]
|
||||
this.$confirm('确认下推单据 ' + row.order_no + ' 生成出库单?出库完成后将按 MM022 回传 SAP。', '下推出库', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.pushing = true
|
||||
outPush(row.id).then(res => {
|
||||
const billCode = (res.data || {}).billCode
|
||||
this.$message.success('下推成功,出库单号:' + (billCode || '-'))
|
||||
this.crud.toQuery()
|
||||
}).finally(() => {
|
||||
this.pushing = false
|
||||
})
|
||||
}).catch(() => {})
|
||||
},
|
||||
handleDelete(row) {
|
||||
this.$confirm('确认删除单据 ' + row.order_no + ' ?', '删除', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
del([row.id]).then(() => {
|
||||
this.$message.success('删除成功')
|
||||
this.crud.toQuery()
|
||||
})
|
||||
}).catch(() => {})
|
||||
},
|
||||
today() {
|
||||
const now = new Date()
|
||||
const month = now.getMonth() + 1 < 10 ? '0' + (now.getMonth() + 1) : '' + (now.getMonth() + 1)
|
||||
const day = now.getDate() < 10 ? '0' + now.getDate() : '' + now.getDate()
|
||||
return '' + now.getFullYear() + month + day
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,34 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function add(data) {
|
||||
return request({ url: 'api/sapManualPicking', method: 'post', data })
|
||||
}
|
||||
|
||||
export function edit(data) {
|
||||
return request({ url: 'api/sapManualPicking', method: 'put', data })
|
||||
}
|
||||
|
||||
export function del(ids) {
|
||||
return request({ url: 'api/sapManualPicking', method: 'delete', data: ids })
|
||||
}
|
||||
|
||||
export function get(id) {
|
||||
return request({ url: 'api/sapManualPicking/' + id, method: 'get' })
|
||||
}
|
||||
|
||||
export function outPush(id) {
|
||||
return request({ url: 'api/sapManualPicking/outPush', method: 'post', data: { id }})
|
||||
}
|
||||
|
||||
export function getCostCenters() {
|
||||
return request({ url: 'api/sapManualPicking/costCenters', method: 'get' })
|
||||
}
|
||||
|
||||
/**
|
||||
* 按物料编码带出物料名称/单位(复用 PDA 物料查询接口)
|
||||
*/
|
||||
export function getMaterial(code) {
|
||||
return request({ url: 'api/pda/inbound/getMatByCode', method: 'get', params: { code }})
|
||||
}
|
||||
|
||||
export default { add, edit, del, get, outPush, getCostCenters, getMaterial }
|
||||
50
sql/20261107_sap_manual_picking.sql
Normal file
50
sql/20261107_sap_manual_picking.sql
Normal file
@@ -0,0 +1,50 @@
|
||||
-- SAP手工领料出库:WMS 新建 → 下推WMS出库单 → 出库完成后按 MM022 回传 SAP
|
||||
-- 库名请按实际修改
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sap_manual_picking` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`order_no` varchar(32) NOT NULL COMMENT '单据号(SLL+时间戳)',
|
||||
`stor_code` varchar(20) DEFAULT NULL COMMENT '仓库编码(MM022 lgort)',
|
||||
`stor_name` varchar(100) DEFAULT NULL COMMENT '仓库名称',
|
||||
`bldat` varchar(8) DEFAULT NULL COMMENT '建单日期 yyyyMMdd',
|
||||
`item_count` int DEFAULT 0 COMMENT '明细行数',
|
||||
`total_qty` decimal(18,3) DEFAULT 0.000 COMMENT '总数量',
|
||||
`status` varchar(20) DEFAULT 'CREATED' COMMENT '状态:CREATED已创建 POSTED已下发 COMPLETED已完成 CANCELED已取消',
|
||||
`out_bill_code` varchar(40) DEFAULT NULL COMMENT '下推生成的WMS出库单号(MM022 mblnr)',
|
||||
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
|
||||
`create_id` varchar(64) DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_name` varchar(50) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` varchar(30) DEFAULT NULL COMMENT '创建时间',
|
||||
`update_id` varchar(64) DEFAULT NULL COMMENT '修改人ID',
|
||||
`update_name` varchar(50) DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` varchar(30) DEFAULT NULL COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_order_no` (`order_no`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_create_time` (`create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SAP手工领料出库单主表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sap_manual_picking_item` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`header_id` bigint NOT NULL COMMENT '主表ID',
|
||||
`order_no` varchar(32) DEFAULT NULL COMMENT '单据号',
|
||||
`posnr` int DEFAULT NULL COMMENT '行项目号',
|
||||
`matnr` varchar(40) DEFAULT NULL COMMENT '物料号',
|
||||
`maktx` varchar(255) DEFAULT NULL COMMENT '物料描述',
|
||||
`menge` decimal(18,3) DEFAULT NULL COMMENT '数量',
|
||||
`meins` varchar(10) DEFAULT NULL COMMENT '计量单位',
|
||||
`kostl` varchar(20) DEFAULT NULL COMMENT '成本中心',
|
||||
`kostl_name` varchar(100) DEFAULT NULL COMMENT '成本中心名称',
|
||||
`werks` varchar(10) DEFAULT NULL COMMENT '工厂',
|
||||
`lgort` varchar(20) DEFAULT NULL COMMENT '库存地点(仓库编码)',
|
||||
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_header_id` (`header_id`),
|
||||
KEY `idx_order_no` (`order_no`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SAP手工领料出库单明细表';
|
||||
|
||||
-- 菜单:挂在 SAP出库 组下(父菜单请按实际调整,这里用交货出库组的 2089884602859524197)
|
||||
UPDATE `sys_menu` SET sub_count = sub_count + 1 WHERE menu_id = '2089884602859524197';
|
||||
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `system_type`, `category`, `title`, `en_title`, `in_title`, `zh_title`, `component_name`, `component`, `menu_sort`, `icon`, `path`, `iframe`, `cache`, `hidden`, `permission`, `create_id`, `create_name`, `create_time`, `update_id`, `update_name`, `update_time`, `is_pc`) VALUES
|
||||
('2089884602910050010', '2089884602859524197', 0, '3', '1', NULL, 'SAP手工领料出库', 'manualPicking', 'manualPicking', 'SAP手工领料出库', 'SapManualPicking', 'wms/pm_manage/sap/manualPicking/index', 9, 'swagger', 'SapManualPicking', 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1');
|
||||
Reference in New Issue
Block a user