Java Spring 批量修改,实体、接口、方法的定义

参数类型:

javascript 复制代码
{"ids":["2085247882935402496"],"VehicleType":"快递"}

Controller.java 接口层

java 复制代码
     @Resource
    private Tj0OutboundJobTaskService tj0OutboundJobTaskService;

/**
     * 批量更新车辆类型
     * Author:Bingo
     * Date:2023-08-10
     * @param reqParam
     * @return
     */
    @PostMapping({"/batchUpdateVehicleType"})
    public Result batchUpdateVehicleType(@RequestBody Map reqParam) {
        return tj0OutboundJobTaskService.batchUpdateVehicleType(reqParam);
    }

service 接口层

java 复制代码
    /**
     * 批量更新车辆类型
     * @param reqParam
     * @return
     */
    Result batchUpdateVehicleType(Map reqParam);

impl 实现层

OutBoundJobTaskExec.java

java 复制代码
/**
     * 批量更新车辆类型
     *
     * @param reqParam 请求参数,包含 ids(其他出库单ID列表)和 VehicleType(车辆类型)
     * @return 操作结果
     * @author Bingo
     * @date 2026-08-19
     */
    @Transactional(rollbackOn = Exception.class)
    public Result batchUpdateVehicleType(Map reqParam) {
        try {
            List<String> ids = (List<String>) reqParam.get("ids");
            String vehicleType = (String) reqParam.get("VehicleType");

            if (ids == null || ids.isEmpty()) {
                return Result.error("出库单ID列表不能为空");
            }
            if (StrUtil.isBlank(vehicleType)) {
                return Result.error("车辆类型不能为空");
            }

            List<Long> idList = ids.stream().map(Long::parseLong).collect(Collectors.toList());
            List<OtherOutboundOrder> orderList = otherOutboundOrderRepository.findByIds(OtherOutboundOrder.class, idList);

            if (CollectionUtil.isEmpty(orderList)) {
                return Result.error("未找到对应的出库单数据");
            }

            for (OtherOutboundOrder order : orderList) {
                order.setTj0VehicleType(vehicleType);
            }

            otherOutboundOrderRepository.updateBatch(orderList);

            return Result.success("更新成功,共更新" + orderList.size() + "条记录");
        } catch (Exception e) {
            logger.error("批量更新车辆类型失败", e);
            return Result.error("批量更新车辆类型失败:" + e.getMessage());
        }
    }

表实体定义

java 复制代码
package com.nancal.wms.entity;

import com.nancal.base.bean.entity.ManufacturingActivity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "whs_mat_recod")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class WhsMatRecod extends ManufacturingActivity {

    /**
     * 智库操作人
     */
    @Column(name = "tj0IwmsOperator")
    private String tj0IwmsOperator;
    private String storeName;
    /**
     * SAP过账结果
     */
    private String tj0SapMBLNR;
    @Column(name = "tj0storeType")
    private String tj0storeType;//库房类型
    @Column(name = "revision")
    private String revision; 
    @Column(name = "bussiness_type")
    private String bussinessType;
    @Transient
    private String displayIvtTrTyName;
    @Transient
    private String displayOperator;
    @Transient
    private String displayStore;
    @Transient
    private String displayUnitName;

    public WhsMatRecod() {
    }

    public String toString() {
        String var10000 = this.getRevision();
        return "WhsMatRecod(revision=" + var10000 + ", matEffectiveDate=" + this.getMatEffectiveDate() + ", materialTyId=" + this.getMaterialTyId() + ", agentSeqMgts=" + this.getAgentSeqMgts() + ", batchNumber=" + this.getBatchNumber() + ", cntnCode=" + this.getCntnCode() + ", externalBatchNumber=" + this.getExternalBatchNumber() + ", ivtTrTyId=" + this.getIvtTrTyId() + ", materialAgentId=" + this.getMaterialAgentId() + ", materialClassName=" + this.getMaterialClassName() + ", materialCode=" + this.getMaterialCode() + ", materialDepict=" + this.getMaterialDepict() + ", materialId=" + this.getMaterialId() + ", materialLedgerId=" + this.getMaterialLedgerId() + ", operateQuantity=" + this.getOperateQuantity() + ", operateTime=" + this.getOperateTime() + ", operateType=" + this.getOperateType() + ", operator=" + this.getOperator() + ", orderNumber=" + this.getOrderNumber() + ", productDraw=" + this.getProductDraw() + ", relatedOrderNumber=" + this.getRelatedOrderNumber() + ", specificationType=" + this.getSpecificationType() + ", storeId=" + this.getStoreId() + ", supplier=" + this.getSupplier() + ", supplierId=" + this.getSupplierId() + ", unit=" + this.getUnit() + ", displayIvtTrTyName=" + this.getDisplayIvtTrTyName() + ", displayOperator=" + this.getDisplayOperator() + ", displayStore=" + this.getDisplayStore() + ", displayUnitName=" + this.getDisplayUnitName() + ")";
    }
}
相关推荐
画中有画2 小时前
软件架构中质量属性(性能、安全、可扩展性)的权衡设计
java·运维·安全
Shaoxi Zhang2 小时前
JAVA学习笔记035——对象和JSON格式
java·笔记·学习
赵丙双2 小时前
CountDownLatch 源码分析
java·aqs·countdownlatch
余额瞒着我当琳2 小时前
C++--深拷贝三件套 + swap + 写时拷贝 + vector 扩容 + reserve
java·开发语言·c++
thefool1122663 小时前
翻转二叉树
java
喜欢打篮球的普通人3 小时前
LLVM Backend Lowering 从入门到实战:把 IR 变成机器码的完整链路
android·java·数据库
FL16238631294 小时前
室内易燃物识别易燃评估室内易燃程度识别分割数据集labelme格式1015张85类别
java·服务器·前端
jufeng13074 小时前
【系列:TDengine 工业物联网实战:从零搭起可运行系统 · 第 8 篇】
java·spring boot·时序数据库·tdengine
程序员贺加贝4 小时前
轻制造SaaS的生产闭环建模-BOM工单领料报工质检与入库
java·设计模式·架构