浏览代码

Merge remote-tracking branch 'origin/master'

lipenghui 1 天之前
父节点
当前提交
ce93360d2f
共有 11 个文件被更改,包括 829 次插入62 次删除
  1. 1 0
      yudao-module-pms/yudao-module-pms-api/src/main/java/cn/iocoder/yudao/module/pms/enums/ErrorCodeConstant.java
  2. 93 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotsapstocklog/IotSapStockLogController.java
  3. 101 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotsapstocklog/vo/IotSapStockLogPageReqVO.java
  4. 124 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotsapstocklog/vo/IotSapStockLogRespVO.java
  5. 91 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotsapstocklog/vo/IotSapStockLogSaveReqVO.java
  6. 133 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotsapstocklog/IotSapStockLogDO.java
  7. 49 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotsapstocklog/IotSapStockLogMapper.java
  8. 110 62
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/sap/service/IotSapServiceImpl.java
  9. 55 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotsapstocklog/IotSapStockLogService.java
  10. 71 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotsapstocklog/IotSapStockLogServiceImpl.java
  11. 1 0
      yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotDeviceMapper.xml

+ 1 - 0
yudao-module-pms/yudao-module-pms-api/src/main/java/cn/iocoder/yudao/module/pms/enums/ErrorCodeConstant.java

@@ -91,4 +91,5 @@ public interface ErrorCodeConstant{
     ErrorCode IOT_RH_DAILY_REPORT_NO_DEPT = new ErrorCode(266, "未传递运行记录所属部门");
     ErrorCode IOT_RY_DAILY_REPORT_NOT_EXISTS = new ErrorCode(267, "瑞鹰日报不存在");
     ErrorCode IOT_RY_DAILY_REPORT_CURRENT_DEPTH_NOT_EXISTS = new ErrorCode(268, "未传递运行记录当前井深");
+    ErrorCode IOT_SAP_STOCK_LOG_NOT_EXISTS = new ErrorCode(269, "PMS SAP 库存(sap同步的原始数据日志)不存在");
 }

+ 93 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotsapstocklog/IotSapStockLogController.java

