| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.system.dto.AddProcurementDto; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TErpGoodsQuery; |
| | | import com.ruoyi.system.query.TErpProcurementQuery; |
| | | import com.ruoyi.system.service.TErpGoodsService; |
| | | import com.ruoyi.system.service.TErpProcurementService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.vo.TErpProcurementDetailNextVo; |
| | | import com.ruoyi.system.vo.TErpProcurementDetailVo; |
| | | import com.ruoyi.system.vo.TErpProcurementVo; |
| | | import com.ruoyi.system.vo.ValidityPeriodWarningVo; |
| | | import com.ruoyi.system.vo.*; |
| | | import lombok.SneakyThrows; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.http.HttpResponse; |
| | |
| | | import java.security.cert.X509Certificate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Resource |
| | | private TErpGoodsMapper erpGoodsMapper; |
| | | |
| | | @Resource |
| | | private TErpGoodsTypeMapper erpGoodsTypeMapper; |
| | | |
| | | @Resource |
| | | private TErpGoodsUnitMapper erpGoodsUnitMapper; |
| | | |
| | | |
| | | |
| | |
| | | return tErpProcurementVo; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<TErpGoods> pageGoodsPageList(TErpGoodsQuery query, SysUser user) { |
| | | PageInfo<TErpGoods> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | PageInfo<TErpGoods> p =erpGoodsMapper.selectPage(pageInfo,new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getGoodsSource,1).isNotNull(TErpGoods::getClinicPurchasePrice).orderByDesc(BaseModel::getCreateTime)); |
| | | List<TErpGoods> list = p.getRecords(); |
| | | |
| | | List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList()); |
| | | if(!typeIds.isEmpty()){ |
| | | List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); |
| | | for (TErpGoods tErpGoodsVO : list) { |
| | | typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); |
| | | tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName()); |
| | | } |
| | | } |
| | | pageInfo.setRecords( list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public List<TErpGoodsVO> inventoryNotEnoughList(SysUser user) { |
| | | List<TErpGoodsVO> list = this.baseMapper.inventoryNotEnoughList(user); |
| | | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String addProcurement(String clinicSupplierId, SysUser user, List<AddProcurementDto> dtos) { |
| | | List<String> goodsIds = dtos.stream().map(AddProcurementDto::getGoodsId).collect(Collectors.toList()); |
| | | List<TErpGoods> tErpGoods = erpGoodsMapper.selectBatchIds(goodsIds); |
| | | for (AddProcurementDto dto : dtos) { |
| | | TErpGoods tErpGoodsVO = tErpGoods.stream().filter(t -> t.getId().equals(dto.getGoodsId())).findFirst().get(); |
| | | dto.setSupplierId(tErpGoodsVO.getSupplierClinicId()); |
| | | dto.setGoodsSalesAmount(tErpGoodsVO.getSalesAmount()); |
| | | } |
| | | // 供应商分组 |
| | | Map<String, List<AddProcurementDto>> supplierClinicIdListMap = dtos.stream().collect(Collectors.groupingBy(AddProcurementDto::getSupplierId)); |
| | | for (Map.Entry<String, List<AddProcurementDto>> entry : supplierClinicIdListMap.entrySet()) { |
| | | String supplierClinicId = entry.getKey(); |
| | | TCrmSupplier supplier = crmSupplierMapper.selectById(supplierClinicId); |
| | | List<AddProcurementDto> value = entry.getValue(); |
| | | TErpProcurement tErpProcurement = new TErpProcurement(); |
| | | tErpProcurement.setClinicId(clinicSupplierId); |
| | | tErpProcurement.setProcurementCode("C"+DateUtils.dateTimeNow()); |
| | | tErpProcurement.setSupplierId(supplierClinicId); |
| | | |
| | | tErpProcurement.setTermNo(supplier.getTermNo()); |
| | | tErpProcurement.setMerchantNo(supplier.getRecvMerchantNo()); |
| | | tErpProcurement.setPayMoney(value.stream().map(AddProcurementDto::getSalesAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | AddProcurementDto addProcurementDto = value.get(0); |
| | | if(addProcurementDto.getState()!=null && addProcurementDto.getState()==1){ |
| | | tErpProcurement.setStatus(1); |
| | | }else { |
| | | tErpProcurement.setStatus(2); |
| | | } |
| | | this.save(tErpProcurement); |
| | | for (AddProcurementDto dto : value) { |
| | | TErpProcurementGoods tErpProcurementGoods = new TErpProcurementGoods(); |
| | | tErpProcurementGoods.setProcurementId(tErpProcurement.getId()); |
| | | TErpGoods goods = tErpGoods.stream().filter(e -> e.getId().equals(dto.getGoodsId())).findFirst().get(); |
| | | tErpProcurementGoods.setGoodsId(dto.getGoodsId()); |
| | | tErpProcurementGoods.setGoodsName(goods.getGoodsName()); |
| | | tErpProcurementGoods.setSupplierName(supplier.getSupplierName()); |
| | | tErpProcurementGoods.setQuasiNumber(goods.getQuasiNumber()); |
| | | |
| | | TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(goods.getPackingUnitId()); |
| | | tErpProcurementGoods.setUnitName(tErpGoodsUnit.getUnitName()); |
| | | tErpProcurementGoods.setPurchasePrice(dto.getGoodsSalesAmount()); |
| | | tErpProcurementGoods.setSalesAmount(dto.getSalesAmount()); |
| | | |
| | | tErpProcurementGoods.setPurchaseCount(dto.getPurchaseCount()); |
| | | tErpProcurementGoods.setSupplierId(supplierClinicId); |
| | | tErpProcurementGoods.setRecvMerchantNo(supplier.getRecvMerchantNo()); |
| | | } |
| | | |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | } |