mirror of
https://github.com/zccbbg/wms-ruoyi.git
synced 2024-09-20 03:05:53 +08:00
客户物料类型维度统计出库金额
This commit is contained in:
parent
879a7465ae
commit
89f1b77c57
|
@ -2,22 +2,29 @@ package com.cyl.wms.controller;
|
|||
|
||||
import com.cyl.wms.convert.ShipmentOrderConvert;
|
||||
import com.cyl.wms.domain.ShipmentOrder;
|
||||
import com.cyl.wms.pojo.query.CustomerShipmentStatQuery;
|
||||
import com.cyl.wms.pojo.query.ShipmentOrderQuery;
|
||||
import com.cyl.wms.pojo.vo.CustomerShipmentStatVO;
|
||||
import com.cyl.wms.pojo.vo.ShipmentOrderVO;
|
||||
import com.cyl.wms.pojo.vo.form.ShipmentOrderFrom;
|
||||
import com.cyl.wms.service.ShipmentOrderService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 出库单Controller
|
||||
*
|
||||
|
@ -100,4 +107,13 @@ public class ShipmentOrderController extends BaseController {
|
|||
service.allocatedInventory(id,type);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@ApiOperation("客户物料类型维度统计出库金额")
|
||||
@PostMapping("/statByCustomerAndType")
|
||||
public ResponseEntity<List<CustomerShipmentStatVO>> statByCustomerAndType(@RequestBody CustomerShipmentStatQuery query) {
|
||||
if(StringUtils.isBlank(query.getBeginTime()) || StringUtils.isBlank(query.getEndTime())){
|
||||
throw new RuntimeException("开始或结束时间不可为空");
|
||||
}
|
||||
return ResponseEntity.ok(service.statByCustomerAndType(query));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package com.cyl.wms.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cyl.wms.domain.ShipmentOrderDetail;
|
||||
import com.cyl.wms.pojo.query.CustomerShipmentStatQuery;
|
||||
import com.cyl.wms.pojo.vo.CustomerShipmentStatVO;
|
||||
import com.cyl.wms.pojo.vo.ShipmentOrderDetailVO;
|
||||
import com.cyl.wms.pojo.vo.ShipmentOrderVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
@ -36,4 +39,6 @@ public interface ShipmentOrderDetailMapper extends BaseMapper<ShipmentOrderDetai
|
|||
List<ShipmentOrderDetail> selectListGroupByItemId(@Param("id") long ids);
|
||||
|
||||
List<ShipmentOrderDetail> selectDetailByWaveNo(String waveNo);
|
||||
|
||||
List<ShipmentOrderDetailVO> statByCustomerAndType(@Param("query") CustomerShipmentStatQuery query);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.cyl.wms.pojo.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CustomerShipmentStatQuery {
|
||||
private String beginTime;
|
||||
private String endTime;
|
||||
private Long customerId;
|
||||
private Long itemTypeId;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.cyl.wms.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class AmountStatByItemTypeVO {
|
||||
private Long itemTypeId;
|
||||
private BigDecimal amount;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.cyl.wms.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CustomerShipmentStatVO {
|
||||
private Long customerId;
|
||||
private String customerName;
|
||||
private List<AmountStatByItemTypeVO> data;
|
||||
private BigDecimal total;
|
||||
//查询出customerId customerName amount type
|
||||
}
|
|
@ -101,4 +101,10 @@ public class ShipmentOrderDetailVO extends BaseAudit {
|
|||
private List<Long> place;
|
||||
|
||||
private ItemVO item;
|
||||
|
||||
private Long itemType;
|
||||
|
||||
private String customerName;
|
||||
|
||||
private Long customerId;
|
||||
}
|
||||
|
|
|
@ -8,16 +8,11 @@ import com.cyl.wms.convert.DeliveryConvert;
|
|||
import com.cyl.wms.convert.ShipmentOrderConvert;
|
||||
import com.cyl.wms.convert.ShipmentOrderDetailConvert;
|
||||
import com.cyl.wms.domain.*;
|
||||
import com.cyl.wms.mapper.CustomerMapper;
|
||||
import com.cyl.wms.mapper.ShipmentOrderDetailMapper;
|
||||
import com.cyl.wms.mapper.ShipmentOrderMapper;
|
||||
import com.cyl.wms.pojo.query.DeliveryQuery;
|
||||
import com.cyl.wms.pojo.query.ItemQuery;
|
||||
import com.cyl.wms.pojo.query.ShipmentOrderDetailQuery;
|
||||
import com.cyl.wms.pojo.query.ShipmentOrderQuery;
|
||||
import com.cyl.wms.pojo.vo.ItemVO;
|
||||
import com.cyl.wms.pojo.vo.ReceiptOrderVO;
|
||||
import com.cyl.wms.pojo.vo.ShipmentOrderDetailVO;
|
||||
import com.cyl.wms.pojo.vo.ShipmentOrderVO;
|
||||
import com.cyl.wms.pojo.query.*;
|
||||
import com.cyl.wms.pojo.vo.*;
|
||||
import com.cyl.wms.pojo.vo.form.OrderWaveFrom;
|
||||
import com.cyl.wms.pojo.vo.form.ShipmentOrderFrom;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
|
@ -74,6 +69,8 @@ public class ShipmentOrderService {
|
|||
private CustomerTransactionService customerTransactionService;
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
@Autowired
|
||||
private CustomerMapper customerMapper;
|
||||
|
||||
/**
|
||||
* 查询出库单
|
||||
|
@ -488,4 +485,42 @@ public class ShipmentOrderService {
|
|||
qw.set(ShipmentOrder::getWaveNo, null);
|
||||
shipmentOrderMapper.update(null, qw);
|
||||
}
|
||||
|
||||
public List<CustomerShipmentStatVO> statByCustomerAndType(CustomerShipmentStatQuery query) {
|
||||
query.setBeginTime(query.getBeginTime() + " 00:00:00");
|
||||
query.setEndTime(query.getEndTime() + " 23:59:59");
|
||||
List<ShipmentOrderDetailVO> shipmentOrderDetailVOS = shipmentOrderDetailMapper.statByCustomerAndType(query);
|
||||
if (CollUtil.isEmpty(shipmentOrderDetailVOS)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//根据客户id和type分组统计
|
||||
// k:客户id k2:typeId v:统计后的金额
|
||||
Map<Long, Map<Long, BigDecimal>> data = shipmentOrderDetailVOS.stream().collect(Collectors.groupingBy(
|
||||
it -> it.getCustomerId() == null ? -1L : it.getCustomerId(),
|
||||
Collectors.groupingBy(
|
||||
ShipmentOrderDetailVO::getItemType,
|
||||
Collectors.reducing(
|
||||
BigDecimal.ZERO,
|
||||
v -> v.getMoney() == null ? BigDecimal.ZERO : v.getMoney().multiply(new BigDecimal(String.valueOf(v.getRealQuantity()))),
|
||||
BigDecimal::add)))
|
||||
);
|
||||
Map<Long, String> customerNameMap = customerMapper.selectBatchIds(data.keySet()).stream().collect(Collectors.toMap(Customer::getId, Customer::getCustomerName));
|
||||
List<CustomerShipmentStatVO> result = new ArrayList<>();
|
||||
for (Map.Entry<Long, Map<Long, BigDecimal>> entry : data.entrySet()) {
|
||||
CustomerShipmentStatVO vo = new CustomerShipmentStatVO();
|
||||
vo.setCustomerId(entry.getKey());
|
||||
vo.setData(new ArrayList<>());
|
||||
vo.setCustomerName(customerNameMap.get(entry.getKey()));
|
||||
vo.setTotal(BigDecimal.ZERO);
|
||||
result.add(vo);
|
||||
for (Map.Entry<Long, BigDecimal> inner : entry.getValue().entrySet()) {
|
||||
AmountStatByItemTypeVO innerVo = new AmountStatByItemTypeVO();
|
||||
innerVo.setItemTypeId(inner.getKey());
|
||||
innerVo.setAmount(inner.getValue());
|
||||
vo.getData().add(innerVo);
|
||||
vo.setTotal(vo.getTotal().add(innerVo.getAmount()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,4 +142,20 @@
|
|||
where sod.del_flag = 0
|
||||
and so.wave_no = #{waveNo};
|
||||
</select>
|
||||
<select id="statByCustomerAndType" resultType="com.cyl.wms.pojo.vo.ShipmentOrderDetailVO">
|
||||
select b.customer_id,a.money,a.real_quantity,d.item_type
|
||||
from wms_shipment_order_detail a
|
||||
left join wms_shipment_order b on a.shipment_order_id=b.id
|
||||
left join wms_item d on a.item_id=d.id
|
||||
where b.customer_id is not null and d.item_type is not null
|
||||
<if test="(query.beginTime != null and query.beginTime != '') and (query.endTime != null and query.endTime != '')">
|
||||
and b.create_time between #{query.beginTime} and #{query.endTime}
|
||||
</if>
|
||||
<if test="query.customerId != null">
|
||||
and b.customer_id=#{query.customerId}
|
||||
</if>
|
||||
<if test="query.itemTypeId != null">
|
||||
and d.item_type=#{query.itemTypeId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in a new issue