入库后续相关代码修复
This commit is contained in:
parent
1c0a5c3f13
commit
d1fcb0d4d5
|
|
@ -87,8 +87,6 @@ public class ReportInventoryBaseController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************************************************************************/
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.io.Serializable;
|
|||
|
||||
/**
|
||||
* 入库记录明细对象 ims_into_inventory_detail
|
||||
*
|
||||
*
|
||||
* @author gaowdong
|
||||
* @date 2025-07-07
|
||||
*/
|
||||
|
|
@ -100,8 +100,8 @@ public class ImsIntoInventoryDetailAdd implements Serializable
|
|||
|
||||
/** 入库原料照片 */
|
||||
@ApiModelProperty(value = "入库原料照片")
|
||||
@NotNull(message = "入库原料照片不能为空")
|
||||
private String imgUrl;
|
||||
// @NotNull(message = "入库原料照片不能为空")
|
||||
private String imgUrl="";
|
||||
|
||||
/** 是否补库存明细(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.ReportInventoryOutDetailParam;
|
||||
import com.bonus.canteen.core.ims.vo.*;
|
||||
import com.bonus.canteen.core.kitchen.vo.IndexMapCountVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
|
|
@ -92,4 +93,16 @@ public interface ReportInventoryMapper {
|
|||
BigDecimal getStoreAmount(@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.setOperatorId("王大力");
|
||||
reportInventoryBase.setOperateTime(DateUtils.getNowDate());
|
||||
reportInventoryBaseMapper.insertReportInventoryBase(reportInventoryBase); //新增库存记录基础信息
|
||||
reportInventoryMapper.insertReportInventory(reportInventory); //新增库存记录
|
||||
if(Objects.nonNull(detail.getInventoryId())){
|
||||
reportInventoryBaseMapper.insertReportInventoryBase(reportInventoryBase); //新增库存记录基础信息
|
||||
reportInventoryMapper.insertReportInventory(reportInventory); //新增库存记录
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
updatetReportInventoryDTO.setWarehouseId(imsOutInventory.getWarehouseId());
|
||||
updatetReportInventoryDTO.setMaterialId(detail.getMaterialId());
|
||||
updatetReportInventoryDTO.setReportInventoryId(reportInventory.getId());
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ import java.math.BigDecimal;
|
|||
import java.math.RoundingMode;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.IImsOutInventoryService;
|
||||
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.utils.DateUtils;
|
||||
import org.apache.catalina.security.SecurityUtil;
|
||||
|
|
@ -120,52 +119,74 @@ public class ReportInventoryBaseServiceImpl implements IReportInventoryBaseServi
|
|||
ImsIndexDataVO imsIndexDataVO = new ImsIndexDataVO();
|
||||
ImsIndexDateDTO thisTime = new ImsIndexDateDTO();
|
||||
ImsIndexDateDTO beforeTime = new ImsIndexDateDTO();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
thisTime.setType(type);
|
||||
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{
|
||||
//不做处理
|
||||
}
|
||||
formatDate(thisTime, beforeTime, type);
|
||||
//采购订单总金额
|
||||
getTotalOrderAmount(thisTime, beforeTime, imsIndexDataVO);
|
||||
//采购订单数量(个)
|
||||
getTotalOrderNum(thisTime, beforeTime, imsIndexDataVO);
|
||||
//未验收完成采购订单数(个)
|
||||
getUnFinshOrderNum(thisTime, beforeTime, imsIndexDataVO);
|
||||
//采购订单货品总数
|
||||
getTotalOrderGoodsNum(thisTime, beforeTime, imsIndexDataVO);
|
||||
//入库货品数量
|
||||
getStoreNum(thisTime, beforeTime, imsIndexDataVO);
|
||||
//出库货品数量
|
||||
getOutboundNum(thisTime, beforeTime, imsIndexDataVO);
|
||||
//入库总金额(元)
|
||||
getStoreAmount(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;
|
||||
}
|
||||
|
||||
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){
|
||||
BigDecimal totalOrderAmount_this = reportInventoryMapper.getOutboundAmount(thisTime);
|
||||
BigDecimal totalOrderAmount_before = reportInventoryMapper.getOutboundAmount(beforeTime);
|
||||
|
|
@ -218,6 +239,65 @@ public class ReportInventoryBaseServiceImpl implements IReportInventoryBaseServi
|
|||
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) {
|
||||
ImsIndexDataDetailsVO totalOrderAmount = new ImsIndexDataDetailsVO();
|
||||
BigDecimal rate;
|
||||
|
|
@ -399,24 +479,31 @@ public class ReportInventoryBaseServiceImpl implements IReportInventoryBaseServi
|
|||
|
||||
}
|
||||
}
|
||||
Set<Long> duplicateMaterialIds = findDuplicateMaterialIds(updatetReportInventoryDTOList);
|
||||
if(updatetReportInventoryDTOList !=null && updatetReportInventoryDTOList.size()>0){
|
||||
for(UpdatetReportInventoryDTO updatetReportInventoryDTO : updatetReportInventoryDTOList){
|
||||
Long materialId = updatetReportInventoryDTO.getMaterialId();
|
||||
if (materialIMoneyMap.containsKey(materialId )) {
|
||||
if (materialIMoneyMap.containsKey(materialId)) {
|
||||
BigDecimal monerValue = materialIMoneyMap.get(materialId);
|
||||
BigDecimal mumValue = materialINumMap.get(materialId);
|
||||
if(1== type){
|
||||
//如果存在则减去
|
||||
monerValue = monerValue.subtract(BigDecimal.valueOf(updatetReportInventoryDTO.getTotalPrice()));
|
||||
materialIMoneyMap.put(materialId, monerValue.setScale(2, RoundingMode.HALF_UP));
|
||||
mumValue = mumValue.subtract(updatetReportInventoryDTO.getPurNum());
|
||||
materialIMoneyMap.put(materialId, mumValue.setScale(2, RoundingMode.HALF_UP));
|
||||
if(duplicateMaterialIds.contains(materialId)){
|
||||
//如果存在则减去
|
||||
monerValue = monerValue.subtract(BigDecimal.valueOf(updatetReportInventoryDTO.getTotalPrice()));
|
||||
materialIMoneyMap.put(materialId, monerValue.setScale(2, RoundingMode.HALF_UP));
|
||||
mumValue = mumValue.subtract(updatetReportInventoryDTO.getPurNum());
|
||||
materialIMoneyMap.put(materialId, mumValue.setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
}else{
|
||||
//如果存在则累加
|
||||
monerValue = monerValue.add(BigDecimal.valueOf(updatetReportInventoryDTO.getTotalPrice()));
|
||||
materialIMoneyMap.put(materialId, monerValue.setScale(2, RoundingMode.HALF_UP));
|
||||
mumValue = mumValue.add(updatetReportInventoryDTO.getPurNum());
|
||||
materialINumMap.put(materialId, mumValue.setScale(2, RoundingMode.HALF_UP));
|
||||
if(duplicateMaterialIds.contains(materialId)){
|
||||
monerValue = monerValue.add(BigDecimal.valueOf(updatetReportInventoryDTO.getTotalPrice()));
|
||||
materialIMoneyMap.put(materialId, monerValue.setScale(2, RoundingMode.HALF_UP));
|
||||
mumValue = mumValue.add(updatetReportInventoryDTO.getPurNum());
|
||||
materialINumMap.put(materialId, mumValue.setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
materialIMoneyMap.put(materialId, monerValue);
|
||||
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){
|
||||
return list.stream()
|
||||
.map(UpdatetReportInventoryDTO :: getMaterialId)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import com.bonus.canteen.core.ims.service.ISupplierBindMaterialService;
|
|||
|
||||
/**
|
||||
* 原料绑定供应商Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-07-14
|
||||
*/
|
||||
|
|
@ -31,7 +31,7 @@ public class SupplierBindMaterialServiceImpl implements ISupplierBindMaterialSer
|
|||
|
||||
/**
|
||||
* 查询原料绑定供应商
|
||||
*
|
||||
*
|
||||
* @param id 原料绑定供应商主键
|
||||
* @return 原料绑定供应商
|
||||
*/
|
||||
|
|
@ -44,7 +44,7 @@ public class SupplierBindMaterialServiceImpl implements ISupplierBindMaterialSer
|
|||
|
||||
/**
|
||||
* 查询原料绑定供应商列表
|
||||
*
|
||||
*
|
||||
* @param supplierBindMaterial 原料绑定供应商
|
||||
* @return 原料绑定供应商
|
||||
*/
|
||||
|
|
@ -52,14 +52,17 @@ public class SupplierBindMaterialServiceImpl implements ISupplierBindMaterialSer
|
|||
public List<SupplierBindMaterial> selectSupplierBindMaterialList(SupplierBindMaterial supplierBindMaterial) {
|
||||
List<SupplierBindMaterial> list = supplierBindMaterialMapper.selectSupplierBindMaterialList(supplierBindMaterial);
|
||||
for (SupplierBindMaterial bindMaterial : list) {
|
||||
bindMaterial.setAlternativeSuppliers((List<SupplierDTO>) JacksonUtil.readValue(bindMaterial.getAlternativeSupplier(), List.class));
|
||||
if(bindMaterial.getAlternativeSupplier() != null){
|
||||
bindMaterial.setAlternativeSuppliers((List<SupplierDTO>) JacksonUtil.readValue(bindMaterial.getAlternativeSupplier(), List.class));
|
||||
}
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增原料绑定供应商
|
||||
*
|
||||
*
|
||||
* @param supplierBindMaterials 原料绑定供应商
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -81,7 +84,7 @@ public class SupplierBindMaterialServiceImpl implements ISupplierBindMaterialSer
|
|||
|
||||
/**
|
||||
* 修改原料绑定供应商
|
||||
*
|
||||
*
|
||||
* @param supplierBindMaterials 原料绑定供应商
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -93,16 +96,18 @@ public class SupplierBindMaterialServiceImpl implements ISupplierBindMaterialSer
|
|||
supplierBindMaterial.setUpdateTime(DateUtils.getNowDate());
|
||||
supplierBindMaterial.setUpdateBy(SecurityUtils.getUsername());
|
||||
List<SupplierDTO> alternativeSuppliers = supplierBindMaterial.getAlternativeSuppliers();
|
||||
for (SupplierDTO supplierDTO : alternativeSuppliers) {
|
||||
Supplier supplier = supplierMapper.selectSupplierBySupplierId(supplierDTO.getSupplierId());
|
||||
if (Objects.nonNull(supplier)) {
|
||||
supplierDTO.setSupplierName(supplier.getSupplierName());
|
||||
supplierDTO.setAreaId(supplier.getAreaId());
|
||||
supplierDTO.setSupplierScore(supplier.getSupplierScore());
|
||||
if(alternativeSuppliers != null){
|
||||
for (SupplierDTO supplierDTO : alternativeSuppliers) {
|
||||
Supplier supplier = supplierMapper.selectSupplierBySupplierId(supplierDTO.getSupplierId());
|
||||
if (Objects.nonNull(supplier)) {
|
||||
supplierDTO.setSupplierName(supplier.getSupplierName());
|
||||
supplierDTO.setAreaId(supplier.getAreaId());
|
||||
supplierDTO.setSupplierScore(supplier.getSupplierScore());
|
||||
}
|
||||
}
|
||||
supplierBindMaterial.setAlternativeSupplier(JacksonUtil.writeValueAsString(alternativeSuppliers));
|
||||
count += supplierBindMaterialMapper.updateSupplierBindMaterial(supplierBindMaterial);
|
||||
}
|
||||
supplierBindMaterial.setAlternativeSupplier(JacksonUtil.writeValueAsString(alternativeSuppliers));
|
||||
count += supplierBindMaterialMapper.updateSupplierBindMaterial(supplierBindMaterial);
|
||||
}
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
|
|
@ -112,7 +117,7 @@ public class SupplierBindMaterialServiceImpl implements ISupplierBindMaterialSer
|
|||
|
||||
/**
|
||||
* 批量删除原料绑定供应商
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的原料绑定供应商主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -123,7 +128,7 @@ public class SupplierBindMaterialServiceImpl implements ISupplierBindMaterialSer
|
|||
|
||||
/**
|
||||
* 删除原料绑定供应商信息
|
||||
*
|
||||
*
|
||||
* @param id 原料绑定供应商主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.bonus.canteen.core.ims.vo;
|
||||
|
||||
import com.bonus.canteen.core.kitchen.vo.IndexMapCountVO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xliu
|
||||
* @date 2025/7/23 15:13
|
||||
|
|
@ -28,12 +31,30 @@ public class ImsIndexDataVO {
|
|||
//出库货品数量
|
||||
private ImsIndexDataDetailsVO outboundNum;
|
||||
|
||||
|
||||
//入库总金额(元)
|
||||
private ImsIndexDataDetailsVO storeAmount;
|
||||
|
||||
|
||||
//出库总金额(元)
|
||||
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>
|
||||
</where>
|
||||
</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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue