入库后续相关代码修复
This commit is contained in:
parent
1c0a5c3f13
commit
d1fcb0d4d5
|
|
@ -87,8 +87,6 @@ public class ReportInventoryBaseController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,8 @@ public class ImsIntoInventoryDetailAdd implements Serializable
|
||||||
|
|
||||||
/** 入库原料照片 */
|
/** 入库原料照片 */
|
||||||
@ApiModelProperty(value = "入库原料照片")
|
@ApiModelProperty(value = "入库原料照片")
|
||||||
@NotNull(message = "入库原料照片不能为空")
|
// @NotNull(message = "入库原料照片不能为空")
|
||||||
private String imgUrl;
|
private String imgUrl="";
|
||||||
|
|
||||||
/** 是否补库存明细(1是2否) */
|
/** 是否补库存明细(1是2否) */
|
||||||
@ApiModelProperty(value = "是否补库存明细(1是2否)")
|
@ApiModelProperty(value = "是否补库存明细(1是2否)")
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.bonus.canteen.core.ims.dto.ImsIndexDateDTO;
|
||||||
import com.bonus.canteen.core.ims.report.ReportInventoryIntoDetailParam;
|
import com.bonus.canteen.core.ims.report.ReportInventoryIntoDetailParam;
|
||||||
import com.bonus.canteen.core.ims.report.ReportInventoryOutDetailParam;
|
import com.bonus.canteen.core.ims.report.ReportInventoryOutDetailParam;
|
||||||
import com.bonus.canteen.core.ims.vo.*;
|
import com.bonus.canteen.core.ims.vo.*;
|
||||||
|
import com.bonus.canteen.core.kitchen.vo.IndexMapCountVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -92,4 +93,16 @@ public interface ReportInventoryMapper {
|
||||||
BigDecimal getStoreAmount(@Param("param")ImsIndexDateDTO thisTime);
|
BigDecimal getStoreAmount(@Param("param")ImsIndexDateDTO thisTime);
|
||||||
|
|
||||||
BigDecimal getOutboundAmount(@Param("param")ImsIndexDateDTO thisTime);
|
BigDecimal getOutboundAmount(@Param("param")ImsIndexDateDTO thisTime);
|
||||||
|
|
||||||
|
List<IndexMapCountVO> getOutImsRanking(@Param("param") ImsIndexDateDTO thisTime);
|
||||||
|
|
||||||
|
List<IndexMapCountVO> getIntoImsRanking(@Param("param") ImsIndexDateDTO thisTime);
|
||||||
|
|
||||||
|
List<IndexMapCountVO> getAcceptanceProportion(@Param("param") ImsIndexDateDTO thisTime);
|
||||||
|
|
||||||
|
List<IndexMapCountVO> getInventoryProportion(@Param("param") ImsIndexDateDTO thisTime);
|
||||||
|
|
||||||
|
List<IndexMapCountVO> getOrderSupplier(@Param("param") ImsIndexDateDTO thisTime);
|
||||||
|
|
||||||
|
List<IndexMapCountVO> getOrderCanteen(@Param("param") ImsIndexDateDTO thisTime);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -279,8 +279,12 @@ public class ImsIntoInventoryServiceImpl implements IImsIntoInventoryService
|
||||||
reportInventoryBase.setFetchUserId(-1L);
|
reportInventoryBase.setFetchUserId(-1L);
|
||||||
reportInventoryBase.setOperatorId("王大力");
|
reportInventoryBase.setOperatorId("王大力");
|
||||||
reportInventoryBase.setOperateTime(DateUtils.getNowDate());
|
reportInventoryBase.setOperateTime(DateUtils.getNowDate());
|
||||||
|
if(Objects.nonNull(detail.getInventoryId())){
|
||||||
reportInventoryBaseMapper.insertReportInventoryBase(reportInventoryBase); //新增库存记录基础信息
|
reportInventoryBaseMapper.insertReportInventoryBase(reportInventoryBase); //新增库存记录基础信息
|
||||||
reportInventoryMapper.insertReportInventory(reportInventory); //新增库存记录
|
reportInventoryMapper.insertReportInventory(reportInventory); //新增库存记录
|
||||||
|
}else{
|
||||||
|
return;
|
||||||
|
}
|
||||||
updatetReportInventoryDTO.setWarehouseId(imsOutInventory.getWarehouseId());
|
updatetReportInventoryDTO.setWarehouseId(imsOutInventory.getWarehouseId());
|
||||||
updatetReportInventoryDTO.setMaterialId(detail.getMaterialId());
|
updatetReportInventoryDTO.setMaterialId(detail.getMaterialId());
|
||||||
updatetReportInventoryDTO.setReportInventoryId(reportInventory.getId());
|
updatetReportInventoryDTO.setReportInventoryId(reportInventory.getId());
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@ import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.time.*;
|
import java.time.*;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.bonus.canteen.core.ims.domain.ImsOutInventory;
|
import com.bonus.canteen.core.ims.domain.ImsOutInventory;
|
||||||
|
|
@ -27,6 +25,7 @@ import com.bonus.canteen.core.ims.service.IImsIntoInventoryService;
|
||||||
import com.bonus.canteen.core.ims.service.IImsInventoryService;
|
import com.bonus.canteen.core.ims.service.IImsInventoryService;
|
||||||
import com.bonus.canteen.core.ims.service.IImsOutInventoryService;
|
import com.bonus.canteen.core.ims.service.IImsOutInventoryService;
|
||||||
import com.bonus.canteen.core.ims.vo.*;
|
import com.bonus.canteen.core.ims.vo.*;
|
||||||
|
import com.bonus.canteen.core.kitchen.vo.IndexMapCountVO;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
import org.apache.catalina.security.SecurityUtil;
|
import org.apache.catalina.security.SecurityUtil;
|
||||||
|
|
@ -120,52 +119,74 @@ public class ReportInventoryBaseServiceImpl implements IReportInventoryBaseServi
|
||||||
ImsIndexDataVO imsIndexDataVO = new ImsIndexDataVO();
|
ImsIndexDataVO imsIndexDataVO = new ImsIndexDataVO();
|
||||||
ImsIndexDateDTO thisTime = new ImsIndexDateDTO();
|
ImsIndexDateDTO thisTime = new ImsIndexDateDTO();
|
||||||
ImsIndexDateDTO beforeTime = new ImsIndexDateDTO();
|
ImsIndexDateDTO beforeTime = new ImsIndexDateDTO();
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
thisTime.setType(type);
|
thisTime.setType(type);
|
||||||
if(type ==1){
|
formatDate(thisTime, beforeTime, type);
|
||||||
LocalDateTime thisStartDate = LocalDate.now().withDayOfMonth(1).atStartOfDay();
|
|
||||||
// 获取当月最后一天结束时间(23:59:59.999999999)
|
|
||||||
LocalDateTime thisEndDate = LocalDate.now().withDayOfMonth(YearMonth.now().lengthOfMonth()).atTime(LocalTime.MAX);
|
|
||||||
LocalDateTime beforeStartDate = LocalDate.now().minusMonths(1).withDayOfMonth(1).atStartOfDay();
|
|
||||||
// 获取上月结束时间(最后一天 23:59:59.999999999)
|
|
||||||
LocalDateTime beforeEndDate = YearMonth.now().minusMonths(1).atEndOfMonth().atTime(LocalTime.MAX);
|
|
||||||
thisTime.setStartDate(thisStartDate.format(formatter));
|
|
||||||
thisTime.setEndDate(thisEndDate.format(formatter));
|
|
||||||
beforeTime.setStartDate(beforeStartDate.format(formatter));
|
|
||||||
beforeTime.setEndDate(beforeEndDate.format(formatter));
|
|
||||||
}else if(type ==2){
|
|
||||||
LocalDate monday = LocalDate.now().with(DayOfWeek.MONDAY);
|
|
||||||
// 获取本周日(结束日期)
|
|
||||||
LocalDate sunday = LocalDate.now().with(DayOfWeek.SUNDAY);
|
|
||||||
// 本周开始时间(周一 00:00:00)
|
|
||||||
LocalDateTime thisWeekStart = monday.atStartOfDay();
|
|
||||||
// 本周结束时间(周日 23:59:59.999999999)
|
|
||||||
LocalDateTime thisWeekEnd = sunday.atTime(LocalTime.MAX);
|
|
||||||
LocalDate lastMonday = LocalDate.now().minusWeeks(1).with(DayOfWeek.MONDAY); // 设置为周一
|
|
||||||
// 获取上周日(结束日期)
|
|
||||||
LocalDate lastSunday = lastMonday.plusDays(6); // 周一加6天到周日
|
|
||||||
// 上周开始时间(周一 00:00:00)
|
|
||||||
LocalDateTime beforeWeekStart = lastMonday.atStartOfDay();
|
|
||||||
// 上周结束时间(周日 23:59:59.999999999)
|
|
||||||
LocalDateTime beforelastWeekEnd = lastSunday.atTime(LocalTime.MAX);
|
|
||||||
thisTime.setStartDate(thisWeekStart.format(formatter));
|
|
||||||
thisTime.setEndDate(thisWeekEnd.format(formatter));
|
|
||||||
beforeTime.setStartDate(beforeWeekStart.format(formatter));
|
|
||||||
beforeTime.setEndDate(beforelastWeekEnd.format(formatter));
|
|
||||||
}else{
|
|
||||||
//不做处理
|
|
||||||
}
|
|
||||||
//采购订单总金额
|
//采购订单总金额
|
||||||
getTotalOrderAmount(thisTime, beforeTime, imsIndexDataVO);
|
getTotalOrderAmount(thisTime, beforeTime, imsIndexDataVO);
|
||||||
|
//采购订单数量(个)
|
||||||
getTotalOrderNum(thisTime, beforeTime, imsIndexDataVO);
|
getTotalOrderNum(thisTime, beforeTime, imsIndexDataVO);
|
||||||
|
//未验收完成采购订单数(个)
|
||||||
getUnFinshOrderNum(thisTime, beforeTime, imsIndexDataVO);
|
getUnFinshOrderNum(thisTime, beforeTime, imsIndexDataVO);
|
||||||
|
//采购订单货品总数
|
||||||
getTotalOrderGoodsNum(thisTime, beforeTime, imsIndexDataVO);
|
getTotalOrderGoodsNum(thisTime, beforeTime, imsIndexDataVO);
|
||||||
|
//入库货品数量
|
||||||
getStoreNum(thisTime, beforeTime, imsIndexDataVO);
|
getStoreNum(thisTime, beforeTime, imsIndexDataVO);
|
||||||
|
//出库货品数量
|
||||||
getOutboundNum(thisTime, beforeTime, imsIndexDataVO);
|
getOutboundNum(thisTime, beforeTime, imsIndexDataVO);
|
||||||
|
//入库总金额(元)
|
||||||
getStoreAmount(thisTime, beforeTime, imsIndexDataVO);
|
getStoreAmount(thisTime, beforeTime, imsIndexDataVO);
|
||||||
|
//出库总金额(元)
|
||||||
getOutboundAmount(thisTime, beforeTime, imsIndexDataVO);
|
getOutboundAmount(thisTime, beforeTime, imsIndexDataVO);
|
||||||
|
//出库排名
|
||||||
|
getOutImsRanking(thisTime, imsIndexDataVO);
|
||||||
|
//入库排名
|
||||||
|
getIntoImsRanking(thisTime, imsIndexDataVO);
|
||||||
|
//验收占比
|
||||||
|
getAcceptanceProportion(thisTime, imsIndexDataVO);
|
||||||
|
//库存占比
|
||||||
|
getInventoryProportion(thisTime, imsIndexDataVO);
|
||||||
|
//供应商占比
|
||||||
|
getOrderSupplier(thisTime, imsIndexDataVO);
|
||||||
|
//食堂占比
|
||||||
|
getOrderCanteen(thisTime, imsIndexDataVO);
|
||||||
return imsIndexDataVO;
|
return imsIndexDataVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getOrderCanteen( ImsIndexDateDTO thisTime , ImsIndexDataVO imsIndexDataVO){
|
||||||
|
List<IndexMapCountVO> orderCanteen = reportInventoryMapper.getOrderCanteen(thisTime);
|
||||||
|
getRate(orderCanteen);
|
||||||
|
imsIndexDataVO.setOrderCanteen(orderCanteen);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getOrderSupplier( ImsIndexDateDTO thisTime , ImsIndexDataVO imsIndexDataVO){
|
||||||
|
List<IndexMapCountVO> rrderSupplier = reportInventoryMapper.getOrderSupplier(thisTime);
|
||||||
|
getRate(rrderSupplier);
|
||||||
|
imsIndexDataVO.setOrderSupplier(rrderSupplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getInventoryProportion( ImsIndexDateDTO thisTime , ImsIndexDataVO imsIndexDataVO){
|
||||||
|
List<IndexMapCountVO> inventoryProportion = reportInventoryMapper.getInventoryProportion(thisTime);
|
||||||
|
getRate(inventoryProportion);
|
||||||
|
imsIndexDataVO.setInventoryProportion(inventoryProportion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getAcceptanceProportion( ImsIndexDateDTO thisTime , ImsIndexDataVO imsIndexDataVO){
|
||||||
|
List<IndexMapCountVO> acceptanceProportion = reportInventoryMapper.getAcceptanceProportion(thisTime);
|
||||||
|
getRate(acceptanceProportion);
|
||||||
|
imsIndexDataVO.setAcceptanceProportion(acceptanceProportion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getIntoImsRanking( ImsIndexDateDTO thisTime , ImsIndexDataVO imsIndexDataVO){
|
||||||
|
List<IndexMapCountVO> intoImsRanking = reportInventoryMapper.getIntoImsRanking(thisTime);
|
||||||
|
getRate(intoImsRanking);
|
||||||
|
imsIndexDataVO.setIntoImsRanking(intoImsRanking);
|
||||||
|
}
|
||||||
|
private void getOutImsRanking( ImsIndexDateDTO thisTime , ImsIndexDataVO imsIndexDataVO){
|
||||||
|
List<IndexMapCountVO> outImsRanking = reportInventoryMapper.getOutImsRanking(thisTime);
|
||||||
|
getRate(outImsRanking);
|
||||||
|
imsIndexDataVO.setOutImsRanking(outImsRanking);
|
||||||
|
}
|
||||||
|
|
||||||
private void getOutboundAmount( ImsIndexDateDTO thisTime , ImsIndexDateDTO beforeTime, ImsIndexDataVO imsIndexDataVO){
|
private void getOutboundAmount( ImsIndexDateDTO thisTime , ImsIndexDateDTO beforeTime, ImsIndexDataVO imsIndexDataVO){
|
||||||
BigDecimal totalOrderAmount_this = reportInventoryMapper.getOutboundAmount(thisTime);
|
BigDecimal totalOrderAmount_this = reportInventoryMapper.getOutboundAmount(thisTime);
|
||||||
BigDecimal totalOrderAmount_before = reportInventoryMapper.getOutboundAmount(beforeTime);
|
BigDecimal totalOrderAmount_before = reportInventoryMapper.getOutboundAmount(beforeTime);
|
||||||
|
|
@ -218,6 +239,65 @@ public class ReportInventoryBaseServiceImpl implements IReportInventoryBaseServi
|
||||||
imsIndexDataVO.setTotalOrderAmount(bean);
|
imsIndexDataVO.setTotalOrderAmount(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void formatDate(ImsIndexDateDTO thisTime, ImsIndexDateDTO beforeTime,Long type) {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
if(type ==1){
|
||||||
|
LocalDateTime thisStartDate = LocalDate.now().withDayOfMonth(1).atStartOfDay();
|
||||||
|
// 获取当月最后一天结束时间(23:59:59.999999999)
|
||||||
|
LocalDateTime thisEndDate = LocalDate.now().withDayOfMonth(YearMonth.now().lengthOfMonth()).atTime(LocalTime.MAX);
|
||||||
|
LocalDateTime beforeStartDate = LocalDate.now().minusMonths(1).withDayOfMonth(1).atStartOfDay();
|
||||||
|
// 获取上月结束时间(最后一天 23:59:59.999999999)
|
||||||
|
LocalDateTime beforeEndDate = YearMonth.now().minusMonths(1).atEndOfMonth().atTime(LocalTime.MAX);
|
||||||
|
thisTime.setStartDate(thisStartDate.format(formatter));
|
||||||
|
thisTime.setEndDate(thisEndDate.format(formatter));
|
||||||
|
beforeTime.setStartDate(beforeStartDate.format(formatter));
|
||||||
|
beforeTime.setEndDate(beforeEndDate.format(formatter));
|
||||||
|
}else if(type ==2){
|
||||||
|
LocalDate monday = LocalDate.now().with(DayOfWeek.MONDAY);
|
||||||
|
// 获取本周日(结束日期)
|
||||||
|
LocalDate sunday = LocalDate.now().with(DayOfWeek.SUNDAY);
|
||||||
|
// 本周开始时间(周一 00:00:00)
|
||||||
|
LocalDateTime thisWeekStart = monday.atStartOfDay();
|
||||||
|
// 本周结束时间(周日 23:59:59.999999999)
|
||||||
|
LocalDateTime thisWeekEnd = sunday.atTime(LocalTime.MAX);
|
||||||
|
LocalDate lastMonday = LocalDate.now().minusWeeks(1).with(DayOfWeek.MONDAY); // 设置为周一
|
||||||
|
// 获取上周日(结束日期)
|
||||||
|
LocalDate lastSunday = lastMonday.plusDays(6); // 周一加6天到周日
|
||||||
|
// 上周开始时间(周一 00:00:00)
|
||||||
|
LocalDateTime beforeWeekStart = lastMonday.atStartOfDay();
|
||||||
|
// 上周结束时间(周日 23:59:59.999999999)
|
||||||
|
LocalDateTime beforelastWeekEnd = lastSunday.atTime(LocalTime.MAX);
|
||||||
|
thisTime.setStartDate(thisWeekStart.format(formatter));
|
||||||
|
thisTime.setEndDate(thisWeekEnd.format(formatter));
|
||||||
|
beforeTime.setStartDate(beforeWeekStart.format(formatter));
|
||||||
|
beforeTime.setEndDate(beforelastWeekEnd.format(formatter));
|
||||||
|
}else{
|
||||||
|
//不做处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void getRate(List<IndexMapCountVO> list) {
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
Long totalCount = list.stream()
|
||||||
|
.map(IndexMapCountVO::getCount)
|
||||||
|
.reduce(0, Integer::sum)
|
||||||
|
.longValue();
|
||||||
|
for (IndexMapCountVO bean : list) {
|
||||||
|
if(totalCount != null){
|
||||||
|
if (BigDecimal.valueOf(totalCount).compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
bean.setPercentage(0.0);
|
||||||
|
} else {
|
||||||
|
Integer countNum = bean.getCount() == null ? 0 : bean.getCount();
|
||||||
|
// 计算百分比
|
||||||
|
BigDecimal count = BigDecimal.valueOf(countNum);
|
||||||
|
BigDecimal rate =count.divide(BigDecimal.valueOf(totalCount), 2, RoundingMode.HALF_UP)
|
||||||
|
.multiply(new BigDecimal("100"));
|
||||||
|
bean.setPercentage(rate.doubleValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
private ImsIndexDataDetailsVO getRate(BigDecimal totalOrderAmount_this,BigDecimal totalOrderAmount_before) {
|
private ImsIndexDataDetailsVO getRate(BigDecimal totalOrderAmount_this,BigDecimal totalOrderAmount_before) {
|
||||||
ImsIndexDataDetailsVO totalOrderAmount = new ImsIndexDataDetailsVO();
|
ImsIndexDataDetailsVO totalOrderAmount = new ImsIndexDataDetailsVO();
|
||||||
BigDecimal rate;
|
BigDecimal rate;
|
||||||
|
|
@ -399,25 +479,32 @@ public class ReportInventoryBaseServiceImpl implements IReportInventoryBaseServi
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Set<Long> duplicateMaterialIds = findDuplicateMaterialIds(updatetReportInventoryDTOList);
|
||||||
if(updatetReportInventoryDTOList !=null && updatetReportInventoryDTOList.size()>0){
|
if(updatetReportInventoryDTOList !=null && updatetReportInventoryDTOList.size()>0){
|
||||||
for(UpdatetReportInventoryDTO updatetReportInventoryDTO : updatetReportInventoryDTOList){
|
for(UpdatetReportInventoryDTO updatetReportInventoryDTO : updatetReportInventoryDTOList){
|
||||||
Long materialId = updatetReportInventoryDTO.getMaterialId();
|
Long materialId = updatetReportInventoryDTO.getMaterialId();
|
||||||
if (materialIMoneyMap.containsKey(materialId )) {
|
if (materialIMoneyMap.containsKey(materialId)) {
|
||||||
BigDecimal monerValue = materialIMoneyMap.get(materialId);
|
BigDecimal monerValue = materialIMoneyMap.get(materialId);
|
||||||
BigDecimal mumValue = materialINumMap.get(materialId);
|
BigDecimal mumValue = materialINumMap.get(materialId);
|
||||||
if(1== type){
|
if(1== type){
|
||||||
|
if(duplicateMaterialIds.contains(materialId)){
|
||||||
//如果存在则减去
|
//如果存在则减去
|
||||||
monerValue = monerValue.subtract(BigDecimal.valueOf(updatetReportInventoryDTO.getTotalPrice()));
|
monerValue = monerValue.subtract(BigDecimal.valueOf(updatetReportInventoryDTO.getTotalPrice()));
|
||||||
materialIMoneyMap.put(materialId, monerValue.setScale(2, RoundingMode.HALF_UP));
|
materialIMoneyMap.put(materialId, monerValue.setScale(2, RoundingMode.HALF_UP));
|
||||||
mumValue = mumValue.subtract(updatetReportInventoryDTO.getPurNum());
|
mumValue = mumValue.subtract(updatetReportInventoryDTO.getPurNum());
|
||||||
materialIMoneyMap.put(materialId, mumValue.setScale(2, RoundingMode.HALF_UP));
|
materialIMoneyMap.put(materialId, mumValue.setScale(2, RoundingMode.HALF_UP));
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
//如果存在则累加
|
//如果存在则累加
|
||||||
|
if(duplicateMaterialIds.contains(materialId)){
|
||||||
monerValue = monerValue.add(BigDecimal.valueOf(updatetReportInventoryDTO.getTotalPrice()));
|
monerValue = monerValue.add(BigDecimal.valueOf(updatetReportInventoryDTO.getTotalPrice()));
|
||||||
materialIMoneyMap.put(materialId, monerValue.setScale(2, RoundingMode.HALF_UP));
|
materialIMoneyMap.put(materialId, monerValue.setScale(2, RoundingMode.HALF_UP));
|
||||||
mumValue = mumValue.add(updatetReportInventoryDTO.getPurNum());
|
mumValue = mumValue.add(updatetReportInventoryDTO.getPurNum());
|
||||||
materialINumMap.put(materialId, mumValue.setScale(2, RoundingMode.HALF_UP));
|
materialINumMap.put(materialId, mumValue.setScale(2, RoundingMode.HALF_UP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
materialIMoneyMap.put(materialId, monerValue);
|
materialIMoneyMap.put(materialId, monerValue);
|
||||||
materialINumMap.put(materialId, mumValue);
|
materialINumMap.put(materialId, mumValue);
|
||||||
|
|
||||||
|
|
@ -437,6 +524,25 @@ public class ReportInventoryBaseServiceImpl implements IReportInventoryBaseServi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Long> findDuplicateMaterialIds(List<UpdatetReportInventoryDTO> list) {
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
return Collections.emptySet(); // 如果列表为空,返回空集合
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 按 materialId 分组,并计算每个 materialId 出现的次数
|
||||||
|
Map<Long, Long> materialIdCountMap = list.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
UpdatetReportInventoryDTO::getMaterialId,
|
||||||
|
Collectors.counting()
|
||||||
|
));
|
||||||
|
|
||||||
|
// 2. 筛选出出现次数 >1 的 materialId
|
||||||
|
return materialIdCountMap.entrySet().stream()
|
||||||
|
.filter(entry -> entry.getValue() > 1) // 只保留重复的 materialId
|
||||||
|
.map(Map.Entry::getKey)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
public List<Long> getDistinctMaterialIds(List<UpdatetReportInventoryDTO> list){
|
public List<Long> getDistinctMaterialIds(List<UpdatetReportInventoryDTO> list){
|
||||||
return list.stream()
|
return list.stream()
|
||||||
.map(UpdatetReportInventoryDTO :: getMaterialId)
|
.map(UpdatetReportInventoryDTO :: getMaterialId)
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,11 @@ public class SupplierBindMaterialServiceImpl implements ISupplierBindMaterialSer
|
||||||
public List<SupplierBindMaterial> selectSupplierBindMaterialList(SupplierBindMaterial supplierBindMaterial) {
|
public List<SupplierBindMaterial> selectSupplierBindMaterialList(SupplierBindMaterial supplierBindMaterial) {
|
||||||
List<SupplierBindMaterial> list = supplierBindMaterialMapper.selectSupplierBindMaterialList(supplierBindMaterial);
|
List<SupplierBindMaterial> list = supplierBindMaterialMapper.selectSupplierBindMaterialList(supplierBindMaterial);
|
||||||
for (SupplierBindMaterial bindMaterial : list) {
|
for (SupplierBindMaterial bindMaterial : list) {
|
||||||
|
if(bindMaterial.getAlternativeSupplier() != null){
|
||||||
bindMaterial.setAlternativeSuppliers((List<SupplierDTO>) JacksonUtil.readValue(bindMaterial.getAlternativeSupplier(), List.class));
|
bindMaterial.setAlternativeSuppliers((List<SupplierDTO>) JacksonUtil.readValue(bindMaterial.getAlternativeSupplier(), List.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,6 +96,7 @@ public class SupplierBindMaterialServiceImpl implements ISupplierBindMaterialSer
|
||||||
supplierBindMaterial.setUpdateTime(DateUtils.getNowDate());
|
supplierBindMaterial.setUpdateTime(DateUtils.getNowDate());
|
||||||
supplierBindMaterial.setUpdateBy(SecurityUtils.getUsername());
|
supplierBindMaterial.setUpdateBy(SecurityUtils.getUsername());
|
||||||
List<SupplierDTO> alternativeSuppliers = supplierBindMaterial.getAlternativeSuppliers();
|
List<SupplierDTO> alternativeSuppliers = supplierBindMaterial.getAlternativeSuppliers();
|
||||||
|
if(alternativeSuppliers != null){
|
||||||
for (SupplierDTO supplierDTO : alternativeSuppliers) {
|
for (SupplierDTO supplierDTO : alternativeSuppliers) {
|
||||||
Supplier supplier = supplierMapper.selectSupplierBySupplierId(supplierDTO.getSupplierId());
|
Supplier supplier = supplierMapper.selectSupplierBySupplierId(supplierDTO.getSupplierId());
|
||||||
if (Objects.nonNull(supplier)) {
|
if (Objects.nonNull(supplier)) {
|
||||||
|
|
@ -104,6 +108,7 @@ public class SupplierBindMaterialServiceImpl implements ISupplierBindMaterialSer
|
||||||
supplierBindMaterial.setAlternativeSupplier(JacksonUtil.writeValueAsString(alternativeSuppliers));
|
supplierBindMaterial.setAlternativeSupplier(JacksonUtil.writeValueAsString(alternativeSuppliers));
|
||||||
count += supplierBindMaterialMapper.updateSupplierBindMaterial(supplierBindMaterial);
|
count += supplierBindMaterialMapper.updateSupplierBindMaterial(supplierBindMaterial);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package com.bonus.canteen.core.ims.vo;
|
package com.bonus.canteen.core.ims.vo;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.kitchen.vo.IndexMapCountVO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xliu
|
* @author xliu
|
||||||
* @date 2025/7/23 15:13
|
* @date 2025/7/23 15:13
|
||||||
|
|
@ -28,12 +31,30 @@ public class ImsIndexDataVO {
|
||||||
//出库货品数量
|
//出库货品数量
|
||||||
private ImsIndexDataDetailsVO outboundNum;
|
private ImsIndexDataDetailsVO outboundNum;
|
||||||
|
|
||||||
|
|
||||||
//入库总金额(元)
|
//入库总金额(元)
|
||||||
private ImsIndexDataDetailsVO storeAmount;
|
private ImsIndexDataDetailsVO storeAmount;
|
||||||
|
|
||||||
|
|
||||||
//出库总金额(元)
|
//出库总金额(元)
|
||||||
private ImsIndexDataDetailsVO outboundAmount;
|
private ImsIndexDataDetailsVO outboundAmount;
|
||||||
|
|
||||||
|
/*******************************************/
|
||||||
|
|
||||||
|
//出库排名
|
||||||
|
private List<IndexMapCountVO> outImsRanking;
|
||||||
|
|
||||||
|
//入库排名
|
||||||
|
private List<IndexMapCountVO> intoImsRanking;
|
||||||
|
|
||||||
|
//验收占比
|
||||||
|
private List<IndexMapCountVO> acceptanceProportion;
|
||||||
|
|
||||||
|
//库存占比
|
||||||
|
private List<IndexMapCountVO> inventoryProportion;
|
||||||
|
|
||||||
|
//采购单趋势-供应商
|
||||||
|
private List<IndexMapCountVO> orderSupplier;
|
||||||
|
|
||||||
|
//采购单趋势-食堂
|
||||||
|
private List<IndexMapCountVO> orderCanteen;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -561,4 +561,102 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getOutImsRanking" resultType="com.bonus.canteen.core.kitchen.vo.IndexMapCountVO">
|
||||||
|
SELECT d.material_name as `name`,SUM(d.fetch_num) as count from (
|
||||||
|
select a.*,b.material_id,c.material_name from (
|
||||||
|
select inventory_id,fetch_num from ims_out_inventory_detail
|
||||||
|
<where>
|
||||||
|
del_flag = '0'
|
||||||
|
<if test="param.startDate !=null and param.startDate !='' and param.endDate !=null and param.endDate !=''">
|
||||||
|
and create_time between #{param.startDate} and #{param.endDate}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
)a
|
||||||
|
LEFT JOIN ims_inventory b on a.inventory_id = b.inventory_id
|
||||||
|
LEFT JOIN cook_material c on c.material_id = b.material_id
|
||||||
|
) d
|
||||||
|
where d.material_name is not null
|
||||||
|
GROUP BY d.material_id
|
||||||
|
ORDER BY count DESC
|
||||||
|
limit 10
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getIntoImsRanking" resultType="com.bonus.canteen.core.kitchen.vo.IndexMapCountVO">
|
||||||
|
|
||||||
|
SELECT d.material_name as `name`,SUM(d.pur_num) as count from (
|
||||||
|
select a.*,b.material_id,c.material_name from (
|
||||||
|
select inventory_id,pur_num from ims_into_inventory_detail
|
||||||
|
<where>
|
||||||
|
del_flag = '0'
|
||||||
|
<if test="param.startDate !=null and param.startDate !='' and param.endDate !=null and param.endDate !=''">
|
||||||
|
and create_time between #{param.startDate} and #{param.endDate}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
)a
|
||||||
|
LEFT JOIN ims_inventory b on a.inventory_id = b.inventory_id
|
||||||
|
LEFT JOIN cook_material c on c.material_id = b.material_id
|
||||||
|
) d
|
||||||
|
where d.material_name is not null
|
||||||
|
GROUP BY d.material_id
|
||||||
|
ORDER BY count DESC
|
||||||
|
limit 10
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getAcceptanceProportion" resultType="com.bonus.canteen.core.kitchen.vo.IndexMapCountVO">
|
||||||
|
select
|
||||||
|
if(if_all_inspect =1,'已验收','未验收') as name,
|
||||||
|
IFNULL(count(order_goods_id),0) as count
|
||||||
|
from
|
||||||
|
ims_order_goods
|
||||||
|
<where>
|
||||||
|
del_flag ='0'
|
||||||
|
<if test="param.startDate !=null and param.startDate !='' and param.endDate !=null and param.endDate !=''">
|
||||||
|
and create_time between #{param.startDate} and #{param.endDate}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY if_all_inspect
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getInventoryProportion" resultType="com.bonus.canteen.core.kitchen.vo.IndexMapCountVO">
|
||||||
|
select COUNT(a.into_detail_id) as `count` ,a.`status` as `name` from (
|
||||||
|
SELECT
|
||||||
|
into_detail_id,
|
||||||
|
expire_time,
|
||||||
|
TIMESTAMPDIFF( DAY, CURDATE(), expire_time ) AS days_remaining,
|
||||||
|
CASE
|
||||||
|
|
||||||
|
WHEN TIMESTAMPDIFF( DAY, CURDATE(), expire_time ) > ( SELECT item_value FROM ims_setting WHERE item_name = 'goods_expireing_day_reminder' ) THEN
|
||||||
|
'正常库存'
|
||||||
|
WHEN ( SELECT item_value FROM ims_setting WHERE item_name = 'goods_expireing_day_reminder' ) > TIMESTAMPDIFF( DAY, CURDATE(), expire_time )
|
||||||
|
AND TIMESTAMPDIFF( DAY, CURDATE(), expire_time ) > 0 THEN
|
||||||
|
'临期库存'
|
||||||
|
WHEN 0 > TIMESTAMPDIFF( DAY, CURDATE(), expire_time ) THEN
|
||||||
|
'过期库存'
|
||||||
|
END AS `status`
|
||||||
|
FROM
|
||||||
|
ims_into_inventory_detail
|
||||||
|
) a
|
||||||
|
GROUP BY a.`status`
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getOrderSupplier" resultType="com.bonus.canteen.core.kitchen.vo.IndexMapCountVO">
|
||||||
|
SELECT b.supplier_name as `name`,COUNT(a.order_goods_id) as count FROM ims_order_goods a
|
||||||
|
LEFT JOIN ims_supplier b on a.supplier_id = b.supplier_id
|
||||||
|
WHERE b.supplier_name is not null
|
||||||
|
<if test="param.startDate !=null and param.startDate !='' and param.endDate !=null and param.endDate !=''">
|
||||||
|
and a.create_time between #{param.startDate} and #{param.endDate}
|
||||||
|
</if>
|
||||||
|
GROUP BY a.supplier_id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getOrderCanteen" resultType="com.bonus.canteen.core.kitchen.vo.IndexMapCountVO">
|
||||||
|
SELECT b.canteen_name as `name`, COUNT(a.order_goods_id) as count FROM ims_order_goods a
|
||||||
|
LEFT JOIN basic_canteen b on a.canteen_id = b.canteen_id
|
||||||
|
WHERE b.canteen_name is not null
|
||||||
|
<if test="param.startDate !=null and param.startDate !='' and param.endDate !=null and param.endDate !=''">
|
||||||
|
and a.create_time between #{param.startDate} and #{param.endDate}
|
||||||
|
</if>
|
||||||
|
GROUP BY a.canteen_id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue