liujie
23 小时以前 f41b11c958ef7d0416d194278d1fe7cd1a1e8219
拉卡拉支付
23个文件已修改
6个文件已添加
1401 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpClinicWarehousingController.java 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpProcurementController.java 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysOrderController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/AddProcurementDto.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/InventoryDto.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/TErpClinicGoodsAddDto.java 132 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/TErpGoodsSetCommissionDto.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/UpdateStatusProcurementDto.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/UpdateStatusProcurementLastDto.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpClinicWarehousingMapper.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpClinicInventoryGoods.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpClinicWarehousing.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpGoods.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpSupplierWarehousing.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpClinicWarehousingService.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpProcurementService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpClinicWarehousingServiceImpl.java 225 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java 206 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/DetailProcurementNextVO.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/DetailProcurementVO.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsInventoryVO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpProcurementVo.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpProcurementMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpClinicWarehousingController.java
@@ -1,8 +1,27 @@
package com.ruoyi.web.controller.api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.InventoryDto;
import com.ruoyi.system.model.TCrmClinic;
import com.ruoyi.system.model.TCrmSupplier;
import com.ruoyi.system.query.TErpGoodsInventoryQuery;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.TErpInventoryQuery;
import com.ruoyi.system.query.ValidityPeriodWarningQuery;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.stream.Collectors;
/**
 * <p>
@@ -16,6 +35,119 @@
@RequestMapping("/t-erp-clinic-warehousing")
public class TErpClinicWarehousingController {
    private final TErpClinicWarehousingService erpClinicWarehousingService;
    private final TErpGoodsService erpGoodsService;
    private final TokenService tokenService;
    private final TCrmClinicService crmClinicService;
    private final TCrmSupplierService crmSupplierService;
    @Autowired
    public TErpClinicWarehousingController(TErpClinicWarehousingService erpClinicWarehousingService, TErpGoodsService erpGoodsService, TokenService tokenService,
                                             TCrmClinicService crmClinicService,TCrmSupplierService crmSupplierService) {
        this.erpClinicWarehousingService = erpClinicWarehousingService;
        this.erpGoodsService = erpGoodsService;
        this.tokenService = tokenService;
        this.crmClinicService = crmClinicService;
        this.crmSupplierService = crmSupplierService;
    }
    /**
     * 获取erp问题上报管理列表
     */
    @ApiOperation(value = "展示获取库存分页列表")
    @PostMapping(value = "/pageList")
    public R<PageInfo<TErpGoodsVO>> pageList(@RequestBody TErpGoodsQuery query) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        if(roleType == 4){
            // 供应商
            TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                    .eq(TCrmSupplier::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            query.setSupplierClinicId(crmSupplier.getId());
        }
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            query.setSupplierClinicId(crmClinic.getId());
        }
        return R.ok(erpClinicWarehousingService.pageList(query,user));
    }
    @ApiOperation(value = "诊所 盘点")
    @PostMapping(value = "/pageInventoryList")
    public R<PageInfo<PageInventoryListVo>> pageInventoryList(@RequestBody TErpInventoryQuery query) {
        SysUser user = tokenService.getLoginUser().getUser();
        return R.ok(erpClinicWarehousingService.pageInventoryList(query,user));
    }
    @ApiOperation(value = "诊所 盘点详情")
    @GetMapping(value = "/detailInventory/{id}")
    public R<List<InventoryDetailVo>> detailInventory(@PathVariable String id) {
        SysUser user = tokenService.getLoginUser().getUser();
        return R.ok(erpClinicWarehousingService.detailInventory(id,user));
    }
    @ApiOperation(value = "诊所 盘点 出库 商品选择")
    @PostMapping(value = "/pageInventoryGoodsPageList")
    public R<PageInfo<TErpGoodsInventoryVO>> pageInventoryGoodsPageList(@RequestBody @Valid TErpGoodsInventoryQuery query) {
        SysUser user = tokenService.getLoginUser().getUser();
        return R.ok(erpGoodsService.pageInventoryGoodsPageList1(query,user));
    }
    @ApiOperation(value = "诊所 有效期预警商品选择")
    @GetMapping(value = "/pageInventoryGoodsList")
    public R<List<TErpGoodsInventoryVO>> pageInventoryGoodsList(String warehouseId,@RequestParam(required = false)String batchId) {
        SysUser user = tokenService.getLoginUser().getUser();
        List<TErpGoodsInventoryVO> tErpGoodsInventoryVOS = erpGoodsService.pageInventoryGoodsList1(warehouseId, user);
        if(batchId!=null && !"".equals(batchId)){
            tErpGoodsInventoryVOS = tErpGoodsInventoryVOS.stream().filter(e->e.getId().equals(batchId)).collect(Collectors.toList());
        }
        return R.ok(tErpGoodsInventoryVOS);
    }
    @ApiOperation(value = "诊所 确认盘点")
    @PostMapping(value = "/inventoryGoods")
    public R<?> inventoryGoods(@RequestBody @Valid InventoryDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        erpGoodsService.inventoryGoods1(dto,user);
        return R.ok();
    }
    @ApiOperation(value = "诊所 有效期预警")
    @PostMapping(value = "/validityPeriodWarning")
    public R<PageInfo<ValidityPeriodWarningVo>> validityPeriodWarning(@RequestBody ValidityPeriodWarningQuery query) {
        SysUser user = tokenService.getLoginUser().getUser();
        PageInfo<ValidityPeriodWarningVo> pageInfo =erpClinicWarehousingService.validityPeriodWarning(query,user);
        return R.ok(pageInfo);
    }
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
@@ -9,16 +9,17 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.AjaxResult;
import com.ruoyi.common.core.domain.BaseModel;
import com.ruoyi.common.core.domain.BasePage;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.utils.WebUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.TErpGoodsAddDto;
import com.ruoyi.system.dto.TErpGoodsInfoSaveDto;
import com.ruoyi.system.dto.TErpGoodsUpdateStatusDto;
import com.ruoyi.system.dto.*;
import com.ruoyi.system.importExcel.TErpGoodsExcel;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TErpGoodsQuery;
@@ -93,7 +94,7 @@
    /**
     * 获取erp问题上报管理列表
     */
    @ApiOperation(value = "供应商获取商品分页列表")
    @ApiOperation(value = "供应商 诊所 获取商品分页列表")
    @PostMapping(value = "/pageList")
    public R<PageInfo<TErpGoodsVO>> pageList(@RequestBody TErpGoodsQuery query) {
        SysUser user = tokenService.getLoginUser().getUser();
@@ -113,6 +114,36 @@
            query.setSupplierClinicId(crmClinic.getId());
        }
        return R.ok(erpGoodsService.pageList(query,user));
    }
    /**
     * 获取erp问题上报管理列表
     */
    @ApiOperation(value = "诊所 一键获取商品分页列表")
    @PostMapping(value = "/pageAddList")
    public R<Page<TErpGoods>> pageAddList(BasePage query) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        String clinicSupplierId=null;
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            clinicSupplierId = crmClinic.getId();
        }
        Page<TErpGoods> tErpGoodsPage = new Page<>(query.getPageNum(), query.getPageSize());
        Page<TErpGoods> page = erpGoodsService.page(tErpGoodsPage, new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getGoodsSource, 1).eq(BaseModel::getDisabled, 0).isNotNull(TErpGoods::getPlatformCommissionPrice).last(" NOT FIND_IN_SET(" + clinicSupplierId + ",clinic_ids)"));
        for (TErpGoods record : page.getRecords()) {
            TCrmSupplier byId = crmSupplierService.getById(record.getSupplierClinicId());
            record.setSupplierName(byId.getSupplierName());
            TErpGoodsType byId1 = erpGoodsTypeService.getById(record.getTypeId());
            record.setTypeName(byId1.getTypeName());
        }
        return R.ok(page);
    }
