From b36839554b0b3b1b39c38b24a64bf1a0355fca30 Mon Sep 17 00:00:00 2001 From: zhaoqiaobo <583671871@qq.com> Date: Wed, 18 Dec 2024 16:57:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E6=9C=8D=E5=8A=A1=E5=95=86?= =?UTF-8?q?=E6=88=90=E6=9C=AC=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1 增加批量新增司机 --- .../ExpenseDispatchPriceServiceEntity.java | 8 ++++ ...ExpenseDispatchPriceServiceController.java | 48 +++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchPriceServiceEntity.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchPriceServiceEntity.java index 6e30210b7..5c76882c4 100644 --- a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchPriceServiceEntity.java +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchPriceServiceEntity.java @@ -16,6 +16,8 @@ */ package com.logpm.statistics.entity; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -23,6 +25,8 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; +import java.util.List; + /** * 成本配送服务商配置价格 实体类 * @@ -60,4 +64,8 @@ public class ExpenseDispatchPriceServiceEntity extends TenantEntity { */ @ApiModelProperty(value = "价格模版id") private Long templateId; + + @ApiModelProperty(value = "司机") + @TableField(exist = false) + private List drivers; } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/ExpenseDispatchPriceServiceController.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/ExpenseDispatchPriceServiceController.java index 2965b3143..88467f842 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/ExpenseDispatchPriceServiceController.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/ExpenseDispatchPriceServiceController.java @@ -16,6 +16,8 @@ */ package com.logpm.statistics.controller; +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; @@ -30,13 +32,16 @@ import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.excel.util.ExcelUtil; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.BladeUser; import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.BladeConstant; +import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -47,8 +52,11 @@ import springfox.documentation.annotations.ApiIgnore; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; /** * 成本配送服务商配置价格 控制器 @@ -74,6 +82,7 @@ public class ExpenseDispatchPriceServiceController extends BladeController { ExpenseDispatchPriceServiceEntity detail = expenseDispatchPriceServiceService.getOne(Condition.getQueryWrapper(expenseDispatchPriceService)); return R.data(ExpenseDispatchPriceServiceWrapper.build().entityVO(detail)); } + /** * 成本配送服务商配置价格 分页 */ @@ -103,8 +112,28 @@ public class ExpenseDispatchPriceServiceController extends BladeController { @ApiOperationSupport(order = 4) @ApiOperation(value = "新增", notes = "传入expenseDispatchPriceService") public R save(@Valid @RequestBody ExpenseDispatchPriceServiceEntity expenseDispatchPriceService) { - expenseDispatchPriceServiceService.save(expenseDispatchPriceService); - return R.data(expenseDispatchPriceService.getId()); + List drivers = expenseDispatchPriceService.getDrivers(); + if (CollUtil.isEmpty(drivers)) { + throw new ServiceException("司机必传"); + } + List list = expenseDispatchPriceServiceService.list(); + Set collect = new HashSet<>(); + if (CollUtil.isNotEmpty(list)) { + collect = list.stream().map(ExpenseDispatchPriceServiceEntity::getDriverId).collect(Collectors.toSet()); + } + for (JSONObject driver : drivers) { + Long driverId = driver.getLong("driverId"); + if (collect.contains(driverId)) { + throw new ServiceException("司机已存在,请检查。"); + } + String driverName = driver.getString("driverName"); + ExpenseDispatchPriceServiceEntity expenseDispatchPriceServiceEntity = new ExpenseDispatchPriceServiceEntity(); + BeanUtil.copyProperties(expenseDispatchPriceService, expenseDispatchPriceServiceEntity); + expenseDispatchPriceServiceEntity.setDriverId(driverId); + expenseDispatchPriceServiceEntity.setDriverName(driverName); + expenseDispatchPriceServiceService.save(expenseDispatchPriceServiceEntity); + } + return R.data(Boolean.TRUE); } /** @@ -114,6 +143,19 @@ public class ExpenseDispatchPriceServiceController extends BladeController { @ApiOperationSupport(order = 5) @ApiOperation(value = "修改", notes = "传入expenseDispatchPriceService") public R update(@Valid @RequestBody ExpenseDispatchPriceServiceEntity expenseDispatchPriceService) { + ExpenseDispatchPriceServiceEntity byId = expenseDispatchPriceServiceService.getById(expenseDispatchPriceService.getId()); + if (ObjectUtil.isEmpty(byId)) { + throw new ServiceException("单据不存在,请联系管理员。"); + } + List list = expenseDispatchPriceServiceService.list(); + if (CollUtil.isNotEmpty(list)) { + Set collect = list.stream() + .filter(item -> !item.getDriverId().equals(byId.getDriverId())) + .map(ExpenseDispatchPriceServiceEntity::getDriverId).collect(Collectors.toSet()); + if (collect.contains(expenseDispatchPriceService.getDriverId())) { + throw new ServiceException("司机已存在,请检查。"); + } + } return R.status(expenseDispatchPriceServiceService.updateById(expenseDispatchPriceService)); } @@ -146,7 +188,7 @@ public class ExpenseDispatchPriceServiceController extends BladeController { @ApiOperation(value = "导出数据", notes = "传入expenseDispatchPriceService") public void exportExpenseDispatchPriceService(@ApiIgnore @RequestParam Map expenseDispatchPriceService, BladeUser bladeUser, HttpServletResponse response) { QueryWrapper queryWrapper = Condition.getQueryWrapper(expenseDispatchPriceService, ExpenseDispatchPriceServiceEntity.class); - //if (!AuthUtil.isAdministrator()) { + // if (!AuthUtil.isAdministrator()) { // queryWrapper.lambda().eq(ExpenseDispatchPriceService::getTenantId, bladeUser.getTenantId()); //} queryWrapper.lambda().eq(ExpenseDispatchPriceServiceEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED);