xuhy
4 天以前 945123b11d6179d9f496a195c271122ff08bc1bc
Merge remote-tracking branch 'origin/master'
21个文件已修改
638 ■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpProcurementController.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysGoodsController.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysOrderController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TSysOrderService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpClinicWarehousingServiceImpl.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java 276 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpMaintenanceReminderServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysGoodsServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysOrderServiceImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/ValidityPeriodWarningVo.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpProcurementMapper.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpSupplierWarehousingMapper.xml 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java
@@ -976,8 +976,8 @@
                        break;
                }
                branchAdminStatisticsOneVo.setBranchMoney(list1.stream().filter(e -> e.getCommissionType() == 1).map(TErpProcurementCommission::getMoney).reduce(BigDecimal::add).get());
                branchAdminStatisticsOneVo.setStaffMoney(list1.stream().filter(e -> e.getCommissionType() == 2).map(TErpProcurementCommission::getMoney).reduce(BigDecimal::add).get());
                branchAdminStatisticsOneVo.setBranchMoney(collect3.stream().filter(e -> e.getCommissionType() == 1).map(TErpProcurementCommission::getMoney).reduce(BigDecimal::add).get());
                branchAdminStatisticsOneVo.setStaffMoney(collect3.stream().filter(e -> e.getCommissionType() == 2).map(TErpProcurementCommission::getMoney).reduce(BigDecimal::add).get());
            }
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
@@ -239,7 +239,10 @@
    public R<Boolean> clinicAdd(@Validated @RequestBody TErpClinicGoodsAddDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(),null)) {
            return R.fail("erp商品已存在");
            return R.fail("erp商品已存在,商品条码重复");
        }
        if (erpGoodsService.isExitOne(dto.getGoodsIdCode(), dto.getQuasiNumber(),null)) {
            return R.fail("erp商品已存在,国药准字号重复");
        }
        Integer roleType = user.getRoleType();
        TErpGoods goods = new TErpGoods();
@@ -254,7 +257,7 @@
        }
        goods.setCreateId(user.getUserId().toString());
        goods.setGoodsIdCode(dto.getGoodsIdCode());
        goods.setClinicPurchasePrice(dto.getSalesAmount());
//        goods.setClinicPurchasePrice(dto.getSalesAmount());
        return R.ok(erpGoodsService.save(goods));
    }
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpProcurementController.java
@@ -24,6 +24,7 @@
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@@ -267,6 +268,7 @@
    @ApiOperation(value = "采购详情入库")
    @PostMapping(value = "/updateStatusProcurement")
    @Transactional(rollbackFor = Exception.class)
    public R<DetailProcurementVO> updateStatusProcurement(@RequestBody @Valid UpdateStatusProcurementLastDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
@@ -308,9 +310,35 @@
//        tErpClinicWarehousing.setUnitAmount(tErpProcurementGoods.getSalesAmount());
        tErpClinicWarehousing.setWarehousingType(1);
        tErpClinicWarehousing.setType(1);
        tErpClinicWarehousing.setWarehouseNo("G"+ DateUtils.dateTimeNow());
        TErpClinicWarehousing last = erpClinicWarehousingService.getOne(new LambdaQueryWrapper<TErpClinicWarehousing>().orderByDesc(BaseModel::getCreateTime).last("LIMIT 1"));
        if(last==null){
            tErpClinicWarehousing.setWarehouseNo("G"+ DateUtils.dateTimeNow()+"00001");
        }else {
            String lastProcurementCode = last.getWarehouseNo();
            String datePart = "G" + DateUtils.dateTimeNow();
            // 直接获取后五位数字并+1,不考虑是否同一天
            try {
                String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                int number = Integer.parseInt(numberPart);
                if (number < 99999) {
                    number++;
                } else {
                    number = 2; // 达到99999后重置为00002
                }
                tErpClinicWarehousing.setWarehouseNo(datePart + String.format("%05d", number));
            } catch (NumberFormatException e) {
                // 如果解析失败,默认从00001开始
                tErpClinicWarehousing.setWarehouseNo(datePart + "00001");
            }
        }
        tErpClinicWarehousing.setProcurementId(erpProcurement.getId());
        erpClinicWarehousingService.save(tErpClinicWarehousing);
        try {
            erpClinicWarehousingService.save(tErpClinicWarehousing);
        }catch (Exception e){
            throw new RuntimeException("网络繁忙,请重试");
        }
        // goodsId分组
        for (UpdateStatusProcurementDto updateStatusProcurementDto : dto.getList()) {
            TErpProcurementGoods tErpProcurementGoods = list.stream().filter(t -> t.getId().equals(updateStatusProcurementDto.getId())).findFirst().get();
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderController.java
@@ -301,7 +301,7 @@
            org.apache.http.HttpResponse response1 = post(LakalaConfig.getServerUrl() + "sit/api/v3/sacs/separate", jsonString, authorization1);
            String responseStr = IOUtils.toString(response1.getEntity().getContent(), ENCODING);
            System.err.println(responseStr);
            System.err.println("分佣!!!!"+responseStr);
            JSONObject jsonObject = JSONObject.parseObject(responseStr);
            if ("成功".equals(jsonObject.getString("msg"))) {
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysGoodsController.java
@@ -97,7 +97,9 @@
                List<TSysGoodsExchange> list = sysGoodsExchangeService.list(new LambdaQueryWrapper<TSysGoodsExchange>().in(TSysGoodsExchange::getGoodsId, records.stream().map(TSysGoods::getId).collect(Collectors.toList())));
                records.forEach(item -> {
                    item.setExchangeQuantity(list.stream().filter(item1 -> item1.getGoodsId().equals(item.getId())).mapToInt(TSysGoodsExchange::getGoodsCount).sum());
                    item.setSurplusQuantity(item.getGoodsTotal() - item.getExchangeQuantity());
                    if(item.getGoodsTotal()!=null){
                        item.setSurplusQuantity(item.getGoodsTotal() - item.getExchangeQuantity());
                    }
                });
            }
            pageInfo.setRecords(records);
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysOrderController.java
@@ -106,7 +106,7 @@
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            sysOrderService.add(dto,crmClinic);
            sysOrderService.add(dto,crmClinic,user.getNickName(),user.getUserId().toString());
            return R.ok("添加成功");
        }
        return R.fail("添加失败");
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
@@ -30,7 +30,7 @@
    public static String YYYY_MM_DD = "yyyy-MM-dd";
    public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
    public static String YYYYMMDDHHMMSS = "yyyyMMdd";
    public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java
@@ -43,6 +43,7 @@
    List<TErpGoodsVO> listExport(TErpGoodsQuery query, SysUser user);
    boolean isExit(String goodsIdCode,String quasiNumber,String id);
    boolean isExitOne(String goodsIdCode,String quasiNumber,String id);
    PageInfo<TErpGoodsInventoryVO> pageInventoryGoodsPageList(@Valid TErpGoodsInventoryQuery query, SysUser user);
ruoyi-system/src/main/java/com/ruoyi/system/service/TSysOrderService.java
@@ -34,7 +34,7 @@
    PageInfo<TSysOrderPageVo> pageList(TSysOrderQuery query);
    void add(TSysOrderDto dto, TCrmClinic crmClinic);
    void add(TSysOrderDto dto, TCrmClinic crmClinic,String name,String userId);
    Integer clinicSalesStatisticsCount(List<String> clinicIds);
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpClinicWarehousingServiceImpl.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.ClinicOutboundGoodsDto;
@@ -18,6 +19,8 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.vo.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -217,7 +220,9 @@
                        inventoryDetailVo.setGoodsName(goods.getGoodsName());
                        TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(goods.getPackingUnitId());
                        inventoryDetailVo.setUnitName(tErpGoodsUnit.getUnitName());
                        if(tErpGoodsUnit!=null){
                            inventoryDetailVo.setUnitName(tErpGoodsUnit.getUnitName());
                        }
                        inventoryDetailVo.setWarehouseNo(tErpSupplierWarehousing.getWarehouseNo());
                        TErpClinicOutboundGoods outboundGoods = erpClinicOutboundGoodsMapper.selectById(tErpSupplierInventoryGood.getWarehousingBatchId());
@@ -358,6 +363,7 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public void warehouseGoods(WarehouseGoodsDto dtos, SysUser user, String supplierClinicId) {
        // dtos根据供应商分组
@@ -373,11 +379,40 @@
        TErpClinicWarehousing tErpClinicWarehousing = new TErpClinicWarehousing();
        tErpClinicWarehousing.setClinicId(supplierClinicId);
        tErpClinicWarehousing.setCreateId(user.getUserId().toString());
        tErpClinicWarehousing.setWarehouseNo("G" + DateUtils.dateTimeNow());
        TErpClinicWarehousing last = this.getOne(new LambdaQueryWrapper<TErpClinicWarehousing>().orderByDesc(BaseModel::getCreateTime).last("LIMIT 1"));
        if(last==null){
            tErpClinicWarehousing.setWarehouseNo("G" + DateUtils.dateTimeNow()+"00001");
        }else{
            String lastProcurementCode = last.getWarehouseNo();
            String datePart = "G" + DateUtils.dateTimeNow();
            // 直接获取后五位数字并+1,不考虑是否同一天
            try {
                String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                int number = Integer.parseInt(numberPart);
                if (number < 99999) {
                    number++;
                } else {
                    number = 2; // 达到99999后重置为00002
                }
                tErpClinicWarehousing.setWarehouseNo(datePart + String.format("%05d", number));
            } catch (NumberFormatException e) {
                // 如果解析失败,默认从00001开始
                tErpClinicWarehousing.setWarehouseNo(datePart + "00001");
            }
        }
        tErpClinicWarehousing.setCreateTime(LocalDateTime.now());
        tErpClinicWarehousing.setType(3);
        tErpClinicWarehousing.setStatus(dtos.getStatus());
        this.save(tErpClinicWarehousing);
        tErpClinicWarehousing.setWarehousingType(2);
        try {
            this.save(tErpClinicWarehousing);
        }catch (Exception e){
            throw new RuntimeException("网络繁忙,请重试");
        }
        BigDecimal totalPrice = new BigDecimal(0);
        ArrayList<String> names = new ArrayList<>();
@@ -428,17 +463,45 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void outboundGoods(ClinicOutboundGoodsDto dto, SysUser user, String supplierClinicId) {
        TErpClinicOutbound tErpClinicOutbound = new TErpClinicOutbound();
        tErpClinicOutbound.setClinicId(supplierClinicId);
        tErpClinicOutbound.setCreateId(user.getUserId().toString());
        tErpClinicOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow());
        TErpClinicOutbound last = erpClinicOutboundMapper.selectOne(new LambdaQueryWrapper<TErpClinicOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
        if(last==null){
            tErpClinicOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+"00001");
        }else{
            String lastProcurementCode = last.getOutboundNumber();
            String datePart = "G" + DateUtils.dateTimeNow();
            // 直接获取后五位数字并+1,不考虑是否同一天
            try {
                String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                int number = Integer.parseInt(numberPart);
                if (number < 99999) {
                    number++;
                } else {
                    number = 2; // 达到99999后重置为00002
                }
                tErpClinicOutbound.setOutboundNumber(datePart + String.format("%05d", number));
            } catch (NumberFormatException e) {
                // 如果解析失败,默认从00001开始
                tErpClinicOutbound.setOutboundNumber(datePart + "00001");
            }
        }
        tErpClinicOutbound.setCreateTime(LocalDateTime.now());
        tErpClinicOutbound.setOutboundType(dto.getOutboundType());
        tErpClinicOutbound.setTotalMoney(dto.getTotalPrice());
        tErpClinicOutbound.setOutboundReason(dto.getOutboundReason());
        tErpClinicOutbound.setTypeNum(dto.getTypeNum());
        erpClinicOutboundMapper.insert(tErpClinicOutbound);
        try {
            erpClinicOutboundMapper.insert(tErpClinicOutbound);
        }catch (Exception e){
            throw new RuntimeException("网络繁忙,请重试");
        }
        List<TErpClinicOutboundGoods> tErpClinicOutboundGoods = new ArrayList<>();
        for (OutboundGoodsNextDto outboundGoodsNextDto : dto.getOutboundGoodsNextDtos()) {
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -7,6 +7,7 @@
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.CodeGenerateUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.dto.InventoryDto;
@@ -198,6 +199,14 @@
    @Override
    public boolean isExit(String goodsIdCode, String quasiNumber,String id) {
        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;
        }
        return false;
    }
    @Override
    public boolean isExitOne(String goodsIdCode, String quasiNumber,String id) {
        Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).eq(TErpGoods::getGoodsSource,1).ne(id!=null,TErpGoods::getId, id).and(q -> q.eq(TErpGoods::getQuasiNumber, quasiNumber)));
        if (size > 0) {
            return true;
        }
@@ -433,14 +442,21 @@
            TErpProcurement tErpProcurement = erpProcurementMapper.selectById(tErpClinicWarehousing.getProcurementId());
            warehouseGoodsDetailVo.setInventoryNumber(tErpProcurement.getProcurementCode());
        }
        if(tErpClinicWarehousing.getType()==2){
            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);
            tErpClinicWarehousingBatch.setGoodsName(tErpGoods.getGoodsName());
            String packingUnitId = tErpGoods.getPackingUnitId();
            TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(packingUnitId);
            tErpClinicWarehousingBatch.setUnitName(tErpGoodsUnit.getUnitName());
            if(tErpGoodsUnit!=null){
                tErpClinicWarehousingBatch.setUnitName(tErpGoodsUnit.getUnitName());
            }
        }
@@ -520,11 +536,38 @@
            supplierClinicId =crmClinic.getId();
        }
        TErpSupplierInventory tErpSupplierInventory = new TErpSupplierInventory();
        String s = DateUtils.dateTimeNow();
        tErpSupplierInventory.setInventoryNumber("P" + s);
        TErpSupplierInventory last1 = erpSupplierInventoryMapper.selectOne(new LambdaQueryWrapper<TErpSupplierInventory>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
        if(last1==null){
            tErpSupplierInventory.setInventoryNumber("P" + DateUtils.dateTimeNow()+"00001");
        }else {
            String lastProcurementCode = last1.getInventoryNumber();
            String datePart = "P" + DateUtils.dateTimeNow();
            // 直接获取后五位数字并+1,不考虑是否同一天
            try {
                String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                int number = Integer.parseInt(numberPart);
                if (number < 99999) {
                    number++;
                } else {
                    number = 2; // 达到99999后重置为00002
                }
                tErpSupplierInventory.setInventoryNumber(datePart + String.format("%05d", number));
            } catch (NumberFormatException e) {
                // 如果解析失败,默认从00001开始
                tErpSupplierInventory.setInventoryNumber(datePart + "00001");
            }
        }
        tErpSupplierInventory.setWarehouseId(dto.getWarehouseId());
        tErpSupplierInventory.setSupplierId(supplierClinicId);
        erpSupplierInventoryMapper.insert(tErpSupplierInventory);
        try {
            erpSupplierInventoryMapper.insert(tErpSupplierInventory);
        }catch (Exception e){
            throw new RuntimeException("网络繁忙,请重试");
        }
        List<InventoryGoodsDto> dtos = dto.getDtos();
        for (InventoryGoodsDto inventoryGoodsDto : dtos) {
@@ -546,10 +589,34 @@
                tErpSupplierWarehousing.setUnitAmount(tErpSupplierWarehousing1.getUnitAmount());
                tErpSupplierWarehousing.setTotalPrice(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(tErpSupplierWarehousing.getGoodsCount())));
                // 当前年月日时分秒
                String time = DateUtils.dateTimeNow();
                tErpSupplierWarehousing.setWarehouseNo("G" + time);
                TErpSupplierWarehousing last = erpSupplierWarehousingMapper.selectOne(new LambdaQueryWrapper<TErpSupplierWarehousing>().orderByDesc(BaseModel::getCreateTime).last("LIMIT 1"));
                if(last==null){
                    tErpSupplierWarehousing.setWarehouseNo("G"+DateUtils.dateTimeNow()+"00001");
                }else {
                    String lastProcurementCode = last.getWarehouseNo();
                    String datePart = "G" + DateUtils.dateTimeNow();
                    // 直接获取后五位数字并+1,不考虑是否同一天
                    try {
                        String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                        int number = Integer.parseInt(numberPart);
                        if (number < 99999) {
                            number++;
                        } else {
                            number = 2; // 达到99999后重置为00002
                        }
                        tErpSupplierWarehousing.setWarehouseNo(datePart + String.format("%05d", number));
                    } catch (NumberFormatException e) {
                        // 如果解析失败,默认从00001开始
                        tErpSupplierWarehousing.setWarehouseNo(datePart + "00001");
                    }
                }
                tErpSupplierWarehousing.setType(2);
                erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing);
                try {
                    erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing);
                }catch (Exception e){
                    throw new RuntimeException("网络繁忙,请重试");
                }
                // 添加批次信息
                TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch1 = new TErpSupplierWarehousingBatch();
@@ -583,12 +650,37 @@
                    tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
                    tErpSupplierOutbound.setSupplierId(supplierClinicId);
                    tErpSupplierOutbound.setOutboundType(1);
                    tErpSupplierOutbound.setOutboundNumber("G" + s);
                    TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
                    if(last==null){
                        tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+ "00001");
                    }else {
                        String lastProcurementCode = last.getOutboundNumber();
                        String datePart = "G" + DateUtils.dateTimeNow();
                        // 直接获取后五位数字并+1,不考虑是否同一天
                        try {
                            String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                            int number = Integer.parseInt(numberPart);
                            if (number < 99999) {
                                number++;
                            } else {
                                number = 2; // 达到99999后重置为00002
                            }
                            tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number));
                        } catch (NumberFormatException e) {
                            // 如果解析失败,默认从00001开始
                            tErpSupplierOutbound.setOutboundNumber(datePart + "00001");
                        }
                    }
                    int count = inventoryGoodsDto.getDamagedCount();
                    tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count)));
                    tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing2.getGoodsId());
                    erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                    try {
                        erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                    }catch (Exception e){
                        throw new RuntimeException("网络繁忙,请重试");
                    }
                    TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
                    tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
@@ -604,11 +696,37 @@
                tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
                tErpSupplierOutbound.setSupplierId(supplierClinicId);
                tErpSupplierOutbound.setOutboundType(6);
                tErpSupplierOutbound.setOutboundNumber("G" + s);
                TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
                if(last==null){
                    tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+ "00001");
                }else {
                    String lastProcurementCode = last.getOutboundNumber();
                    String datePart = "G" + DateUtils.dateTimeNow();
                    // 直接获取后五位数字并+1,不考虑是否同一天
                    try {
                        String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                        int number = Integer.parseInt(numberPart);
                        if (number < 99999) {
                            number++;
                        } else {
                            number = 2; // 达到99999后重置为00002
                        }
                        tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number));
                    } catch (NumberFormatException e) {
                        // 如果解析失败,默认从00001开始
                        tErpSupplierOutbound.setOutboundNumber(datePart + "00001");
                    }
                }
                int count = inventoryGoodsDto.getNum() - inventoryGoodsDto.getInventoryCount();
                tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count)));
                tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing2.getGoodsId());
                erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                try {
                    erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                }catch (Exception e){
                    throw new RuntimeException("网络繁忙,请重试");
                }
                TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
@@ -636,6 +754,7 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public void inventoryGoods1(InventoryDto dto, SysUser user) {
        Integer roleType = user.getRoleType();
        String supplierClinicId = null;
@@ -654,10 +773,36 @@
            supplierClinicId =crmClinic.getId();
        }
        TErpClinicInventory tErpSupplierInventory = new TErpClinicInventory();
        String s = DateUtils.dateTimeNow();
        tErpSupplierInventory.setInventoryNumber("P" + s);
        TErpClinicInventory last = erpClinicInventoryMapper.selectOne(new LambdaQueryWrapper<TErpClinicInventory>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
        if(last==null){
            tErpSupplierInventory.setInventoryNumber("P" + DateUtils.dateTimeNow()+"00001");
        }else {
            String lastProcurementCode = last.getInventoryNumber();
            String datePart = "P" + DateUtils.dateTimeNow();
            // 直接获取后五位数字并+1,不考虑是否同一天
            try {
                String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                int number = Integer.parseInt(numberPart);
                if (number < 99999) {
                    number++;
                } else {
                    number = 2; // 达到99999后重置为00002
                }
                tErpSupplierInventory.setInventoryNumber(datePart + String.format("%05d", number));
            } catch (NumberFormatException e) {
                // 如果解析失败,默认从00001开始
                tErpSupplierInventory.setInventoryNumber(datePart + "00001");
            }
        }
        tErpSupplierInventory.setClinicId(supplierClinicId);
        erpClinicInventoryMapper.insert(tErpSupplierInventory);
        try {
            erpClinicInventoryMapper.insert(tErpSupplierInventory);
        }catch (Exception e){
            throw new RuntimeException("网络繁忙,请重试");
        }
        List<InventoryGoodsDto> dtos = dto.getDtos();
        for (InventoryGoodsDto inventoryGoodsDto : dtos) {
@@ -668,8 +813,6 @@
            TErpClinicWarehousing tErpSupplierWarehousing1 = erpClinicWarehousingMapper.selectById(warehousingId);
            TErpGoods erpGoods = this.getById(tErpSupplierWarehousingBatch.getGoodsId());
            // 盘点是盘亏盘盈   赢
            if (inventoryGoodsDto.getNum() < inventoryGoodsDto.getInventoryCount()) {
                // 添加入库信息
@@ -678,13 +821,43 @@
//                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())));
                tErpSupplierWarehousing.setTotalPrice(tErpSupplierWarehousingBatch.getUnitAmount().multiply(new BigDecimal(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum())));
                // 当前年月日时分秒
                String time = DateUtils.dateTimeNow();
                tErpSupplierWarehousing.setWarehouseNo("G" + time);
                TErpClinicWarehousing last1 = erpClinicWarehousingMapper.selectOne(new LambdaQueryWrapper<TErpClinicWarehousing>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
                if(last1==null){
                    tErpSupplierWarehousing.setWarehouseNo("G" + DateUtils.dateTimeNow()+"00001");
                }else {
                    String lastProcurementCode = last1.getWarehouseNo();
                    String datePart = "G" + DateUtils.dateTimeNow();
                    // 直接获取后五位数字并+1,不考虑是否同一天
                    try {
                        String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                        int number = Integer.parseInt(numberPart);
                        if (number < 99999) {
                            number++;
                        } else {
                            number = 2; // 达到99999后重置为00002
                        }
                        tErpSupplierWarehousing.setWarehouseNo(datePart + String.format("%05d", number));
                    } catch (NumberFormatException e) {
                        // 如果解析失败,默认从00001开始
                        tErpSupplierWarehousing.setWarehouseNo(datePart + "00001");
                    }
                }
                tErpSupplierWarehousing.setType(2);
                tErpSupplierWarehousing.setInventoryId(tErpSupplierInventory.getId());
                erpClinicWarehousingMapper.insert(tErpSupplierWarehousing);
                if(erpGoods.getGoodsSource()==1){
                    TCrmSupplier supplier = crmSupplierMapper.selectById(erpGoods.getSupplierClinicId());
                    tErpSupplierWarehousing.setSupplierName(supplier.getSupplierName());
                }else {
                    tErpSupplierWarehousing.setSupplierName(erpGoods.getSupplierName());
                }
                try {
                    erpClinicWarehousingMapper.insert(tErpSupplierWarehousing);
                }catch (Exception e){
                    throw new RuntimeException("网络繁忙,请重试");
                }
                // 添加批次信息
                TErpClinicWarehousingBatch tErpSupplierWarehousingBatch1 = new TErpClinicWarehousingBatch();
@@ -714,17 +887,41 @@
            } 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);
                    TErpClinicOutbound last2 = erpClinicOutboundMapper.selectOne(new LambdaQueryWrapper<TErpClinicOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
                    if(last2==null){
                        tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+"00001");
                    }else {
                        String lastProcurementCode = last2.getOutboundNumber();
                        String datePart = "G" + DateUtils.dateTimeNow();
                        // 直接获取后五位数字并+1,不考虑是否同一天
                        try {
                            String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                            int number = Integer.parseInt(numberPart);
                            if (number < 99999) {
                                number++;
                            } else {
                                number = 2; // 达到99999后重置为00002
                            }
                            tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number));
                        } catch (NumberFormatException e) {
                            // 如果解析失败,默认从00001开始
                            tErpSupplierOutbound.setOutboundNumber(datePart + "00001");
                        }
                    }
                    int count = inventoryGoodsDto.getDamagedCount();
                    tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
                    tErpSupplierOutbound.setInventoryId(tErpSupplierInventory.getId());
                    erpClinicOutboundMapper.insert(tErpSupplierOutbound);
                    try {
                        erpClinicOutboundMapper.insert(tErpSupplierOutbound);
                    }catch (Exception e){
                        throw new RuntimeException("网络繁忙,请重试");
                    }
                    TErpClinicOutboundGoods tErpSupplierOutboundGoods = new TErpClinicOutboundGoods();
@@ -739,11 +936,36 @@
//                tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
//                tErpSupplierOutbound.setSupplierId(supplierClinicId);
                tErpSupplierOutbound.setOutboundType(6);
                tErpSupplierOutbound.setOutboundNumber("G" + s);
                TErpClinicOutbound last4 = erpClinicOutboundMapper.selectOne(new LambdaQueryWrapper<TErpClinicOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
                if(last4==null){
                    tErpSupplierOutbound.setOutboundNumber("G" +  DateUtils.dateTimeNow()+"00001");
                }else {
                    String lastProcurementCode = last4.getOutboundNumber();
                    String datePart = "G" + DateUtils.dateTimeNow();
                    // 直接获取后五位数字并+1,不考虑是否同一天
                    try {
                        String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                        int number = Integer.parseInt(numberPart);
                        if (number < 99999) {
                            number++;
                        } else {
                            number = 2; // 达到99999后重置为00002
                        }
                        tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number));
                    } catch (NumberFormatException e) {
                        // 如果解析失败,默认从00001开始
                        tErpSupplierOutbound.setOutboundNumber(datePart + "00001");
                    }
                }
                int count = inventoryGoodsDto.getNum() - inventoryGoodsDto.getInventoryCount();
                tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
                tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousingBatch.getSalesAmount().multiply(new BigDecimal(count)));
                tErpSupplierOutbound.setInventoryId(tErpSupplierInventory.getId());
                erpClinicOutboundMapper.insert(tErpSupplierOutbound);
                try {
                    erpClinicOutboundMapper.insert(tErpSupplierOutbound);
                }catch (Exception e){
                    throw new RuntimeException("网络繁忙,请重试");
                }
                TErpClinicOutboundGoods tErpSupplierOutboundGoods = new TErpClinicOutboundGoods();
@@ -751,7 +973,7 @@
                tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId());
                tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
                tErpSupplierOutboundGoods.setOutboundCount(count);
                tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
                tErpSupplierOutboundGoods.setTotalPrice(tErpSupplierWarehousingBatch.getSalesAmount().multiply(new BigDecimal(count)));
                erpClinicOutboundGoodsMapper.insert(tErpSupplierOutboundGoods);
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpMaintenanceReminderServiceImpl.java
@@ -109,7 +109,7 @@
        if(!personIds.isEmpty()){
            List<SysUser> userList = sysUserMapper.selectBatchIds(personIds);
            for (TErpMaintenanceReminderListVo tErpMaintenanceReminderListVo : list) {
                userList.stream().filter(t ->tErpMaintenanceReminderListVo.getMaintenancePersonId()!=null &&  t.getUserId().toString().equals(tErpMaintenanceReminderListVo.getMaintenancePersonId().toString())).findFirst().ifPresent(t -> tErpMaintenanceReminderListVo.setMaintenancePersonName(t.getUserName()));
                userList.stream().filter(t ->tErpMaintenanceReminderListVo.getMaintenancePersonId()!=null &&  t.getUserId().toString().equals(tErpMaintenanceReminderListVo.getMaintenancePersonId().toString())).findFirst().ifPresent(t -> tErpMaintenanceReminderListVo.setMaintenancePersonName(t.getNickName()));
            }
        }
        page.setRecords( list);
@@ -127,7 +127,7 @@
        tErpMaintenanceReminderDetailVo.setMaintenanceRecord(tErpMaintenanceReminder.getMaintenanceRecord());
        tErpMaintenanceReminderDetailVo.setMaintenancePersonId(tErpMaintenanceReminder.getMaintenancePersonId());
        if(tErpMaintenanceReminder.getMaintenancePersonId()!=null){
            tErpMaintenanceReminderDetailVo.setMaintenancePersonName(sysUserMapper.selectUserById(Long.valueOf(tErpMaintenanceReminder.getMaintenancePersonId())).getUserName());
            tErpMaintenanceReminderDetailVo.setMaintenancePersonName(sysUserMapper.selectUserById(Long.valueOf(tErpMaintenanceReminder.getMaintenancePersonId())).getNickName());
        }
        tErpMaintenanceReminderDetailVo.setStatus(tErpMaintenanceReminder.getStatus());
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java
@@ -394,7 +394,7 @@
            List<AddProcurementDto> value = entry.getValue();
            TErpProcurement tErpProcurement = new TErpProcurement();
            tErpProcurement.setClinicId(clinicSupplierId);
            tErpProcurement.setProcurementCode("C" + DateUtils.dateTimeNow());
            tErpProcurement.setSupplierId(supplierClinicId);
            tErpProcurement.setTermNo(supplier.getTermNo());
@@ -456,7 +456,37 @@
                throw new RuntimeException("金额设置错误,请联系平台管理员");
            }
            tErpProcurement.setSupplierMoney(supplierCommissionPrice);
            this.save(tErpProcurement);
            // 获取上一条最新的数据
            TErpProcurement tErpProcurement1 = this.baseMapper.selectOne(new QueryWrapper<TErpProcurement>().orderByDesc("create_time").last("limit 1"));
            if(tErpProcurement1==null){
                tErpProcurement.setProcurementCode("C" + DateUtils.dateTimeNow()+"00001");
            }else {
                String lastProcurementCode = tErpProcurement1.getProcurementCode();
                String datePart = "C" + DateUtils.dateTimeNow();
                // 直接获取后五位数字并+1,不考虑是否同一天
                try {
                    String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                    int number = Integer.parseInt(numberPart);
                    if (number < 99999) {
                        number++;
                    } else {
                        number = 2; // 达到99999后重置为00002
                    }
                    tErpProcurement.setProcurementCode(datePart + String.format("%05d", number));
                } catch (NumberFormatException e) {
                    // 如果解析失败,默认从00001开始
                    tErpProcurement.setProcurementCode(datePart + "00001");
                }
            }
            try {
                this.save(tErpProcurement);
            }catch (Exception e){
                throw new RuntimeException("网络繁忙,请重试");
            }
            tErpProcurementGoods1.forEach(e -> e.setProcurementId(tErpProcurement.getId()));
            erpProcurementGoodsService.saveBatch(tErpProcurementGoods1);
        }
@@ -469,7 +499,7 @@
        TErpProcurement tErpProcurement = this.getById(id);
        if (tErpProcurement.getWarehousingUserId()!=null && !tErpProcurement.getWarehousingUserId().isEmpty()) {
            SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(tErpProcurement.getWarehousingUserId()));
            detailProcurementVO.setWarehousingUserName(sysUser.getUserName());
            detailProcurementVO.setWarehousingUserName(sysUser.getNickName());
        }
        detailProcurementVO.setWarehousingTime(tErpProcurement.getWarehousingTime());