@@ -149,6 +180,28 @@
        goods.setFormulationSpec(dto.getFormulationSpec());
        goods.setPackingSpec(dto.getPackingSpec());
        goods.setGoodsName(dto.getGoodsName());
        return R.ok(erpGoodsService.save(goods));
    }
    @ApiOperation(value = "诊所添加商品")
    @PostMapping(value = "/clinicAdd")
    public R<Boolean> clinicAdd(@Validated @RequestBody TErpClinicGoodsAddDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber())) {
            return R.fail("erp商品已存在");
        }
        Integer roleType = user.getRoleType();
        TErpGoods goods = new TErpGoods();
        BeanUtils.copyProperties(dto,goods);
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            goods.setSupplierClinicId(crmClinic.getId());
            goods.setGoodsSource(2);
        }
        goods.setCreateId(user.getUserId().toString());
        goods.setGoodsIdCode(dto.getGoodsIdCode());
        return R.ok(erpGoodsService.save(goods));
    }
@@ -467,5 +520,20 @@
    }
    @ApiOperation(value = "平台设置分佣")
    @PostMapping(value = "/setCommission")
    public R<Boolean> setCommission(@RequestBody @Valid TErpGoodsSetCommissionDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        if(user.getRoleType()==1){
            TErpGoods goods = erpGoodsService.getById(dto.getId());
            goods.setClinicPurchasePrice(BigDecimal.valueOf(dto.getClinicPurchasePrice()).setScale(2,RoundingMode.HALF_UP));
            goods.setPlatformCommissionPrice(BigDecimal.valueOf(dto.getPlatformCommissionPrice()).setScale(2,RoundingMode.HALF_UP));
            erpGoodsService.updateById( goods);
        }
        return R.ok();
    }
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpProcurementController.java
@@ -1,21 +1,22 @@
package com.ruoyi.web.controller.api;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.lkl.laop.sdk.request.V3LabsTransPreorderRequest;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.AddProcurementDto;
import com.ruoyi.system.model.TCrmClinic;
import com.ruoyi.system.model.TCrmSupplier;
import com.ruoyi.system.model.TErpGoods;
import com.ruoyi.system.dto.UpdateStatusProcurementDto;
import com.ruoyi.system.dto.UpdateStatusProcurementLastDto;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.TErpProcurementQuery;
import com.ruoyi.system.service.TCrmClinicService;
import com.ruoyi.system.service.TErpProcurementService;
import com.ruoyi.system.service.TErpSupplierWarehousingService;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.DetailProcurementVO;
import com.ruoyi.system.vo.TErpGoodsVO;
import com.ruoyi.system.vo.TErpProcurementDetailVo;
import com.ruoyi.system.vo.TErpProcurementVo;
@@ -26,7 +27,10 @@
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * <p>
@@ -45,13 +49,22 @@
    private final TErpProcurementService erpProcurementService;
    private final TokenService tokenService;
    private final TCrmClinicService crmClinicService;
    private final TErpProcurementGoodsService erpProcurementGoodsService;
    private final TErpGoodsService erpGoodsService;
    private final TErpClinicWarehousingService erpClinicWarehousingService;
    private final TErpClinicWarehousingBatchService erpClinicWarehousingBatchService;
    @Autowired
    public TErpProcurementController(TErpProcurementService erpProcurementService, TokenService tokenService,TCrmClinicService crmClinicService) {
    public TErpProcurementController(TErpProcurementService erpProcurementService, TokenService tokenService,TCrmClinicService crmClinicService,TErpProcurementGoodsService erpProcurementGoodsService
    , TErpGoodsService erpGoodsService,TErpClinicWarehousingService erpClinicWarehousingService,TErpClinicWarehousingBatchService erpClinicWarehousingBatchService) {
        this.erpProcurementService = erpProcurementService;
        this.tokenService = tokenService;
        this.crmClinicService = crmClinicService;
        this.erpProcurementGoodsService = erpProcurementGoodsService;
        this.erpGoodsService = erpGoodsService;
        this.erpClinicWarehousingService = erpClinicWarehousingService;
        this.erpClinicWarehousingBatchService = erpClinicWarehousingBatchService;
    }
@@ -112,10 +125,95 @@
                    .last("LIMIT 1"));
            clinicSupplierId = crmClinic.getId();
        }
        return R.ok(erpProcurementService.addProcurement(clinicSupplierId,user,dtos));
        erpProcurementService.addProcurement(clinicSupplierId, user, dtos);
        return R.ok();
    }
    @ApiOperation(value = "采购详情")
    @GetMapping(value = "/detailProcurement/{id}")
    public R<DetailProcurementVO> detailProcurement(@PathVariable String id) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        String clinicSupplierId=null;
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            clinicSupplierId = crmClinic.getId();
        }
        return R.ok( erpProcurementService.detailProcurement(clinicSupplierId, user, id));
    }
    @ApiOperation(value = "采购详情入库")
    @PostMapping(value = "/updateStatusProcurement")
    public R<DetailProcurementVO> updateStatusProcurement(@RequestParam @Valid UpdateStatusProcurementLastDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        String clinicSupplierId=null;
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            clinicSupplierId = crmClinic.getId();
        }
        TErpProcurement erpProcurement = erpProcurementService.getById(dto.getId());
        if(!erpProcurement.getClinicId().equals(clinicSupplierId)){
            return R.fail("无权限操作");
        }
        if(erpProcurement.getStatus()!=4){
            return R.fail("目前状态无法入库");
        }
        erpProcurement.setStatus(5);
        erpProcurementService.updateById(erpProcurement);
        List<String> collect = dto.getList().stream().map(UpdateStatusProcurementDto::getId).collect(Collectors.toList());
        List<TErpProcurementGoods> list = erpProcurementGoodsService.list(new LambdaQueryWrapper<TErpProcurementGoods>().in(TErpProcurementGoods::getId, collect));
        // goodsId分组
        for (UpdateStatusProcurementDto updateStatusProcurementDto : dto.getList()) {
            TErpProcurementGoods tErpProcurementGoods = list.stream().filter(t -> t.getId().equals(updateStatusProcurementDto.getId())).findFirst().get();
            TErpGoods erpGoods = erpGoodsService.getById(tErpProcurementGoods.getGoodsId());
            TErpClinicWarehousing tErpClinicWarehousing = new TErpClinicWarehousing();
            tErpClinicWarehousing.setClinicId(erpProcurement.getClinicId());
            tErpClinicWarehousing.setProcurementId(erpProcurement.getId());
            tErpClinicWarehousing.setGoodsId(erpGoods.getId());
            tErpClinicWarehousing.setGoodsName(erpGoods.getGoodsName());
            tErpClinicWarehousing.setSupplierName(erpGoods.getSupplierName());
            tErpClinicWarehousing.setQuasiNumber(erpGoods.getQuasiNumber());
            tErpClinicWarehousing.setSalesAmount(tErpProcurementGoods.getSalesAmount());
            tErpClinicWarehousing.setPurchaseCount(updateStatusProcurementDto.getPurchaseCount());
            tErpClinicWarehousing.setTotalPrice(tErpProcurementGoods.getSalesAmount().multiply(new BigDecimal(updateStatusProcurementDto.getPurchaseCount())));
            tErpClinicWarehousing.setUnitAmount(tErpProcurementGoods.getSalesAmount());
            tErpClinicWarehousing.setWarehousingType(1);
            tErpClinicWarehousing.setWarehouseNo("G"+ DateUtils.dateTimeNow());
            erpClinicWarehousingService.save(tErpClinicWarehousing);
            TErpClinicWarehousingBatch tErpClinicWarehousingGoods = new TErpClinicWarehousingBatch();
            tErpClinicWarehousingGoods.setWarehousingId(tErpClinicWarehousing.getId());
            tErpClinicWarehousingGoods.setWarehousingNumber(tErpClinicWarehousing.getPurchaseCount());
            tErpClinicWarehousingGoods.setBatchNumber(updateStatusProcurementDto.getBatchNumber());
            tErpClinicWarehousingGoods.setProductionDate(updateStatusProcurementDto.getProductionDate());
            tErpClinicWarehousingGoods.setExpiryDate(updateStatusProcurementDto.getExpiryDate());
            erpClinicWarehousingBatchService.save(tErpClinicWarehousingGoods);
        }
        return R.ok();
    }
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysOrderController.java
@@ -126,6 +126,10 @@
            String amount = String.valueOf(erpProcurement.getPayMoney().multiply(new BigDecimal("100")).intValue());
            TCrmSupplier supplier = crmSupplierService.getById(erpProcurement.getSupplierId());
            String trans_type ="41";
            if("WECHAT".equals(type)){
                trans_type= "51";
            }
            String apiPath = "sit/api/v3/labs/trans/preorder";