@@ -0,0 +1,93 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo.IotSapStockLogPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo.IotSapStockLogRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo.IotSapStockLogSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstocklog.IotSapStockLogDO;
+import cn.iocoder.yudao.module.pms.service.iotsapstocklog.IotSapStockLogService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.IOException;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Tag(name = "管理后台 - PMS SAP 库存(sap同步的原始数据日志)")
+@RestController
+@RequestMapping("/pms/iot-sap-stock-log")
+@Validated
+public class IotSapStockLogController {
+
+    @Resource
+    private IotSapStockLogService iotSapStockLogService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建PMS SAP 库存(sap同步的原始数据日志)")
+    @PreAuthorize("@ss.hasPermission('pms:iot-sap-stock-log:create')")
+    public CommonResult<Long> createIotSapStockLog(@Valid @RequestBody IotSapStockLogSaveReqVO createReqVO) {
+        return success(iotSapStockLogService.createIotSapStockLog(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新PMS SAP 库存(sap同步的原始数据日志)")
+    @PreAuthorize("@ss.hasPermission('pms:iot-sap-stock-log:update')")
+    public CommonResult<Boolean> updateIotSapStockLog(@Valid @RequestBody IotSapStockLogSaveReqVO updateReqVO) {
+        iotSapStockLogService.updateIotSapStockLog(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除PMS SAP 库存(sap同步的原始数据日志)")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('pms:iot-sap-stock-log:delete')")
+    public CommonResult<Boolean> deleteIotSapStockLog(@RequestParam("id") Long id) {
+        iotSapStockLogService.deleteIotSapStockLog(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得PMS SAP 库存(sap同步的原始数据日志)")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('pms:iot-sap-stock-log:query')")
+    public CommonResult<IotSapStockLogRespVO> getIotSapStockLog(@RequestParam("id") Long id) {
+        IotSapStockLogDO iotSapStockLog = iotSapStockLogService.getIotSapStockLog(id);
+        return success(BeanUtils.toBean(iotSapStockLog, IotSapStockLogRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得PMS SAP 库存(sap同步的原始数据日志)分页")
+    @PreAuthorize("@ss.hasPermission('pms:iot-sap-stock-log:query')")
+    public CommonResult<PageResult<IotSapStockLogRespVO>> getIotSapStockLogPage(@Valid IotSapStockLogPageReqVO pageReqVO) {
+        PageResult<IotSapStockLogDO> pageResult = iotSapStockLogService.getIotSapStockLogPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, IotSapStockLogRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出PMS SAP 库存(sap同步的原始数据日志) Excel")
+    @PreAuthorize("@ss.hasPermission('pms:iot-sap-stock-log:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotSapStockLogExcel(@Valid IotSapStockLogPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<IotSapStockLogDO> list = iotSapStockLogService.getIotSapStockLogPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "PMS SAP 库存(sap同步的原始数据日志).xls", "数据", IotSapStockLogRespVO.class,
+                        BeanUtils.toBean(list, IotSapStockLogRespVO.class));
+    }
+
+}

+ 101 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotsapstocklog/vo/IotSapStockLogPageReqVO.java

@@ -0,0 +1,101 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - PMS SAP 库存(sap同步的原始数据日志)分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IotSapStockLogPageReqVO extends PageParam {
+
+    @Schema(description = "组织部门id", example = "15891")
+    private Long deptId;
+
+    @Schema(description = "sap工厂编号")
+    private String factoryCode;
+
+    @Schema(description = "工厂id (system_sap_org表id)", example = "24138")
+    private Long factoryId;
+
+    @Schema(description = "工厂(SAP) 专业公司")
+    private String factory;
+
+    @Schema(description = "SAP库存地点编码")
+    private String storageLocationCode;
+
+    @Schema(description = "库存地点id", example = "27743")
+    private Long storageLocationId;
+
+    @Schema(description = "库存地点 - SAP 部门 项目部级 通用库 项目部库")
+    private String projectDepartment;
+
+    @Schema(description = "物料编码")
+    private String materialCode;
+
+    @Schema(description = "物料名称", example = "赵六")
+    private String materialName;
+
+    @Schema(description = "物料组", example = "赵六")
+    private String materialGroupName;
+
+    @Schema(description = "物料组id", example = "21077")
+    private Long materialGroupId;
+
+    @Schema(description = "数量")
+    private BigDecimal quantity;
+
+    @Schema(description = "单价", example = "14247")
+    private BigDecimal unitPrice;
+
+    @Schema(description = "单位")
+    private String unit;
+
+    @Schema(description = "安全库存")
+    private BigDecimal safetyStock;
+
+    @Schema(description = "库区id", example = "16041")
+    private Long storageAreaId;
+
+    @Schema(description = "货架id", example = "5170")
+    private Long shelvesId;
+
+    @Schema(description = "库位id", example = "32430")
+    private Long cargoLocationId;
+
+    @Schema(description = "类型(通用库 项目部库)", example = "2")
+    private Integer type;
+
+    @Schema(description = "同步状态 0未同步 1同步成功 2同步失败", example = "2")
+    private Integer syncStatus;
+
+    @Schema(description = "最后一次同步时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] syncTime;
+
+    @Schema(description = "同步失败时的错误信息")
+    private String syncError;
+
+    @Schema(description = "排序")
+    private Integer sort;
+
+    @Schema(description = "状态 0启用  1停用", example = "2")
+    private Integer status;
+
+    @Schema(description = "备注", example = "随便")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 124 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotsapstocklog/vo/IotSapStockLogRespVO.java

@@ -0,0 +1,124 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - PMS SAP 库存(sap同步的原始数据日志) Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotSapStockLogRespVO {
+
+    @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "22454")
+    @ExcelProperty("主键")
+    private Long id;
+
+    @Schema(description = "组织部门id", example = "15891")
+    @ExcelProperty("组织部门id")
+    private Long deptId;
+
+    @Schema(description = "sap工厂编号")
+    @ExcelProperty("sap工厂编号")
+    private String factoryCode;
+
+    @Schema(description = "工厂id (system_sap_org表id)", example = "24138")
+    @ExcelProperty("工厂id (system_sap_org表id)")
+    private Long factoryId;
+
+    @Schema(description = "工厂(SAP) 专业公司")
+    @ExcelProperty("工厂(SAP) 专业公司")
+    private String factory;
+
+    @Schema(description = "SAP库存地点编码")
+    @ExcelProperty("SAP库存地点编码")
+    private String storageLocationCode;
+
+    @Schema(description = "库存地点id", example = "27743")
+    @ExcelProperty("库存地点id")
+    private Long storageLocationId;
+
+    @Schema(description = "库存地点 - SAP 部门 项目部级 通用库 项目部库")
+    @ExcelProperty("库存地点 - SAP 部门 项目部级 通用库 项目部库")
+    private String projectDepartment;
+
+    @Schema(description = "物料编码")
+    @ExcelProperty("物料编码")
+    private String materialCode;
+
+    @Schema(description = "物料名称", example = "赵六")
+    @ExcelProperty("物料名称")
+    private String materialName;
+
+    @Schema(description = "物料组", example = "赵六")
+    @ExcelProperty("物料组")
+    private String materialGroupName;
+
+    @Schema(description = "物料组id", example = "21077")
+    @ExcelProperty("物料组id")
+    private Long materialGroupId;
+
+    @Schema(description = "数量")
+    @ExcelProperty("数量")
+    private BigDecimal quantity;
+
+    @Schema(description = "单价", example = "14247")
+    @ExcelProperty("单价")
+    private BigDecimal unitPrice;
+
+    @Schema(description = "单位")
+    @ExcelProperty("单位")
+    private String unit;
+
+    @Schema(description = "安全库存")
+    @ExcelProperty("安全库存")
+    private BigDecimal safetyStock;
+
+    @Schema(description = "库区id", example = "16041")
+    @ExcelProperty("库区id")
+    private Long storageAreaId;
+
+    @Schema(description = "货架id", example = "5170")
+    @ExcelProperty("货架id")
+    private Long shelvesId;
+
+    @Schema(description = "库位id", example = "32430")
+    @ExcelProperty("库位id")
+    private Long cargoLocationId;
+
+    @Schema(description = "类型(通用库 项目部库)", example = "2")
+    @ExcelProperty("类型(通用库 项目部库)")
+    private Integer type;
+
+    @Schema(description = "同步状态 0未同步 1同步成功 2同步失败", example = "2")
+    @ExcelProperty("同步状态 0未同步 1同步成功 2同步失败")
+    private Integer syncStatus;
+
+    @Schema(description = "最后一次同步时间")
+    @ExcelProperty("最后一次同步时间")
+    private LocalDateTime syncTime;
+
+    @Schema(description = "同步失败时的错误信息")
+    @ExcelProperty("同步失败时的错误信息")
+    private String syncError;
+
+    @Schema(description = "排序")
+    @ExcelProperty("排序")
+    private Integer sort;
+
+    @Schema(description = "状态 0启用  1停用", example = "2")
+    @ExcelProperty("状态 0启用  1停用")
+    private Integer status;
+
+    @Schema(description = "备注", example = "随便")
+    @ExcelProperty("备注")
+    private String remark;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 91 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotsapstocklog/vo/IotSapStockLogSaveReqVO.java

@@ -0,0 +1,91 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - PMS SAP 库存(sap同步的原始数据日志)新增/修改 Request VO")
+@Data
+public class IotSapStockLogSaveReqVO {
+
+    @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "22454")
+    private Long id;
+
+    @Schema(description = "组织部门id", example = "15891")
+    private Long deptId;
+
+    @Schema(description = "sap工厂编号")
+    private String factoryCode;
+
+    @Schema(description = "工厂id (system_sap_org表id)", example = "24138")
+    private Long factoryId;
+
+    @Schema(description = "工厂(SAP) 专业公司")
+    private String factory;
+
+    @Schema(description = "SAP库存地点编码")
+    private String storageLocationCode;
+
+    @Schema(description = "库存地点id", example = "27743")
+    private Long storageLocationId;
+
+    @Schema(description = "库存地点 - SAP 部门 项目部级 通用库 项目部库")
+    private String projectDepartment;
+
+    @Schema(description = "物料编码")
+    private String materialCode;
+
+    @Schema(description = "物料名称", example = "赵六")
+    private String materialName;
+
+    @Schema(description = "物料组", example = "赵六")
+    private String materialGroupName;
+
+    @Schema(description = "物料组id", example = "21077")
+    private Long materialGroupId;
+
+    @Schema(description = "数量")
+    private BigDecimal quantity;
+
+    @Schema(description = "单价", example = "14247")
+    private BigDecimal unitPrice;
+
+    @Schema(description = "单位")
+    private String unit;
+
+    @Schema(description = "安全库存")
+    private BigDecimal safetyStock;
+
+    @Schema(description = "库区id", example = "16041")
+    private Long storageAreaId;
+
+    @Schema(description = "货架id", example = "5170")
+    private Long shelvesId;
+
+    @Schema(description = "库位id", example = "32430")
+    private Long cargoLocationId;
+
+    @Schema(description = "类型(通用库 项目部库)", example = "2")
+    private Integer type;
+
+    @Schema(description = "同步状态 0未同步 1同步成功 2同步失败", example = "2")
+    private Integer syncStatus;
+
+    @Schema(description = "最后一次同步时间")
+    private LocalDateTime syncTime;
+
+    @Schema(description = "同步失败时的错误信息")
+    private String syncError;
+
+    @Schema(description = "排序")
+    private Integer sort;
+
+    @Schema(description = "状态 0启用  1停用", example = "2")
+    private Integer status;
+
+    @Schema(description = "备注", example = "随便")
+    private String remark;
+
+}

+ 133 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotsapstocklog/IotSapStockLogDO.java

@@ -0,0 +1,133 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstocklog;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * PMS SAP 库存(sap同步的原始数据日志) DO
+ *
+ * @author ruiqi
+ */
+@TableName("rq_iot_sap_stock_log")
+@KeySequence("rq_iot_sap_stock_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class IotSapStockLogDO extends BaseDO {
+
+    /**
+     * 主键
+     */
+    @TableId
+    private Long id;
+    /**
+     * 组织部门id
+     */
+    private Long deptId;
+    /**
+     * sap工厂编号
+     */
+    private String factoryCode;
+    /**
+     * 工厂id (system_sap_org表id)
+     */
+    private Long factoryId;
+    /**
+     * 工厂(SAP) 专业公司
+     */
+    private String factory;
+    /**
+     * SAP库存地点编码
+     */
+    private String storageLocationCode;
+    /**
+     * 库存地点id
+     */
+    private Long storageLocationId;
+    /**
+     * 库存地点 - SAP 部门 项目部级 通用库 项目部库
+     */
+    private String projectDepartment;
+    /**
+     * 物料编码
+     */
+    private String materialCode;
+    /**
+     * 物料名称
+     */
+    private String materialName;
+    /**
+     * 物料组
+     */
+    private String materialGroupName;
+    /**
+     * 物料组id
+     */
+    private Long materialGroupId;
+    /**
+     * 数量
+     */
+    private BigDecimal quantity;
+    /**
+     * 单价
+     */
+    private BigDecimal unitPrice;
+    /**
+     * 单位
+     */
+    private String unit;
+    /**
+     * 安全库存
+     */
+    private BigDecimal safetyStock;
+    /**
+     * 库区id
+     */
+    private Long storageAreaId;
+    /**
+     * 货架id
+     */
+    private Long shelvesId;
+    /**
+     * 库位id
+     */
+    private Long cargoLocationId;
+    /**
+     * 类型(通用库 项目部库)
+     */
+    private Integer type;
+    /**
+     * 同步状态 0未同步 1同步成功 2同步失败
+     */
+    private Integer syncStatus;
+    /**
+     * 最后一次同步时间
+     */
+    private LocalDateTime syncTime;
+    /**
+     * 同步失败时的错误信息
+     */
+    private String syncError;
+    /**
+     * 排序
+     */
+    private Integer sort;
+    /**
+     * 状态 0启用  1停用
+     */
+    private Integer status;
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

+ 49 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotsapstocklog/IotSapStockLogMapper.java

@@ -0,0 +1,49 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.iotsapstocklog;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo.IotSapStockLogPageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstocklog.IotSapStockLogDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * PMS SAP 库存(sap同步的原始数据日志) Mapper
+ *
+ * @author ruiqi
+ */
+@Mapper
+public interface IotSapStockLogMapper extends BaseMapperX<IotSapStockLogDO> {
+
+    default PageResult<IotSapStockLogDO> selectPage(IotSapStockLogPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<IotSapStockLogDO>()
+                .eqIfPresent(IotSapStockLogDO::getDeptId, reqVO.getDeptId())
+                .eqIfPresent(IotSapStockLogDO::getFactoryCode, reqVO.getFactoryCode())
+                .eqIfPresent(IotSapStockLogDO::getFactoryId, reqVO.getFactoryId())
+                .eqIfPresent(IotSapStockLogDO::getFactory, reqVO.getFactory())
+                .eqIfPresent(IotSapStockLogDO::getStorageLocationCode, reqVO.getStorageLocationCode())
+                .eqIfPresent(IotSapStockLogDO::getStorageLocationId, reqVO.getStorageLocationId())
+                .eqIfPresent(IotSapStockLogDO::getProjectDepartment, reqVO.getProjectDepartment())
+                .eqIfPresent(IotSapStockLogDO::getMaterialCode, reqVO.getMaterialCode())
+                .likeIfPresent(IotSapStockLogDO::getMaterialName, reqVO.getMaterialName())
+                .likeIfPresent(IotSapStockLogDO::getMaterialGroupName, reqVO.getMaterialGroupName())
+                .eqIfPresent(IotSapStockLogDO::getMaterialGroupId, reqVO.getMaterialGroupId())
+                .eqIfPresent(IotSapStockLogDO::getQuantity, reqVO.getQuantity())
+                .eqIfPresent(IotSapStockLogDO::getUnitPrice, reqVO.getUnitPrice())
+                .eqIfPresent(IotSapStockLogDO::getUnit, reqVO.getUnit())
+                .eqIfPresent(IotSapStockLogDO::getSafetyStock, reqVO.getSafetyStock())
+                .eqIfPresent(IotSapStockLogDO::getStorageAreaId, reqVO.getStorageAreaId())
+                .eqIfPresent(IotSapStockLogDO::getShelvesId, reqVO.getShelvesId())
+                .eqIfPresent(IotSapStockLogDO::getCargoLocationId, reqVO.getCargoLocationId())
+                .eqIfPresent(IotSapStockLogDO::getType, reqVO.getType())
+                .eqIfPresent(IotSapStockLogDO::getSyncStatus, reqVO.getSyncStatus())
+                .betweenIfPresent(IotSapStockLogDO::getSyncTime, reqVO.getSyncTime())
+                .eqIfPresent(IotSapStockLogDO::getSyncError, reqVO.getSyncError())
+                .eqIfPresent(IotSapStockLogDO::getSort, reqVO.getSort())
+                .eqIfPresent(IotSapStockLogDO::getStatus, reqVO.getStatus())
+                .eqIfPresent(IotSapStockLogDO::getRemark, reqVO.getRemark())
+                .betweenIfPresent(IotSapStockLogDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(IotSapStockLogDO::getId));
+    }
+
+}

+ 110 - 62
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/sap/service/IotSapServiceImpl.java

@@ -11,11 +11,13 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.iotlockstock.IotLockStockDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmaterial.IotMaterialDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotsappickinglist.IotSapPickingListDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstock.IotSapStockDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstocklog.IotSapStockLogDO;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotlockstock.IotLockStockMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotmaterial.IotMaterialMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotmaterial.IotSapMaterialMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotsappickinglist.IotSapPickingListMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotsapstock.IotSapStockMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.iotsapstocklog.IotSapStockLogMapper;
 import cn.iocoder.yudao.module.pms.sap.vo.*;
 import cn.iocoder.yudao.module.supplier.dal.dataobject.product.SupplierDO;
 import cn.iocoder.yudao.module.supplier.dal.mysql.product.SupplierMapper;
@@ -23,6 +25,7 @@ import cn.iocoder.yudao.module.system.api.dept.DeptApi;
 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 import cn.iocoder.yudao.module.system.api.saporg.SapOrgApi;
 import cn.iocoder.yudao.module.system.api.saporg.dto.SapOrgRespDTO;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -65,6 +68,8 @@ public class IotSapServiceImpl implements IotSapService {
     @Autowired
     private IotSapStockMapper iotSapStockMapper;
     @Autowired
+    private IotSapStockLogMapper iotSapStockLogMapper;
+    @Autowired
     private IotSapPickingListMapper iotSapPickingListMapper;
 
     @Override
@@ -564,20 +569,21 @@ public class IotSapServiceImpl implements IotSapService {
                 });
             }
         });
-        // 查询所有SAP库存集合A,以 ‘库存地点id+物料编码’ 为唯一key 如果 sapStocks 中有物料不在A中 新增物料
+        // 查询所有SAP库存集合A,以 ‘工厂编码+库存地点code+物料编码’ 为唯一key 如果 sapStocks 中有物料不在A中 新增物料
         Set<String> existStockKeys = new HashSet<>();
         List<IotSapStockDO> existStocks = TenantUtils.execute(1L, () -> iotSapStockMapper.selectList());
         if (CollUtil.isNotEmpty(existStocks)) {
             existStockKeys = existStocks.stream()
                     // 过滤非空对象和非空code
-                    .filter(stk -> ObjUtil.isNotEmpty(stk) && StrUtil.isNotBlank(stk.getMaterialCode()) && ObjUtil.isNotEmpty(stk.getStorageLocationId()))
-                    .map(stk -> StrUtil.join("-", String.valueOf(stk.getStorageLocationId()), stk.getMaterialCode()))
+                    .filter(stk -> ObjUtil.isNotEmpty(stk) && StrUtil.isNotBlank(stk.getMaterialCode())
+                            && StrUtil.isNotBlank(stk.getFactoryCode()) && StrUtil.isNotBlank(stk.getStorageLocationCode()))
+                    .map(stk -> StrUtil.join("-", stk.getFactoryCode(), stk.getStorageLocationCode(), stk.getMaterialCode()))
                     .collect(Collectors.toSet());
         }
         System.out.println(factoryCode + "当前库中已有sap库存数量:" + existStockKeys.size());
 
         // todo 没有维护SAP工厂 库存地点的组织 已经存在的库存数据
-        Set<String> noFactoryExistStockKeys = new HashSet<>();
+        /* Set<String> noFactoryExistStockKeys = new HashSet<>();
         if (CollUtil.isNotEmpty(existStocks)) {
             noFactoryExistStockKeys = existStocks.stream()
                     // 过滤非空对象和非空code
@@ -585,16 +591,16 @@ public class IotSapServiceImpl implements IotSapService {
                             && StrUtil.isNotBlank(stk.getFactoryCode()) && StrUtil.isNotBlank(stk.getStorageLocationCode()))
                     .map(stk -> StrUtil.join("-", stk.getFactoryCode(), stk.getStorageLocationCode(), stk.getMaterialCode()))
                     .collect(Collectors.toSet());
-        }
+        } */
 
         // 将已经存在的库存数据 设置成 Map<String, IotSapStockDO> 的形式 便于后续更新
-        // key库存地点id-物料编码       value库存对象   从此集合中筛选将要被更新的库存对象
+        // key工厂code-库存地点code-物料编码       value库存对象   从此集合中筛选将要被更新的库存对象
         Map<String, IotSapStockDO> tobeUpdatedStockPair = new HashMap<>();
         tobeUpdatedStockPair = existStocks.stream()
-                .filter(stk -> StrUtil.isNotBlank(stk.getMaterialCode()) && ObjUtil.isNotEmpty(stk.getStorageLocationId())
-                        && stockLocationCodeIdPair.containsKey(stk.getStorageLocationId()))
+                .filter(stk -> StrUtil.isNotBlank(stk.getMaterialCode()) && StrUtil.isNotBlank(stk.getFactoryCode())
+                        && StrUtil.isNotBlank(stk.getStorageLocationCode()))
                 .collect(Collectors.toMap(
-                        stk -> StrUtil.join("-", stk.getStorageLocationId(), stk.getMaterialCode()),
+                        stk -> StrUtil.join("-", stk.getFactoryCode(), stk.getStorageLocationCode(), stk.getMaterialCode()),
                         stk -> stk, // 值为对象本身
                         (existing, replacement) -> existing // 处理键冲突: 保留先出现的元素
                 ));
@@ -602,7 +608,7 @@ public class IotSapServiceImpl implements IotSapService {
         // todo 没有配置SAP 工厂 库存地点 的组织库存更新
         // 将已经存在的库存数据 设置成 Map<String, IotSapStockDO> 的形式 便于后续更新
         // key工厂code-库存地点code-物料编码       value库存对象   从此集合中筛选将要被更新的库存对象
-        Map<String, IotSapStockDO> noFactoryTobeUpdatedStockPair = new HashMap<>();
+        /* Map<String, IotSapStockDO> noFactoryTobeUpdatedStockPair = new HashMap<>();
         noFactoryTobeUpdatedStockPair = existStocks.stream()
                 .filter(stk -> StrUtil.isNotBlank(stk.getMaterialCode()) && StrUtil.isNotBlank(stk.getFactoryCode())
                         && StrUtil.isNotBlank(stk.getStorageLocationCode()))
@@ -610,7 +616,7 @@ public class IotSapServiceImpl implements IotSapService {
                         stk -> StrUtil.join("-", stk.getFactoryCode(), stk.getStorageLocationCode(), stk.getMaterialCode()),
                         stk -> stk, // 值为对象本身
                         (existing, replacement) -> existing // 处理键冲突: 保留先出现的元素
-                ));
+                )); */
 
         // 找出需要新增的库存(SAP物料编码去掉前导零后,不在现有物料集合中的记录)
         Set<String> finalExistStockKeys = existStockKeys;
@@ -621,8 +627,9 @@ public class IotSapServiceImpl implements IotSapService {
                     // 处理前导零:移除MATNR前的 00000000
                     String processedCode = stk.getMATNR().replaceFirst("^0+", "");
                     // 本地已经配置过库存地点 包含SAP库存接口返回的库存地点
-                    Long storageLocationId = storageLocationIdPair.get(StrUtil.join("-", stk.getWERKS(), stk.getLGORT()));
-                    return !finalExistStockKeys.contains(StrUtil.join("-", storageLocationId, processedCode));
+                    // Long storageLocationId = storageLocationIdPair.get(StrUtil.join("-", stk.getWERKS(), stk.getLGORT()));
+                    String uniqueKey = StrUtil.join("-", stk.getWERKS(), stk.getLGORT());
+                    return !finalExistStockKeys.contains(StrUtil.join("-", uniqueKey, processedCode));
                 })
                 .collect(Collectors.toList());
 
@@ -630,7 +637,7 @@ public class IotSapServiceImpl implements IotSapService {
 
         // todo 没有维护SAP工厂 库存地点的组织 新增的库存数据
         // 找出需要新增的库存(SAP物料编码去掉前导零后,不在现有物料集合中的记录)
-        Set<String> noFactoryFinalExistStockKeys = noFactoryExistStockKeys;
+        /* Set<String> noFactoryFinalExistStockKeys = noFactoryExistStockKeys;
         List<IotSapStockVO> noFactoryNewStocks = sapStocks.stream()
                 .filter(stk -> StrUtil.isNotBlank(stk.getMATNR()) && StrUtil.isNotBlank(stk.getLGORT()) && StrUtil.isNotBlank(stk.getWERKS()))
                 .filter(stk -> {
@@ -639,7 +646,7 @@ public class IotSapServiceImpl implements IotSapService {
                     // 本地已经配置过库存地点 包含SAP库存接口返回的库存地点
                     return !noFactoryFinalExistStockKeys.contains(StrUtil.join("-", stk.getWERKS(), stk.getLGORT(), processedCode));
                 })
-                .collect(Collectors.toList());
+                .collect(Collectors.toList()); */
 
         // 新增SAP库存数据
         List<IotSapStockDO> tobeAddedStocks = new ArrayList<>();
@@ -647,69 +654,76 @@ public class IotSapServiceImpl implements IotSapService {
             newStocks.forEach(stock -> {
                 // 只保存pms维护过库存地点的数据
                 String uniqueKey = StrUtil.join("-", stock.getWERKS(), stock.getLGORT());
+                IotSapStockDO sapStock = new IotSapStockDO();
+                // 部门id 已经关联的组织部门的SAP工厂 库存地点
                 if (locationCodeDeptIdPair.containsKey(uniqueKey)) {
-                    IotSapStockDO sapStock = new IotSapStockDO();
-                    // 部门id
                     sapStock.setDeptId(locationCodeDeptIdPair.get(uniqueKey));
-                    // 工厂id
-                    if (factoryIdPair.containsKey(stock.getWERKS())) {
-                        sapStock.setFactoryId(factoryIdPair.get(stock.getWERKS()));
-                    }
-                    // 工厂名称
-                    if (factoryNamePair.containsKey(stock.getWERKS())) {
-                        sapStock.setFactory(factoryNamePair.get(stock.getWERKS()));
-                    }
-                    // 库存地点id
-                    if (storageLocationIdPair.containsKey(uniqueKey)) {
-                        sapStock.setStorageLocationId(storageLocationIdPair.get(uniqueKey));
-                    }
-                    // 库存地点名称
-                    if (stockLocationNamePair.containsKey(uniqueKey)) {
-                        sapStock.setProjectDepartment(stockLocationNamePair.get(uniqueKey));
-                    }
-                    // 物料编码 需要去掉前缀 00000000
-                    sapStock.setMaterialCode(stock.getMATNR().replaceFirst("^0+", ""));
-                    // 物料描述
-                    sapStock.setMaterialName(stock.getMAKTX());
-                    // 库存数量
-                    sapStock.setQuantity(stock.getLABST());
-                    // 单价
-                    sapStock.setUnitPrice(stock.getJIAGE());
-                    // 基本单位
-                    sapStock.setUnit(stock.getMEINS());
-                    // 同步时间
-                    sapStock.setSyncTime(LocalDateTime.now());
-                    tobeAddedStocks.add(sapStock);
+                } else {
+                    // 没有关联组织部门的SAP工厂 库存地点 暂时设置部门 为 163 科瑞石油技术
+                    sapStock.setDeptId(163l);
+                }
+                // 工厂id
+                if (factoryIdPair.containsKey(stock.getWERKS())) {
+                    sapStock.setFactoryId(factoryIdPair.get(stock.getWERKS()));
+                }
+                // 工厂 code
+                sapStock.setFactoryCode(stock.getWERKS());
+                // 工厂名称
+                if (factoryNamePair.containsKey(stock.getWERKS())) {
+                    sapStock.setFactory(factoryNamePair.get(stock.getWERKS()));
+                }
+                // 库存地点id
+                if (storageLocationIdPair.containsKey(uniqueKey)) {
+                    sapStock.setStorageLocationId(storageLocationIdPair.get(uniqueKey));
+                }
+                // 库存地点code
+                sapStock.setStorageLocationCode(stock.getLGORT());
+                // 库存地点名称
+                if (stockLocationNamePair.containsKey(uniqueKey)) {
+                    sapStock.setProjectDepartment(stockLocationNamePair.get(uniqueKey));
                 }
+                // 物料编码 需要去掉前缀 00000000
+                sapStock.setMaterialCode(stock.getMATNR().replaceFirst("^0+", ""));
+                // 物料描述
+                sapStock.setMaterialName(stock.getMAKTX());
+                // 库存数量
+                sapStock.setQuantity(stock.getLABST());
+                // 单价
+                sapStock.setUnitPrice(stock.getJIAGE());
+                // 基本单位
+                sapStock.setUnit(stock.getMEINS());
+                // 同步时间
+                sapStock.setSyncTime(LocalDateTime.now());
+                tobeAddedStocks.add(sapStock);
             });
         }
 
         // todo 新增 没有配置组织部门的 SAP库存数据
-        List<IotSapStockDO> noFactoryTobeAddedStocks = new ArrayList<>();
+        /** List<IotSapStockDO> noFactoryTobeAddedStocks = new ArrayList<>();
         if (CollUtil.isNotEmpty(noFactoryNewStocks)) {
             noFactoryNewStocks.forEach(stock -> {
                 // 只保存pms维护过库存地点的数据
                 String uniqueKey = StrUtil.join("-", stock.getWERKS(), stock.getLGORT());
                 IotSapStockDO sapStock = new IotSapStockDO();
                 // 部门统一设置为 科瑞石油技术
-                sapStock.setDeptId(156l);
+                sapStock.setDeptId(156l); **/
                 // 工厂id
                 /* if (factoryIdPair.containsKey(stock.getWERKS())) {
                     sapStock.setFactoryId(factoryIdPair.get(stock.getWERKS()));
                 } */
-                sapStock.setFactoryCode(stock.getWERKS());
+                /** sapStock.setFactoryCode(stock.getWERKS());
                 // 工厂名称
                 if (factoryNamePair.containsKey(stock.getWERKS())) {
                     sapStock.setFactory(factoryNamePair.get(stock.getWERKS()));
                 }
                 // 库存地点 code
-                sapStock.setStorageLocationCode(stock.getLGORT());
+                sapStock.setStorageLocationCode(stock.getLGORT()); **/
                 // 库存地点id
                 /* if (storageLocationIdPair.containsKey(uniqueKey)) {
                     sapStock.setStorageLocationId(storageLocationIdPair.get(uniqueKey));
                 } */
                 // 库存地点名称
-                if (stockLocationNamePair.containsKey(uniqueKey)) {
+                /** if (stockLocationNamePair.containsKey(uniqueKey)) {
                     sapStock.setProjectDepartment(stockLocationNamePair.get(uniqueKey));
                 }
                 // 物料编码 需要去掉前缀 00000000
@@ -726,10 +740,10 @@ public class IotSapServiceImpl implements IotSapService {
                 sapStock.setSyncTime(LocalDateTime.now());
                 noFactoryTobeAddedStocks.add(sapStock);
             });
-        }
+        } **/
 
         // 使用返回的SAP库存数据更新已有的 库存数据
-        // pms中已有 SAP返回数据中也存在 则更新
+        // pms中已有 SAP返回数据中也存在 则更新 再次判断更新deptId 因为有可能又将SAP库存地点关联到了 组织部门
         List<IotSapStockDO> actualUpdatedStocks = new ArrayList<>();
         // key库存id-物料编码      value库存对象
         Map<String, IotSapStockVO> existStockPair = createExistStockMap(sapStocks, existStockKeys, storageLocationIdPair);
@@ -737,7 +751,12 @@ public class IotSapServiceImpl implements IotSapService {
             Map<String, IotSapStockDO> finalTobeUpdatedStockPair = tobeUpdatedStockPair;
             existStockPair.forEach((k, v) -> {
                 if (finalTobeUpdatedStockPair.containsKey(k)) {
+                    // 再次查询当前 工厂-库存地点-物料编码 是否已经关联了组织部门
                     IotSapStockDO sapStock = finalTobeUpdatedStockPair.get(k);
+                    String uniqueKey = StrUtil.join("-", sapStock.getFactoryCode(), sapStock.getStorageLocationCode());
+                    if (locationCodeDeptIdPair.containsKey(uniqueKey)) {
+                        sapStock.setDeptId(locationCodeDeptIdPair.get(uniqueKey));
+                    }
                     sapStock.setUnitPrice(v.getJIAGE());    // 更新库存价格
                     sapStock.setQuantity(v.getLABST());     // 更新库存数量
                     sapStock.setUnit(v.getMEINS());         // 更新基本单位
@@ -747,9 +766,30 @@ public class IotSapServiceImpl implements IotSapService {
         }
         System.out.println(factoryCode + "需要更新的SAP库存数量:" + actualUpdatedStocks.size());
 
+        // 每次请求都 保存 SAP接口返回的原始库存数据
+        List<IotSapStockLogDO> tobeAddedSapStockLogs = new ArrayList<>();
+        if (CollUtil.isNotEmpty(sapStocks)) {
+            sapStocks.forEach(stock -> {
+                IotSapStockLogDO sapStockLog = new IotSapStockLogDO();
+                sapStockLog.setFactoryCode(stock.getWERKS());
+                sapStockLog.setStorageLocationCode(stock.getLGORT());
+                sapStockLog.setMaterialCode(stock.getMATNR().replaceFirst("^0+", ""));
+                sapStockLog.setMaterialName(stock.getMAKTX());
+                // 库存数量
+                sapStockLog.setQuantity(stock.getLABST());
+                // 单价
+                sapStockLog.setUnitPrice(stock.getJIAGE());
+                // 基本单位
+                sapStockLog.setUnit(stock.getMEINS());
+                // 同步时间
+                sapStockLog.setSyncTime(LocalDateTime.now());
+                tobeAddedSapStockLogs.add(sapStockLog);
+            });
+        }
+
         // todo sap 工厂 库存地点 未关联组织部门
         // 使用返回的SAP库存数据更新已有的 库存数据 pms中已有 SAP返回数据中也存在 则更新
-        List<IotSapStockDO> noFactoryActualUpdatedStocks = new ArrayList<>();
+        /* List<IotSapStockDO> noFactoryActualUpdatedStocks = new ArrayList<>();
         // key工厂code-库存地点code-物料编码      value库存对象
         Map<String, IotSapStockVO> noFactoryExistStockPair = createNoFactoryExistStockMap(sapStocks, noFactoryExistStockKeys, storageLocationIdPair);
         if (CollUtil.isNotEmpty(noFactoryExistStockPair)) {
@@ -764,7 +804,7 @@ public class IotSapServiceImpl implements IotSapService {
                 }
             });
         }
-        System.out.println(factoryCode + "SAP工厂库存地点未关联组织部门-需要更新的SAP库存数量:" + noFactoryActualUpdatedStocks.size());
+        System.out.println(factoryCode + "SAP工厂库存地点未关联组织部门-需要更新的SAP库存数量:" + noFactoryActualUpdatedStocks.size()); */
 
         // pms中已有 但是 SAP返回数据不存在 如果设置了安全库存,则库存为0,若没有设置安全库存,则可以删除
 
@@ -807,22 +847,28 @@ public class IotSapServiceImpl implements IotSapService {
                 tobeSapStocks.add(sapStock);
             }
         }); */
+        // 保存SAP库存原始数据 先删除 再新增
+        QueryWrapper<IotSapStockLogDO> queryWrapper = new QueryWrapper<>();
+        TenantUtils.execute(1L, () -> iotSapStockLogMapper.delete(queryWrapper));
+        if (CollUtil.isNotEmpty(tobeAddedSapStockLogs)) {
+            TenantUtils.execute(1L, () -> iotSapStockLogMapper.insertBatch(tobeAddedSapStockLogs));
+        }
         // 本地库存 初始化 批量插入SAP 库存 工厂 库存地点 已经关联了组织架构部门
         if (CollUtil.isNotEmpty(tobeAddedStocks)) {
             TenantUtils.execute(1L, () -> iotSapStockMapper.insertBatch(tobeAddedStocks));
         }
         // 本地库存 初始化 批量插入本地库存 记录 工厂 库存地点 未关联了组织架构部门
-        if (CollUtil.isNotEmpty(noFactoryTobeAddedStocks)) {
+        /* if (CollUtil.isNotEmpty(noFactoryTobeAddedStocks)) {
             TenantUtils.execute(1L, () -> iotSapStockMapper.insertBatch(noFactoryTobeAddedStocks));
-        }
+        } */
         // pms中存在而且SAP接口也返回的库存数据:更新
         if (CollUtil.isNotEmpty(actualUpdatedStocks)) {
             TenantUtils.execute(1L, () -> iotSapStockMapper.updateBatch(actualUpdatedStocks));
         }
         // pms中存在而且SAP接口也返回的库存数据:更新 工厂 库存地点 未关联了组织架构部门
-        if (CollUtil.isNotEmpty(noFactoryActualUpdatedStocks)) {
+        /* if (CollUtil.isNotEmpty(noFactoryActualUpdatedStocks)) {
             TenantUtils.execute(1L, () -> iotSapStockMapper.updateBatch(noFactoryActualUpdatedStocks));
-        }
+        } */
     }
 
     /**
@@ -879,7 +925,8 @@ public class IotSapServiceImpl implements IotSapService {
      * @param storageLocationIdPair key库存地点code    value库存地点id
      * @return 物料编码到描述的映射
      */
-    private Map<String, IotSapStockVO> createExistStockMap(List<IotSapStockVO> sapStocks, Set<String> existStockKeys, Map<String, Long> storageLocationIdPair) {
+    private Map<String, IotSapStockVO> createExistStockMap(List<IotSapStockVO> sapStocks, Set<String> existStockKeys,
+                                                           Map<String, Long> storageLocationIdPair) {
         return sapStocks.stream()
                 .filter(sapStock -> StrUtil.isNotBlank(sapStock.getMATNR()) &&
                         StrUtil.isNotBlank(sapStock.getLGORT()) &&
@@ -888,8 +935,9 @@ public class IotSapServiceImpl implements IotSapService {
                     // 处理前导零:移除MATNR前的 00000000
                     String processedCode = sapStock.getMATNR().replaceFirst("^0+", "");
                     // 本地已经配置过库存地点 包含SAP库存接口返回的库存地点
-                    Long storageLocationId = storageLocationIdPair.get(StrUtil.join("-", sapStock.getWERKS(), sapStock.getLGORT()));
-                    return new AbstractMap.SimpleEntry<>(StrUtil.join("-", storageLocationId, processedCode), sapStock);
+                    // Long storageLocationId = storageLocationIdPair.get(StrUtil.join("-", sapStock.getWERKS(), sapStock.getLGORT()));
+                    String uniqueKey = StrUtil.join("-", sapStock.getWERKS(), sapStock.getLGORT());
+                    return new AbstractMap.SimpleEntry<>(StrUtil.join("-", uniqueKey, processedCode), sapStock);
                 })
                 .filter(entry -> existStockKeys.contains(entry.getKey()))
                 .collect(Collectors.toMap(

+ 55 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotsapstocklog/IotSapStockLogService.java

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.pms.service.iotsapstocklog;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo.IotSapStockLogPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo.IotSapStockLogSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstocklog.IotSapStockLogDO;
+
+import javax.validation.Valid;
+
+/**
+ * PMS SAP 库存(sap同步的原始数据日志) Service 接口
+ *
+ * @author ruiqi
+ */
+public interface IotSapStockLogService {
+
+    /**
+     * 创建PMS SAP 库存(sap同步的原始数据日志)
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createIotSapStockLog(@Valid IotSapStockLogSaveReqVO createReqVO);
+
+    /**
+     * 更新PMS SAP 库存(sap同步的原始数据日志)
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIotSapStockLog(@Valid IotSapStockLogSaveReqVO updateReqVO);
+
+    /**
+     * 删除PMS SAP 库存(sap同步的原始数据日志)
+     *
+     * @param id 编号
+     */
+    void deleteIotSapStockLog(Long id);
+
+    /**
+     * 获得PMS SAP 库存(sap同步的原始数据日志)
+     *
+     * @param id 编号
+     * @return PMS SAP 库存(sap同步的原始数据日志)
+     */
+    IotSapStockLogDO getIotSapStockLog(Long id);
+
+    /**
+     * 获得PMS SAP 库存(sap同步的原始数据日志)分页
+     *
+     * @param pageReqVO 分页查询
+     * @return PMS SAP 库存(sap同步的原始数据日志)分页
+     */
+    PageResult<IotSapStockLogDO> getIotSapStockLogPage(IotSapStockLogPageReqVO pageReqVO);
+
+}

+ 71 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotsapstocklog/IotSapStockLogServiceImpl.java

@@ -0,0 +1,71 @@
+package cn.iocoder.yudao.module.pms.service.iotsapstocklog;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo.IotSapStockLogPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotsapstocklog.vo.IotSapStockLogSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstocklog.IotSapStockLogDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.iotsapstocklog.IotSapStockLogMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_SAP_STOCK_LOG_NOT_EXISTS;
+
+/**
+ * PMS SAP 库存(sap同步的原始数据日志) Service 实现类
+ *
+ * @author ruiqi
+ */
+@Service
+@Validated
+public class IotSapStockLogServiceImpl implements IotSapStockLogService {
+
+    @Resource
+    private IotSapStockLogMapper iotSapStockLogMapper;
+
+    @Override
+    public Long createIotSapStockLog(IotSapStockLogSaveReqVO createReqVO) {
+        // 插入
+        IotSapStockLogDO iotSapStockLog = BeanUtils.toBean(createReqVO, IotSapStockLogDO.class);
+        iotSapStockLogMapper.insert(iotSapStockLog);
+        // 返回
+        return iotSapStockLog.getId();
+    }
+
+    @Override
+    public void updateIotSapStockLog(IotSapStockLogSaveReqVO updateReqVO) {
+        // 校验存在
+        validateIotSapStockLogExists(updateReqVO.getId());
+        // 更新
+        IotSapStockLogDO updateObj = BeanUtils.toBean(updateReqVO, IotSapStockLogDO.class);
+        iotSapStockLogMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteIotSapStockLog(Long id) {
+        // 校验存在
+        validateIotSapStockLogExists(id);
+        // 删除
+        iotSapStockLogMapper.deleteById(id);
+    }
+
+    private void validateIotSapStockLogExists(Long id) {
+        if (iotSapStockLogMapper.selectById(id) == null) {
+            throw exception(IOT_SAP_STOCK_LOG_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public IotSapStockLogDO getIotSapStockLog(Long id) {
+        return iotSapStockLogMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<IotSapStockLogDO> getIotSapStockLogPage(IotSapStockLogPageReqVO pageReqVO) {
+        return iotSapStockLogMapper.selectPage(pageReqVO);
+    }
+
+}

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotDeviceMapper.xml

@@ -55,6 +55,7 @@
         rid.device_code AS deviceCode,
         rid.device_name AS deviceName,
         rid.device_status AS deviceStatus,
+        rid.model AS model,
         rid.asset_property AS assetProperty
         FROM rq_iot_device rid
         WHERE rid.deleted = 0