| | |
| | | |
| | | 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | 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.common.utils.uuid.IdUtils; |
| | |
| | | import com.ruoyi.system.dto.InventoryGoodsDto; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TClinicGoodsWarehouseQuery; |
| | | import com.ruoyi.system.query.TErpGoodsInventoryQuery; |
| | | import com.ruoyi.system.query.TErpGoodsQuery; |
| | | import com.ruoyi.system.service.TErpGoodsService; |
| | | import com.ruoyi.system.service.TErpSupplierInventoryGoodsService; |
| | | import com.ruoyi.system.vo.TErpGoodsInventoryVO; |
| | | import com.ruoyi.system.vo.TErpGoodsVO; |
| | | import com.ruoyi.system.vo.*; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | private TErpGoodsTypeMapper erpGoodsTypeMapper; |
| | | |
| | | @Resource |
| | | private TErpGoodsMapper erpGoodsMapper; |
| | | |
| | | @Resource |
| | | private TErpGoodsUnitMapper erpGoodsUnitMapper; |
| | | |
| | | @Resource |
| | | private TErpSupplierInventoryMapper erpSupplierInventoryMapper; |
| | | @Resource |
| | | private TErpClinicInventoryMapper erpClinicInventoryMapper; |
| | | |
| | | @Resource |
| | | private TErpSupplierInventoryGoodsMapper erpSupplierInventoryGoodsMapper; |
| | | @Resource |
| | | private TErpClinicInventoryGoodsMapper erpClinicInventoryGoodsMapper; |
| | | |
| | | @Resource |
| | | private TErpSupplierWarehousingMapper erpSupplierWarehousingMapper; |
| | | @Resource |
| | | private TErpClinicWarehousingMapper erpClinicWarehousingMapper; |
| | | |
| | | @Resource |
| | | private TErpSupplierWarehousingBatchMapper erpSupplierWarehousingBatchMapper; |
| | | @Resource |
| | | private TErpClinicWarehousingBatchMapper erpClinicWarehousingBatchMapper; |
| | | |
| | | @Resource |
| | | private TErpSupplierOutboundMapper erpSupplierOutboundMapper; |
| | | @Resource |
| | | private TErpClinicOutboundMapper erpClinicOutboundMapper; |
| | | |
| | | @Resource |
| | | private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper; |
| | | @Resource |
| | | private TErpClinicOutboundGoodsMapper erpClinicOutboundGoodsMapper; |
| | | |
| | | @Resource |
| | | private TCrmClinicMapper crmClinicMapper; |
| | |
| | | |
| | | @Override |
| | | public PageInfo<TErpGoodsVO> pageList(TErpGoodsQuery query, SysUser user) { |
| | | PageInfo<TErpGoodsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TErpGoodsVO> list = this.baseMapper.pageList(query, pageInfo, user); |
| | | if (list.isEmpty()) { |
| | | return pageInfo; |
| | | } |
| | | List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList()); |
| | | if (!typeIds.isEmpty()) { |
| | | List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); |
| | | for (TErpGoodsVO tErpGoodsVO : list) { |
| | | typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); |
| | | } |
| | | } |
| | | List<String> collect = list.stream().filter(e -> e.getGoodsSource() == 1).map(TErpGoods::getSupplierClinicId).collect(Collectors.toList()); |
| | | if (!collect.isEmpty()) { |
| | | List<TCrmSupplier> crmClinics = crmSupplierMapper.selectBatchIds(collect); |
| | | for (TErpGoodsVO tErpGoodsVO : list) { |
| | | crmClinics.stream().filter(t -> t.getId().equals(tErpGoodsVO.getSupplierClinicId())).findFirst().ifPresent(t -> tErpGoodsVO.setSupplierName(t.getSupplierName())); |
| | | } |
| | | } |
| | | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | @Override |
| | | public PageInfo<TErpGoodsVO> pageList1(TErpGoodsQuery query, SysUser user) { |
| | | PageInfo<TErpGoodsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TErpGoodsVO> list = this.baseMapper.pageList(query, pageInfo, user); |
| | | if (list.isEmpty()) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean isExit(String goodsIdCode, String quasiNumber) { |
| | | Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).eq(TErpGoods::getGoodsIdCode, goodsIdCode).or().eq(TErpGoods::getQuasiNumber, quasiNumber)); |
| | | public boolean isExit(String goodsIdCode, String quasiNumber,String id) { |
| | | Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).ne(id!=null,TErpGoods::getId, id).eq(TErpGoods::getGoodsIdCode, goodsIdCode).or().eq(TErpGoods::getQuasiNumber, quasiNumber)); |
| | | if (size > 0) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | @Override |
| | | public PageInfo<TErpGoodsInventoryVO> pageInventoryGoodsPageList1(TErpGoodsInventoryQuery query, SysUser user) { |
| | | Integer roleType = user.getRoleType(); |
| | | String supplierClinicId = null; |
| | | if(roleType == 4){ |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | supplierClinicId =crmSupplier.getId(); |
| | | } |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | supplierClinicId =crmClinic.getId(); |
| | | } |
| | | |
| | | // 当前时间一个月后 |
| | | Date endDate = DateUtils.addMonths(DateUtils.getNowDate(), 1); |
| | | |
| | | PageInfo<TErpGoodsInventoryVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsPageList1(query, pageInfo, user,supplierClinicId,endDate); |
| | | if (list.isEmpty()) { |
| | | return pageInfo; |
| | | } |
| | | List<String> typeIds = list.stream().map(TErpGoodsInventoryVO::getTypeId).collect(Collectors.toList()); |
| | | if (!typeIds.isEmpty()) { |
| | | List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); |
| | | for (TErpGoodsInventoryVO tErpGoodsVO : list) { |
| | | typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); |
| | | tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName()); |
| | | } |
| | | } |
| | | List<String> packingUnitId = list.stream().map(TErpGoodsInventoryVO::getPackingUnitId).collect(Collectors.toList()); |
| | | if (!packingUnitId.isEmpty()) { |
| | | List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(packingUnitId); |
| | | for (TErpGoodsInventoryVO tErpGoodsVO : list) { |
| | | tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName())); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | @Override |
| | | public List<TErpGoodsInventoryVO> pageInventoryGoodsList(String warehouseId, SysUser user) { |
| | | Integer roleType = user.getRoleType(); |
| | | String supplierClinicId = null; |
| | | if(roleType == 4){ |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | supplierClinicId =crmSupplier.getId(); |
| | | } |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | supplierClinicId =crmClinic.getId(); |
| | | } |
| | | |
| | | // 当前时间一个月后 |
| | | Date endDate = DateUtils.addMonths(DateUtils.getNowDate(), 1); |
| | | |
| | | List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsList(warehouseId, user,supplierClinicId,endDate); |
| | | if (list.isEmpty()) { |
| | | return list; |
| | | } |
| | | List<String> typeIds = list.stream().map(TErpGoodsInventoryVO::getTypeId).collect(Collectors.toList()); |
| | | if (!typeIds.isEmpty()) { |
| | | List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); |
| | | for (TErpGoodsInventoryVO tErpGoodsVO : list) { |
| | | typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); |
| | | tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName()); |
| | | } |
| | | } |
| | | List<String> packingUnitId = list.stream().map(TErpGoodsInventoryVO::getPackingUnitId).collect(Collectors.toList()); |
| | | if (!packingUnitId.isEmpty()) { |
| | | List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(packingUnitId); |
| | | for (TErpGoodsInventoryVO tErpGoodsVO : list) { |
| | | tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName())); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | @Override |
| | | public List<TErpGoodsInventoryVO> pageInventoryGoodsList1(String warehouseId, SysUser user) { |
| | | Integer roleType = user.getRoleType(); |
| | | String supplierClinicId = null; |
| | | if(roleType == 4){ |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | supplierClinicId =crmSupplier.getId(); |
| | | } |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | supplierClinicId =crmClinic.getId(); |
| | | } |
| | | |
| | | // 当前时间一个月后 |
| | | Date endDate = DateUtils.addMonths(DateUtils.getNowDate(), 1); |
| | | |
| | | List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsList1(warehouseId, user,supplierClinicId,endDate); |
| | | if (list.isEmpty()) { |
| | | return list; |
| | | } |
| | | List<String> typeIds = list.stream().map(TErpGoodsInventoryVO::getTypeId).collect(Collectors.toList()); |
| | | if (!typeIds.isEmpty()) { |
| | | List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); |
| | | for (TErpGoodsInventoryVO tErpGoodsVO : list) { |
| | | typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); |
| | | tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName()); |
| | | } |
| | | } |
| | | List<String> packingUnitId = list.stream().map(TErpGoodsInventoryVO::getPackingUnitId).collect(Collectors.toList()); |
| | | if (!packingUnitId.isEmpty()) { |
| | | List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(packingUnitId); |
| | | for (TErpGoodsInventoryVO tErpGoodsVO : list) { |
| | | tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName())); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public Page<TErpGoods> warehouseGoodsPageList(TClinicGoodsWarehouseQuery query, SysUser user, String supplierClinicId) { |
| | | LambdaQueryWrapper<TErpGoods> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(BaseModel::getDisabled,0); |
| | | wrapper.eq(TErpGoods::getSupplierClinicId,supplierClinicId).eq(TErpGoods::getGoodsSource,2); |
| | | if(query.getGoodsName()!=null && !query.getGoodsName().isEmpty()){ |
| | | wrapper.like(TErpGoods::getGoodsName,query.getGoodsName()); |
| | | } |
| | | if(query.getGoodsIdCode()!=null && !query.getGoodsIdCode().isEmpty()){ |
| | | wrapper.eq(TErpGoods::getGoodsIdCode,query.getGoodsIdCode()); |
| | | } |
| | | if(query.getQuasiNumber()!=null && !query.getQuasiNumber().isEmpty()){ |
| | | wrapper.eq(TErpGoods::getQuasiNumber,query.getQuasiNumber()); |
| | | } |
| | | if(query.getTypeId()!=null && !query.getTypeId().isEmpty()){ |
| | | wrapper.eq(TErpGoods::getTypeId,query.getTypeId()); |
| | | } |
| | | wrapper.orderByDesc(BaseModel::getCreateTime); |
| | | Page<TErpGoods> page = this.page(new Page<>(query.getPageNum(), query.getPageSize()), wrapper); |
| | | return page; |
| | | } |
| | | |
| | | @Override |
| | | public WarehouseGoodsDetailVo warehouseGoodsDetail(String id) { |
| | | WarehouseGoodsDetailVo warehouseGoodsDetailVo = new WarehouseGoodsDetailVo(); |
| | | TErpClinicWarehousing tErpClinicWarehousing = erpClinicWarehousingMapper.selectById(id); |
| | | warehouseGoodsDetailVo.setCreateTime(tErpClinicWarehousing.getCreateTime()); |
| | | warehouseGoodsDetailVo.setCreateBy(tErpClinicWarehousing.getCreateBy()); |
| | | if(tErpClinicWarehousing.getType()==1){ |
| | | TErpClinicInventory tErpClinicInventory = erpClinicInventoryMapper.selectById(tErpClinicWarehousing.getInventoryId()); |
| | | warehouseGoodsDetailVo.setInventoryNumber(tErpClinicInventory.getInventoryNumber()); |
| | | } |
| | | |
| | | List<TErpClinicWarehousingBatch> tErpClinicWarehousingBatches = erpClinicWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpClinicWarehousingBatch>().eq(TErpClinicWarehousingBatch::getWarehousingId, id)); |
| | | for (TErpClinicWarehousingBatch tErpClinicWarehousingBatch : tErpClinicWarehousingBatches) { |
| | | String goodsId = tErpClinicWarehousingBatch.getGoodsId(); |
| | | TErpGoods tErpGoods = erpGoodsMapper.selectById(goodsId); |
| | | String packingUnitId = tErpGoods.getPackingUnitId(); |
| | | TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(packingUnitId); |
| | | tErpClinicWarehousingBatch.setUnitName(tErpGoodsUnit.getUnitName()); |
| | | |
| | | } |
| | | |
| | | warehouseGoodsDetailVo.setList(tErpClinicWarehousingBatches); |
| | | return warehouseGoodsDetailVo; |
| | | } |
| | | |
| | | @Override |
| | | public OutboundGoodsDetailVo outboundGoodsDetail(String id) { |
| | | OutboundGoodsDetailVo outboundGoodsDetailVo = new OutboundGoodsDetailVo(); |
| | | TErpClinicOutbound tErpClinicOutbound = erpClinicOutboundMapper.selectById(id); |
| | | outboundGoodsDetailVo.setCreateTime(tErpClinicOutbound.getCreateTime()); |
| | | outboundGoodsDetailVo.setCreateBy(tErpClinicOutbound.getCreateBy()); |
| | | outboundGoodsDetailVo.setOutboundType(tErpClinicOutbound.getOutboundType()); |
| | | outboundGoodsDetailVo.setOrderNumber(tErpClinicOutbound.getOrderNumber()); |
| | | if(tErpClinicOutbound.getOutboundType()==6){ |
| | | TErpClinicInventory tErpClinicInventory = erpClinicInventoryMapper.selectById(tErpClinicOutbound.getInventoryId()); |
| | | outboundGoodsDetailVo.setInventoryNumber(tErpClinicInventory.getInventoryNumber()); |
| | | } |
| | | ArrayList<OutboundGoodsDetailNextVo> tErpClinicOutboundGoods1 = new ArrayList<>(); |
| | | List<TErpClinicOutboundGoods> tErpClinicOutboundGoods = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getOutboundId, id)); |
| | | for (TErpClinicOutboundGoods outboundGoods : tErpClinicOutboundGoods) { |
| | | TErpClinicWarehousing tErpClinicWarehousing = erpClinicWarehousingMapper.selectById(outboundGoods.getWarehousingId()); |
| | | TErpClinicWarehousingBatch tErpClinicWarehousingBatch = erpClinicWarehousingBatchMapper.selectById(outboundGoods.getWarehousingBatchId()); |
| | | |
| | | OutboundGoodsDetailNextVo outboundGoodsDetailNextVo = new OutboundGoodsDetailNextVo(); |
| | | outboundGoodsDetailNextVo.setWarehouseNo(tErpClinicWarehousing.getWarehouseNo()); |
| | | |
| | | outboundGoodsDetailNextVo.setGoodsId(outboundGoods.getGoodsId()); |
| | | TErpGoods goods = erpGoodsMapper.selectById(outboundGoods.getGoodsId()); |
| | | outboundGoodsDetailNextVo.setGoodsName(goods.getGoodsName()); |
| | | |
| | | outboundGoodsDetailNextVo.setTypeId(goods.getTypeId()); |
| | | TErpGoodsType tErpGoodsType = erpGoodsTypeMapper.selectById(goods.getTypeId()); |
| | | outboundGoodsDetailNextVo.setTypeName(tErpGoodsType.getTypeName()); |
| | | outboundGoodsDetailNextVo.setQuasiNumber(goods.getQuasiNumber()); |
| | | outboundGoodsDetailNextVo.setBatchNumber(tErpClinicWarehousingBatch.getBatchNumber()); |
| | | TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(goods.getPackingUnitId()); |
| | | outboundGoodsDetailNextVo.setUnitName(tErpGoodsUnit.getUnitName()); |
| | | |
| | | |
| | | List<TErpClinicOutboundGoods> tErpClinicOutboundGoods2 = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getWarehousingBatchId, outboundGoods.getWarehousingBatchId())); |
| | | int sum = tErpClinicOutboundGoods2.stream().mapToInt(TErpClinicOutboundGoods::getOutboundCount).sum(); |
| | | |
| | | int count = tErpClinicWarehousingBatch.getPurchaseCount() - sum; |
| | | outboundGoodsDetailNextVo.setSurplusCount(count); |
| | | |
| | | outboundGoodsDetailNextVo.setUnitAmount(tErpClinicWarehousingBatch.getUnitAmount()); |
| | | outboundGoodsDetailNextVo.setOutboundCount(outboundGoods.getOutboundCount()); |
| | | outboundGoodsDetailNextVo.setExpiryDate(tErpClinicWarehousingBatch.getExpiryDate()); |
| | | outboundGoodsDetailNextVo.setTotalAmount(outboundGoodsDetailNextVo.getUnitAmount().multiply(new BigDecimal(outboundGoods.getOutboundCount()))); |
| | | tErpClinicOutboundGoods1.add(outboundGoodsDetailNextVo); |
| | | |
| | | } |
| | | outboundGoodsDetailVo.setList(tErpClinicOutboundGoods1); |
| | | return outboundGoodsDetailVo; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods(); |
| | | tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId()); |
| | | tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing.getId()); |
| | | tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId()); |
| | | tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId()); |
| | | tErpSupplierOutboundGoods.setOutboundCount(count); |
| | | tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count))); |
| | |
| | | |
| | | |
| | | } |
| | | @Override |
| | | public void inventoryGoods1(InventoryDto dto, SysUser user) { |
| | | Integer roleType = user.getRoleType(); |
| | | String supplierClinicId = null; |
| | | if(roleType == 4){ |
| | | // 供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | supplierClinicId =crmSupplier.getId(); |
| | | } |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | supplierClinicId =crmClinic.getId(); |
| | | } |
| | | TErpClinicInventory tErpSupplierInventory = new TErpClinicInventory(); |
| | | String s = DateUtils.dateTimeNow(); |
| | | tErpSupplierInventory.setInventoryNumber("P" + s); |
| | | tErpSupplierInventory.setClinicId(supplierClinicId); |
| | | erpClinicInventoryMapper.insert(tErpSupplierInventory); |
| | | |
| | | List<InventoryGoodsDto> dtos = dto.getDtos(); |
| | | for (InventoryGoodsDto inventoryGoodsDto : dtos) { |
| | | // 根据入库批次id查询入库信息 |
| | | TErpClinicWarehousing tErpSupplierWarehousing = new TErpClinicWarehousing(); |
| | | TErpClinicWarehousingBatch tErpSupplierWarehousingBatch = erpClinicWarehousingBatchMapper.selectById(inventoryGoodsDto.getId()); |
| | | String warehousingId = tErpSupplierWarehousingBatch.getWarehousingId(); |
| | | TErpClinicWarehousing tErpSupplierWarehousing1 = erpClinicWarehousingMapper.selectById(warehousingId); |
| | | TErpGoods erpGoods = this.getById(tErpSupplierWarehousingBatch.getGoodsId()); |
| | | |
| | | // 盘点是盘亏盘盈 赢 |
| | | if (inventoryGoodsDto.getNum() < inventoryGoodsDto.getInventoryCount()) { |
| | | // 添加入库信息 |
| | | tErpSupplierWarehousing.setClinicId(supplierClinicId); |
| | | // tErpSupplierWarehousing.setGoodsId(tErpSupplierWarehousing1.getGoodsId()); |
| | | // tErpSupplierWarehousing.setGoodsName(erpGoods.getGoodsName()); |
| | | // tErpSupplierWarehousing.setPurchaseCount(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum()); |
| | | // tErpSupplierWarehousing.setUnitAmount(erpGoods.getSalesAmount()); |
| | | tErpSupplierWarehousing.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum()))); |
| | | // 当前年月日时分秒 |
| | | String time = DateUtils.dateTimeNow(); |
| | | tErpSupplierWarehousing.setWarehouseNo("G" + time); |
| | | tErpSupplierWarehousing.setType(2); |
| | | tErpSupplierWarehousing.setInventoryId(tErpSupplierInventory.getId()); |
| | | erpClinicWarehousingMapper.insert(tErpSupplierWarehousing); |
| | | |
| | | // 添加批次信息 |
| | | TErpClinicWarehousingBatch tErpSupplierWarehousingBatch1 = new TErpClinicWarehousingBatch(); |
| | | tErpSupplierWarehousingBatch1.setWarehousingId(tErpSupplierWarehousing.getId()); |
| | | tErpSupplierWarehousingBatch1.setWarehousingNumber(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum()); |
| | | tErpSupplierWarehousingBatch1.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber()); |
| | | tErpSupplierWarehousingBatch1.setProductionDate(tErpSupplierWarehousingBatch.getProductionDate()); |
| | | tErpSupplierWarehousingBatch1.setExpiryDate(tErpSupplierWarehousingBatch.getExpiryDate()); |
| | | tErpSupplierWarehousingBatch1.setGoodsId(tErpSupplierWarehousingBatch.getGoodsId()); |
| | | tErpSupplierWarehousingBatch1.setQuasiNumber(tErpSupplierWarehousingBatch.getQuasiNumber()); |
| | | tErpSupplierWarehousingBatch1.setPurchaseCount(tErpSupplierWarehousingBatch.getPurchaseCount()); |
| | | tErpSupplierWarehousingBatch1.setSalesAmount(tErpSupplierWarehousingBatch.getSalesAmount()); |
| | | tErpSupplierWarehousingBatch1.setUnitAmount(tErpSupplierWarehousingBatch.getUnitAmount()); |
| | | erpClinicWarehousingBatchMapper.insert(tErpSupplierWarehousingBatch1); |
| | | |
| | | |
| | | // 添加盘点信息 |
| | | TErpClinicInventoryGoods tErpSupplierInventoryGoods = new TErpClinicInventoryGoods(); |
| | | tErpSupplierInventoryGoods.setInventoryId(tErpSupplierInventory.getId()); |
| | | tErpSupplierInventoryGoods.setWarehousingId(tErpSupplierWarehousing.getId()); |
| | | tErpSupplierInventoryGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch1.getId()); |
| | | tErpSupplierInventoryGoods.setInventoryCount(inventoryGoodsDto.getInventoryCount()); |
| | | tErpSupplierInventoryGoods.setDamagedCount(inventoryGoodsDto.getDamagedCount()); |
| | | tErpSupplierInventoryGoods.setInventoryType(1); |
| | | tErpSupplierInventoryGoods.setGoodsId(tErpSupplierWarehousingBatch.getGoodsId()); |
| | | erpClinicInventoryGoodsMapper.insert(tErpSupplierInventoryGoods); |
| | | |
| | | } else { |
| | | |
| | | |
| | | TErpClinicOutbound tErpSupplierOutbound = new TErpClinicOutbound(); |
| | | // tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId()); |
| | | // tErpSupplierOutbound.setSupplierId(supplierClinicId); |
| | | tErpSupplierOutbound.setOutboundType(6); |
| | | tErpSupplierOutbound.setOutboundNumber("G" + s); |
| | | int count = inventoryGoodsDto.getNum() - inventoryGoodsDto.getInventoryCount(); |
| | | tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count))); |
| | | tErpSupplierOutbound.setInventoryId(tErpSupplierInventory.getId()); |
| | | erpClinicOutboundMapper.insert(tErpSupplierOutbound); |
| | | |
| | | |
| | | TErpClinicOutboundGoods tErpSupplierOutboundGoods = new TErpClinicOutboundGoods(); |
| | | tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId()); |
| | | tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId()); |
| | | tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId()); |
| | | tErpSupplierOutboundGoods.setOutboundCount(count); |
| | | tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count))); |
| | | erpClinicOutboundGoodsMapper.insert(tErpSupplierOutboundGoods); |
| | | |
| | | |
| | | // 添加盘点信息 |
| | | TErpClinicInventoryGoods tErpSupplierInventoryGoods = new TErpClinicInventoryGoods(); |
| | | tErpSupplierInventoryGoods.setInventoryId(tErpSupplierInventory.getId()); |
| | | tErpSupplierInventoryGoods.setWarehousingId(tErpSupplierOutbound.getId()); |
| | | tErpSupplierInventoryGoods.setWarehousingBatchId(tErpSupplierOutboundGoods.getId()); |
| | | tErpSupplierInventoryGoods.setInventoryCount(inventoryGoodsDto.getInventoryCount()); |
| | | tErpSupplierInventoryGoods.setDamagedCount(inventoryGoodsDto.getDamagedCount()); |
| | | tErpSupplierInventoryGoods.setInventoryType(2); |
| | | tErpSupplierInventoryGoods.setGoodsId(tErpSupplierWarehousingBatch.getGoodsId()); |
| | | erpClinicInventoryGoodsMapper.insert(tErpSupplierInventoryGoods); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |