marge:重新提交缺失部分代码
This commit is contained in:
@@ -10,7 +10,7 @@ public class BiStockReconcileRow {
|
||||
private String materialCode;
|
||||
private String materialName;
|
||||
private String unitName;
|
||||
private BigDecimal easQty;
|
||||
private BigDecimal sapQty;
|
||||
private BigDecimal compareQty;
|
||||
private BigDecimal diffQty;
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.nl.wms.bi_manage.service.impl;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -19,10 +21,10 @@ import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.bi_manage.service.IBiStockService;
|
||||
import org.nl.wms.bi_manage.service.dto.BiStockReconcileResult;
|
||||
import org.nl.wms.bi_manage.service.dto.BiStockReconcileRow;
|
||||
import org.nl.wms.ext_manage.api.EasApi;
|
||||
import org.nl.wms.ext_manage.api.request.QueryEasStockRequest;
|
||||
import org.nl.wms.ext_manage.api.response.QueryEasStockResponse;
|
||||
import org.nl.wms.bi_manage.service.dto.SapStockQueryResult;
|
||||
import org.nl.wms.ext_manage.enums.EXTConstant;
|
||||
import org.nl.wms.ext_manage.sap.api.SapApi;
|
||||
import org.nl.wms.ext_manage.sap.enums.SapConstant;
|
||||
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
|
||||
import org.nl.wms.ext_manage.service.dto.ZDInventory;
|
||||
import org.nl.wms.system_manage.service.param.ISysParamService;
|
||||
@@ -53,10 +55,8 @@ import java.util.Set;
|
||||
@Slf4j
|
||||
public class BiStockServiceImpl implements IBiStockService {
|
||||
|
||||
private static final String EAS_ORG_NO = "01.09.14";
|
||||
|
||||
@Autowired
|
||||
private EasApi easApi;
|
||||
private SapApi sapApi;
|
||||
@Autowired
|
||||
private WmsToZDWmdService wmsToZDWmdService;
|
||||
@Autowired
|
||||
@@ -76,16 +76,9 @@ public class BiStockServiceImpl implements IBiStockService {
|
||||
materialCode = materialCode.trim();
|
||||
}
|
||||
|
||||
QueryEasStockRequest easRequest = new QueryEasStockRequest();
|
||||
easRequest.setOrgno(EAS_ORG_NO);
|
||||
easRequest.setWarehouseno(sectCode);
|
||||
if (StringUtils.isNotBlank(materialCode)) {
|
||||
easRequest.setMaterialno(materialCode);
|
||||
}
|
||||
List<QueryEasStockResponse> easStocks = easApi.queryStock(easRequest);
|
||||
if (easStocks == null) {
|
||||
easStocks = new ArrayList<>();
|
||||
}
|
||||
JSONObject sapResult = sapApi.stockQuery(materialCode, SapConstant.WERKS, sectCode);
|
||||
SapStockQueryResult sapStock = toSapStock(sapResult);
|
||||
List<SapStockQueryResult.Item> sapStocks = sapStock.getBody();
|
||||
|
||||
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
|
||||
List ZD_STOR_SET;
|
||||
@@ -134,40 +127,40 @@ public class BiStockServiceImpl implements IBiStockService {
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, BigDecimal> easQtyMap = new HashMap<>();
|
||||
Map<String, String> easNameMap = new HashMap<>();
|
||||
Map<String, String> easUnitMap = new HashMap<>();
|
||||
for (QueryEasStockResponse eas : easStocks) {
|
||||
String skuCode = StringUtils.trimToEmpty(eas.getMaterialno());
|
||||
Map<String, BigDecimal> sapQtyMap = new HashMap<>();
|
||||
Map<String, String> sapNameMap = new HashMap<>();
|
||||
Map<String, String> sapUnitMap = new HashMap<>();
|
||||
for (SapStockQueryResult.Item sap : sapStocks) {
|
||||
String skuCode = StringUtils.trimToEmpty(sap.getMatnr());
|
||||
if (StringUtils.isBlank(skuCode) || !matchMaterial(skuCode, materialCode)) {
|
||||
continue;
|
||||
}
|
||||
easQtyMap.merge(skuCode, parseQty(eas.getQty()), BigDecimal::add);
|
||||
if (StringUtils.isNotBlank(eas.getMaterialname())) {
|
||||
easNameMap.putIfAbsent(skuCode, eas.getMaterialname());
|
||||
sapQtyMap.merge(skuCode, parseQty(sap.stockQty()), BigDecimal::add);
|
||||
if (StringUtils.isNotBlank(sap.getMaktx())) {
|
||||
sapNameMap.putIfAbsent(skuCode, sap.getMaktx().trim());
|
||||
}
|
||||
if (StringUtils.isNotBlank(eas.getUnitname())) {
|
||||
easUnitMap.putIfAbsent(skuCode, eas.getUnitname());
|
||||
if (StringUtils.isNotBlank(sap.getMeins())) {
|
||||
sapUnitMap.putIfAbsent(skuCode, sap.getMeins().trim());
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> materialCodes = new LinkedHashSet<>();
|
||||
materialCodes.addAll(easQtyMap.keySet());
|
||||
materialCodes.addAll(sapQtyMap.keySet());
|
||||
materialCodes.addAll(localQtyMap.keySet());
|
||||
|
||||
List<BiStockReconcileRow> rows = new ArrayList<>();
|
||||
for (String skuCode : materialCodes) {
|
||||
BigDecimal easQty = normalize(easQtyMap.getOrDefault(skuCode, BigDecimal.ZERO));
|
||||
BigDecimal sapQty = normalize(sapQtyMap.getOrDefault(skuCode, BigDecimal.ZERO));
|
||||
BigDecimal compareQty = normalize(localQtyMap.getOrDefault(skuCode, BigDecimal.ZERO));
|
||||
BiStockReconcileRow row = new BiStockReconcileRow();
|
||||
row.setWarehouseCode(sectCode);
|
||||
row.setMaterialCode(skuCode);
|
||||
row.setMaterialName(firstNotBlank(easNameMap.get(skuCode), localNameMap.get(skuCode)));
|
||||
row.setUnitName(firstNotBlank(easUnitMap.get(skuCode), localUnitMap.get(skuCode)));
|
||||
row.setEasQty(easQty);
|
||||
row.setMaterialName(firstNotBlank(sapNameMap.get(skuCode), localNameMap.get(skuCode)));
|
||||
row.setUnitName(firstNotBlank(sapUnitMap.get(skuCode), localUnitMap.get(skuCode)));
|
||||
row.setSapQty(sapQty);
|
||||
row.setCompareQty(compareQty);
|
||||
row.setDiffQty(normalize(easQty.subtract(compareQty)));
|
||||
row.setDiff(easQty.compareTo(compareQty) != 0);
|
||||
row.setDiffQty(normalize(sapQty.subtract(compareQty)));
|
||||
row.setDiff(sapQty.compareTo(compareQty) != 0);
|
||||
rows.add(row);
|
||||
}
|
||||
if (Boolean.TRUE.equals(onlyDiff)) {
|
||||
@@ -183,8 +176,8 @@ public class BiStockServiceImpl implements IBiStockService {
|
||||
result.setCompareSource(zdStor ? "ZD" : "WMS");
|
||||
result.setCompareSourceName(zdStor ? "中鼎库存" : "WMS库存");
|
||||
result.setRows(rows);
|
||||
log.info("库存对账 sectCode={}, source={}, easSize={}, localSize={}, rowSize={}",
|
||||
sectCode, result.getCompareSource(), easStocks.size(), localQtyMap.size(), rows.size());
|
||||
log.info("库存对账 sectCode={}, source={}, sapSize={}, localSize={}, rowSize={}",
|
||||
sectCode, result.getCompareSource(), sapStocks.size(), localQtyMap.size(), rows.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -200,14 +193,14 @@ public class BiStockServiceImpl implements IBiStockService {
|
||||
excelRow.put("物料编码", row.getMaterialCode());
|
||||
excelRow.put("物料名称", row.getMaterialName());
|
||||
excelRow.put("单位", row.getUnitName());
|
||||
excelRow.put("EAS库存", row.getEasQty());
|
||||
excelRow.put("SAP库存", row.getSapQty());
|
||||
excelRow.put(compareName, row.getCompareQty());
|
||||
excelRow.put("差异", row.getDiffQty());
|
||||
excelRows.add(excelRow);
|
||||
}
|
||||
ExcelWriter writer = ExcelUtil.getWriter(true);
|
||||
if (excelRows.isEmpty()) {
|
||||
writer.writeHeadRow(Arrays.asList("仓库编号", "物料编码", "物料名称", "单位", "EAS库存", compareName, "差异"));
|
||||
writer.writeHeadRow(Arrays.asList("仓库编号", "物料编码", "物料名称", "单位", "SAP库存", compareName, "差异"));
|
||||
} else {
|
||||
writer.write(excelRows, true);
|
||||
}
|
||||
@@ -314,4 +307,84 @@ public class BiStockServiceImpl implements IBiStockService {
|
||||
private String firstNotBlank(String first, String second) {
|
||||
return StringUtils.isNotBlank(first) ? first : second;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把 MM027 响应转成实体。body 可能是数组,也可能是带 data 的对象。
|
||||
* status=E 且没有物料号时视为查询失败。
|
||||
*/
|
||||
private SapStockQueryResult toSapStock(JSONObject result) {
|
||||
SapStockQueryResult response = new SapStockQueryResult();
|
||||
if (result == null) {
|
||||
return response;
|
||||
}
|
||||
JSONObject headerJson = result.getJSONObject("header");
|
||||
if (headerJson != null) {
|
||||
SapStockQueryResult.Header header = headerJson.toJavaObject(SapStockQueryResult.Header.class);
|
||||
response.setHeader(header);
|
||||
if (header != null && "E".equalsIgnoreCase(StringUtils.trimToEmpty(header.getStatus()))) {
|
||||
throw new BadRequestException(StringUtils.defaultIfBlank(header.getMessage(), "SAP库存查询失败"));
|
||||
}
|
||||
}
|
||||
JSONArray rows = resolveBodyRows(result.get("body"));
|
||||
if (rows == null || rows.isEmpty()) {
|
||||
return response;
|
||||
}
|
||||
List<SapStockQueryResult.Item> items = JSON.parseArray(rows.toJSONString(), SapStockQueryResult.Item.class);
|
||||
if (items == null) {
|
||||
return response;
|
||||
}
|
||||
for (SapStockQueryResult.Item item : items) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if ("E".equalsIgnoreCase(StringUtils.trimToEmpty(item.getStatus())) && StringUtils.isBlank(item.getMatnr())) {
|
||||
throw new BadRequestException(StringUtils.defaultIfBlank(item.getMessage(), "SAP库存查询失败"));
|
||||
}
|
||||
}
|
||||
response.setBody(items);
|
||||
return response;
|
||||
}
|
||||
|
||||
private JSONArray resolveBodyRows(Object body) {
|
||||
if (body == null) {
|
||||
return null;
|
||||
}
|
||||
if (body instanceof JSONArray) {
|
||||
return (JSONArray) body;
|
||||
}
|
||||
if (body instanceof JSONObject) {
|
||||
JSONObject bodyObj = (JSONObject) body;
|
||||
JSONArray rows = firstArray(bodyObj, "data", "item", "items", "result");
|
||||
if (rows != null) {
|
||||
return rows;
|
||||
}
|
||||
JSONArray single = new JSONArray();
|
||||
single.add(bodyObj);
|
||||
return single;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private JSONArray firstArray(JSONObject obj, String... keys) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
for (String key : keys) {
|
||||
JSONArray array = obj.getJSONArray(key);
|
||||
if (array != null) {
|
||||
return array;
|
||||
}
|
||||
}
|
||||
for (String actual : obj.keySet()) {
|
||||
for (String key : keys) {
|
||||
if (actual.equalsIgnoreCase(key)) {
|
||||
JSONArray array = obj.getJSONArray(actual);
|
||||
if (array != null) {
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
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> {
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
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> {
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,362 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function del(ids) {
|
||||
return request({ url: 'api/sapDeptPicking', method: 'delete', data: ids })
|
||||
}
|
||||
|
||||
export function get(id) {
|
||||
return request({ url: 'api/sapDeptPicking/' + id, method: 'get' })
|
||||
}
|
||||
|
||||
export function getDetail(orderNo) {
|
||||
return request({ url: 'api/sapDeptPicking/getDetail', method: 'get', params: { orderNo }})
|
||||
}
|
||||
|
||||
export function outPush(data) {
|
||||
return request({ url: 'api/sapDeptPicking/outPush', method: 'post', data })
|
||||
}
|
||||
|
||||
export default { del, get, getDetail, outPush }
|
||||
@@ -1,227 +0,0 @@
|
||||
<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-input v-model="query.aufnr" clearable placeholder="请输入工单号" @keyup.enter.native="crud.toQuery" />
|
||||
</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.bwart" clearable placeholder="全部" @change="crud.toQuery">
|
||||
<el-option v-for="item in bwartOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</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="success"
|
||||
icon="el-icon-s-promotion"
|
||||
size="mini"
|
||||
:disabled="isPushDisabled()"
|
||||
@click="handlePush"
|
||||
>下推出库</el-button>
|
||||
</crudOperation>
|
||||
|
||||
<el-dialog :visible.sync="detailVisible" title="部门领料出库明细" width="1200px" :close-on-click-modal="false" @close="closeDetailDialog">
|
||||
<div style="margin-bottom: 10px; color: #606266; font-size: 13px;">
|
||||
单据号:<strong>{{ currentOrder.order_no }}</strong> |
|
||||
来源系统:<strong>{{ currentOrder.src_system || '-' }}</strong> |
|
||||
状态:<strong>{{ statusLabel(currentOrder.status) }}</strong>
|
||||
</div>
|
||||
<el-table v-loading="detailLoading" :data="itemList" size="small" border max-height="500">
|
||||
<el-table-column type="index" label="序号" width="55" align="center" />
|
||||
<el-table-column prop="rsnum" label="预留号" width="100" />
|
||||
<el-table-column prop="rspos" label="行项目" width="75" align="center" />
|
||||
<el-table-column prop="aufnr" label="工单号" width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="kostl" label="成本中心" width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="matnr" label="物料号" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column prop="maktx" label="物料描述" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="bdmng" label="数量" width="90" align="right" />
|
||||
<el-table-column prop="meins" label="单位" width="70" align="center" />
|
||||
<el-table-column prop="werks" label="工厂" width="75" align="center" />
|
||||
<el-table-column prop="lgort" label="库存地点" width="90" align="center" />
|
||||
<el-table-column prop="bwart" label="移动类型" width="90" align="center" />
|
||||
<el-table-column prop="wempf" label="领料人" width="100" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="closeDetailDialog">关闭</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="openDetailDialog(scope.row)">{{ scope.row.order_no }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="src_msgid" label="来源消息ID" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="lgort" label="库存地点" width="100" align="center" />
|
||||
<el-table-column prop="item_count" label="明细行数" width="90" align="center" />
|
||||
<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="created_at" label="创建时间" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="160" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="primary" plain @click="openDetailDialog(scope.row)">明细</el-button>
|
||||
<el-button size="mini" type="danger" plain :disabled="!canDelete(scope.row)" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudDeptPicking, { del, getDetail, outPush } from './deptPicking'
|
||||
import CRUD, { crud, header, presenter } from '@crud/crud'
|
||||
import crudOperation from '@crud/CRUD.operation.vue'
|
||||
import rrOperation from '@crud/RR.operation.vue'
|
||||
import pagination from '@crud/Pagination.vue'
|
||||
|
||||
export default {
|
||||
name: 'SapDeptPicking',
|
||||
components: { pagination, crudOperation, rrOperation },
|
||||
mixins: [presenter(), header(), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: 'SAP部门领料出库',
|
||||
url: 'api/sapDeptPicking',
|
||||
idField: 'id',
|
||||
sort: 'id,desc',
|
||||
crudMethod: { del, ...crudDeptPicking },
|
||||
optShow: { add: false, edit: false, del: false, reset: true }
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
permission: {
|
||||
del: ['admin', 'sapDeptPicking:del']
|
||||
},
|
||||
statusOptions: [
|
||||
{ value: 'CREATED', label: '已创建' },
|
||||
{ value: 'POSTED', label: '已下发' },
|
||||
{ value: 'COMPLETED', label: '已完成' },
|
||||
{ value: 'CANCELED', label: '已取消' }
|
||||
],
|
||||
bwartOptions: [
|
||||
{ value: '261', label: '261 工单领料' },
|
||||
{ value: '201', label: '201 成本中心领料' }
|
||||
],
|
||||
multipleSelection: [],
|
||||
detailVisible: false,
|
||||
detailLoading: false,
|
||||
currentOrder: {},
|
||||
itemList: []
|
||||
}
|
||||
},
|
||||
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 = ''
|
||||
}
|
||||
},
|
||||
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] || ''
|
||||
},
|
||||
canDelete(row) {
|
||||
return row.status === 'CREATED' || row.status === 'CANCELED'
|
||||
},
|
||||
handleSelectionChange(selection) {
|
||||
this.multipleSelection = selection
|
||||
this.crud.selectionChangeHandler(selection)
|
||||
},
|
||||
isPushDisabled() {
|
||||
if (this.multipleSelection.length !== 1) {
|
||||
return true
|
||||
}
|
||||
return this.multipleSelection[0].status !== 'CREATED'
|
||||
},
|
||||
openDetailDialog(row) {
|
||||
this.currentOrder = { ...row }
|
||||
this.detailVisible = true
|
||||
this.detailLoading = true
|
||||
getDetail(row.order_no).then(res => {
|
||||
const detail = res.data || {}
|
||||
this.currentOrder = { ...this.currentOrder, ...detail }
|
||||
this.itemList = detail.items || []
|
||||
}).catch(() => {
|
||||
this.itemList = []
|
||||
}).finally(() => {
|
||||
this.detailLoading = false
|
||||
})
|
||||
},
|
||||
closeDetailDialog() {
|
||||
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 + ' 生成出库单?出库完成后将按 PP055 回传 SAP。', '下推出库', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
outPush({ id: row.id }).then(() => {
|
||||
this.$message.success('下推成功')
|
||||
this.crud.toQuery()
|
||||
})
|
||||
}).catch(() => {})
|
||||
},
|
||||
handleDelete(row) {
|
||||
this.$confirm('确认删除单据 ' + row.order_no + ' ?', '删除', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
del([row.id]).then(() => {
|
||||
this.$message.success('删除成功')
|
||||
this.crud.toQuery()
|
||||
})
|
||||
}).catch(() => {})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,57 +0,0 @@
|
||||
-- SAP部门领料出库单同步(PP113)建表 + 菜单
|
||||
-- 已有库执行,库名请按实际修改,默认 wms_nlwq
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sap_dept_picking` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`order_no` varchar(50) NOT NULL COMMENT '单据号:header.src_msgid,为空时系统生成',
|
||||
`intf_id` varchar(20) DEFAULT NULL COMMENT '接口编号 PP113',
|
||||
`src_system` varchar(20) DEFAULT NULL COMMENT '来源系统',
|
||||
`dest_system` varchar(20) DEFAULT NULL COMMENT '目标系统',
|
||||
`src_msgid` varchar(64) DEFAULT NULL COMMENT '来源消息ID',
|
||||
`request_time` varchar(32) DEFAULT NULL COMMENT '报文请求时间',
|
||||
`backup1` varchar(64) DEFAULT NULL,
|
||||
`backup2` varchar(64) DEFAULT NULL,
|
||||
`lgort` varchar(20) DEFAULT NULL COMMENT '存储地点,取明细第一条',
|
||||
`item_count` int DEFAULT 0 COMMENT '明细行数',
|
||||
`status` varchar(20) DEFAULT 'CREATED' COMMENT '状态:CREATED/POSTED/COMPLETED/CANCELED',
|
||||
`remark` varchar(255) DEFAULT NULL,
|
||||
`created_at` datetime DEFAULT NULL,
|
||||
`updated_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_order_no` (`order_no`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = 'SAP部门领料出库单(PP113)';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sap_dept_picking_item` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`header_id` bigint NOT NULL COMMENT '主表ID',
|
||||
`order_no` varchar(50) DEFAULT NULL COMMENT '单据号',
|
||||
`rsnum` varchar(20) DEFAULT NULL COMMENT '预留号',
|
||||
`rspos` varchar(10) DEFAULT NULL COMMENT '预留行项目',
|
||||
`erdat` varchar(20) DEFAULT NULL COMMENT '创建日期',
|
||||
`ernam` varchar(30) DEFAULT NULL COMMENT '创建人',
|
||||
`kostl` varchar(20) DEFAULT NULL COMMENT '成本中心',
|
||||
`aufnr` varchar(20) DEFAULT NULL COMMENT '生产/工单号',
|
||||
`matnr` varchar(40) DEFAULT NULL COMMENT '物料号',
|
||||
`maktx` varchar(255) DEFAULT NULL COMMENT '物料描述',
|
||||
`bdmng` decimal(20, 8) DEFAULT 0 COMMENT '数量',
|
||||
`werks` varchar(10) DEFAULT NULL COMMENT '工厂',
|
||||
`lgort` varchar(20) DEFAULT NULL COMMENT '库存地点',
|
||||
`meins` varchar(10) DEFAULT NULL COMMENT '单位',
|
||||
`bwart` varchar(10) DEFAULT NULL COMMENT '移动类型:261工单领料/201成本中心领料',
|
||||
`wempf` varchar(30) DEFAULT NULL COMMENT '收货方/领料人',
|
||||
`backup1` varchar(64) DEFAULT NULL,
|
||||
`backup2` varchar(64) DEFAULT NULL,
|
||||
`backup3` varchar(64) DEFAULT NULL,
|
||||
`backup4` varchar(64) DEFAULT NULL,
|
||||
`created_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_header_id` (`header_id`),
|
||||
KEY `idx_order_no` (`order_no`),
|
||||
KEY `idx_rsnum` (`rsnum`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = 'SAP部门领料出库单明细(PP113)';
|
||||
|
||||
-- 菜单:挂在「SAP出库」组下
|
||||
INSERT INTO `wms_nlwq`.`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
|
||||
('2089884602910050006', '2089884602859524197', 0, '3', '1', NULL, 'SAP部门领料出库', 'deptPicking', 'deptPicking', 'SAP部门领料出库', 'SapDeptPicking', 'wms/pm_manage/sap/deptPicking/index', 7, 'swagger', 'SapDeptPicking', 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1');
|
||||
|
||||
UPDATE `wms_nlwq`.`sys_menu` SET sub_count = sub_count + 1 WHERE menu_id = '2089884602859524197';
|
||||
Reference in New Issue
Block a user