xuhy
4 天以前 433bc1e314ecfd483379ca0e2e74e7c815d3261f
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -13,10 +13,7 @@
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.TErpGoodsAdminQuery;
import com.ruoyi.system.query.TErpGoodsInventoryQuery;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.*;
import com.ruoyi.system.service.TErpGoodsService;
import com.ruoyi.system.service.TErpSupplierInventoryGoodsService;
import com.ruoyi.system.vo.*;
@@ -55,31 +52,37 @@
    @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;
@@ -88,6 +91,10 @@
    @Resource
    private  TCrmSupplierMapper crmSupplierMapper;
    @Resource
    private TErpProcurementMapper erpProcurementMapper;
    @Override
@@ -153,6 +160,11 @@
    }
    @Override
    public List<TErpGoods> pageAddList(Page<TErpGoods> tErpGoodsPage, String clinicSupplierId, PageAddListQuery query) {
        return this.baseMapper.pageAddList(tErpGoodsPage, clinicSupplierId, query);
    }
    @Override
    public List<TErpGoodsVO> listExport(TErpGoodsQuery query, SysUser user) {
        List<TErpGoodsVO> list = this.baseMapper.listExport(query, user);
        if (list.isEmpty()) {
@@ -185,7 +197,7 @@
    @Override
    public boolean isExit(String goodsIdCode, String quasiNumber,String id) {
        Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).ne(id!=null,TErpGoods::getId, id).and(q -> q.eq(TErpGoods::getGoodsIdCode, goodsIdCode).or().eq(TErpGoods::getQuasiNumber, quasiNumber)));
        Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).eq(TErpGoods::getGoodsSource,1).ne(id!=null,TErpGoods::getId, id).and(q -> q.eq(TErpGoods::getGoodsIdCode, goodsIdCode).or().eq(TErpGoods::getQuasiNumber, quasiNumber)));
        if (size > 0) {
            return true;
        }
@@ -410,8 +422,8 @@
        warehouseGoodsDetailVo.setCreateTime(tErpClinicWarehousing.getCreateTime());
        warehouseGoodsDetailVo.setCreateBy(tErpClinicWarehousing.getCreateBy());
        if(tErpClinicWarehousing.getType()==1){
            TErpClinicInventory tErpClinicInventory = erpClinicInventoryMapper.selectById(tErpClinicWarehousing.getInventoryId());
            warehouseGoodsDetailVo.setInventoryNumber(tErpClinicInventory.getInventoryNumber());
            TErpProcurement tErpProcurement = erpProcurementMapper.selectById(tErpClinicWarehousing.getProcurementId());
            warehouseGoodsDetailVo.setInventoryNumber(tErpProcurement.getProcurementCode());
        }
        List<TErpClinicWarehousingBatch> tErpClinicWarehousingBatches = erpClinicWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpClinicWarehousingBatch>().eq(TErpClinicWarehousingBatch::getWarehousingId, id));
@@ -554,6 +566,31 @@
            } else {
                TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch1 = erpSupplierWarehousingBatchMapper.selectById(inventoryGoodsDto.getId());
                String warehousingId1 = tErpSupplierWarehousingBatch1.getWarehousingId();
                TErpSupplierWarehousing tErpSupplierWarehousing2 = erpSupplierWarehousingMapper.selectById(warehousingId1);
                if(inventoryGoodsDto.getDamagedCount()!=null && inventoryGoodsDto.getDamagedCount()>0){
                    TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound();
                    tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
                    tErpSupplierOutbound.setSupplierId(supplierClinicId);
                    tErpSupplierOutbound.setOutboundType(1);
                    tErpSupplierOutbound.setOutboundNumber("G" + s);
                    int count = inventoryGoodsDto.getDamagedCount();
                    tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count)));
                    tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing2.getGoodsId());
                    erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                    TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
                    tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
                    tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId());
                    tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
                    tErpSupplierOutboundGoods.setOutboundCount(count);
                    tErpSupplierOutboundGoods.setTotalPrice(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count)));
                    erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods);
                }
                TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound();
                tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
@@ -561,7 +598,8 @@
                tErpSupplierOutbound.setOutboundType(6);
                tErpSupplierOutbound.setOutboundNumber("G" + s);
                int count = inventoryGoodsDto.getNum() - inventoryGoodsDto.getInventoryCount();
                tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
                tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count)));
                tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing2.getGoodsId());
                erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
@@ -622,6 +660,8 @@
            TErpClinicWarehousing tErpSupplierWarehousing1 = erpClinicWarehousingMapper.selectById(warehousingId);
            TErpGoods erpGoods = this.getById(tErpSupplierWarehousingBatch.getGoodsId());
            // 盘点是盘亏盘盈   赢
            if (inventoryGoodsDto.getNum() < inventoryGoodsDto.getInventoryCount()) {
                // 添加入库信息
@@ -667,6 +707,26 @@
            } else {
                if(inventoryGoodsDto.getDamagedCount()!=null && inventoryGoodsDto.getDamagedCount()>0){
                    TErpClinicOutbound tErpSupplierOutbound = new TErpClinicOutbound();
//                tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
//                tErpSupplierOutbound.setSupplierId(supplierClinicId);
                    tErpSupplierOutbound.setOutboundType(1);
                    tErpSupplierOutbound.setOutboundNumber("G" + s);
                    int count = inventoryGoodsDto.getDamagedCount();
                    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);
                }
                TErpClinicOutbound tErpSupplierOutbound = new TErpClinicOutbound();
//                tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
//                tErpSupplierOutbound.setSupplierId(supplierClinicId);