Browse Source

feat(all): 配送明细报表

1 优化配送明细广播推送
pre-production
zhaoqiaobo 3 months ago
parent
commit
5e0a7e2a3c
  1. 2
      blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchTrainDetailChangeEntity.java
  2. 3
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseDispatchTrainDetailMapper.xml
  3. 5
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/query/ExpenseDispatchTrainDetailQuery.java
  4. 22
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseDispatchTrainDetailServiceImpl.java
  5. 21
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseDispatchWarehouseMonthServiceImpl.java
  6. 23
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseOrderWarehouseTotalServiceImpl.java
  7. 22
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseDayServiceImpl.java
  8. 23
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseMonthServiceImpl.java
  9. 26
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseTransitMonthServiceImpl.java
  10. 29
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseTransitServiceImpl.java
  11. 97
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/util/ReportUtil.java

2
blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchTrainDetailChangeEntity.java

@ -60,6 +60,6 @@ public class ExpenseDispatchTrainDetailChangeEntity extends TenantEntity {
* 结算表id
*/
@ApiModelProperty(value = "结算表id")
private String detailId;
private Long detailId;
}

3
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseDispatchTrainDetailMapper.xml

@ -19,6 +19,9 @@
<if test="expenseDispatchTrainDetail.settlementStatus != null and expenseDispatchTrainDetail.settlementStatus != ''">
and settlement_status = #{expenseDispatchTrainDetail.settlementStatus}
</if>
<if test="expenseDispatchTrainDetail.deliveryDriver != null and expenseDispatchTrainDetail.deliveryDriver != ''">
and delivery_driver = #{expenseDispatchTrainDetail.deliveryDriver}
</if>
<if test="expenseDispatchTrainDetail.settlementYear != null and expenseDispatchTrainDetail.settlementYear != ''">
and settlement_year = #{expenseDispatchTrainDetail.settlementYear}
</if>

5
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/query/ExpenseDispatchTrainDetailQuery.java

@ -18,6 +18,11 @@ public class ExpenseDispatchTrainDetailQuery extends Query {
*/
@ApiModelProperty(value = "配送日期结束")
private String deliveryDateEnd;
/**
* 配送司机
*/
@ApiModelProperty(value = "配送司机")
private String deliveryDriver;
/**
* 车次号
*/

22
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseDispatchTrainDetailServiceImpl.java

@ -18,8 +18,11 @@ package com.logpm.statistics.service.impl;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.statistics.entity.ExpenseDispatchTrainDetailChangeEntity;
import com.logpm.statistics.entity.ExpenseDispatchTrainDetailEntity;
import com.logpm.statistics.excel.ExpenseDispatchTrainDetailExcel;
@ -40,6 +43,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 配送成本-车次成本明细表 服务实现类
@ -52,13 +56,29 @@ public class ExpenseDispatchTrainDetailServiceImpl extends BaseServiceImpl<Expen
@Resource
private IExpenseDispatchTrainDetailChangeService changeService;
@Resource
private IBasicdataWarehouseClient warehouseClient;
@Override
public IPage<ExpenseDispatchTrainDetailVO> selectExpenseDispatchTrainDetailPage(ExpenseDispatchTrainDetailQuery query) {
IPage<ExpenseDispatchTrainDetailVO> page = Condition.getPage(query);
// 增加仓库权限
buildWarehouseAuth(query);
return page.setRecords(baseMapper.selectExpenseDispatchTrainDetailPage(page, query));
}
private void buildWarehouseAuth(ExpenseDispatchTrainDetailQuery query) {
if (StrUtil.isEmpty(query.getDestinationWarehouse())) {
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse();
if (ObjectUtil.isNotEmpty(myCurrentWarehouse)) {
query.setDestinationWarehouse(myCurrentWarehouse.getName());
} else {
List<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.getMyWarehouseList();
query.setDestinationWarehouse(warehouseEntities.stream().map(BasicdataWarehouseEntity::getName).collect(Collectors.joining(",")));
}
}
}
@Override
public List<ExpenseDispatchTrainDetailExcel> exportExpenseDispatchTrainDetail(Wrapper<ExpenseDispatchTrainDetailEntity> queryWrapper) {
@ -94,6 +114,7 @@ public class ExpenseDispatchTrainDetailServiceImpl extends BaseServiceImpl<Expen
// 保存记录
ExpenseDispatchTrainDetailChangeEntity changeEntity = new ExpenseDispatchTrainDetailChangeEntity();
changeEntity.setDetailId(id);
changeEntity.setChangeAmount(changeAmount);
changeEntity.setChangeNote(changeNote);
changeEntity.setChangeOperator(AuthUtil.getNickName());
@ -107,6 +128,7 @@ public class ExpenseDispatchTrainDetailServiceImpl extends BaseServiceImpl<Expen
IPage<ExpenseDispatchTrainDetailVO> page = Condition.getPage(query);
page.setSize(-1);
page.setCurrent(1);
buildWarehouseAuth(query);
List<ExpenseDispatchTrainDetailVO> list = baseMapper.selectExpenseDispatchTrainDetailPage(page, query);
ExcelUtil.export(response, list, ExpenseDispatchTrainDetailVO.class);

21
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseDispatchWarehouseMonthServiceImpl.java

@ -20,8 +20,11 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.statistics.entity.ExpenseDispatchWarehouseMonthEntity;
import com.logpm.statistics.excel.ExpenseDispatchWarehouseMonthExcel;
import com.logpm.statistics.mapper.ExpenseDispatchWarehouseMonthMapper;
@ -34,8 +37,10 @@ import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
/**
* 配送成本-仓库月度配送成本 服务实现类
@ -47,6 +52,8 @@ import java.util.List;
public class ExpenseDispatchWarehouseMonthServiceImpl extends BaseServiceImpl<ExpenseDispatchWarehouseMonthMapper, ExpenseDispatchWarehouseMonthEntity> implements IExpenseDispatchWarehouseMonthService {
private final CollectorRegistry collectorRegistry;
@Resource
private IBasicdataWarehouseClient warehouseClient;
public ExpenseDispatchWarehouseMonthServiceImpl(CollectorRegistry collectorRegistry) {
this.collectorRegistry = collectorRegistry;
@ -55,9 +62,22 @@ public class ExpenseDispatchWarehouseMonthServiceImpl extends BaseServiceImpl<Ex
@Override
public IPage<ExpenseDispatchWarehouseMonthVO> selectExpenseDispatchWarehouseMonthPage(ExpenseDispatchTrainDetailMonthQuery query) {
IPage<ExpenseDispatchWarehouseMonthVO> page = Condition.getPage(query);
buildWarehouseAuth(query);
return page.setRecords(baseMapper.selectExpenseDispatchWarehouseMonthPage(page, query));
}
private void buildWarehouseAuth(ExpenseDispatchTrainDetailMonthQuery query) {
if (StrUtil.isEmpty(query.getDestinationWarehouse())) {
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse();
if (ObjectUtil.isNotEmpty(myCurrentWarehouse)) {
query.setDestinationWarehouse(myCurrentWarehouse.getName());
} else {
List<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.getMyWarehouseList();
query.setDestinationWarehouse(warehouseEntities.stream().map(BasicdataWarehouseEntity::getName).collect(Collectors.joining(",")));
}
}
}
@Override
public List<ExpenseDispatchWarehouseMonthExcel> exportExpenseDispatchWarehouseMonth(Wrapper<ExpenseDispatchWarehouseMonthEntity> queryWrapper) {
@ -86,6 +106,7 @@ public class ExpenseDispatchWarehouseMonthServiceImpl extends BaseServiceImpl<Ex
IPage<ExpenseDispatchWarehouseMonthVO> page = Condition.getPage(query);
page.setSize(-1);
page.setCurrent(1);
buildWarehouseAuth(query);
List<ExpenseDispatchWarehouseMonthVO> list = baseMapper.selectExpenseDispatchWarehouseMonthPage(page, query);
ExcelUtil.export(response, list, ExpenseDispatchWarehouseMonthVO.class);
}

23
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseOrderWarehouseTotalServiceImpl.java

@ -16,7 +16,11 @@
*/
package com.logpm.statistics.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.statistics.entity.ExpenseWarehouseOrderEntity;
import com.logpm.statistics.mapper.ExpenseOrderWarehouseTotalMapper;
import com.logpm.statistics.query.ExpenseWarehouseOrderQuery;
@ -27,8 +31,10 @@ import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
/**
* 订单总仓储成本明细 服务实现类
@ -39,17 +45,34 @@ import java.util.List;
@Service
public class ExpenseOrderWarehouseTotalServiceImpl extends BaseServiceImpl<ExpenseOrderWarehouseTotalMapper, ExpenseWarehouseOrderEntity> implements IExpenseOrderWarehouseTotalService {
@Resource
private IBasicdataWarehouseClient warehouseClient;
@Override
public IPage<ExpenseWarehouseOrderVO> orderPage(ExpenseWarehouseOrderQuery query) {
IPage<ExpenseWarehouseOrderVO> page = Condition.getPage(query);
buildWarehouseAuth(query);
return page.setRecords(baseMapper.selectExpenseOrderWarehouseTotalPage(page, query));
}
private void buildWarehouseAuth(ExpenseWarehouseOrderQuery query) {
if (StrUtil.isEmpty(query.getWarehouseName())) {
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse();
if (ObjectUtil.isNotEmpty(myCurrentWarehouse)) {
query.setWarehouseName(myCurrentWarehouse.getName());
} else {
List<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.getMyWarehouseList();
query.setWarehouseName(warehouseEntities.stream().map(BasicdataWarehouseEntity::getName).collect(Collectors.joining(",")));
}
}
}
@Override
public void exporOrder(HttpServletResponse response, ExpenseWarehouseOrderQuery query) {
IPage<ExpenseWarehouseOrderVO> page = Condition.getPage(query);
page.setSize(-1);
page.setCurrent(1);
buildWarehouseAuth(query);
List<ExpenseWarehouseOrderVO> list = baseMapper.selectExpenseOrderWarehouseTotalPage(page, query);
ExcelUtil.export(response, list, ExpenseWarehouseOrderVO.class);
}

22
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseDayServiceImpl.java

@ -17,7 +17,10 @@
package com.logpm.statistics.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.statistics.entity.ExpenseWarehouseDayEntity;
import com.logpm.statistics.entity.ExpenseWarehouseMonthEntity;
import com.logpm.statistics.mapper.ExpenseWarehouseDayMapper;
@ -29,9 +32,11 @@ import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* 日仓储成本统计表 服务实现类
@ -42,12 +47,28 @@ import java.util.List;
@Service
public class ExpenseWarehouseDayServiceImpl extends BaseServiceImpl<ExpenseWarehouseDayMapper, ExpenseWarehouseDayEntity> implements IExpenseWarehouseDayService {
@Resource
private IBasicdataWarehouseClient warehouseClient;
@Override
public IPage<ExpenseWarehouseDayVO> dayPage(ExpenseWarehouseDayQuery query) {
IPage<ExpenseWarehouseDayVO> page = Condition.getPage(query);
buildWarehouseAuth(query);
return page.setRecords(baseMapper.selectExpenseWarehouseDayPage(page, query));
}
private void buildWarehouseAuth(ExpenseWarehouseDayQuery query) {
if (StrUtil.isEmpty(query.getWarehouseName())) {
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse();
if (ObjectUtil.isNotEmpty(myCurrentWarehouse)) {
query.setWarehouseName(myCurrentWarehouse.getName());
} else {
List<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.getMyWarehouseList();
query.setWarehouseName(warehouseEntities.stream().map(BasicdataWarehouseEntity::getName).collect(Collectors.joining(",")));
}
}
}
@Override
public List<ExpenseWarehouseMonthEntity> statisticsMonthWarehouseExpense(int year, int month) {
if (ObjectUtil.isEmpty(year) || ObjectUtil.isEmpty(month)) {
@ -61,6 +82,7 @@ public class ExpenseWarehouseDayServiceImpl extends BaseServiceImpl<ExpenseWareh
IPage<ExpenseWarehouseDayVO> page = Condition.getPage(query);
page.setSize(-1);
page.setCurrent(1);
buildWarehouseAuth(query);
List<ExpenseWarehouseDayVO> list = baseMapper.selectExpenseWarehouseDayPage(page, query);
ExcelUtil.export(response, list, ExpenseWarehouseDayVO.class);
}

23
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseMonthServiceImpl.java

@ -16,7 +16,11 @@
*/
package com.logpm.statistics.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.statistics.entity.ExpenseWarehouseMonthEntity;
import com.logpm.statistics.mapper.ExpenseWarehouseMonthMapper;
import com.logpm.statistics.query.ExpenseWarehouseMonthQuery;
@ -27,8 +31,10 @@ import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
/**
* 月度仓储成本统计表 服务实现类
@ -39,17 +45,34 @@ import java.util.List;
@Service
public class ExpenseWarehouseMonthServiceImpl extends BaseServiceImpl<ExpenseWarehouseMonthMapper, ExpenseWarehouseMonthEntity> implements IExpenseWarehouseMonthService {
@Resource
private IBasicdataWarehouseClient warehouseClient;
@Override
public IPage<ExpenseWarehouseMonthVO> monthPage(ExpenseWarehouseMonthQuery query) {
IPage<ExpenseWarehouseMonthVO> page = Condition.getPage(query);
buildWarehouseAuth(query);
return page.setRecords(baseMapper.selectExpenseWarehouseMonthPage(page, query));
}
private void buildWarehouseAuth(ExpenseWarehouseMonthQuery query) {
if (StrUtil.isEmpty(query.getWarehouseName())) {
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse();
if (ObjectUtil.isNotEmpty(myCurrentWarehouse)) {
query.setWarehouseName(myCurrentWarehouse.getName());
} else {
List<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.getMyWarehouseList();
query.setWarehouseName(warehouseEntities.stream().map(BasicdataWarehouseEntity::getName).collect(Collectors.joining(",")));
}
}
}
@Override
public void exporMonth(HttpServletResponse response, ExpenseWarehouseMonthQuery query) {
IPage<ExpenseWarehouseMonthVO> page = Condition.getPage(query);
page.setSize(-1);
page.setCurrent(1);
buildWarehouseAuth(query);
List<ExpenseWarehouseMonthVO> list = baseMapper.selectExpenseWarehouseMonthPage(page, query);
ExcelUtil.export(response, list, ExpenseWarehouseMonthVO.class);
}

26
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseTransitMonthServiceImpl.java

@ -17,7 +17,10 @@
package com.logpm.statistics.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.statistics.entity.ExpenseWarehouseTransitMonthEntity;
import com.logpm.statistics.mapper.ExpenseWarehouseTransitMonthMapper;
import com.logpm.statistics.query.ExpenseWarehouseTransitMonthQuery;
@ -36,6 +39,7 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
/**
* 中转仓月度仓储作业账单 服务实现类
@ -48,13 +52,34 @@ import java.util.List;
public class ExpenseWarehouseTransitMonthServiceImpl extends BaseServiceImpl<ExpenseWarehouseTransitMonthMapper, ExpenseWarehouseTransitMonthEntity> implements IExpenseWarehouseTransitMonthService {
private final IExpenseWarehouseTransitChangeService expenseWarehouseTransitChangeService;
private final IBasicdataWarehouseClient warehouseClient;
@Override
public IPage<ExpenseWarehouseTransitMonthVO> selectExpenseWarehouseTransitMonthPage(ExpenseWarehouseTransitMonthQuery query) {
IPage<ExpenseWarehouseTransitMonthVO> page = Condition.getPage(query);
buildWarehouseAuth(query);
return page.setRecords(baseMapper.selectExpenseWarehouseTransitMonthPage(page, query));
}
private void buildWarehouseAuth(ExpenseWarehouseTransitMonthQuery query) {
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse();
List<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.getMyWarehouseList();
if (StrUtil.isEmpty(query.getTransitWarehouseName())) {
if (ObjectUtil.isNotEmpty(myCurrentWarehouse)) {
query.setTransitWarehouseName(myCurrentWarehouse.getName());
} else {
query.setTransitWarehouseName(warehouseEntities.stream().map(BasicdataWarehouseEntity::getName).collect(Collectors.joining(",")));
}
}
if (StrUtil.isEmpty(query.getDestinationWarehouseName())) {
if (ObjectUtil.isNotEmpty(myCurrentWarehouse)) {
query.setDestinationWarehouseName(myCurrentWarehouse.getName());
} else {
query.setDestinationWarehouseName(warehouseEntities.stream().map(BasicdataWarehouseEntity::getName).collect(Collectors.joining(",")));
}
}
}
@Override
public ExpenseWarehouseTransitMonthVO detail(Long id, String type) {
if (ObjectUtil.isEmpty(id)) {
@ -75,6 +100,7 @@ public class ExpenseWarehouseTransitMonthServiceImpl extends BaseServiceImpl<Exp
IPage<ExpenseWarehouseTransitMonthVO> page = Condition.getPage(query);
page.setSize(-1);
page.setCurrent(1);
buildWarehouseAuth(query);
List<ExpenseWarehouseTransitMonthVO> list = baseMapper.selectExpenseWarehouseTransitMonthPage(page, query);
ExcelUtil.export(response, list, ExpenseWarehouseTransitMonthVO.class);
}

29
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseTransitServiceImpl.java

@ -16,8 +16,12 @@
*/
package com.logpm.statistics.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.statistics.entity.ExpenseWarehouseTransitEntity;
import com.logpm.statistics.excel.ExpenseWarehouseTransitExcel;
import com.logpm.statistics.mapper.ExpenseWarehouseTransitMapper;
@ -29,8 +33,10 @@ import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
/**
* 中转仓仓储作业明细 服务实现类
@ -41,12 +47,34 @@ import java.util.List;
@Service
public class ExpenseWarehouseTransitServiceImpl extends BaseServiceImpl<ExpenseWarehouseTransitMapper, ExpenseWarehouseTransitEntity> implements IExpenseWarehouseTransitService {
@Resource
private IBasicdataWarehouseClient warehouseClient;
@Override
public IPage<ExpenseWarehouseTransitVO> selectExpenseWarehouseTransitPage(ExpenseWarehouseTransitQuery query) {
IPage<ExpenseWarehouseTransitVO> page = Condition.getPage(query);
buildWarehouseAuth(query);
return page.setRecords(baseMapper.selectExpenseWarehouseTransitPage(page, query));
}
private void buildWarehouseAuth(ExpenseWarehouseTransitQuery query) {
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse();
List<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.getMyWarehouseList();
if (StrUtil.isEmpty(query.getTransitWarehouseName())) {
if (ObjectUtil.isNotEmpty(myCurrentWarehouse)) {
query.setTransitWarehouseName(myCurrentWarehouse.getName());
} else {
query.setTransitWarehouseName(warehouseEntities.stream().map(BasicdataWarehouseEntity::getName).collect(Collectors.joining(",")));
}
}
if (StrUtil.isEmpty(query.getDestinationWarehouseName())) {
if (ObjectUtil.isNotEmpty(myCurrentWarehouse)) {
query.setDestinationWarehouseName(myCurrentWarehouse.getName());
} else {
query.setDestinationWarehouseName(warehouseEntities.stream().map(BasicdataWarehouseEntity::getName).collect(Collectors.joining(",")));
}
}
}
@Override
public List<ExpenseWarehouseTransitExcel> exportExpenseWarehouseTransit(Wrapper<ExpenseWarehouseTransitEntity> queryWrapper) {
@ -62,6 +90,7 @@ public class ExpenseWarehouseTransitServiceImpl extends BaseServiceImpl<ExpenseW
IPage<ExpenseWarehouseTransitVO> page = Condition.getPage(query);
page.setSize(-1);
page.setCurrent(1);
buildWarehouseAuth(query);
List<ExpenseWarehouseTransitVO> list = baseMapper.selectExpenseWarehouseTransitPage(page, query);
ExcelUtil.export(response, list, ExpenseWarehouseTransitVO.class);
}

97
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/util/ReportUtil.java

@ -0,0 +1,97 @@
package com.logpm.statistics.util;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import org.springblade.core.log.exception.ServiceException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 报表工具类
*
* @Author zqb
* @Date 2024/6/13
**/
public class ReportUtil {
/**
* 校验两个时间相差不超过 30
* 如果不跨月则返回 true
* 如果跨月则不超过 30
*
* @Param start 开始时间
* @Param end 解释时间
* @Return boolean
* @Author zqb 2024/6/13
**/
public static boolean isWithinOneMonth(Date start, Date end) {
// 检查输入是否为null
if (start == null || end == null) {
return false;
}
// 是否跨月,不跨越则直接返回true
if (DateUtil.year(start) == DateUtil.year(end) && DateUtil.month(start) == DateUtil.month(end)) {
return true;
}
// 跨越则判断两个日期是否相差超过30天
return DateUtil.between(start, end, DateUnit.DAY) <= 30;
}
public static void buildReportWarehouseAuth(String warehouseName, String warehouseNameRange,
QueryWrapper queryWrapper, IBasicdataWarehouseClient warehouseClient) {
if (StrUtil.isEmpty(warehouseName) && StrUtil.isEmpty(warehouseNameRange)) {
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse();
if (ObjectUtil.isNotEmpty(myCurrentWarehouse)) {
queryWrapper.eq("warehouse_id", myCurrentWarehouse.getId());
} else {
List<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.getMyWarehouseList();
queryWrapper.in("warehouse_id", warehouseEntities.stream().map(BasicdataWarehouseEntity::getId).collect(Collectors.toList()));
}
}
}
public static void dateIsWithinOneMonth(String taskTime, Date startTaskTime, Date endTaskTime, String title) {
if (ObjectUtil.isEmpty(taskTime)) {
boolean withinOneMonth = isWithinOneMonth(startTaskTime, endTaskTime);
if (!withinOneMonth) {
throw new ServiceException(title + "必选且时间不超过一个月");
}
}
}
public static boolean areAllPropertiesEmpty(Object obj) {
if (obj == null) return true;
return Stream.of(obj.getClass().getDeclaredFields())
.filter(field -> !field.getName().equals("serialVersionUID"))
.peek(field -> field.setAccessible(true)) // 设置所有字段可访问
.allMatch(field -> {
Object value = null;
try {
value = field.get(obj);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
if (value == null) return true;
if (value instanceof String) return ((String) value).isEmpty();
if (value instanceof Collection) return ((Collection<?>) value).isEmpty();
if (value instanceof Map) return ((Map<?, ?>) value).isEmpty();
if (value.getClass().isArray()) return Arrays.asList((Object[]) value).isEmpty();
// 对于基本类型或其他不可空类型,你可能需要返回 false 或进行更详细的检查
return false;
});
}
}
Loading…
Cancel
Save