feat(integration): 新增外部完工入库和物料消耗功能
- 新增 OutMaterialCompleteLog 和 OutSapMaterialLog 实体类 - 新增 OutMaterialSapService 接口和 OutMaterialSapServiceImpl 实现类 - 新增完工入库和物料消耗的 SAP 调用逻辑 - 新增 OutSapCompleteMapper 和 OutSapMaterialMapper 接口
This commit is contained in:
parent
6584f1a045
commit
eb84ad00b6
@ -0,0 +1,338 @@
|
||||
package com.foreverwin.iep.integration.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 完工入库事务表
|
||||
*
|
||||
* @author mom code generator
|
||||
* @date 2024-11-11 09:56:21
|
||||
*/
|
||||
@Data
|
||||
@TableName("out_material_complete_log")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "完工入库记录表")
|
||||
public class OutMaterialCompleteLog extends Model<OutMaterialCompleteLog> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String sid;
|
||||
|
||||
/**
|
||||
* 站点
|
||||
*/
|
||||
@ApiModelProperty(value = "站点")
|
||||
private String site;
|
||||
|
||||
/**
|
||||
* 车间
|
||||
*/
|
||||
@ApiModelProperty(value = "车间")
|
||||
private String fabNo;
|
||||
|
||||
/**
|
||||
* 工作中心
|
||||
*/
|
||||
@ApiModelProperty(value = "工作中心")
|
||||
private String workCenter;
|
||||
|
||||
/**
|
||||
* 资源
|
||||
*/
|
||||
@ApiModelProperty(value = "资源")
|
||||
private String resource;
|
||||
|
||||
/**
|
||||
* WMS_INVENTORY_LOG表主键
|
||||
*/
|
||||
@ApiModelProperty(value = "WMS_INVENTORY_LOG表主键")
|
||||
private String inventoryLogSid;
|
||||
|
||||
/**
|
||||
* 工单
|
||||
*/
|
||||
@ApiModelProperty(value = "工单")
|
||||
private String shopOrder;
|
||||
|
||||
/**
|
||||
* 生产批号,卷号
|
||||
*/
|
||||
@ApiModelProperty(value = "生产批号,卷号")
|
||||
private String lotNo;
|
||||
|
||||
/**
|
||||
* 101(主产品入库)、531(副产品入库)
|
||||
*/
|
||||
@ApiModelProperty(value = "101(主产品入库)、531(副产品入库)")
|
||||
private String productType;
|
||||
|
||||
/**
|
||||
* 物料批次,默认为SAP_BATCH_NO
|
||||
*/
|
||||
@ApiModelProperty(value = "物料批次,默认为SAP_BATCH_NO")
|
||||
private String materialLot;
|
||||
|
||||
@ApiModelProperty(value = "班次")
|
||||
private String userWorkShift;
|
||||
|
||||
/**
|
||||
* 生产批序列号
|
||||
*/
|
||||
@ApiModelProperty(value = "生产批序列号")
|
||||
private String lotSerial;
|
||||
|
||||
/**
|
||||
* 客户外部批次
|
||||
*/
|
||||
@ApiModelProperty(value = "客户外部批次")
|
||||
private String externalLot;
|
||||
|
||||
/**
|
||||
* 品质判定等级
|
||||
*/
|
||||
@ApiModelProperty(value = "品质判定等级")
|
||||
private String qcGrade;
|
||||
|
||||
/**
|
||||
* 物料编号
|
||||
*/
|
||||
@ApiModelProperty(value = "物料编号")
|
||||
private String item;
|
||||
|
||||
@ApiModelProperty(value = "SAP的物料号MATNR,也就是ITEM的ERP_ITEM")
|
||||
private String erpItem;
|
||||
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
private String itemDesc;
|
||||
|
||||
/**
|
||||
* 物料主单位
|
||||
*/
|
||||
@ApiModelProperty(value = "物料主单位")
|
||||
private String mainUom;
|
||||
|
||||
/**
|
||||
* 主单位完工数量
|
||||
*/
|
||||
@ApiModelProperty(value = "主单位完工数量")
|
||||
private BigDecimal mainQty;
|
||||
|
||||
/**
|
||||
* 组件物料辅单位
|
||||
*/
|
||||
@ApiModelProperty(value = "组件物料辅单位")
|
||||
private String subUom;
|
||||
|
||||
/**
|
||||
* 辅单位完工数量
|
||||
*/
|
||||
@ApiModelProperty(value = "辅单位完工数量")
|
||||
private BigDecimal subQty;
|
||||
|
||||
/**
|
||||
* 完工仓库
|
||||
*/
|
||||
@ApiModelProperty(value = "完工仓库")
|
||||
private String warehouseCode;
|
||||
|
||||
/**
|
||||
* 完工存储位置
|
||||
*/
|
||||
@ApiModelProperty(value = "完工存储位置")
|
||||
private String storageLocation;
|
||||
|
||||
/**
|
||||
* 消耗存储货格
|
||||
*/
|
||||
@ApiModelProperty(value = "消耗存储货格")
|
||||
private String storageBin;
|
||||
|
||||
/**
|
||||
* ERP仓库编号
|
||||
*/
|
||||
@ApiModelProperty(value = "ERP仓库编号")
|
||||
private String erpInventory;
|
||||
|
||||
/**
|
||||
* 移动日志(0:入库、2:销售出库)
|
||||
*/
|
||||
@ApiModelProperty(value = "移动日志(0:入库、2:销售出库)")
|
||||
private String moveType;
|
||||
|
||||
/**
|
||||
* 状态(0:正常、1:冻结、2:已扫描出库、3:待出库过账)
|
||||
*/
|
||||
@ApiModelProperty(value = "状态(0:正常、1:冻结、2:已扫描出库、3:待出库过账)")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 制造日期
|
||||
*/
|
||||
@ApiModelProperty(value = "制造日期")
|
||||
private LocalDateTime dateMfg;
|
||||
|
||||
/**
|
||||
* 到期日
|
||||
*/
|
||||
@ApiModelProperty(value = "到期日")
|
||||
private LocalDateTime dateExp;
|
||||
|
||||
/**
|
||||
* 库存日期
|
||||
*/
|
||||
@ApiModelProperty(value = "库存日期")
|
||||
private LocalDateTime dateInventory;
|
||||
|
||||
/**
|
||||
* 事务处理类型
|
||||
*/
|
||||
@ApiModelProperty(value = "事务处理类型")
|
||||
private String transactionType;
|
||||
|
||||
/**
|
||||
* 事务处理日期
|
||||
*/
|
||||
@ApiModelProperty(value = "事务处理日期")
|
||||
private LocalDateTime transactionDate;
|
||||
|
||||
/**
|
||||
* ERP抛送旗帜
|
||||
*/
|
||||
@ApiModelProperty(value = "ERP抛送旗帜")
|
||||
private String erpFlag;
|
||||
|
||||
/**
|
||||
* SAP批次编号(向SAP申请的批次号)
|
||||
*/
|
||||
@ApiModelProperty(value = "SAP批次编号(向SAP申请的批次号)")
|
||||
private String sapBatchNo;
|
||||
|
||||
/**
|
||||
* 库存类型(质检库存、冻结库存等)
|
||||
*/
|
||||
@ApiModelProperty(value = "库存类型(质检库存、冻结库存等)")
|
||||
private String inventoryType;
|
||||
|
||||
/**
|
||||
* 特殊库存标识
|
||||
*/
|
||||
@ApiModelProperty(value = "特殊库存标识")
|
||||
private String inventoryMark;
|
||||
|
||||
/**
|
||||
* 销售订单行号
|
||||
*/
|
||||
@ApiModelProperty(value = "销售订单行号")
|
||||
private String soLineNo;
|
||||
|
||||
/**
|
||||
* 销售订单号
|
||||
*/
|
||||
@ApiModelProperty(value = "销售订单号")
|
||||
private String soNo;
|
||||
|
||||
/**
|
||||
* 同步提交人
|
||||
*/
|
||||
@ApiModelProperty(value = "同步提交人")
|
||||
private String syncSubmitter;
|
||||
|
||||
/**
|
||||
* 同步过账日期
|
||||
*/
|
||||
@ApiModelProperty(value = "同步过账日期")
|
||||
private LocalDate syncPostingDate;
|
||||
|
||||
/**
|
||||
* 同步请求处理编号
|
||||
*/
|
||||
@ApiModelProperty(value = "同步请求处理编号")
|
||||
private String syncTransBatch;
|
||||
|
||||
/**
|
||||
* 同步请求处理时间
|
||||
*/
|
||||
@ApiModelProperty(value = "同步请求处理时间")
|
||||
private LocalDateTime syncTransDate;
|
||||
|
||||
/**
|
||||
* 同步返回结果
|
||||
*/
|
||||
@ApiModelProperty(value = "同步返回结果")
|
||||
private String syncStatus;
|
||||
|
||||
/**
|
||||
* 同步消息识别
|
||||
*/
|
||||
@ApiModelProperty(value = "同步消息识别")
|
||||
private String syncMsgId;
|
||||
|
||||
/**
|
||||
* 同步系统消息编号
|
||||
*/
|
||||
@ApiModelProperty(value = "同步系统消息编号")
|
||||
private String syncMsgNo;
|
||||
|
||||
/**
|
||||
* 同步返回消息文本
|
||||
*/
|
||||
@ApiModelProperty(value = "同步返回消息文本")
|
||||
private String syncMsgText;
|
||||
|
||||
/**
|
||||
* 同步返回物料凭证编号
|
||||
*/
|
||||
@ApiModelProperty(value = "同步返回物料凭证编号")
|
||||
private String syncVoucherNo;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime dateCreate;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime dateUpdate;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updater;
|
||||
|
||||
@ApiModelProperty(value = "erp冲销标识(Y:冲销成功、无值代表无冲销动作、其它值代表erp冲销返回结果值)")
|
||||
private String erpReverse;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String startTime;
|
||||
@TableField(exist = false)
|
||||
private String endTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,294 @@
|
||||
package com.foreverwin.iep.integration.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
/**
|
||||
* 物料消耗记录表
|
||||
*
|
||||
* @author Snow
|
||||
* @date 2024-11-10 17:14:03
|
||||
*/
|
||||
@Data
|
||||
@TableName("out_sap_material_log")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "物料消耗记录表")
|
||||
public class OutSapMaterialLog extends Model<OutSapMaterialLog> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String sid;
|
||||
|
||||
/**
|
||||
* 站点
|
||||
*/
|
||||
@ApiModelProperty(value = "站点")
|
||||
private String site;
|
||||
|
||||
/**
|
||||
* 车间
|
||||
*/
|
||||
@ApiModelProperty(value = "车间")
|
||||
private String fabNo;
|
||||
|
||||
/**
|
||||
* 工作中心
|
||||
*/
|
||||
@ApiModelProperty(value = "工作中心")
|
||||
private String workCenter;
|
||||
|
||||
/**
|
||||
* 资源
|
||||
*/
|
||||
@ApiModelProperty(value = "资源")
|
||||
private String resource;
|
||||
|
||||
/**
|
||||
* lot_material主键
|
||||
*/
|
||||
@ApiModelProperty(value = "lot_material主键")
|
||||
private String lotMaterialSid;
|
||||
|
||||
/**
|
||||
* 工单
|
||||
*/
|
||||
@ApiModelProperty(value = "工单")
|
||||
private String shopOrder;
|
||||
|
||||
/**
|
||||
* 生产批号
|
||||
*/
|
||||
@ApiModelProperty(value = "生产批号")
|
||||
private String lotNo;
|
||||
|
||||
/**
|
||||
* 生产批序列号
|
||||
*/
|
||||
@ApiModelProperty(value = "生产批序列号")
|
||||
private String lotSerial;
|
||||
|
||||
/**
|
||||
* 消耗组件物料批次
|
||||
*/
|
||||
@ApiModelProperty(value = "消耗组件物料批次")
|
||||
private String materialLot;
|
||||
|
||||
/**
|
||||
* 消耗组件物料编号
|
||||
*/
|
||||
@ApiModelProperty(value = "消耗组件物料编号")
|
||||
private String componentItem;
|
||||
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
private String itemDesc;
|
||||
|
||||
@ApiModelProperty(value = "SAP的物料号MATNR,也就是ITEM的ERP_ITEM")
|
||||
private String erpItem;
|
||||
|
||||
@ApiModelProperty(value = "班次")
|
||||
private String userWorkShift;
|
||||
|
||||
/**
|
||||
* 消耗组件物料主单位
|
||||
*/
|
||||
@ApiModelProperty(value = "消耗组件物料主单位")
|
||||
private String mainUom;
|
||||
|
||||
/**
|
||||
* 投料主单位数量
|
||||
*/
|
||||
@ApiModelProperty(value = "投料主单位数量")
|
||||
private BigDecimal mainQty;
|
||||
|
||||
/**
|
||||
* 投料组件物料辅单位
|
||||
*/
|
||||
@ApiModelProperty(value = "投料组件物料辅单位")
|
||||
private String subUom;
|
||||
|
||||
/**
|
||||
* subQty
|
||||
*/
|
||||
@ApiModelProperty(value = "subQty")
|
||||
private BigDecimal subQty;
|
||||
|
||||
/**
|
||||
* 消耗仓库
|
||||
*/
|
||||
@ApiModelProperty(value = "消耗仓库")
|
||||
private String warehouseCode;
|
||||
|
||||
/**
|
||||
* 消耗存储位置
|
||||
*/
|
||||
@ApiModelProperty(value = "消耗存储位置")
|
||||
private String storageLocation;
|
||||
|
||||
/**
|
||||
* 消耗存储货格
|
||||
*/
|
||||
@ApiModelProperty(value = "消耗存储货格")
|
||||
private String storageBin;
|
||||
|
||||
/**
|
||||
* ERP仓库
|
||||
*/
|
||||
@ApiModelProperty(value = "ERP仓库")
|
||||
private String erpInventory;
|
||||
|
||||
/**
|
||||
* 预留编号
|
||||
*/
|
||||
@ApiModelProperty(value = "预留编号")
|
||||
private String reservedNo;
|
||||
|
||||
/**
|
||||
* 预留行号
|
||||
*/
|
||||
@ApiModelProperty(value = "预留行号")
|
||||
private String reservedLine;
|
||||
|
||||
/**
|
||||
* SAP批次编号
|
||||
*/
|
||||
@ApiModelProperty(value = "SAP批次编号")
|
||||
private String sapBatchNo;
|
||||
|
||||
/**
|
||||
* 供货商编号
|
||||
*/
|
||||
@ApiModelProperty(value = "供货商编号")
|
||||
private String supplierNo;
|
||||
|
||||
/**
|
||||
* 供货商物料批次
|
||||
*/
|
||||
@ApiModelProperty(value = "供货商物料批次")
|
||||
private String supplierBatch;
|
||||
|
||||
/**
|
||||
* ERP抛送旗帜
|
||||
*/
|
||||
@ApiModelProperty(value = "ERP抛送旗帜")
|
||||
private String erpFlag;
|
||||
|
||||
/**
|
||||
* 事务处理类型
|
||||
*/
|
||||
@ApiModelProperty(value = "事务处理类型")
|
||||
private String transactionType;
|
||||
|
||||
/**
|
||||
* 事务处理日期
|
||||
*/
|
||||
@ApiModelProperty(value = "事务处理日期")
|
||||
private LocalDateTime transactionDate;
|
||||
|
||||
/**
|
||||
* 同步提交人
|
||||
*/
|
||||
@ApiModelProperty(value = "同步提交人")
|
||||
private String syncSubmitter;
|
||||
|
||||
/**
|
||||
* 同步过账日期
|
||||
*/
|
||||
@ApiModelProperty(value = "同步过账日期")
|
||||
private LocalDate syncPostingDate;
|
||||
|
||||
/**
|
||||
* 同步请求处理编号
|
||||
*/
|
||||
@ApiModelProperty(value = "同步请求处理编号")
|
||||
private String syncTransBatch;
|
||||
|
||||
/**
|
||||
* 同步请求处理时间
|
||||
*/
|
||||
@ApiModelProperty(value = "同步请求处理时间")
|
||||
private LocalDateTime syncTransDate;
|
||||
|
||||
/**
|
||||
* 同步返回结果
|
||||
*/
|
||||
@ApiModelProperty(value = "同步返回结果")
|
||||
private String syncStatus;
|
||||
|
||||
/**
|
||||
* 同步消息识别
|
||||
*/
|
||||
@ApiModelProperty(value = "同步消息识别")
|
||||
private String syncMsgId;
|
||||
|
||||
/**
|
||||
* 同步系统消息编号
|
||||
*/
|
||||
@ApiModelProperty(value = "同步系统消息编号")
|
||||
private String syncMsgNo;
|
||||
|
||||
/**
|
||||
* 同步返回消息文本
|
||||
*/
|
||||
@ApiModelProperty(value = "同步返回消息文本")
|
||||
private String syncMsgText;
|
||||
|
||||
/**
|
||||
* 同步返回物料凭证编号
|
||||
*/
|
||||
@ApiModelProperty(value = "同步返回物料凭证编号")
|
||||
private String syncVoucherNo;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime dateCreate;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime dateUpdate;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updater;
|
||||
|
||||
@ApiModelProperty(value = "erp冲销标识(Y:冲销成功、无值代表无冲销动作、其它值代表erp冲销返回结果值)")
|
||||
private String erpReverse;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String startTime;
|
||||
@TableField(exist = false)
|
||||
private String endTime;
|
||||
@TableField(exist = false)
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,263 @@
|
||||
package com.foreverwin.iep.integration.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 生产报工事务明细
|
||||
*
|
||||
* @author mom code generator
|
||||
* @date 2024-11-11 10:34:47
|
||||
*/
|
||||
@Data
|
||||
@TableName("out_sap_shoporder_statistics")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "生产报工记录")
|
||||
public class OutSapShoporderStatistics extends Model<OutSapShoporderStatistics> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String sid;
|
||||
|
||||
/**
|
||||
* 站点
|
||||
*/
|
||||
@ApiModelProperty(value = "站点")
|
||||
private String site;
|
||||
|
||||
/**
|
||||
* 车间
|
||||
*/
|
||||
@ApiModelProperty(value = "车间")
|
||||
private String fabNo;
|
||||
|
||||
/**
|
||||
* 工作中心
|
||||
*/
|
||||
@ApiModelProperty(value = "工作中心")
|
||||
private String workCenter;
|
||||
|
||||
/**
|
||||
* 资源
|
||||
*/
|
||||
@ApiModelProperty(value = "资源")
|
||||
private String resource;
|
||||
|
||||
/**
|
||||
* 工单
|
||||
*/
|
||||
@ApiModelProperty(value = "工单")
|
||||
private String shopOrder;
|
||||
|
||||
/**
|
||||
* 工序
|
||||
*/
|
||||
@ApiModelProperty(value = "工序")
|
||||
private String operation;
|
||||
|
||||
/**
|
||||
* 工单计划物料
|
||||
*/
|
||||
@ApiModelProperty(value = "工单计划物料")
|
||||
private String item;
|
||||
|
||||
/**
|
||||
* 产品物料主单位
|
||||
*/
|
||||
@ApiModelProperty(value = "产品物料主单位")
|
||||
private String mainUom;
|
||||
|
||||
/**
|
||||
* 产品物料辅单位
|
||||
*/
|
||||
@ApiModelProperty(value = "产品物料辅单位")
|
||||
private String subUom;
|
||||
|
||||
@ApiModelProperty(value = "完工数量")
|
||||
private BigDecimal qtyDone;
|
||||
|
||||
@ApiModelProperty(value = "报废数量")
|
||||
private BigDecimal qtyScrapped;
|
||||
|
||||
/**
|
||||
* 人工工时
|
||||
*/
|
||||
@ApiModelProperty(value = "人工工时")
|
||||
private BigDecimal laborTime;
|
||||
|
||||
/**
|
||||
* 机器工时
|
||||
*/
|
||||
@ApiModelProperty(value = "机器工时")
|
||||
private BigDecimal machineTime;
|
||||
|
||||
/**
|
||||
* 异常停机时间
|
||||
*/
|
||||
@ApiModelProperty(value = "异常停机时间")
|
||||
private BigDecimal abnormalTime;
|
||||
|
||||
/**
|
||||
* 设备清机换型时间
|
||||
*/
|
||||
@ApiModelProperty(value = "设备清机换型时间")
|
||||
private BigDecimal switchTime;
|
||||
|
||||
/**
|
||||
* 能耗
|
||||
*/
|
||||
@ApiModelProperty(value = "能耗")
|
||||
private BigDecimal energy;
|
||||
|
||||
/**
|
||||
* 辅料
|
||||
*/
|
||||
@ApiModelProperty(value = "辅料")
|
||||
private BigDecimal accessories;
|
||||
|
||||
/**
|
||||
* 其它
|
||||
*/
|
||||
@ApiModelProperty(value = "其它")
|
||||
private BigDecimal othersQty;
|
||||
|
||||
/**
|
||||
* 报工确认人
|
||||
*/
|
||||
@ApiModelProperty(value = "报工确认人")
|
||||
private String confirmedUser;
|
||||
|
||||
/**
|
||||
* 确认时间
|
||||
*/
|
||||
@ApiModelProperty(value = "确认时间")
|
||||
private LocalDateTime confirmedDate;
|
||||
|
||||
/**
|
||||
* 同步提交人
|
||||
*/
|
||||
@ApiModelProperty(value = "同步提交人")
|
||||
private String syncSubmitter;
|
||||
|
||||
/**
|
||||
* 同步过账日期
|
||||
*/
|
||||
@ApiModelProperty(value = "同步过账日期")
|
||||
private LocalDate syncPostingDate;
|
||||
|
||||
/**
|
||||
* 同步请求处理编号
|
||||
*/
|
||||
@ApiModelProperty(value = "同步请求处理编号")
|
||||
private String syncTransBatch;
|
||||
|
||||
/**
|
||||
* 同步请求处理时间
|
||||
*/
|
||||
@ApiModelProperty(value = "同步请求处理时间")
|
||||
private LocalDateTime syncTransDate;
|
||||
|
||||
/**
|
||||
* 同步返回结果(SAP同步返回状态,S: 成功 E: 失败)
|
||||
*/
|
||||
@ApiModelProperty(value = "同步返回结果(SAP同步返回状态,S: 成功 E: 失败)")
|
||||
private String syncStatus;
|
||||
|
||||
/**
|
||||
* 同步消息识别
|
||||
*/
|
||||
@ApiModelProperty(value = "同步消息识别")
|
||||
private String syncMessageRemark;
|
||||
|
||||
/**
|
||||
* 同步系统消息编号
|
||||
*/
|
||||
@ApiModelProperty(value = "同步系统消息编号")
|
||||
private String syncMessageNo;
|
||||
|
||||
/**
|
||||
* 同步返回消息文本(SAP同步返回消息)
|
||||
*/
|
||||
@ApiModelProperty(value = "同步返回消息文本(SAP同步返回消息)")
|
||||
private String syncMessageText;
|
||||
|
||||
/**
|
||||
* 同步返回确认号(SAP同步返回凭证确认号)
|
||||
*/
|
||||
@ApiModelProperty(value = "同步返回确认号(SAP同步返回凭证确认号)")
|
||||
private String syncTicketNo;
|
||||
|
||||
/**
|
||||
* 同步返回确认号计数器(SAP返回计数器)
|
||||
*/
|
||||
@ApiModelProperty(value = "同步返回确认号计数器(SAP返回计数器)")
|
||||
private String syncTicketLine;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime dateCreate;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime dateUpdate;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String creator;
|
||||
|
||||
@ApiModelProperty(value = "erp冲销标识(Y:冲销成功、无值代表无冲销动作、其它值代表erp冲销返回结果值)")
|
||||
private String erpReverse;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updater;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String startTime;
|
||||
@TableField(exist = false)
|
||||
private String endTime;
|
||||
@TableField(exist = false)
|
||||
private String status;
|
||||
@TableField(exist = false)
|
||||
private String itemDesc;
|
||||
@TableField(exist = false)
|
||||
private String erpItem;
|
||||
@TableField(exist = false)
|
||||
private String statusDescription;
|
||||
@TableField(exist = false)
|
||||
private String wcDesc;
|
||||
@TableField(exist = false)
|
||||
private String opDesc;
|
||||
@TableField(exist = false)
|
||||
private String fabDesc;
|
||||
@TableField(exist = false)
|
||||
private BigDecimal sumQtyDone;
|
||||
@TableField(exist = false)
|
||||
private BigDecimal sumQtyScrapped;
|
||||
|
||||
}
|
||||
@ -261,10 +261,8 @@ public class CopyShopOrderStatisticTransController {
|
||||
jsonObject.put("MATKL", ""); // 物料组
|
||||
jsonObject.put("WERKS", site); // 工厂
|
||||
jsonObject.put("LGORT", consumptionTransaction.getErpInventory()); // 存储地点
|
||||
String sapBatchNo = registerDocumentService.getSapBatchNo(consumptionTransaction.getWorkshopNumber());
|
||||
|
||||
|
||||
jsonObject.put("CHARG", sapBatchNo); // 批次号
|
||||
// String sapBatchNo = registerDocumentService.getSapBatchNo(consumptionTransaction.getWorkshopNumber());
|
||||
jsonObject.put("CHARG", consumptionTransaction.getSapBatchNo()); // 批次号
|
||||
jsonObject.put("BWART", "261"); // 移动类型
|
||||
jsonObject.put("SOBKZ", ""); // 特殊库存标识
|
||||
jsonObject.put("AUFNR", consumptionTransaction.getShopOrder()); // 订单号
|
||||
@ -346,7 +344,7 @@ public class CopyShopOrderStatisticTransController {
|
||||
targetObj.setSyncVoucherNo(mblnr);
|
||||
targetObj.setCreator(SecurityUtils.getUserName());
|
||||
targetObj.setDateCreate(LocalDateTime.now());
|
||||
targetObj.setIsSap("1");
|
||||
// targetObj.setIsSap("1");
|
||||
R r = inventoryRecordMapper.apiUpdateById(targetObj);
|
||||
r.getMsg();
|
||||
}
|
||||
|
||||
@ -0,0 +1,429 @@
|
||||
package com.foreverwin.iep.integration.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.foreverwin.iep.common.faas.common.util.StringUtils;
|
||||
import com.foreverwin.iep.integration.domain.InvokeRequest;
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.integration.entity.*;
|
||||
import com.foreverwin.iep.integration.handler.def.sap.*;
|
||||
import com.foreverwin.iep.integration.mapper.OutSapShoporderStatisticsMapper;
|
||||
import com.foreverwin.iep.integration.service.*;
|
||||
import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction;
|
||||
import com.foreverwin.iep.prd.entity.ZLotMaterialConsumptionTransaction;
|
||||
import com.foreverwin.iep.prd.entity.ZShoporderStatisticsTransaction;
|
||||
import com.foreverwin.iep.prd.mapper.ZLotMaterialCompleteTransactionMapper;
|
||||
import com.foreverwin.iep.prd.mapper.ZLotMaterialConsumptionTransactionMapper;
|
||||
import com.foreverwin.iep.prd.mapper.ZShoporderStatisticsTransactionMapper;
|
||||
import com.foreverwin.iep.wip.entity.LotMaterial;
|
||||
import com.foreverwin.iep.wip.mapper.LotMaterialMapper;
|
||||
import com.foreverwin.mom.common.core.exception.BusinessException;
|
||||
import com.foreverwin.mom.common.core.util.R;
|
||||
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
|
||||
import com.foreverwin.mom.common.log.annotation.SysLog;
|
||||
import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import com.foreverwin.mom.wms.entity.InventoryRecord;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
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.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 生产管理报工平台
|
||||
*
|
||||
* @author mom code generator
|
||||
* @date 2024-11-11 10:06:18
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/outSapReport")
|
||||
@Api(value = "shopOrderStatisticTransCallErp", tags = "完工入库事务表管理")
|
||||
public class OutSapReportController {
|
||||
|
||||
private final ZShoporderStatisticsTransactionMapper zShoporderStatisticsTransactionMapper;
|
||||
private final ShopOrderStatisticTransService shopOrderStatisticTransService;
|
||||
private final ShopOrderStatisticTransCancelService shopOrderStatisticTransCancelService;
|
||||
private final ZLotMaterialConsumptionTransactionMapper zLotMaterialConsumptionTransactionMapper;
|
||||
private final ZLotMaterialCompleteTransactionMapper zLotMaterialCompleteTransactionMapper;
|
||||
private final IntInDataService intInDataService;
|
||||
private final IntInDataLogService intInDataLogService;
|
||||
private final RegisterDocumentService registerDocumentService;
|
||||
private final LotMaterialMapper lotMaterialMapper;
|
||||
private final OutMaterialSapService outMaterialSapService;
|
||||
private final OutSapShoporderStatisticsMapper outSapShoporderStatisticsMapper;
|
||||
private final OutShopOrderStatisticService outSapShoporderStatisticService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("ZMM_MES_GOODMVT_REVERSE") // 通过 Bean 名称注入
|
||||
private GoodMvtReverseService goodMvtReverseService;
|
||||
|
||||
@ApiOperation(value = "生产管理报工平台-工单报工", notes = "生产管理报工平台-工单报工")
|
||||
@SysLog("生产管理报工平台-工单报工")
|
||||
@PostMapping("/callErp")
|
||||
public R callErp(@RequestBody List<OutSapShoporderStatistics> shoporderStatisticsTransactionList) {
|
||||
InvokeResponse invokeResponse = new InvokeResponse();
|
||||
String site = TenantContextHolder.getTenantId();
|
||||
List<OutSapShoporderStatistics> newList = new ArrayList<>();
|
||||
String bat = SapUtil.noPrefixGenerateReqId();
|
||||
for (OutSapShoporderStatistics soStatisticsTrans : shoporderStatisticsTransactionList) {
|
||||
soStatisticsTrans.setSid(UUID.randomUUID().toString());
|
||||
soStatisticsTrans.setSite(site);
|
||||
soStatisticsTrans.setSyncTransBatch(bat);
|
||||
soStatisticsTrans.setCreator(SecurityUtils.getUserName());
|
||||
soStatisticsTrans.setDateCreate(LocalDateTime.now());
|
||||
soStatisticsTrans.setConfirmedDate(LocalDateTime.now());
|
||||
soStatisticsTrans.setConfirmedUser(SecurityUtils.getUserName());
|
||||
outSapShoporderStatisticsMapper.insert(soStatisticsTrans);
|
||||
newList.add(soStatisticsTrans);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(newList)) {
|
||||
// 传参对象
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
String nowTime = nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
String shopOrder = "";
|
||||
try {
|
||||
for (OutSapShoporderStatistics statisticsTransaction : newList) {
|
||||
shopOrder = statisticsTransaction.getShopOrder();
|
||||
invokeRequest.setTransSid(SapUtil.generateReqId());
|
||||
invokeRequest.setTransTime(nowTime);
|
||||
invokeRequest.setFromSystem("IEP");
|
||||
invokeRequest.setToSystem("ERP");
|
||||
invokeRequest.setSite(site);
|
||||
invokeRequest.setMessageId("ZPP_MES_PRODORDCONF");
|
||||
|
||||
// 组装抛送的报完呢
|
||||
String jsonObjectStr = SapUtil.appendHead(assembleMsgBody(statisticsTransaction));
|
||||
invokeRequest.setMessageContent(jsonObjectStr);
|
||||
invokeRequest.setStart(nowTime);
|
||||
invokeRequest.setKeyValue(statisticsTransaction.getSid());
|
||||
invokeRequest.setRetry(false);
|
||||
TenantContextHolder.setTenantId(site);
|
||||
invokeResponse = outSapShoporderStatisticService.call(invokeRequest);
|
||||
updateCallErp(invokeResponse.getObjectResponse(), newList, invokeResponse);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.build("工单" + shopOrder + "报工失败!" + invokeResponse.getMessageContent());
|
||||
} finally {
|
||||
// 保存日志
|
||||
saveLogData(invokeRequest, invokeResponse);
|
||||
}
|
||||
}
|
||||
if ("E".equals(invokeResponse.getResult())) {
|
||||
return R.failed(invokeResponse.getMessageContent());
|
||||
} else {
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
public void updateCallErp(JSONObject jsonObject, List<OutSapShoporderStatistics> srcList, InvokeResponse invokeResponse) {
|
||||
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
|
||||
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
|
||||
String result = outJson.getString("MSGTY");
|
||||
String message = outJson.getString("MSGTX");
|
||||
for (OutSapShoporderStatistics targetObj : srcList) {
|
||||
targetObj.setSyncTransBatch(outJson.getString("RUECK"));
|
||||
targetObj.setSyncTicketLine(outJson.getString("RMZHL"));
|
||||
targetObj.setSyncTicketNo(outJson.getString("VORNR"));
|
||||
targetObj.setErpReverse(result);
|
||||
targetObj.setSyncMessageRemark(outJson.getString("MSGID"));
|
||||
targetObj.setSyncMessageNo(outJson.getString("MSGNO"));
|
||||
targetObj.setSyncMessageText(message);
|
||||
targetObj.setUpdater(SecurityUtils.getUserName());
|
||||
targetObj.setDateUpdate(LocalDateTime.now());
|
||||
outSapShoporderStatisticsMapper.updateById(targetObj);
|
||||
}
|
||||
invokeResponse.setResult(result);
|
||||
invokeResponse.setMessageContent(message);
|
||||
}
|
||||
|
||||
private String assembleMsgBody(OutSapShoporderStatistics statisticsTransaction) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RFC_FUNCTION", "ZPP_MES_PRODORDCONF");
|
||||
JSONObject headRe = new JSONObject();
|
||||
headRe.put("EXCHANGE_SYSTEM", "MES");
|
||||
headRe.put("EXCHANGE_ID", SapUtil.generateReqId());
|
||||
headRe.put("EXCHANGE_DOC", "iMES_Call_SAP");
|
||||
jsonObject.put("REQUEST_CONTEXT", headRe);
|
||||
JSONObject bodyRe = new JSONObject();
|
||||
JSONObject isInput = new JSONObject();
|
||||
isInput.put("AUFNR", statisticsTransaction.getShopOrder());
|
||||
isInput.put("VORNR", statisticsTransaction.getOperation());
|
||||
isInput.put("PLNBEZ", statisticsTransaction.getItem());
|
||||
isInput.put("LMNGA", statisticsTransaction.getQtyDone());
|
||||
isInput.put("XMNGA", statisticsTransaction.getQtyScrapped());
|
||||
isInput.put("MEINH", statisticsTransaction.getMainUom());
|
||||
isInput.put("BUDAT", statisticsTransaction.getSyncPostingDate());
|
||||
isInput.put("ISM01", statisticsTransaction.getLaborTime());
|
||||
isInput.put("ILE01", "");
|
||||
isInput.put("ISM02", "");
|
||||
isInput.put("ILE02", "");
|
||||
isInput.put("ISM03", statisticsTransaction.getEnergy());
|
||||
isInput.put("ILE03", "");
|
||||
isInput.put("ISM04", statisticsTransaction.getAccessories());
|
||||
isInput.put("ILE04", "");
|
||||
isInput.put("ISM05", statisticsTransaction.getOthersQty());
|
||||
isInput.put("ILE05", "");
|
||||
bodyRe.put("IS_INPUT", isInput);
|
||||
jsonObject.put("REQUEST_BODY", bodyRe);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
// --------------------------------------------- 生产报工取消开始 -----------------------------------------------------
|
||||
@ApiOperation(value = "生产管理报工平台-工单取消报工", notes = "生产管理报工平台-工单取消报工")
|
||||
@SysLog("生产管理报工平台-工单取消报工")
|
||||
@PostMapping("/callErpCancel")
|
||||
public R callErpCancel(@RequestBody List<ZShoporderStatisticsTransaction> shoporderStatisticsTransactionList) {
|
||||
InvokeResponse invokeResponse = new InvokeResponse();
|
||||
List<ZShoporderStatisticsTransaction> newList = new ArrayList<>();
|
||||
for (ZShoporderStatisticsTransaction statisticsTransaction : shoporderStatisticsTransactionList) {
|
||||
if (StringUtils.isEmpty(statisticsTransaction.getSid())) {
|
||||
throw BusinessException.build("此笔数据还未报工无需取消报工");
|
||||
}
|
||||
// 重新校验一遍是否已经报过工,防止重复报工
|
||||
ZShoporderStatisticsTransaction targetObj = zShoporderStatisticsTransactionMapper.selectById(statisticsTransaction.getSid());
|
||||
if (targetObj == null || !"S".equals(targetObj.getSyncStatus())) {
|
||||
throw BusinessException.build("工单" + targetObj.getShopOrder() + "还未报工无需取消报工");
|
||||
} else if ("Y".equalsIgnoreCase(targetObj.getErpReverse())) {
|
||||
throw BusinessException.build("该笔数据已经冲销");
|
||||
} else {
|
||||
newList.add(targetObj);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(newList)) {
|
||||
// 传参对象
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
String nowTime = nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
String shopOrder = "";
|
||||
try {
|
||||
for (ZShoporderStatisticsTransaction statisticsTransaction : newList) {
|
||||
String site = statisticsTransaction.getSite();
|
||||
shopOrder = statisticsTransaction.getShopOrder();
|
||||
invokeRequest.setTransSid(SapUtil.generateReqId());
|
||||
invokeRequest.setTransTime(nowTime);
|
||||
invokeRequest.setFromSystem("IEP");
|
||||
invokeRequest.setToSystem("ERP");
|
||||
invokeRequest.setSite(site);
|
||||
invokeRequest.setMessageId("ZPP_MES_PRODOR_CANCEL");
|
||||
|
||||
// 组装抛送的报完呢
|
||||
String jsonObjectStr = SapUtil.appendHead(assembleCancelMsgBody(statisticsTransaction));
|
||||
invokeRequest.setMessageContent(jsonObjectStr);
|
||||
invokeRequest.setStart(nowTime);
|
||||
invokeRequest.setKeyValue(shopOrder);
|
||||
invokeRequest.setRetry(false);
|
||||
TenantContextHolder.setTenantId(site);
|
||||
invokeResponse = shopOrderStatisticTransCancelService.call(invokeRequest);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.build("工单" + shopOrder + "取消报工失败!");
|
||||
} finally {
|
||||
// 保存日志
|
||||
saveLogData(invokeRequest, invokeResponse);
|
||||
}
|
||||
}
|
||||
if ("E".equals(invokeResponse.getResult())) {
|
||||
return R.failed(invokeResponse.getMessageContent());
|
||||
} else {
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
private String assembleCancelMsgBody(ZShoporderStatisticsTransaction statisticsTransaction) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RFC_FUNCTION", "ZPP_MES_PRODOR_CANCEL");
|
||||
JSONObject headRe = new JSONObject();
|
||||
headRe.put("EXCHANGE_SYSTEM", "MES");
|
||||
headRe.put("EXCHANGE_ID", SapUtil.generateReqId());
|
||||
headRe.put("EXCHANGE_DOC", "iMES_Call_SAP");
|
||||
jsonObject.put("REQUEST_CONTEXT", headRe);
|
||||
JSONObject bodyRe = new JSONObject();
|
||||
JSONObject isInput = new JSONObject();
|
||||
isInput.put("AUFNR", statisticsTransaction.getShopOrder()); // 工单
|
||||
isInput.put("RUECK", statisticsTransaction.getSyncTransBatch()); // 操作完成的确认编号
|
||||
isInput.put("RMZHL", statisticsTransaction.getSyncTicketLine()); // 确认计算器
|
||||
isInput.put("VORNR", statisticsTransaction.getSyncTicketNo()); // 活动编号
|
||||
bodyRe.put("IS_INPUT", isInput);
|
||||
jsonObject.put("REQUEST_BODY", bodyRe);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
private void saveLogData(InvokeRequest invokeRequest, InvokeResponse invokeResponse) {
|
||||
if (StringUtils.isNotEmpty(invokeRequest.getTransSid())) {
|
||||
// 存储日志
|
||||
IntInData intInData = new IntInData();
|
||||
intInData.setSid(invokeRequest.getTransSid());
|
||||
intInData.setRequest(invokeRequest.getMessageContent());
|
||||
intInData.setFunctionName(invokeRequest.getMessageId());
|
||||
intInData.setKeyValue(invokeRequest.getKeyValue());
|
||||
intInData.setFromSystem(invokeRequest.getFromSystem());
|
||||
intInData.setToSystem(invokeRequest.getToSystem());
|
||||
intInData.setRetryCount(0);
|
||||
intInData.setSite(invokeRequest.getSite());
|
||||
intInData.setCreator(SecurityUtils.getUserName());
|
||||
intInData.setDateCreate(LocalDateTime.now());
|
||||
intInDataService.save(intInData);
|
||||
IntInDataLog log = new IntInDataLog();
|
||||
log.setSid(UUID.randomUUID().toString());
|
||||
log.setIntInDataSid(intInData.getSid());
|
||||
log.setCreator(SecurityUtils.getUserName());
|
||||
log.setDateCreate(LocalDateTime.now());
|
||||
log.setSeq(0);
|
||||
log.setMessage(StringUtils.isEmpty(invokeResponse.getMessageContent()) ? "N/A" : invokeResponse.getMessageContent());
|
||||
log.setResponse(invokeResponse.getObjectResponse().toJSONString());
|
||||
log.setState(invokeResponse.getResult());
|
||||
intInDataLogService.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------- 物料消耗报工开始 -----------------------------------------------
|
||||
@ApiOperation(value = "生产管理报工平台-物料消耗报工", notes = "生产管理报工平台-物料消耗报工")
|
||||
@SysLog("生产管理报工平台-物料消耗报工")
|
||||
@PostMapping("/callErpMaterial")
|
||||
public R callErpMaterial(@RequestBody List<OutSapMaterialLog> outSapMaterialLogs) {
|
||||
InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialConsumption(outSapMaterialLogs, false,"");
|
||||
if ("E".equals(invokeResponse.getResult())) {
|
||||
return R.failed("SAP错误:" + invokeResponse.getMessageContent());
|
||||
} else {
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------- 批次完工入库报工开始 -----------------------------------------------
|
||||
|
||||
@ApiOperation(value = "生产管理报工平台-批次完工入库获取SAP批次号", notes = "生产管理报工平台-批次完工入库获取SAP批次号")
|
||||
@SysLog("生产管理报工平台-批次完工入库获取SAP批次号")
|
||||
@PostMapping("/api/getSapBatchNo")
|
||||
public R<String> getSapBatchNo(@RequestBody String erpItem) {
|
||||
String sapBatchNo = registerDocumentService.getSapBatchNo(erpItem);
|
||||
return R.ok(sapBatchNo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "生产管理报工平台-批次完工入库报工", notes = "生产管理报工平台-批次完工入库报工")
|
||||
@SysLog("生产管理报工平台-批次完工入库报工")
|
||||
@PostMapping("/callErpLot")
|
||||
public R callErpLot(@RequestBody List<OutMaterialCompleteLog> outMaterialCompleteLogList) {
|
||||
InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialComplete(outMaterialCompleteLogList, false,"");
|
||||
if ("E".equals(invokeResponse.getResult())) {
|
||||
return R.failed("SAP错误:" + invokeResponse.getMessageContent());
|
||||
} else {
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "生产管理报工平台-物料消耗冲销", notes = "生产管理报工平台-物料消耗冲销")
|
||||
@SysLog("生产管理报工平台-物料消耗冲销")
|
||||
@PostMapping("/callErpLotCancel")
|
||||
public R callErpLotCancel(@RequestBody List<ZLotMaterialConsumptionTransaction> lotMaterialConsumptionTransactions) {
|
||||
for (ZLotMaterialConsumptionTransaction consumptionTransaction : lotMaterialConsumptionTransactions) {
|
||||
// 重新校验一遍是否已经报过工,防止重复报工
|
||||
ZLotMaterialConsumptionTransaction targetObj = zLotMaterialConsumptionTransactionMapper.selectById(consumptionTransaction.getSid());
|
||||
if ("S".equals(targetObj.getSyncStatus()) && "Y".equals(targetObj.getErpReverse())) {
|
||||
throw BusinessException.build("批次" + targetObj.getLotNo() + "完工已经报工且已冲销,不可重复冲销");
|
||||
} else if ("S".equals(targetObj.getSyncStatus())) {
|
||||
InvokeResponse invokeResponse = sendSapToCancel(targetObj.getSyncVoucherNo());
|
||||
if (!"S".equals(invokeResponse.getResult())) {
|
||||
return R.failed("SAP错误:" + invokeResponse.getMessageContent());
|
||||
} else {
|
||||
// 更新lotMaterial表
|
||||
targetObj.setErpReverse("Y");
|
||||
zLotMaterialConsumptionTransactionMapper.updateById(targetObj);
|
||||
LotMaterial lotMaterial = lotMaterialMapper.selectById(targetObj.getLotMaterialSid());
|
||||
if (lotMaterial != null) {
|
||||
lotMaterial.setQty(BigDecimal.ZERO);
|
||||
lotMaterialMapper.updateById(lotMaterial);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw BusinessException.build("批次" + targetObj.getLotNo() + "还未报工,不可冲销");
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "生产管理报工平台-完工入库冲销", notes = "生产管理报工平台-完工入库冲销")
|
||||
@SysLog("生产管理报工平台-完工入库冲销")
|
||||
@PostMapping("/callErpLotInStockCancel")
|
||||
public R callErpLotInStockCancel(@RequestBody List<ZLotMaterialCompleteTransaction> lotMaterialCompleteTransactions) {
|
||||
for (ZLotMaterialCompleteTransaction completeTransaction : lotMaterialCompleteTransactions) {
|
||||
// 重新校验一遍是否已经报过工,防止重复报工
|
||||
ZLotMaterialCompleteTransaction targetObj = zLotMaterialCompleteTransactionMapper.selectById(completeTransaction.getSid());
|
||||
if ("S".equals(targetObj.getSyncStatus()) && "Y".equals(targetObj.getErpReverse())) {
|
||||
throw BusinessException.build("批次" + targetObj.getLotNo() + "完工已经报工且已冲销,不可重复冲销");
|
||||
} else if ("S".equals(targetObj.getSyncStatus())) {
|
||||
InvokeResponse invokeResponse = sendSapToCancel(targetObj.getSyncVoucherNo());
|
||||
if (!"S".equals(invokeResponse.getResult())) {
|
||||
return R.failed("SAP错误:" + invokeResponse.getMessageContent());
|
||||
} else {
|
||||
// 更新冲销标识
|
||||
targetObj.setErpReverse("Y");
|
||||
zLotMaterialCompleteTransactionMapper.updateById(targetObj);
|
||||
}
|
||||
} else {
|
||||
throw BusinessException.build("批次" + targetObj.getLotNo() + "还未报工,不可冲销");
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
private InvokeResponse sendSapToCancel(String syncVoucherNo) {
|
||||
InvokeResponse invokeResponse = new InvokeResponse();
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
// 传参对象
|
||||
try {
|
||||
String messageId = "ZMM_MES_GOODMVT_REVERSE";
|
||||
LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
String nowTime = nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
invokeRequest.setTransSid(SapUtil.generateReqId());
|
||||
invokeRequest.setTransTime(nowTime); // 设定过账日期
|
||||
invokeRequest.setFromSystem("IEP");
|
||||
invokeRequest.setToSystem("ERP");
|
||||
invokeRequest.setSite(TenantContextHolder.getTenantId());
|
||||
invokeRequest.setMessageId(messageId);
|
||||
|
||||
String postingDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RFC_FUNCTION", messageId);
|
||||
JSONObject headRe = new JSONObject();
|
||||
headRe.put("EXCHANGE_SYSTEM", "MES");
|
||||
headRe.put("EXCHANGE_ID", SapUtil.generateReqId());
|
||||
headRe.put("EXCHANGE_DOC", "iMES_Call_SAP");
|
||||
jsonObject.put("REQUEST_CONTEXT", headRe);
|
||||
JSONObject bodyRe = new JSONObject();
|
||||
JSONObject isInput = new JSONObject();
|
||||
isInput.put("MBLNR", syncVoucherNo); // 物料凭证编号
|
||||
isInput.put("ZPARTNER", SecurityUtils.getUserName()); // 员工BP编号
|
||||
isInput.put("BUDAT", postingDate); // 凭证中的过账日期
|
||||
bodyRe.put("IS_INPUT", isInput);
|
||||
jsonObject.put("REQUEST_BODY", bodyRe);
|
||||
|
||||
// 组装抛送的报完呢
|
||||
String jsonObjectStr = SapUtil.appendHead(jsonObject.toJSONString());
|
||||
invokeRequest.setMessageContent(jsonObjectStr);
|
||||
invokeRequest.setStart(nowTime);
|
||||
invokeRequest.setKeyValue(nowTime);
|
||||
invokeRequest.setRetry(false);
|
||||
invokeResponse = goodMvtReverseService.call(invokeRequest);
|
||||
} catch (Exception e) {
|
||||
// 不用回滚,将错误抛出
|
||||
invokeResponse.setResult("E");
|
||||
invokeResponse.setMessageContent(e.getMessage());
|
||||
}
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
package com.foreverwin.iep.integration.handler.def.sap;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foreverwin.iep.integration.domain.InvokeRequest;
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.integration.service.HandlerService;
|
||||
import com.foreverwin.iep.integration.utils.JS;
|
||||
import com.foreverwin.iep.integration.utils.Local;
|
||||
import com.foreverwin.iep.prd.entity.ZShoporderStatisticsTransaction;
|
||||
import com.foreverwin.iep.prd.mapper.ZShoporderStatisticsTransactionMapper;
|
||||
import com.foreverwin.mom.common.core.exception.BusinessException;
|
||||
import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 生产订单报工接口
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service("OUT_ZPP_MES_PRODORDCONF")
|
||||
public class OutShopOrderStatisticService implements HandlerService {
|
||||
|
||||
private final ZShoporderStatisticsTransactionMapper zShoporderStatisticsTransactionMapper;
|
||||
|
||||
@Override
|
||||
public InvokeResponse call(InvokeRequest invokeRequest) {
|
||||
InvokeResponse invokeResponse = new InvokeResponse(invokeRequest);
|
||||
try {
|
||||
// 处理响应
|
||||
invokeResponse = SapUtil.sendSap(invokeRequest.getMessageContent());
|
||||
invokeResponse.setTransSid(invokeRequest.getTransSid());
|
||||
invokeResponse.setTransTime(Local.now());
|
||||
if(!"E".equals(invokeResponse.getResult())){
|
||||
// 请求处理成功
|
||||
JSONObject jsonObject = invokeResponse.getObjectResponse();
|
||||
// 处理结果事务
|
||||
invokeResponse = updateShopOrderStatistic(jsonObject,invokeRequest.getKeyValue(),invokeResponse);
|
||||
}
|
||||
return invokeResponse;
|
||||
} catch (Exception e) {
|
||||
invokeResponse.setResult("E");
|
||||
invokeResponse.setMessageContent(e.getMessage());
|
||||
return invokeResponse;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String validation(InvokeRequest invokeRequest) {
|
||||
JSONObject jsonObject = JS.parseObject(invokeRequest.getMessageContent());
|
||||
return null;
|
||||
}
|
||||
|
||||
public InvokeResponse updateShopOrderStatistic(JSONObject jsonObject, String sid, InvokeResponse invokeResponse) {
|
||||
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
|
||||
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
|
||||
String result = outJson.getString("MSGTY");
|
||||
invokeResponse.setResult(result);
|
||||
String message = outJson.getString("MSGTX");
|
||||
invokeResponse.setMessageContent(message);
|
||||
return invokeResponse;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.foreverwin.iep.integration.service;
|
||||
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.integration.entity.OutMaterialCompleteLog;
|
||||
import com.foreverwin.iep.integration.entity.OutSapMaterialLog;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OutMaterialSapService {
|
||||
|
||||
InvokeResponse callLotMaterialComplete(List<OutMaterialCompleteLog> outMaterialCompleteLogs, boolean isPass, String postingDate);
|
||||
|
||||
InvokeResponse callLotMaterialConsumption(List<OutSapMaterialLog> outSapMaterialLogs, boolean isPass, String postingDate);
|
||||
}
|
||||
@ -0,0 +1,298 @@
|
||||
package com.foreverwin.iep.integration.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foreverwin.iep.common.faas.common.util.StringUtils;
|
||||
import com.foreverwin.iep.integration.domain.InvokeRequest;
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.integration.entity.OutMaterialCompleteLog;
|
||||
import com.foreverwin.iep.integration.entity.OutSapMaterialLog;
|
||||
import com.foreverwin.iep.integration.handler.def.sap.GoodMvtCreateService;
|
||||
import com.foreverwin.iep.integration.handler.def.sap.SapUtil;
|
||||
import com.foreverwin.iep.integration.mapper.OutSapCompleteMapper;
|
||||
import com.foreverwin.iep.integration.mapper.OutSapMaterialMapper;
|
||||
import com.foreverwin.iep.integration.service.OutMaterialSapService;
|
||||
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
|
||||
import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class OutMaterialSapServiceImpl implements OutMaterialSapService {
|
||||
|
||||
private final GoodMvtCreateService goodMvtCreateService;
|
||||
private final OutSapCompleteMapper outSapCompleteMapper ;
|
||||
private final OutSapMaterialMapper outSapMaterialMapper;
|
||||
|
||||
private final String messageId = "ZMM_MES_GOODSMVT_CREATE";
|
||||
|
||||
@Override
|
||||
public InvokeResponse callLotMaterialComplete(List<OutMaterialCompleteLog> outMaterialCompleteLogs, boolean isPass, String postingDate) {
|
||||
InvokeResponse invokeResponse = new InvokeResponse();
|
||||
List<OutMaterialCompleteLog> newOneZeroOneList = new ArrayList<>();
|
||||
List<OutMaterialCompleteLog> newFiveThreeOneList = new ArrayList<>();
|
||||
String site = "";
|
||||
JSONArray oneZeroOneList = new JSONArray();
|
||||
JSONArray fiveThreeOneList = new JSONArray();
|
||||
List<OutMaterialCompleteLog> srcList = new ArrayList<>();
|
||||
for (OutMaterialCompleteLog completeTransaction : outMaterialCompleteLogs) {
|
||||
// 重新校验一遍是否已经报过工,防止重复报工
|
||||
OutMaterialCompleteLog targetObj = completeTransaction;
|
||||
|
||||
if (StringUtils.isEmpty(postingDate)) {
|
||||
postingDate = completeTransaction.getSyncPostingDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
} else {
|
||||
completeTransaction.setSyncPostingDate(LocalDate.parse(postingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
}
|
||||
targetObj.setSyncPostingDate(completeTransaction.getSyncPostingDate());
|
||||
srcList.add(targetObj);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
site = completeTransaction.getSite();
|
||||
jsonObject.put("ZEILE", null); // 物料凭证中的项目
|
||||
jsonObject.put("MATNR", completeTransaction.getErpItem()); // 物料编号
|
||||
jsonObject.put("MATKL", ""); // 物料组
|
||||
jsonObject.put("WERKS", site); // 工厂
|
||||
jsonObject.put("LGORT", completeTransaction.getErpInventory()); // 存储地点
|
||||
jsonObject.put("CHARG", completeTransaction.getSapBatchNo()); // 批次号
|
||||
jsonObject.put("BWART", completeTransaction.getProductType()); // 移动类型
|
||||
jsonObject.put("SOBKZ", ""); // 特殊库存标识
|
||||
jsonObject.put("AUFNR", completeTransaction.getShopOrder()); // 订单号
|
||||
jsonObject.put("EBELN", ""); // 采购订单号
|
||||
jsonObject.put("EBELP", ""); // 采购凭证的项目编号
|
||||
jsonObject.put("MENGE", completeTransaction.getMainQty()); // 数量
|
||||
jsonObject.put("MEINS", completeTransaction.getMainUom()); // 基本计量单位
|
||||
if (StringUtils.isEmpty(completeTransaction.getSubUom()) || completeTransaction.getSubQty() == null) {
|
||||
jsonObject.put("ERFMG", null); // 以录入项单位表示的数量
|
||||
jsonObject.put("ERFME", ""); // 录入单位
|
||||
} else {
|
||||
jsonObject.put("ERFMG", completeTransaction.getSubQty()); // 以录入项单位表示的数量
|
||||
jsonObject.put("ERFME", completeTransaction.getSubUom()); // 录入单位
|
||||
}
|
||||
jsonObject.put("MAT_KDAUF", completeTransaction.getSoNo()); // 评估销售定单库存的销售定单号
|
||||
if (StringUtils.isNotEmpty(completeTransaction.getSoLineNo())) {
|
||||
jsonObject.put("MAT_KDPOS", Integer.valueOf(completeTransaction.getSoLineNo())); // 评估销售订单库存的销售订单项目
|
||||
} else {
|
||||
jsonObject.put("MAT_KDPOS", null); // 评估销售订单库存的销售订单项目
|
||||
}
|
||||
jsonObject.put("UMWRK", ""); // 收货工厂/发货工厂
|
||||
jsonObject.put("UMLGO", ""); // 收货/发货库存地点
|
||||
jsonObject.put("UMCHA", ""); // 收货/发货批量
|
||||
jsonObject.put("RSNUM", ""); // 预留/相关需求的编号
|
||||
jsonObject.put("RSPOS", ""); // 预留 / 相关需求的项目编号
|
||||
jsonObject.put("Z_JH", completeTransaction.getLotNo()); // 卷号
|
||||
jsonObject.put("Z_CVN", completeTransaction.getExternalLot()); // 客户卷号
|
||||
jsonObject.put("Z_GRADE", completeTransaction.getQcGrade()); // 等级
|
||||
if ("101".equals(completeTransaction.getProductType())) {
|
||||
oneZeroOneList.add(jsonObject);
|
||||
newOneZeroOneList.add(targetObj);
|
||||
} else if ("531".equals(completeTransaction.getProductType())) {
|
||||
fiveThreeOneList.add(jsonObject);
|
||||
newFiveThreeOneList.add(targetObj);
|
||||
}
|
||||
}
|
||||
|
||||
if (oneZeroOneList.size() > 0) {
|
||||
invokeResponse = sendSap(invokeResponse, site, oneZeroOneList, postingDate, newOneZeroOneList);
|
||||
} else {
|
||||
invokeResponse.setResult("S");
|
||||
}
|
||||
if ("S".equals(invokeResponse.getResult()) && fiveThreeOneList.size() > 0) {
|
||||
invokeResponse = sendSap(invokeResponse, site, fiveThreeOneList, postingDate, newFiveThreeOneList);
|
||||
}
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
public InvokeResponse sendSap(InvokeResponse invokeResponse, String site, JSONArray itemList, String postingDate, List<OutMaterialCompleteLog> srcList) {
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
// 传参对象
|
||||
try {
|
||||
LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
String nowTime = nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
invokeRequest.setTransSid(SapUtil.generateReqId());
|
||||
invokeRequest.setTransTime(nowTime); // 设定过账日期
|
||||
invokeRequest.setFromSystem("IEP");
|
||||
invokeRequest.setToSystem("ERP");
|
||||
invokeRequest.setSite(site);
|
||||
invokeRequest.setMessageId(messageId);
|
||||
|
||||
// 组装抛送的报完呢
|
||||
String jsonObjectStr = SapUtil.appendHead(assembleMaterialMsgBody(itemList, postingDate));
|
||||
invokeRequest.setMessageContent(jsonObjectStr);
|
||||
invokeRequest.setStart(nowTime);
|
||||
invokeRequest.setKeyValue(nowTime);
|
||||
invokeRequest.setRetry(false);
|
||||
TenantContextHolder.setTenantId(site);
|
||||
invokeResponse = goodMvtCreateService.call(invokeRequest);
|
||||
// 处理ERP返回的报文
|
||||
invokeResponse = updateLotComplete(invokeResponse.getObjectResponse(), srcList, invokeResponse);
|
||||
} catch (Exception e) {
|
||||
// 不用回滚,将错误抛出
|
||||
invokeResponse.setResult("E");
|
||||
invokeResponse.setMessageContent(e.getMessage());
|
||||
}
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
|
||||
// 凭证中的过账日期 yyyy-MM-dd
|
||||
private String assembleMaterialMsgBody(JSONArray itemList, String postingDate) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RFC_FUNCTION", messageId);
|
||||
JSONObject headRe = new JSONObject();
|
||||
headRe.put("EXCHANGE_SYSTEM", "MES");
|
||||
headRe.put("EXCHANGE_ID", SapUtil.generateReqId());
|
||||
headRe.put("EXCHANGE_DOC", "iMES_Call_SAP");
|
||||
jsonObject.put("REQUEST_CONTEXT", headRe);
|
||||
JSONObject bodyRe = new JSONObject();
|
||||
JSONObject headBody = new JSONObject();
|
||||
headBody.put("ZPARTNER", SecurityUtils.getUserName()); // 员工BP编号
|
||||
headBody.put("BUDAT", postingDate); // 凭证中的过账日期
|
||||
bodyRe.put("IS_HEAD", headBody);
|
||||
bodyRe.put("IT_ITEM", itemList);
|
||||
jsonObject.put("REQUEST_BODY", bodyRe);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
public InvokeResponse updateLotComplete(JSONObject jsonObject, List<OutMaterialCompleteLog> srcList, InvokeResponse invokeResponse) {
|
||||
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
|
||||
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
|
||||
String result = outJson.getString("MSGTY");
|
||||
String message = outJson.getString("MSGTX");
|
||||
String msgNo = outJson.getString("MSGNO");
|
||||
String mblnr = outJson.getString("MBLNR"); // 物料凭证编号
|
||||
for (OutMaterialCompleteLog targetObj : srcList) {
|
||||
targetObj.setSyncStatus(result);
|
||||
targetObj.setSyncMsgText(message);
|
||||
targetObj.setSyncMsgNo(msgNo);
|
||||
targetObj.setSyncVoucherNo(mblnr);
|
||||
targetObj.setSyncSubmitter(SecurityUtils.getUserName());
|
||||
targetObj.setCreator(SecurityUtils.getUserName());
|
||||
targetObj.setDateCreate(LocalDateTime.now());
|
||||
targetObj.setDateUpdate(LocalDateTime.now());
|
||||
outSapCompleteMapper.insert(targetObj);
|
||||
}
|
||||
invokeResponse.setResult(result);
|
||||
invokeResponse.setMessageContent(message);
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------- 物料消耗报工开始 ----------------------------------------------------------
|
||||
@Override
|
||||
public InvokeResponse callLotMaterialConsumption(List<OutSapMaterialLog> outSapMaterialLogs, boolean isPass, String postingDate) {
|
||||
InvokeResponse invokeResponse = new InvokeResponse();
|
||||
String site = "";
|
||||
JSONArray itemList = new JSONArray();
|
||||
List<OutSapMaterialLog> srcList = new ArrayList<>();
|
||||
for (OutSapMaterialLog consumptionTransaction : outSapMaterialLogs) {
|
||||
OutSapMaterialLog targetObj = consumptionTransaction;
|
||||
if (StringUtils.isEmpty(postingDate)) {
|
||||
postingDate = consumptionTransaction.getSyncPostingDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
} else {
|
||||
consumptionTransaction.setSyncPostingDate(LocalDate.parse(postingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
}
|
||||
targetObj.setSyncPostingDate(consumptionTransaction.getSyncPostingDate());
|
||||
srcList.add(targetObj);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
site = consumptionTransaction.getSite();
|
||||
jsonObject.put("ZEILE", ""); // 物料凭证中的项目
|
||||
jsonObject.put("MATNR", consumptionTransaction.getComponentItem()); // 物料编号
|
||||
jsonObject.put("MATKL", ""); // 物料组
|
||||
jsonObject.put("WERKS", site); // 工厂
|
||||
jsonObject.put("LGORT", consumptionTransaction.getErpInventory()); // 存储地点
|
||||
jsonObject.put("CHARG", consumptionTransaction.getSapBatchNo()); // 批次号
|
||||
jsonObject.put("BWART", "261"); // 移动类型
|
||||
jsonObject.put("SOBKZ", ""); // 特殊库存标识
|
||||
jsonObject.put("AUFNR", consumptionTransaction.getShopOrder()); // 订单号
|
||||
jsonObject.put("EBELN", ""); // 采购订单号
|
||||
jsonObject.put("EBELP", ""); // 采购凭证的项目编号
|
||||
jsonObject.put("MENGE", consumptionTransaction.getMainQty()); // 数量
|
||||
jsonObject.put("MEINS", consumptionTransaction.getMainUom()); // 基本计量单位
|
||||
if (StringUtils.isEmpty(consumptionTransaction.getSubUom()) || consumptionTransaction.getSubQty() == null) {
|
||||
jsonObject.put("ERFMG", null); // 以录入项单位表示的数量
|
||||
jsonObject.put("ERFME", ""); // 录入单位
|
||||
} else {
|
||||
jsonObject.put("ERFMG", consumptionTransaction.getSubQty()); // 以录入项单位表示的数量
|
||||
jsonObject.put("ERFME", consumptionTransaction.getSubUom()); // 录入单位
|
||||
}
|
||||
jsonObject.put("MAT_KDAUF", ""); // 评估销售定单库存的销售定单号
|
||||
jsonObject.put("MAT_KDPOS", ""); // 评估销售订单库存的销售订单项目
|
||||
jsonObject.put("UMWRK", ""); // 收货工厂/发货工厂
|
||||
jsonObject.put("UMLGO", ""); // 收货/发货库存地点
|
||||
jsonObject.put("UMCHA", ""); // 收货/发货批量
|
||||
jsonObject.put("RSNUM", consumptionTransaction.getReservedNo()); // 预留/相关需求的编号
|
||||
jsonObject.put("RSPOS", consumptionTransaction.getReservedLine()); // 预留 / 相关需求的项目编号
|
||||
itemList.add(jsonObject);
|
||||
}
|
||||
|
||||
if (itemList.size() > 0) {
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
// 传参对象
|
||||
try {
|
||||
LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
String nowTime = nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
invokeRequest.setTransSid(SapUtil.generateReqId());
|
||||
invokeRequest.setTransTime(nowTime);
|
||||
invokeRequest.setFromSystem("IEP");
|
||||
invokeRequest.setToSystem("ERP");
|
||||
invokeRequest.setSite(site);
|
||||
invokeRequest.setMessageId(messageId);
|
||||
|
||||
// 组装抛送的报完呢
|
||||
String jsonObjectStr = SapUtil.appendHead(assembleMaterialMsgBody(itemList, postingDate));
|
||||
invokeRequest.setMessageContent(jsonObjectStr);
|
||||
invokeRequest.setStart(nowTime);
|
||||
invokeRequest.setKeyValue(nowTime);
|
||||
invokeRequest.setRetry(false);
|
||||
TenantContextHolder.setTenantId(site);
|
||||
invokeResponse = goodMvtCreateService.call(invokeRequest);
|
||||
// 处理ERP返回的报文
|
||||
invokeResponse = updateMaterialConsumption(invokeResponse.getObjectResponse(), srcList, invokeResponse);
|
||||
} catch (Exception e) {
|
||||
// 不用回滚,将错误抛出
|
||||
invokeResponse.setResult("E");
|
||||
invokeResponse.setMessageContent(e.getMessage());
|
||||
}
|
||||
}
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
public InvokeResponse updateMaterialConsumption(JSONObject jsonObject, List<OutSapMaterialLog> srcList, InvokeResponse invokeResponse) {
|
||||
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
|
||||
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
|
||||
String result = outJson.getString("MSGTY");
|
||||
String message = outJson.getString("MSGTX");
|
||||
String msgno = outJson.getString("MSGNO"); // 系统消息编号
|
||||
String mblnr = outJson.getString("MBLNR"); // 物料凭证编号
|
||||
for (OutSapMaterialLog targetObj : srcList) {
|
||||
targetObj.setSyncStatus(result);
|
||||
targetObj.setSyncMsgText(message);
|
||||
targetObj.setSyncMsgNo(msgno);
|
||||
targetObj.setSyncSubmitter(SecurityUtils.getUserName());
|
||||
targetObj.setSyncVoucherNo(mblnr);
|
||||
targetObj.setUpdater(SecurityUtils.getUserName());
|
||||
targetObj.setDateCreate(LocalDateTime.now());
|
||||
targetObj.setCreator(SecurityUtils.getUserName());
|
||||
outSapMaterialMapper.insert(targetObj);
|
||||
// 如果报工成功,就更新消耗表的erp标识为Y
|
||||
// if ("S".equalsIgnoreCase(result)) {
|
||||
// LotMaterial lotMaterial = lotMaterialMapper.selectById(targetObj.getLotMaterialSid());
|
||||
// if (lotMaterial != null) {
|
||||
// lotMaterial.setErpFlag("Y");
|
||||
// lotMaterialMapper.updateById(lotMaterial);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
invokeResponse.setResult(result);
|
||||
invokeResponse.setMessageContent(message);
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.foreverwin.iep.integration.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.foreverwin.iep.integration.entity.OutMaterialCompleteLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 完工入库事务表
|
||||
*
|
||||
* @author Snow
|
||||
* @date 2024-11-11 10:40:03
|
||||
*/
|
||||
@Mapper
|
||||
public interface OutSapCompleteMapper extends BaseMapper<OutMaterialCompleteLog> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.foreverwin.iep.integration.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.foreverwin.iep.integration.entity.OutSapMaterialLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 物料消耗事务表
|
||||
*
|
||||
* @author Snow
|
||||
* @date 2024-11-10 17:14:03
|
||||
*/
|
||||
@Mapper
|
||||
public interface OutSapMaterialMapper extends BaseMapper<OutSapMaterialLog> {
|
||||
|
||||
// OutSapMaterialLog selectBySapBatchNo(String sapBatchNo);
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.foreverwin.iep.integration.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.foreverwin.iep.integration.entity.OutSapShoporderStatistics;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface OutSapShoporderStatisticsMapper extends BaseMapper<OutSapShoporderStatistics> {
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user