package com.ruoyi.management.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.enums.ClientTypeEnum;
|
import com.ruoyi.common.core.utils.page.PageDTO;
|
import com.ruoyi.management.domain.InventoriesSupplies;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.ruoyi.management.domain.SlGoodsShelf;
|
import com.ruoyi.management.domain.SlStoreManagement;
|
import com.ruoyi.management.domain.SlVolumeProductionRk;
|
import com.ruoyi.management.domain.dto.InventoriesSuppDTO;
|
import com.ruoyi.management.domain.dto.InventoriesSuppliesQuery;
|
import com.ruoyi.management.domain.dto.ScanCodesDTO;
|
import com.ruoyi.management.domain.vo.InventoriesSuppliesVO;
|
import com.ruoyi.management.domain.vo.SlGoodsMaterialsVO;
|
import com.ruoyi.management.domain.vo.SlGoodsShelfVO;
|
import com.ruoyi.management.mapper.InventoriesSuppliesMapper;
|
import com.ruoyi.management.mapper.SlStoreManagementMapper;
|
import com.ruoyi.management.mapper.SlVolumeProductionRkMapper;
|
import com.ruoyi.management.service.InventoriesSuppliesService;
|
import com.ruoyi.management.service.SlVolumeProductionRkService;
|
import com.ruoyi.system.api.constants.NotificationTypeConstant;
|
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.WebsocketMessageDTO;
|
import com.ruoyi.system.api.feignClient.SysUserClient;
|
import io.swagger.models.auth.In;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.*;
|
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.stream.Collectors;
|
|
/**
|
* <p>
|
* 物资盘点 服务实现类
|
* </p>
|
*
|
* @author hjl
|
* @since 2024-07-01
|
*/
|
@Service
|
public class InventoriesSuppliesServiceImpl extends ServiceImpl<InventoriesSuppliesMapper, InventoriesSupplies> implements InventoriesSuppliesService {
|
|
@Resource
|
private SlStoreManagementMapper slStoreManagementMapper;
|
|
@Resource
|
private SysUserClient sysUserClient;
|
|
@Resource
|
private SlVolumeProductionRkMapper slVolumeProductionRkMapper;
|
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
|
@Override
|
public PageDTO<InventoriesSuppliesVO> getInventoriesSuppliesList(InventoriesSuppliesQuery inventoriesSuppliesQuery) {
|
LambdaQueryWrapper<SlStoreManagement> wrapper= Wrappers.lambdaQuery();
|
if (inventoriesSuppliesQuery.getStoreManagementName()!=null&&inventoriesSuppliesQuery.getStoreManagementName()!=""){
|
wrapper.eq(SlStoreManagement::getStoreManagementName,inventoriesSuppliesQuery.getStoreManagementName());
|
}
|
if (inventoriesSuppliesQuery.getStoreManagementNo()!=null&&inventoriesSuppliesQuery.getStoreManagementNo()!=""){
|
wrapper.eq(SlStoreManagement::getStoreManagementNo,inventoriesSuppliesQuery.getStoreManagementNo());
|
}
|
List<SlStoreManagement> slStoreManagements = slStoreManagementMapper.selectList(wrapper);
|
|
Set<Long> slStoreManagementIdList = null;
|
slStoreManagementIdList = slStoreManagements.stream().map(SlStoreManagement::getId)
|
.collect(Collectors.toSet());
|
|
Page<InventoriesSupplies> page = new Page<>(inventoriesSuppliesQuery.getPageCurr(), inventoriesSuppliesQuery.getPageSize());
|
LambdaQueryWrapper< InventoriesSupplies> wrapper1= Wrappers.lambdaQuery();
|
if (inventoriesSuppliesQuery.getPdrName()!=null&&inventoriesSuppliesQuery.getPdrName()!=""){
|
wrapper1.like(InventoriesSupplies::getPdrName,inventoriesSuppliesQuery.getPdrName());
|
}
|
if (slStoreManagementIdList.size()>0){
|
wrapper1.in(InventoriesSupplies::getMaterialsId,slStoreManagementIdList);
|
}else {
|
Set<Long> goodsSkuIdList1 = new HashSet<>();
|
goodsSkuIdList1.add(0L);
|
wrapper1.in(InventoriesSupplies::getMaterialsId,goodsSkuIdList1);
|
}
|
if (inventoriesSuppliesQuery.getStartpdTime()!=null){
|
|
wrapper1.gt(InventoriesSupplies::getPdTime, inventoriesSuppliesQuery.getStartpdTime());
|
}
|
if (inventoriesSuppliesQuery.getEndpdTime()!=null&&inventoriesSuppliesQuery.getPdrName()!=""){
|
wrapper1.le(InventoriesSupplies::getPdTime, inventoriesSuppliesQuery.getEndpdTime());
|
}
|
|
|
wrapper1.eq( InventoriesSupplies::getDelFlag,0);
|
wrapper1.orderByDesc(InventoriesSupplies::getCreateTime);
|
Page<InventoriesSupplies> page2 = this.page(page, wrapper1);
|
PageDTO<InventoriesSuppliesVO> slGoodsMaterialsVO = PageDTO.of(page2, InventoriesSuppliesVO.class);
|
List<InventoriesSuppliesVO> list = slGoodsMaterialsVO.getList();
|
for (InventoriesSuppliesVO sl:list){
|
SlStoreManagement slStoreManagementzs = slStoreManagementMapper.selectById(sl.getMaterialsId());
|
sl.setStoreManagementName(slStoreManagementzs.getStoreManagementName());
|
sl.setStoreManagementNo(slStoreManagementzs.getStoreManagementNo());
|
}
|
|
return slGoodsMaterialsVO;
|
}
|
|
@Override
|
public void addInventoriesSupp(InventoriesSuppDTO inventoriesSuppDTO) {
|
InventoriesSupplies inventoriesSupplies=new InventoriesSupplies();
|
inventoriesSupplies.setMaterialsId(inventoriesSuppDTO.getMaterialsId());
|
inventoriesSupplies.setPdTime(new Date());
|
inventoriesSupplies.setCreateTime(new Date());
|
inventoriesSupplies.setPdrId(inventoriesSuppDTO.getPdrId());
|
R<SysUser> sysUser = sysUserClient.getSysUser(inventoriesSuppDTO.getPdrId());
|
inventoriesSupplies.setPdrName(sysUser.getData().getNickName());
|
this.save(inventoriesSupplies);
|
}
|
|
@Override
|
public void scanCodes(String rkNumber) {
|
LambdaQueryWrapper< SlVolumeProductionRk> wrapper1= Wrappers.lambdaQuery();
|
wrapper1.like(SlVolumeProductionRk::getRkNumber,rkNumber);
|
wrapper1.eq( SlVolumeProductionRk::getDelFlag,0);
|
wrapper1.orderByDesc(SlVolumeProductionRk::getCreateTime);
|
SlVolumeProductionRk page2 = slVolumeProductionRkMapper.selectOne(wrapper1);
|
if (page2.getSmerwmNum()>0){
|
Integer i=page2.getSmerwmNum()-1;
|
page2.setSmerwmNum(i);
|
slVolumeProductionRkMapper.updateById(page2);
|
}
|
Map<String, Object> map = new ConcurrentHashMap<>();
|
map.put("notification_type", NotificationTypeConstant.SCANCODES);
|
map.put("SlVolumeProductionRk",page2);
|
String msg = null;
|
try {
|
msg = objectMapper.writeValueAsString(map);
|
} catch (JsonProcessingException e) {
|
}
|
sysUserClient.pushAll(msg, SecurityConstants.INNER);
|
}
|
|
|
}
|