@@ -479,7 +509,7 @@
        detailProcurementVO.setSendTime(tErpProcurement.getSendTime());
        TCrmSupplier supplier = crmSupplierMapper.selectById(tErpProcurement.getSupplierId());
        detailProcurementVO.setSupplierName(supplier.getSupplierName());
        detailProcurementVO.setUserName(sysUserMapper.selectUserById(Long.valueOf(tErpProcurement.getCreateId())).getUserName());
        detailProcurementVO.setUserName(sysUserMapper.selectUserById(Long.valueOf(tErpProcurement.getCreateId())).getNickName());
        TCrmClinic tCrmClinic = crmClinicMapper.selectById(tErpProcurement.getClinicId());
        detailProcurementVO.setClinicName(tCrmClinic.getClinicName());
        detailProcurementVO.setClinicAddress(tCrmClinic.getClinicAddress());
@@ -576,8 +606,34 @@
                        tErpSupplierOutbound.setOutboundType(7);
                        //TODO 确定这个是采购价还是销售价格
                        tErpSupplierOutbound.setTotalMoney(tErpProcurementGoods.getPurchasePrice().multiply(new BigDecimal(purchaseCount)));
                        tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow());
                        erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                        TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
                        if(last==null){
                            tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+"00001");
                        }else {
                            String lastProcurementCode = last.getOutboundNumber();
                            String datePart = "G" + DateUtils.dateTimeNow();
                            // 直接获取后五位数字并+1,不考虑是否同一天
                            try {
                                String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                                int number = Integer.parseInt(numberPart);
                                if (number < 99999) {
                                    number++;
                                } else {
                                    number = 2; // 达到99999后重置为00002
                                }
                                tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number));
                            } catch (NumberFormatException e) {
                                // 如果解析失败,默认从00001开始
                                tErpSupplierOutbound.setOutboundNumber(datePart + "00001");
                            }
                        }
                        try {
                            erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                        }catch (Exception e){
                            throw new RuntimeException("网络繁忙,请重试");
                        }
                        TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
                        tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
@@ -599,8 +655,35 @@
                        tErpSupplierOutbound.setOutboundType(7);
                        //TODO 确定这个是采购价还是销售价格
                        tErpSupplierOutbound.setTotalMoney(tErpProcurementGoods.getPurchasePrice().multiply(new BigDecimal(purchaseCount)));
                        tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow());
                        erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                        TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
                        if(last==null){
                            tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+"00001");
                        }else {
                            String lastProcurementCode = last.getOutboundNumber();
                            String datePart = "G" + DateUtils.dateTimeNow();
                            // 直接获取后五位数字并+1,不考虑是否同一天
                            try {
                                String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                                int number = Integer.parseInt(numberPart);
                                if (number < 99999) {
                                    number++;
                                } else {
                                    number = 2; // 达到99999后重置为00002
                                }
                                tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number));
                            } catch (NumberFormatException e) {
                                // 如果解析失败,默认从00001开始
                                tErpSupplierOutbound.setOutboundNumber(datePart + "00001");
                            }
                        }
                        try {
                            erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                        }catch (Exception e){
                            throw new RuntimeException("网络繁忙,请重试");
                        }
                        TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
                        tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
@@ -3,6 +3,7 @@
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.core.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
@@ -24,6 +25,8 @@
import com.ruoyi.system.vo.*;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -253,6 +256,7 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void warehousingGoods(List<WarehousingGoodsDto> dtos, SysUser user) {
        Integer roleType = user.getRoleType();
        String supplierClinicId = null;
@@ -273,8 +277,32 @@
        for (WarehousingGoodsDto dto : dtos) {
            TErpSupplierWarehousing tErpSupplierWarehousing = new TErpSupplierWarehousing();
            // 当前年月日时分秒
            String time = DateUtils.dateTimeNow();
            tErpSupplierWarehousing.setWarehouseNo("G"+time);
            // 查询上一个入库单
            TErpSupplierWarehousing last = erpSupplierWarehousingMapper.selectOne(new LambdaQueryWrapper<TErpSupplierWarehousing>().orderByDesc(TErpSupplierWarehousing::getCreateTime).last("LIMIT 1"));
            if(last==null){
                tErpSupplierWarehousing.setWarehouseNo("G"+DateUtils.dateTimeNow()+"00001");
            }else {
                String lastProcurementCode = last.getWarehouseNo();
                String datePart = "G" + DateUtils.dateTimeNow();
                // 直接获取后五位数字并+1,不考虑是否同一天
                try {
                    String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                    int number = Integer.parseInt(numberPart);
                    if (number < 99999) {
                        number++;
                    } else {
                        number = 2; // 达到99999后重置为00002
                    }
                    tErpSupplierWarehousing.setWarehouseNo(datePart + String.format("%05d", number));
                } catch (NumberFormatException e) {
                    // 如果解析失败,默认从00001开始
                    tErpSupplierWarehousing.setWarehouseNo(datePart + "00001");
                }
            }
            tErpSupplierWarehousing.setSupplierId(supplierClinicId);
            tErpSupplierWarehousing.setWarehouseId(dto.getWarehouseId());
            tErpSupplierWarehousing.setGoodsId(dto.getGoodsId());
@@ -285,8 +313,12 @@
            tErpSupplierWarehousing.setTotalPrice(dto.getTotalPrice());
            List<WarehousingGoodsNextDto> warehousingGoodsNextDtos = dto.getWarehousingGoodsNextDtos();
            int sum = warehousingGoodsNextDtos.stream().mapToInt(WarehousingGoodsNextDto::getWarehousingNum).sum();
            tErpSupplierWarehousing.setGoodsCount( sum);
            erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing);
            tErpSupplierWarehousing.setGoodsCount(sum);
            try {
                erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing);
            }catch (Exception e){
                throw new RuntimeException("网络繁忙,请重试");
            }
            for (WarehousingGoodsNextDto warehousingGoodsNextDto : warehousingGoodsNextDtos) {
                TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = new TErpSupplierWarehousingBatch();
@@ -513,6 +545,7 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public void outbountGoods(OutboundGoodsDto dto, SysUser user) {
        Integer roleType = user.getRoleType();
        String supplierClinicId = null;
@@ -561,10 +594,34 @@
            tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
            tErpSupplierOutbound.setSupplierId(supplierClinicId);
            tErpSupplierOutbound.setTotalMoney(add);
            String s = DateUtils.dateTimeNow();
            tErpSupplierOutbound.setOutboundNumber("G" + s);
            TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).last("LIMIT 1"));
            if(last==null){
                tErpSupplierOutbound.setOutboundNumber("G" +  DateUtils.dateTimeNow()+ "00001");
            }else{
                String lastProcurementCode = last.getOutboundNumber();
                String datePart = "G" + DateUtils.dateTimeNow();
                // 直接获取后五位数字并+1,不考虑是否同一天
                try {
                    String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
                    int number = Integer.parseInt(numberPart);
                    if (number < 99999) {
                        number++;
                    } else {
                        number = 2; // 达到99999后重置为00002
                    }
                    tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number));
                } catch (NumberFormatException e) {
                    // 如果解析失败,默认从00001开始
                    tErpSupplierOutbound.setOutboundNumber(datePart + "00001");
                }
            }
            tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing.getGoodsId());
            erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
            try {
                erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
            }catch (Exception e){
                throw new RuntimeException("网络繁忙,请重试");
            }
            for (TErpSupplierOutboundGoods tErpSupplierOutboundGoods2 : arrayList) {
                tErpSupplierOutboundGoods2.setOutboundId(tErpSupplierOutbound.getId());
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysGoodsServiceImpl.java
@@ -48,10 +48,10 @@
        // 判断已经购买的了多少
        List<TSysGoodsExchange> list = sysGoodsExchangeMapper.selectList(new LambdaQueryWrapper<TSysGoodsExchange>().eq(TSysGoodsExchange::getGoodsId, dto.getGoodsId()));
        int sum = list.stream().mapToInt(TSysGoodsExchange::getGoodsCount).sum();
        if(sum+dto.getCount()>tSysGoods.getGoodsTotal()){
        if(tSysGoods.getGoodsTotal()!=null && sum+dto.getCount()>tSysGoods.getGoodsTotal()){
            throw new RuntimeException("商品库存不足");
        }
        if(sum+dto.getCount()>tSysGoods.getConvertibleQuantity()){
        if(tSysGoods.getConvertibleQuantity()!=null && sum+dto.getCount()>tSysGoods.getConvertibleQuantity()){
            throw new RuntimeException("可兑换数量不足");
        }
        List<TCrmClinicPoints> points = crmClinicPointsMapper.selectList(new LambdaQueryWrapper<TCrmClinicPoints>().eq(TCrmClinicPoints::getClinicId, crmClinic.getId()).ge(TCrmClinicPoints::getExpireTime, new Date()).last(" and points > use_points ORDER BY create_time ASC"));
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysOrderServiceImpl.java
@@ -25,6 +25,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
@@ -92,21 +93,23 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void add(TSysOrderDto dto, TCrmClinic crmClinic) {
    public void add(TSysOrderDto dto, TCrmClinic crmClinic,String name,String userId) {
        // 判断库存够不够  添加订单 添加订单二级  出库记录
        List<TSysOrderNextDto> dtoList = dto.getDtoList();
        ArrayList<TSysOrderGoods> tSysOrderGoods = new ArrayList<>();
        ArrayList<TErpClinicOutboundGoods> erpClinicOutboundGoods = new ArrayList<>();
        HashSet<String> goodsIds = new HashSet<>();
        for (TSysOrderNextDto sysOrderNextDto : dtoList) {
            TErpClinicWarehousingBatch tErpClinicWarehousingBatch = erpClinicWarehousingBatchMapper.selectById(sysOrderNextDto.getBatchId());
            // 找出这个批次出库多少
            List<TErpClinicOutboundGoods> tErpClinicOutboundGoods = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getWarehousingBatchId, sysOrderNextDto.getBatchId()));
            int count = tErpClinicOutboundGoods.stream().mapToInt(TErpClinicOutboundGoods::getOutboundCount).sum();
            if(tErpClinicWarehousingBatch.getPurchaseCount() < count + sysOrderNextDto.getNum()){
            if(tErpClinicWarehousingBatch.getWarehousingNumber() < count + sysOrderNextDto.getNum()){
                throw new RuntimeException("库存不足");
            }
            TErpGoods goods = erpGoodsMapper.selectById(tErpClinicWarehousingBatch.getGoodsId());
            goodsIds.add(goods.getId());
            TSysOrderGoods tSysOrderGoods1 = new TSysOrderGoods();
            tSysOrderGoods1.setGoodsName(goods.getGoodsName());
            TErpGoodsType tErpGoodsType = erpGoodsTypeMapper.selectById(goods.getTypeId());
@@ -152,6 +155,9 @@
        tErpClinicOutbound.setOrderNumber(tSysOrder.getOrderNumber());
        tErpClinicOutbound.setTotalMoney(dto.getTotalMoney());
        tErpClinicOutbound.setOutboundNumber("G"+System.currentTimeMillis());
        tErpClinicOutbound.setCreateBy(name);
        tErpClinicOutbound.setCreateId(userId);
        tErpClinicOutbound.setTypeNum(goodsIds.size());
        erpClinicOutboundMapper.insert(tErpClinicOutbound);
        for (TErpClinicOutboundGoods erpClinicOutboundGood : erpClinicOutboundGoods) {
ruoyi-system/src/main/java/com/ruoyi/system/vo/ValidityPeriodWarningVo.java
@@ -38,6 +38,7 @@
    @ApiModelProperty(value = "有效日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime expiryDate;
    @ApiModelProperty(value = "单位")
ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml
@@ -131,7 +131,7 @@
    <select id="warehousePageList" resultType="com.ruoyi.system.vo.TErpClinicWarehousePageListVO">
        select t1.id,t1.warehouse_no,
               case when t1.type =1 then  t2.supplier_name else t1.supplier_name end as supplierName,
              t1.supplier_name  as supplierName,
              t3.procurement_code,
              case when t1.type =1 then     t3.pay_money else t1.total_price end as allTotalPrice,
            t1.create_time warehouseTime,t1.type
@@ -156,8 +156,8 @@
    </select>
    <select id="outboundPageList" resultType="com.ruoyi.system.vo.TErpClinicOutboundPageListVO">
        select t1.id,t1.outbound_number,t1.order_number,t1.total_money allTotalPrice,t1.create_time ,t1.outbound_type,t2.user_name,t1.type_num
        from t_erp_clinic_outbound t1 left join sys_user t2 on t1.create_by = t2.user_id
        select t1.id,t1.outbound_number,t1.order_number,t1.total_money allTotalPrice,t1.create_time ,t1.outbound_type,t2.nick_name userName,t1.type_num
        from t_erp_clinic_outbound t1 left join sys_user t2 on t1.create_id = t2.user_id
        where t1.disabled = 0 and t1.clinic_id = #{supplierClinicId}
        <if test="query.outboundNumber != null and query.outboundNumber != ''">
            and t1.outbound_number like concat('%',#{query.outboundNumber},'%')
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -210,7 +210,11 @@
        LEFT JOIN t_erp_clinic_warehousing t2 on t1.warehousing_id = t2.id
        LEFT JOIN t_erp_goods t3 on t1.goods_id = t3.id
        LEFT JOIN t_crm_supplier t4 on t3.supplier_clinic_id = t4.id
        LEFT JOIN t_erp_clinic_outbound_goods t5 on t5.warehousing_batch_id =t1.id
        left join (
            select warehousing_batch_id, sum(outbound_count) as outbound_count
            from t_erp_supplier_outbound_goods
            group by warehousing_batch_id
        ) t5 on t5.warehousing_batch_id =t1.id
        where t2.disabled = 0  and t2.clinic_id =#{supplierClinicId}
        <if test="query.type != null and query.type ==1">
            and #{time} > t1.expiry_date
@@ -259,7 +263,11 @@
        LEFT JOIN t_erp_supplier_warehousing t2 on t1.warehousing_id = t2.id
        LEFT JOIN t_erp_goods t3 on t2.goods_id = t3.id
        LEFT JOIN t_crm_supplier t4 on t3.supplier_clinic_id = t4.id
        LEFT JOIN t_erp_supplier_outbound_goods t5 on t5.warehousing_batch_id =t1.id
        left join (
        select warehousing_batch_id, sum(outbound_count) as outbound_count
        from t_erp_supplier_outbound_goods
        group by warehousing_batch_id
        ) t5 on t5.warehousing_batch_id =t1.id
        where t2.disabled = 0 and t2.warehouse_id = #{warehouseId}
        and #{endDate} > t1.expiry_date
        <if test="user.roleType !=null and user.roleType ==4">
ruoyi-system/src/main/resources/mapper/system/TErpProcurementMapper.xml
@@ -35,7 +35,7 @@
        sum(t2.total_price) as totalPrice,
        t1.create_time,
        t2.id tErpProcurementGoodsId,
        t4.user_name,
        t1.create_by as userName,
        t1.status,
        t1.supplier_money,
        t1.money as platformMoney,
@@ -47,7 +47,7 @@
        left join t_crm_clinic t5 on t1.clinic_id = t5.id
        where t1.disabled = 0 and t1.status !=1
        <if test="user.roleType !=null and user.roleType==4">
            and t2.supplier_id =#{supplierClinicId}
            and t2.supplier_id =#{supplierClinicId} and t1.status in(3,4,5)
        </if>
        <if test="query.procurementCode != null and query.procurementCode != ''">
            and t1.procurement_code = #{query.procurementCode}
@@ -56,7 +56,7 @@
            and t3.supplier_name like concat('%',#{query.clinicName},'%')
        </if>
        <if test="query.userName != null and query.userName != ''">
            and t4.user_name like concat('%',#{query.userName},'%')
            and t1.create_by like concat('%',#{query.userName},'%')
        </if>
        <if test="query.status != null">
            and t1.status = #{query.status}
@@ -91,7 +91,8 @@
               t1.logistics_number,
                t1.send_time,
               t1.clinic_id,
               t1.status
               t1.status,
               t1.create_by  userName
               from t_erp_procurement t1
               left JOIN t_crm_clinic t2 on t1.clinic_id = t2.id
        where t1.disabled = 0 and t1.status in(3,4,5) and t1.supplier_id in
ruoyi-system/src/main/resources/mapper/system/TErpSupplierWarehousingMapper.xml
@@ -115,13 +115,14 @@
    <select id="validityPeriodWarning" resultType="com.ruoyi.system.vo.ValidityPeriodWarningVo">
        select * from (select t2.warehouse_id,t2.warehouse_no warehousingNo, t4.goods_name, t4.quasi_number,
        t1.batch_number, t1.id as batchId,t1.expiry_date, t4.id as goodsId,t5.type_name,t6.unit_name packingUnitName,
        case
        when t3.id is null then t1.warehousing_number
        else t1.warehousing_number -t3.outbound_count
        end as num,t3.id as ogid
        t1.warehousing_number -t3.outbound_count as num
        from t_erp_supplier_warehousing_batch t1
        left join t_erp_supplier_warehousing t2 on t1.warehousing_id = t2.id
        LEFT JOIN t_erp_supplier_outbound_goods t3 on t3.warehousing_batch_id = t1.id
        left join (
        select warehousing_batch_id,  COALESCE(sum(outbound_count), 0) as outbound_count
        from t_erp_supplier_outbound_goods
        group by warehousing_batch_id
        )  t3 on t3.warehousing_batch_id = t1.id
        LEFT JOIN t_erp_goods t4 on t2.goods_id = t4.id
        left join t_erp_goods_type t5 on t4.type_id = t5.id
        left join t_erp_goods_unit t6 on t4.packing_unit_id = t6.id
@@ -141,12 +142,12 @@
            and t4.type_id = #{query.typeId}
        </if>
        group by t1.id
        ) as o where (o.num > 0 or o.ogid is null)
        ) as o where (o.num > 0 )
        order by o.expiry_date
    </select>
    <select id="pageInventoryList" resultType="com.ruoyi.system.vo.PageInventoryListVo">
        select t1.id,t1.create_time,t2.user_name createBy,t3.warehouse_name
        select t1.id,t1.create_time,t1.create_by,t3.warehouse_name
        from t_erp_supplier_inventory t1 left join sys_user t2 on t1.create_id = t2.user_id
        left join t_crm_warehouse t3 on t1.warehouse_id =t3.id
        where t1.disabled = 0
@@ -157,7 +158,7 @@
            and t1.warehouse_id = #{query.warehouseId}
        </if>
        <if test="query.createBy != null and query.createBy != ''">
            and t2.user_name like concat('%',#{query.createBy},'%')
            and t1.create_by like concat('%',#{query.createBy},'%')
        </if>
        <if test="sTime != null and eTime !=null ">
            and t1.create_time between #{sTime} and #{eTime}