尧图建网站 尧图建网站 YAOTU WEB BUILD 免费咨询
ARTICLE DETAIL

资讯详情

深耕网站建设与建站编程的一线实战洞察。

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

Java Spring 批量修改,实体、接口、方法的定义 参数类型{ids:[2085247882935402496],VehicleType:快递}Controller.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 接口层/** * 批量更新车辆类型 * param reqParam * return */ Result batchUpdateVehicleType(Map reqParam);impl 实现层OutBoundJobTaskExec.java/** * 批量更新车辆类型 * * param reqParam 请求参数包含 ids其他出库单ID列表和 VehicleType车辆类型 * return 操作结果 * author Bingo * date 2026-08-19 */ Transactional(rollbackOn Exception.class) public Result batchUpdateVehicleType(Map reqParam) { try { ListString ids (ListString) 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(车辆类型不能为空); } ListLong idList ids.stream().map(Long::parseLong).collect(Collectors.toList()); ListOtherOutboundOrder 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()); } }表实体定义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() ); } }
返回列表