@@ -144,7 +148,7 @@
                    "\t\t\"settle_type\": \"1\",\n" +
                    "\t\t\"total_amount\": " + amount + ",\n" +
                    "\t\t\"account_type\": \"" + type + "\",\n" +
                    "\t\t\"trans_type\": \"41\"\n" +
                    "\t\t\"trans_type\": \""+trans_type+"\"\n" +
                    "\t}\n" +
                    "}";
            String authorization = getAuthorization(body);
@@ -409,7 +413,6 @@
                return jsonObject;
            }
        }
        return null;
    }
@@ -486,7 +489,7 @@
        } catch (Exception e) {
            e.printStackTrace();
        }
        return R.fail(500, "调用支付宝支付预下单接口错误");
        return R.fail(500, "退款失败请联系平台管理员");
    }
ruoyi-system/src/main/java/com/ruoyi/system/dto/AddProcurementDto.java
@@ -1,5 +1,6 @@
package com.ruoyi.system.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -29,4 +30,8 @@
    @ApiModelProperty("状态 1草稿")
    private Integer state;
    private BigDecimal platformCommissionPrice;
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/InventoryDto.java
@@ -13,7 +13,6 @@
public class InventoryDto {
    @ApiModelProperty(value = "仓库id")
    @NotBlank(message = "仓库id不能为空")
    private String warehouseId;
    @ApiModelProperty(value = "商品信息")
ruoyi-system/src/main/java/com/ruoyi/system/dto/TErpClinicGoodsAddDto.java
New file
@@ -0,0 +1,132 @@
package com.ruoyi.system.dto;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Data
@ApiModel(value = "erp诊所商品添加DTO")
public class TErpClinicGoodsAddDto {
    @ApiModelProperty(value = "商品名称")
    @NotBlank ( message = "商品名称不能为空")
    private String goodsName;
    @ApiModelProperty(value = "供应商名称")
    @NotBlank ( message = "供应商名称不能为空")
    private String supplierName;
    @ApiModelProperty(value = "国药准字号")
    @NotBlank ( message = "国药准字号不能为空")
    private String quasiNumber;
    @ApiModelProperty(value = "生产厂家")
    @NotBlank ( message = "生产厂家不能为空")
    private String manufacturer;
    @ApiModelProperty(value = "制剂规格")
    @NotBlank ( message = "制剂规格不能为空")
    private String formulationSpec;
    @ApiModelProperty(value = "包装规格")
    @NotBlank ( message = "包装规格不能为空")
    private String packingSpec;
    @ApiModelProperty(value = "商品类型id")
    @NotBlank ( message = "商品类型id不能为空")
    private String typeId;
    @ApiModelProperty(value = "商品标识码")
    @NotBlank ( message = "商品标识码不能为空")
    private String goodsIdCode;
    @ApiModelProperty(value = "保养周期")
    private String maintenanceInterval;
    @ApiModelProperty(value = "保养周期单位")
    private String maintenanceIntervalUnit;
    @ApiModelProperty(value = "是否为处方药 1=是 2=否")
    private Integer isPrescriptionDrug;
    @ApiModelProperty(value = "商品规格")
    @NotBlank ( message = "商品规格不能为空")
    private String goodsSpec;
    @ApiModelProperty(value = "预警库存")
    @NotNull(message = "预警库存不能为空")
    private Integer warningInventory;
    @ApiModelProperty(value = "包装单位,单位id")
    @NotBlank ( message = "包装单位,单位id不能为空")
    private String packingUnitId;
    @ApiModelProperty(value = "商品售价")
    @NotNull(message = "商品售价不能为空")
    private BigDecimal salesAmount;
    @ApiModelProperty(value = "使用说明")
    private String instructionsUse;
    @ApiModelProperty(value = "副作用")
    private String sideEffect;
    @ApiModelProperty(value = "拼音简码")
    private String simplifiedCode;
    @ApiModelProperty(value = "剂型")
    private String dosageForm;
    @ApiModelProperty(value = "用途分类")
    private String usageClassification;
    @ApiModelProperty(value = "商品品牌名")
    private String productBrand;
    @ApiModelProperty(value = "产地")
    private String placeOfOrigin;
    @ApiModelProperty(value = "成分")
    private String ingredient;
    @ApiModelProperty(value = "性状")
    private String trait;
    @ApiModelProperty(value = "适应症")
    private String indication;
    @ApiModelProperty(value = "禁忌")
    private String taboo;
    @ApiModelProperty(value = "注意事项")
    private String precautions;
    @ApiModelProperty(value = "相互作用")
    private String interaction;
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/TErpGoodsSetCommissionDto.java
New file
@@ -0,0 +1,23 @@
package com.ruoyi.system.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Data
@ApiModel(value = "商品设置分佣DTO")
public class TErpGoodsSetCommissionDto {
    @ApiModelProperty(value = "商品id")
    @NotBlank(message = "商品id不能为空")
    private String id;
    @ApiModelProperty(value = "采购价")
    @NotNull(message = "采购价不能为空")
    private Double clinicPurchasePrice;
    @ApiModelProperty(value = "平台分佣金额")
    @NotNull(message = "平台分佣金额不能为空")
    private Double platformCommissionPrice;
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/UpdateStatusProcurementDto.java
New file
@@ -0,0 +1,38 @@
package com.ruoyi.system.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Data
@ApiModel("诊所采购入库二级dto")
public class UpdateStatusProcurementDto {
    @ApiModelProperty("采购二级id")
    @NotBlank(message = "采购二级id不能为空")
    private String id;
    @ApiModelProperty("数量")
    @NotNull(message = "数量不能为空")
    private Integer purchaseCount;
    @ApiModelProperty("批次号")
    @NotBlank(message = "批次号不能为空")
    private String batchNumber;
    @ApiModelProperty(value = "生产日期")
    @NotNull(message = "生产日期不能为空")
    private LocalDateTime productionDate;
    @ApiModelProperty(value = "有效日期")
    @NotNull(message = "有效日期不能为空")
    private LocalDateTime expiryDate;
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/UpdateStatusProcurementLastDto.java
New file
@@ -0,0 +1,25 @@
package com.ruoyi.system.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.util.List;
@Data
@ApiModel("诊所采购入库一级dto")
public class UpdateStatusProcurementLastDto {
    @ApiModelProperty("采购id")
    @NotBlank(message = "采购id不能为空")
    private String id;
    @ApiModelProperty("采购二级dto")
    private List<UpdateStatusProcurementDto> list;
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpClinicWarehousingMapper.java
@@ -1,7 +1,19 @@
package com.ruoyi.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.model.TErpClinicWarehousing;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.TErpInventoryQuery;
import com.ruoyi.system.query.ValidityPeriodWarningQuery;
import com.ruoyi.system.vo.PageInventoryListVo;
import com.ruoyi.system.vo.TErpGoodsVO;
import com.ruoyi.system.vo.ValidityPeriodWarningVo;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
import java.util.List;
/**
 * <p>
@@ -13,4 +25,12 @@
 */
public interface TErpClinicWarehousingMapper extends BaseMapper<TErpClinicWarehousing> {
    List<PageInventoryListVo> pageInventoryList(@Param("pageInfo") PageInfo<PageInventoryListVo> pageInfo, @Param("query") TErpInventoryQuery query, @Param("user") SysUser user, @Param("sTime") String sTime, @Param("eTime") String eTime, @Param("supplierClinicId") String supplierClinicId);
    PageInfo<ValidityPeriodWarningVo> validityPeriodWarning(@Param("pageInfo") PageInfo<ValidityPeriodWarningVo> pageInfo, @Param("query") ValidityPeriodWarningQuery query, @Param("user") SysUser user, @Param("nineMonthLater") LocalDateTime nineMonthLater, @Param("supplierClinicId") String supplierClinicId);
    List<TErpGoodsVO> pageList(@Param("query") TErpGoodsQuery query, @Param("pageInfo") PageInfo<TErpGoodsVO> pageInfo, @Param("user") SysUser user);
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java
@@ -31,4 +31,11 @@
    List<TErpGoodsInventoryVO> pageInventoryGoodsList(@Param("warehouseId") String warehouseId, @Param("user") SysUser user, @Param("supplierClinicId") String supplierClinicId, @Param("endDate") Date endDate);
    List<TErpGoodsInventoryVO> pageInventoryGoodsList1(@Param("warehouseId") String warehouseId, @Param("user") SysUser user, @Param("supplierClinicId") String supplierClinicId, @Param("endDate") Date endDate);
    List<TErpGoodsInventoryVO> pageInventoryGoodsPageList1(@Param("query") TErpGoodsInventoryQuery query, @Param("pageInfo") PageInfo<TErpGoodsInventoryVO> pageInfo, @Param("user") SysUser user, @Param("supplierClinicId") String supplierClinicId, @Param("endDate") Date endDate);
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpClinicInventoryGoods.java
@@ -55,5 +55,8 @@
    @TableField("inventory_type")
    private Integer inventoryType;
    @ApiModelProperty(value = "商品id")
    @TableField("goods_id")
    private String goodsId;
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpClinicWarehousing.java
@@ -70,4 +70,14 @@
    @TableField("warehousing_type")
    private Integer warehousingType;
    @ApiModelProperty(value = "入库单号")
    @TableField("warehouse_no")
    private String warehouseNo;
    @ApiModelProperty(value = "单价")
    @TableField("unit_amount")
    private BigDecimal unitAmount;
    @ApiModelProperty(value = "1正常 2盘点")
    private Integer type;
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpGoods.java
@@ -222,6 +222,12 @@
    private String storage;
    @ApiModelProperty(value = "商品条码")
    private String barcode;
    @ApiModelProperty(value = "诊所添加供应商")
    @TableField("supplier_name")
    private String supplierName;
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpSupplierWarehousing.java
@@ -64,4 +64,7 @@
    @ApiModelProperty(value = "入库单号")
    @TableField("warehouse_no")
    private String warehouseNo;
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpClinicWarehousingService.java
@@ -1,7 +1,18 @@
package com.ruoyi.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.model.TErpClinicWarehousing;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.TErpInventoryQuery;
import com.ruoyi.system.query.ValidityPeriodWarningQuery;
import com.ruoyi.system.vo.InventoryDetailVo;
import com.ruoyi.system.vo.PageInventoryListVo;
import com.ruoyi.system.vo.TErpGoodsVO;
import com.ruoyi.system.vo.ValidityPeriodWarningVo;
import java.util.List;
/**
 * <p>
@@ -13,4 +24,12 @@
 */
public interface TErpClinicWarehousingService extends IService<TErpClinicWarehousing> {
    PageInfo<PageInventoryListVo> pageInventoryList(TErpInventoryQuery query, SysUser user);
    List<InventoryDetailVo> detailInventory(String id, SysUser user);
    PageInfo<ValidityPeriodWarningVo> validityPeriodWarning(ValidityPeriodWarningQuery query, SysUser user);
    PageInfo<TErpGoodsVO> pageList(TErpGoodsQuery query, SysUser user);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java
@@ -52,4 +52,11 @@
    List<TErpGoodsInventoryVO> pageInventoryGoodsList(@Valid String warehouseId, SysUser user);
    PageInfo<TErpGoodsInventoryVO> pageInventoryGoodsPageList1(@Valid TErpGoodsInventoryQuery query, SysUser user);
    void inventoryGoods1(@Valid InventoryDto dto, SysUser user);
    List<TErpGoodsInventoryVO> pageInventoryGoodsList1(String warehouseId, SysUser user);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpProcurementService.java
@@ -8,6 +8,7 @@
import com.ruoyi.system.model.TErpProcurement;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.TErpProcurementQuery;
import com.ruoyi.system.vo.DetailProcurementVO;
import com.ruoyi.system.vo.TErpGoodsVO;
import com.ruoyi.system.vo.TErpProcurementDetailVo;
import com.ruoyi.system.vo.TErpProcurementVo;
@@ -36,6 +37,7 @@
    List<TErpGoodsVO> inventoryNotEnoughList(SysUser user);
    String addProcurement(String clinicSupplierId, SysUser user, @Valid List<AddProcurementDto> dtos);
    void addProcurement(String clinicSupplierId, SysUser user, @Valid List<AddProcurementDto> dtos);
    DetailProcurementVO detailProcurement(String clinicSupplierId, SysUser user, String id);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpClinicWarehousingServiceImpl.java
@@ -1,10 +1,29 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.system.model.TErpClinicWarehousing;
import com.ruoyi.system.mapper.TErpClinicWarehousingMapper;
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.entity.SysUser;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.TErpInventoryQuery;
import com.ruoyi.system.query.ValidityPeriodWarningQuery;
import com.ruoyi.system.service.TErpClinicWarehousingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.vo.InventoryDetailVo;
import com.ruoyi.system.vo.PageInventoryListVo;
import com.ruoyi.system.vo.TErpGoodsVO;
import com.ruoyi.system.vo.ValidityPeriodWarningVo;
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.List;
import java.util.stream.Collectors;
/**
 * <p>
@@ -17,4 +36,206 @@
@Service
public class TErpClinicWarehousingServiceImpl extends ServiceImpl<TErpClinicWarehousingMapper, TErpClinicWarehousing> implements TErpClinicWarehousingService {
    @Resource
    private TCrmClinicMapper crmClinicMapper;
    @Resource
    private TErpClinicInventoryGoodsMapper erpClinicInventoryGoodsMapper;
    @Resource
    private TErpGoodsMapper erpGoodsMapper;
    @Resource
    private TErpClinicWarehousingMapper erpClinicWarehousingMapper;
    @Resource
    private TErpClinicWarehousingBatchMapper erpClinicWarehousingBatchMapper;
    @Resource
    private TErpClinicOutboundGoodsMapper erpClinicOutboundGoodsMapper;
    @Resource
    private TErpClinicOutboundMapper erpClinicOutboundMapper;
    @Resource
    private TErpGoodsUnitMapper erpGoodsUnitMapper;
    @Resource
    private TErpGoodsTypeMapper erpGoodsTypeMapper;
    @Override
    public PageInfo<PageInventoryListVo> pageInventoryList(TErpInventoryQuery query, SysUser user) {
        Integer roleType = user.getRoleType();
        String supplierClinicId = null;
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            supplierClinicId =crmClinic.getId();
        }
        String sTime=null;
        String eTime =null;
        if(query.getTime()!=null && !query.getTime().isEmpty()){
            String[] split = query.getTime().split(" - ");
            sTime = split[0] + " 00:00:00";
            eTime = split[1] + " 23:59:59";
        }
        PageInfo<PageInventoryListVo> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<PageInventoryListVo> list = this.baseMapper.pageInventoryList(pageInfo,query,user,sTime,eTime,supplierClinicId);
        if(list.isEmpty()){
            return pageInfo;
        }
        List<String> collect = list.stream().map(PageInventoryListVo::getId).collect(Collectors.toList());
        List<TErpClinicInventoryGoods> tErpSupplierInventoryGoods = erpClinicInventoryGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicInventoryGoods>().in(TErpClinicInventoryGoods::getInventoryId,collect));
        for (PageInventoryListVo pageInventoryListVo : list) {
            // 盘盈
            BigDecimal add = BigDecimal.ZERO;
            // 盘亏
            BigDecimal subtract = BigDecimal.ZERO;
            List<TErpClinicInventoryGoods> tErpSupplierInventoryGoodsList = tErpSupplierInventoryGoods.stream().filter(t -> t.getInventoryId().equals(pageInventoryListVo.getId())).collect(Collectors.toList());
            for (TErpClinicInventoryGoods tErpSupplierInventoryGoods1 : tErpSupplierInventoryGoodsList) {
                if(tErpSupplierInventoryGoods1!=null){
                    // 盘盈 查入库
                    if(tErpSupplierInventoryGoods1.getInventoryType()==1){
                        TErpClinicWarehousing tErpSupplierWarehousing = erpClinicWarehousingMapper.selectById(tErpSupplierInventoryGoods1.getWarehousingId());
//                        List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().eq(TErpSupplierWarehousingBatch::getWarehousingId, tErpSupplierWarehousing.getId()));
//                        int sum = tErpSupplierWarehousingBatches.stream().mapToInt(TErpSupplierWarehousingBatch::getWarehousingNumber).sum();
                        String goodsId = tErpSupplierWarehousing.getGoodsId();
                        TErpGoods goods = erpGoodsMapper.selectById(goodsId);
                        int count = tErpSupplierInventoryGoods1.getInventoryCount() - tErpSupplierInventoryGoods1.getDamagedCount();
                        BigDecimal multiply = goods.getSalesAmount().multiply(new BigDecimal(count));
                        add = add.add(multiply);
                    }else {
                        // 盘亏 查出库
                        TErpClinicOutbound tErpSupplierOutbound = erpClinicOutboundMapper.selectById(tErpSupplierInventoryGoods1.getWarehousingId());
                        List<TErpClinicOutboundGoods> tErpSupplierOutboundGoods = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getOutboundId, tErpSupplierOutbound.getId()));
                        for (TErpClinicOutboundGoods tErpSupplierOutboundGood : tErpSupplierOutboundGoods) {
                            TErpClinicWarehousing tErpSupplierWarehousing = erpClinicWarehousingMapper.selectById(tErpSupplierOutboundGood.getWarehousingId());
                            String goodsId = tErpSupplierWarehousing.getGoodsId();
                            TErpGoods goods = erpGoodsMapper.selectById(goodsId);
                            int count = tErpSupplierInventoryGoods1.getInventoryCount() - tErpSupplierInventoryGoods1.getDamagedCount();
                            BigDecimal multiply = goods.getSalesAmount().multiply(new BigDecimal(count));
                            add = add.add(multiply);
                        }
//                        int sum = tErpSupplierOutboundGoods.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum();
//                        String goodsId = tErpSupplierOutbound.getGoodsId();
//                        TErpGoods goods = erpGoodsMapper.selectById(goodsId);
//                        BigDecimal multiply = goods.getSalesAmount().multiply(new BigDecimal(sum));
//                        subtract = subtract.add(multiply);
                    }
                }
            }
            int size = tErpSupplierInventoryGoodsList.stream().map(TErpClinicInventoryGoods::getGoodsId).collect(Collectors.toSet()).size();
            pageInventoryListVo.setNum(size);
            pageInventoryListVo.setTotalPrice(add);
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
    public List<InventoryDetailVo> detailInventory(String id, SysUser user) {
        ArrayList<InventoryDetailVo> inventoryDetailVos = new ArrayList<>();
        List<TErpClinicInventoryGoods> tErpSupplierInventoryGoods = erpClinicInventoryGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicInventoryGoods>().eq(TErpClinicInventoryGoods::getInventoryId, id));
        if(tErpSupplierInventoryGoods!=null && !tErpSupplierInventoryGoods.isEmpty()){
            for (TErpClinicInventoryGoods tErpSupplierInventoryGood : tErpSupplierInventoryGoods) {
                InventoryDetailVo inventoryDetailVo = new InventoryDetailVo();
                if(tErpSupplierInventoryGood.getInventoryType()==1){
                    TErpClinicWarehousing tErpSupplierWarehousing = erpClinicWarehousingMapper.selectById(tErpSupplierInventoryGood.getWarehousingId());
                    String goodsId = tErpSupplierWarehousing.getGoodsId();
                    TErpGoods goods = erpGoodsMapper.selectById(goodsId);
                    inventoryDetailVo.setGoodsName(goods.getGoodsName());
                    TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(goods.getPackingUnitId());
                    inventoryDetailVo.setUnitName(tErpGoodsUnit.getUnitName());
                    inventoryDetailVo.setWarehouseNo(tErpSupplierWarehousing.getWarehouseNo());
                    TErpClinicWarehousingBatch tErpSupplierWarehousingBatch = erpClinicWarehousingBatchMapper.selectById(tErpSupplierInventoryGood.getWarehousingBatchId());
                    inventoryDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
                    List<TErpClinicWarehousingBatch> tErpSupplierWarehousingBatches = erpClinicWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpClinicWarehousingBatch>().eq(TErpClinicWarehousingBatch::getBatchNumber, tErpSupplierWarehousingBatch.getBatchNumber()));
                    int sum = tErpSupplierWarehousingBatches.stream().mapToInt(TErpClinicWarehousingBatch::getWarehousingNumber).sum();
                    List<String> collect = tErpSupplierWarehousingBatches.stream().map(TErpClinicWarehousingBatch::getId).collect(Collectors.toList());
                    if(!collect.isEmpty()){
                        List<TErpClinicOutboundGoods> tErpSupplierOutboundGoods = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getWarehousingBatchId, collect));
                        int sum1 = tErpSupplierOutboundGoods.stream().mapToInt(TErpClinicOutboundGoods::getOutboundCount).sum();
                        sum = sum-sum1;
                    }
                    // sum = 剩余库存
                    inventoryDetailVo.setNowCount(sum);
                    inventoryDetailVo.setInventoryCount(tErpSupplierInventoryGood.getInventoryCount());
                    inventoryDetailVo.setInventoryType(tErpSupplierInventoryGood.getInventoryType());
                    inventoryDetailVo.setDamagedCount(tErpSupplierInventoryGood.getDamagedCount());
                }
                inventoryDetailVos.add(inventoryDetailVo);
            }
            return inventoryDetailVos;
        }
        return Collections.emptyList();
    }
    @Override
    public PageInfo<ValidityPeriodWarningVo> validityPeriodWarning(ValidityPeriodWarningQuery query, SysUser user) {
        Integer roleType = user.getRoleType();
        String supplierClinicId = null;
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            supplierClinicId =crmClinic.getId();
        }
        // 获取当前时间后9个月的时间
        LocalDateTime nineMonthLater = LocalDateTime.now().plusMonths(9);
        PageInfo<ValidityPeriodWarningVo> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        return this.baseMapper.validityPeriodWarning(pageInfo,query,user,nineMonthLater,supplierClinicId);
    }
    @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()));
                tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName());
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -46,21 +46,33 @@
    @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;
@@ -175,6 +187,51 @@
        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;
@@ -197,6 +254,49 @@
        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;
        }
@@ -326,4 +426,110 @@
    }
    @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(tErpSupplierWarehousing1.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(tErpSupplierWarehousing.getPurchaseCount())));
                // 当前年月日时分秒
                String time = DateUtils.dateTimeNow();
                tErpSupplierWarehousing.setWarehouseNo("G" + time);
                tErpSupplierWarehousing.setType(2);
                erpClinicWarehousingMapper.insert(tErpSupplierWarehousing);
                // 添加批次信息
                TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch1 = new TErpSupplierWarehousingBatch();
                tErpSupplierWarehousingBatch1.setWarehousingId(tErpSupplierWarehousing.getId());
                tErpSupplierWarehousingBatch1.setWarehousingNumber(tErpSupplierWarehousing.getPurchaseCount());
                tErpSupplierWarehousingBatch1.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
                tErpSupplierWarehousingBatch1.setProductionDate(tErpSupplierWarehousingBatch.getProductionDate());
                tErpSupplierWarehousingBatch1.setExpiryDate(tErpSupplierWarehousingBatch.getExpiryDate());
                erpSupplierWarehousingBatchMapper.insert(tErpSupplierWarehousingBatch1);
                // 添加盘点信息
                TErpSupplierInventoryGoods tErpSupplierInventoryGoods = new TErpSupplierInventoryGoods();
                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(tErpSupplierWarehousing1.getGoodsId());
                erpSupplierInventoryGoodsMapper.insert(tErpSupplierInventoryGoods);
            } else {
                TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound();
                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)));
                erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
                tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
                tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId());
                tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
                tErpSupplierOutboundGoods.setOutboundCount(count);
                tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
                erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods);
                // 添加盘点信息
                TErpSupplierInventoryGoods tErpSupplierInventoryGoods = new TErpSupplierInventoryGoods();
                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(tErpSupplierWarehousing1.getGoodsId());
                erpSupplierInventoryGoodsMapper.insert(tErpSupplierInventoryGoods);
            }
        }
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.BaseModel;
@@ -12,6 +13,7 @@
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.TErpProcurementQuery;
import com.ruoyi.system.service.TErpGoodsService;
import com.ruoyi.system.service.TErpProcurementGoodsService;
import com.ruoyi.system.service.TErpProcurementService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.vo.*;
@@ -26,7 +28,10 @@
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.net.ssl.SSLContext;
@@ -36,6 +41,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
@@ -77,6 +83,9 @@
    @Resource
    private TErpGoodsUnitMapper erpGoodsUnitMapper;
    @Autowired
    private TErpProcurementGoodsService erpProcurementGoodsService;
@@ -238,18 +247,22 @@
    @Override
    public List<TErpGoodsVO> inventoryNotEnoughList(SysUser user) {
        List<TErpGoodsVO> list =  this.baseMapper.inventoryNotEnoughList(user);
        return null;
        return list;
    }
    @Override
    public String addProcurement(String clinicSupplierId, SysUser user, List<AddProcurementDto> dtos) {
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public void addProcurement(String clinicSupplierId, SysUser user, List<AddProcurementDto> dtos) {
        List<String> goodsIds = dtos.stream().map(AddProcurementDto::getGoodsId).collect(Collectors.toList());
        List<TErpGoods> tErpGoods = erpGoodsMapper.selectBatchIds(goodsIds);
        for (AddProcurementDto dto : dtos) {
            TErpGoods tErpGoodsVO = tErpGoods.stream().filter(t -> t.getId().equals(dto.getGoodsId())).findFirst().get();
            dto.setPlatformCommissionPrice(tErpGoodsVO.getPlatformCommissionPrice());
            dto.setSupplierId(tErpGoodsVO.getSupplierClinicId());
            dto.setGoodsSalesAmount(tErpGoodsVO.getSalesAmount());
            dto.setGoodsSalesAmount(tErpGoodsVO.getClinicPurchasePrice());
            if(dto.getSalesAmount()==null){
                dto.setSalesAmount(tErpGoodsVO.getClinicPurchasePrice());
            }
        }
        // 供应商分组
        Map<String, List<AddProcurementDto>> supplierClinicIdListMap = dtos.stream().collect(Collectors.groupingBy(AddProcurementDto::getSupplierId));
@@ -271,7 +284,10 @@
            }else {
                tErpProcurement.setStatus(2);
            }
            this.save(tErpProcurement);
            ArrayList<TErpProcurementGoods> tErpProcurementGoods1 = new ArrayList<>();
            BigDecimal add =BigDecimal.ZERO;
            for (AddProcurementDto dto : value) {
                TErpProcurementGoods tErpProcurementGoods = new TErpProcurementGoods();
                tErpProcurementGoods.setProcurementId(tErpProcurement.getId());
@@ -285,15 +301,56 @@
                tErpProcurementGoods.setUnitName(tErpGoodsUnit.getUnitName());
                tErpProcurementGoods.setPurchasePrice(dto.getGoodsSalesAmount());
                tErpProcurementGoods.setSalesAmount(dto.getSalesAmount());
                tErpProcurementGoods.setTotalPrice(dto.getSalesAmount().multiply(new BigDecimal(dto.getPurchaseCount())));
                tErpProcurementGoods.setPurchaseCount(dto.getPurchaseCount());
                tErpProcurementGoods.setSupplierId(supplierClinicId);
                tErpProcurementGoods.setRecvMerchantNo(supplier.getRecvMerchantNo());
                tErpProcurementGoods.setSupplierMoney(dto.getSalesAmount().subtract(dto.getPlatformCommissionPrice()));
                if(tErpProcurementGoods.getSupplierMoney().doubleValue()<0){
                    throw new RuntimeException("平台抽成不能大于售卖价格");
                }
                add = add.add(dto.getPlatformCommissionPrice());
                tErpProcurementGoods1.add(tErpProcurementGoods);
            }
            BigDecimal bigDecimal = tErpProcurement.getPayMoney().multiply(BigDecimal.valueOf(0.0038)).setScale(2, RoundingMode.HALF_UP);
            tErpProcurement.setMoney(add.subtract(bigDecimal));
            if(tErpProcurement.getMoney().doubleValue()<0){
                throw new RuntimeException("金额设置错误,请联系平台管理员");
            }
            this.save(tErpProcurement);
            tErpProcurementGoods1.forEach(e->e.setProcurementId(tErpProcurement.getId()));
            erpProcurementGoodsService.saveBatch(tErpProcurementGoods1);
        }
        return "";
    }
    @Override
    public DetailProcurementVO detailProcurement(String clinicSupplierId, SysUser user, String id) {
        DetailProcurementVO detailProcurementVO = new DetailProcurementVO();
        TErpProcurement tErpProcurement = this.getById(id);
        detailProcurementVO.setStatus(tErpProcurement.getStatus());
        detailProcurementVO.setCreateTime(tErpProcurement.getCreateTime());
        detailProcurementVO.setSendTime(tErpProcurement.getSendTime());
        TCrmSupplier supplier = crmSupplierMapper.selectById(tErpProcurement.getSupplierId());
        detailProcurementVO.setSupplierName(supplier.getSupplierName());
        detailProcurementVO.setUserName(sysUserMapper.selectUserById(Long.valueOf(tErpProcurement.getCreateId())).getUserName());
        List<TErpProcurementGoods> list = erpProcurementGoodsService.list(new QueryWrapper<TErpProcurementGoods>().eq("procurement_id", id));
        ArrayList<DetailProcurementNextVO> detailProcurementNextVOS = new ArrayList<>();
        for (TErpProcurementGoods tErpProcurementGoods : list) {
            DetailProcurementNextVO detailProcurementNextVO = new DetailProcurementNextVO();
            detailProcurementNextVO.setGoodsName(tErpProcurementGoods.getGoodsName());
            detailProcurementNextVO.setQuasiNumber(tErpProcurementGoods.getQuasiNumber());
            detailProcurementNextVO.setPackingUnitName(tErpProcurementGoods.getUnitName());
            detailProcurementNextVO.setSalesAmount(tErpProcurementGoods.getSalesAmount());
            detailProcurementNextVO.setNum(tErpProcurementGoods.getPurchaseCount());
            detailProcurementNextVO.setTotalPrice(tErpProcurement.getPayMoney());
            detailProcurementNextVO.setId(tErpProcurementGoods.getId());
            detailProcurementNextVOS.add(detailProcurementNextVO);
        }
        detailProcurementVO.setList(detailProcurementNextVOS);
        return detailProcurementVO;
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/DetailProcurementNextVO.java
New file
@@ -0,0 +1,39 @@
package com.ruoyi.system.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@ApiModel(value = "诊所采购详情二级Vo")
public class DetailProcurementNextVO {
    @ApiModelProperty(value = "采购二级id")
    private String id;
    private String goodsName;
    @ApiModelProperty(value = "国药准字号")
    private String quasiNumber;
    @ApiModelProperty(value = "单位")
    private String packingUnitName;
    @ApiModelProperty(value = "商品售价")
    private BigDecimal salesAmount;
    @ApiModelProperty(value = "数量")
    private Integer num;
    @ApiModelProperty(value = "状态")
    private BigDecimal totalPrice=BigDecimal.ZERO;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/DetailProcurementVO.java
New file
@@ -0,0 +1,33 @@
package com.ruoyi.system.vo;
import com.ruoyi.system.model.TErpGoods;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Data
@ApiModel(value = "诊所采购详情Vo")
public class DetailProcurementVO{
    @ApiModelProperty(value = "状态 1=草稿 2=待支付 3=待发货 4=已发货 5=已入库 6=已取消")
    private Integer status;
    @ApiModelProperty(value = "供应商名称")
    private String supplierName;
    @ApiModelProperty(value = "发起人")
    private String userName;
    @ApiModelProperty(value = "发起时间")
    private LocalDateTime createTime;
    @ApiModelProperty(value = "发货时间")
    private LocalDateTime sendTime;
    @ApiModelProperty(value = "采购二级详情")
    private List<DetailProcurementNextVO> list;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsInventoryVO.java
@@ -58,4 +58,7 @@
    private LocalDateTime expiryDate;
    private Integer goodsSource;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpProcurementVo.java
@@ -26,6 +26,10 @@
    @ApiModelProperty(value = "诊所名称")
    private String clinicName;
    @ApiModelProperty(value = "供应商名称")
    private String supplierName;
    @ApiModelProperty(value = "品种数")
    private Integer typeNum;
ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml
@@ -26,5 +26,97 @@
    <sql id="Base_Column_List">
        id, procurement_id, clinic_id, goods_id, goods_name, supplier_name, quasi_number, sales_amount, purchase_count, total_price, warehousing_type, create_time, update_time, create_by, update_by, disabled
    </sql>
    <select id="pageInventoryList" resultType="com.ruoyi.system.vo.PageInventoryListVo">
        select t1.id,t1.create_time,t2.user_name createBy,t3.warehouse_name
        from t_erp_clinic_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
        <if test="user.roleType !=null and user.roleType ==5">
            and t1.clinic_id = #{supplierClinicId}
        </if>
        <if test="query.createBy != null and query.createBy != ''">
            and t2.user_name like concat('%',#{query.createBy},'%')
        </if>
        <if test="sTime != null and eTime !=null ">
            and t1.create_time between #{sTime} and #{eTime}
        </if>
        order by t1.create_time desc
    </select>
    <select id="validityPeriodWarning" resultType="com.ruoyi.system.vo.ValidityPeriodWarningVo">
        select 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
        from t_erp_clinic_warehousing_batch t1
        left join t_erp_clinic_warehousing t2 on t1.warehousing_id = t2.id
        LEFT JOIN t_erp_clinic_outbound_goods 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
        where #{time} > t1.expiry_date
        and (t1.warehousing_number - t3.outbound_count > 0 or t3.id is null)
        <if test="user.roleType !=null and user.roleType ==5">
            and t2.clinic_id =#{supplierClinicId}
        </if>
        <if test="query.name != null and query.name != ''">
            and t4.goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="query.quasiNumber != null and query.quasiNumber != ''">
            and t4.quasi_number like concat('%',#{query.quasiNumber},'%')
        </if>
        <if test="query.batchNumber != null and query.batchNumber != ''">
            and t1.batch_number like concat('%',#{query.batchNumber},'%')
        </if>
        <if test="query.typeId != null and query.typeId != ''">
            and t4.type_id = #{query.typeId}
        </if>
        order by t1.expiry_date
    </select>
    <sql id="Base_Column_List1">
        t1.id, t1.supplier_clinic_id, t1.goods_source, t1.goods_name, t1.goods_id_code, t1.quasi_number, t1.manufacturer, t1.formulation_spec, t1.packing_spec, t1.type_id, t1.goods_yards, t1.maintenance_interval, t1.low_purchase_quantity, t1.low_unit_id, t1.is_prescription_drug, t1.goods_spec, t1.warning_inventory, t1.sales_amount, t1.packing_unit_id, t1.instructions_use, t1.side_effect, t1.clinic_purchase_price, t1.platform_commission_price, t1.create_time, t1.update_time, t1.create_by,t1.`state`, t1.update_by, t1.disabled,
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select * from (
        select <include refid="Base_Column_List1"/>
        COALESCE(sum(t2.goods_count), 0) - COALESCE(sum(t3.outbound_count), 0) as allNum,
        SUM(t2.unit_amount * (t2.goods_count - COALESCE(t3.outbound_count, 0))) as allTotalPrice,
        COALESCE(sum(t3.outbound_count), 0) as outNum
        from t_erp_goods t1  left join  t_erp_clinic_warehousing t2  on t1.id = t2.goods_id
        left join  t_erp_clinic_outbound_goods t3 on t2.id = t3.warehousing_id
        where t1.disabled = 0 and t2.id is not null
        <if test="query.goodsName != null and query.goodsName != ''">
            and t1.goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="query.goodsIdCode != null and query.goodsIdCode != ''">
            and t1.goods_id_code like concat('%',#{query.goodsIdCode},'%')
        </if>
        <if test="query.typeId != null and query.typeId != ''">
            and t1.type_id = #{query.typeId}
        </if>
        <if test="query.quasiNumber != null and query.quasiNumber != ''">
            and t1.quasi_number like concat('%',#{query.quasiNumber},'%')
        </if>
        <if test="query.state != null ">
            and t1.state = #{query.state}
        </if>
        <if test="user.roleType != null and user.roleType == 4 ">
            and t1.goods_source =1 and t1.supplier_clinic_id =#{query.supplierClinicId}
        </if>
        <if test="user.roleType != null and user.roleType == 5 ">
            and ( ( t1.goods_source =2 and  t1.supplier_clinic_id =#{query.supplierClinicId} ) or  find_in_set(#{query.supplierClinicId},t1.clinic_ids) )
        </if>
        GROUP BY t1.id
        ) o where 1=1
        <if test="query.type != null and query.type ==1">
            and  o.warning_inventory  > (o.allNum-o.outNum)
        </if>
        order by o.create_time desc
    </select>
</mapper>
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -76,7 +76,7 @@
            and goods_source =1 and supplier_clinic_id = #{query.supplierClinicId}
        </if>
        <if test="user.roleType != null and user.roleType == 5 ">
            and goods_source =2 and supplier_clinic_id = #{query.supplierClinicId}
            and  ( (goods_source =2 and supplier_clinic_id = #{query.supplierClinicId} ) or FIND_IN_SET(#{query.supplierClinicId},clinic_ids) )
        </if>
        order by create_time desc
    </select>
@@ -164,6 +164,55 @@
        where (o.warehousing_number -o.outbound_count) >0
        order by o.create_time desc
    </select>
    <select id="pageInventoryGoodsPageList1" resultType="com.ruoyi.system.vo.TErpGoodsInventoryVO">
        select * from (
        SELECT t1.id,t2.warehouse_no,
        t3.goods_name,t3.goods_source,
        t4.supplier_name,
        t3.type_id,
        t3.packing_unit_id,
        t3.quasi_number,
        t3.goods_id_code,
        t1.batch_number,
        coalesce(sum(t5.outbound_count),0) as outbound_count,
        t1.warehousing_number,
        t2.create_time,
        t1.warehousing_number - coalesce(sum(t5.outbound_count),0) as num,
        t2.unit_amount as sales_amount,
        t1.expiry_date
        from t_erp_clinic_warehousing_batch t1
        LEFT JOIN t_erp_clinic_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_clinic_outbound_goods t5 on t5.warehousing_batch_id =t1.id
        where t2.disabled = 0 and t2.warehouse_id = #{query.warehouseId}
        <if test="query.type != null and query.type ==1">
            and #{time} > t1.expiry_date
        </if>
        <if test="query.goodsName != null and query.goodsName != ''">
            and t3.goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="query.supplierName != null and query.supplierName != ''">
            and (t4.supplier_name like concat('%',#{query.supplierName},'%') or t3.supplierName like concat('%',#{query.supplierName},'%'))
        </if>
        <if test="query.typeId != null and query.typeId != ''">
            and t3.type_id = #{query.typeId}
        </if>
        <if test="query.quasiNumber != null and query.quasiNumber != ''">
            and t3.quasi_number =#{query.quasiNumber}
        </if>
        <if test="query.batchNumber != null and query.batchNumber != ''">
            and t1.batch_number =#{query.batchNumber}
        </if>
        <if test="query.warehouseNo != null and query.warehouseNo != ''">
            and t2.warehouse_no = #{query.warehouseNo}
        </if>
        GROUP BY t1.id
        ) as o
        where (o.warehousing_number -o.outbound_count) >0
        order by o.create_time desc
    </select>
    <select id="pageInventoryGoodsList" resultType="com.ruoyi.system.vo.TErpGoodsInventoryVO">
        select * from (
        SELECT t1.id,t2.warehouse_no,
@@ -199,5 +248,40 @@
        where (o.warehousing_number -o.outbound_count) >0
        order by o.create_time desc
    </select>
    <select id="pageInventoryGoodsList1" resultType="com.ruoyi.system.vo.TErpGoodsInventoryVO">
        select * from (
        SELECT t1.id,t2.warehouse_no,
        t3.goods_name,
        t4.supplier_name,
        t3.type_id,
        t3.packing_unit_id,
        t3.quasi_number,
        t3.goods_id_code,
        t1.batch_number,
        coalesce(sum(t5.outbound_count),0) as outbound_count,
        t1.warehousing_number,
        t2.create_time,
        t1.warehousing_number - coalesce(sum(t5.outbound_count),0) as num,
        t2.unit_amount as sales_amount,
        t1.expiry_date
        from t_erp_clinic_warehousing_batch t1
        LEFT JOIN t_erp_clinic_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
        where t2.disabled = 0
        and #{endDate} > t1.expiry_date
        <if test="user.roleType !=null and user.roleType ==4">
            and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=1
        </if>
        <if test="user.roleType !=null and user.roleType ==5">
            and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=2
        </if>
        GROUP BY t1.id
        ) as o
        where (o.warehousing_number -o.outbound_count) >0
        order by o.create_time desc
    </select>
</mapper>
ruoyi-system/src/main/resources/mapper/system/TErpProcurementMapper.xml
@@ -30,7 +30,7 @@
        select t1.id,
        t1.procurement_code,
        t1.clinic_id,
        t3.clinic_name,
        t3.supplier_name,
        sum(t2.total_price) as totalPrice,
        t1.create_time,
        t2.id tErpProcurementGoodsId,
@@ -38,7 +38,7 @@
        t1.status
        from t_erp_procurement t1
        left JOIN t_erp_procurement_goods t2 on t1.id = t2.procurement_id
        LEFT JOIN t_crm_clinic t3 on t1.clinic_id = t3.id
        LEFT JOIN t_crm_supplier t3 on t1.supplier_id = t3.id
        left JOIN sys_user t4 on t1.create_id = t4.user_id
        where t1.disabled = 0
        <if test="user.roleType !=null and user.roleType==4">
@@ -48,7 +48,7 @@
            and t1.procurement_code = #{query.procurementCode}
        </if>
        <if test="query.clinicName != null and query.clinicName != ''">
            and t3.clinic_name like concat('%',#{query.clinicName},'%')
            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},'%')