Browse Source

feat(all): 服务商成本维护

1 增加批量新增司机
dev
zhaoqiaobo 1 month ago
parent
commit
b36839554b
  1. 8
      blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchPriceServiceEntity.java
  2. 48
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/ExpenseDispatchPriceServiceController.java

8
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<JSONObject> drivers;
}

48
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<JSONObject> drivers = expenseDispatchPriceService.getDrivers();
if (CollUtil.isEmpty(drivers)) {
throw new ServiceException("司机必传");
}
List<ExpenseDispatchPriceServiceEntity> list = expenseDispatchPriceServiceService.list();
Set<Long> 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<ExpenseDispatchPriceServiceEntity> list = expenseDispatchPriceServiceService.list();
if (CollUtil.isNotEmpty(list)) {
Set<Long> 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<String, Object> expenseDispatchPriceService, BladeUser bladeUser, HttpServletResponse response) {
QueryWrapper<ExpenseDispatchPriceServiceEntity> 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);

Loading…
Cancel
Save