|
|
|
@ -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); |
|
|
|
|