liujie
4 天以前 5ba50d43ea3384a606ab16501633797297a78de3
供应商erp
15个文件已修改
385 ■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpSupplierWarehousingController.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpMaintenanceReminderMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpProcurementMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpSupplierWarehousingMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsWarehouseQuery.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpMaintenanceReminderServiceImpl.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpMaintenanceReminderMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpProcurementMapper.xml 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpSupplierWarehousingMapper.xml 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
@@ -181,6 +181,23 @@
    @PostMapping(value = "/saveDataInfo")
    public R<Boolean> saveDataInfo(@RequestBody @Valid TErpGoodsInfoSaveDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        String clinicSupplierId=null;
        if(roleType == 4){
            // 供应商
            TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                    .eq(TCrmSupplier::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            clinicSupplierId = crmSupplier.getId();
        }
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            clinicSupplierId =crmClinic.getId();
        }
        TErpGoods goods = erpGoodsService.getById(dto.getId());
        BeanUtils.copyProperties(dto,goods);
        if(goods.getMaintenanceInterval()!=null){
@@ -195,7 +212,7 @@
                        if (tErpSupplierWarehousingBatch.getWarehousingNumber()-sum>0) {
                            // 生成保养单
                            TErpMaintenanceReminder tErpMaintenanceReminder = new TErpMaintenanceReminder();
                            tErpMaintenanceReminder.setClinicSupplierId(user.getUserId().toString());
                            tErpMaintenanceReminder.setClinicSupplierId(clinicSupplierId);
                            tErpMaintenanceReminder.setMaintenanceType(1);
                            tErpMaintenanceReminder.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
                            Integer day = Integer.valueOf(goods.getMaintenanceInterval());
@@ -228,6 +245,23 @@
    public void listExport(@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());
        }
        List<TErpGoodsVO> pageList = erpGoodsService.listExport(query,user);
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TErpGoodsVO.class, pageList);
        HttpServletResponse response = WebUtils.response();
@@ -274,10 +308,26 @@
            if (collect.size() != carAnnuallyImportExcels.size()) {
                return AjaxResult.error("导入数据中商品标识码重复");
            }
            Integer roleType = user.getRoleType();
            for (TErpGoodsExcel erpGoodsExcel : carAnnuallyImportExcels) {
                TErpGoods goods = new TErpGoods();
                goods.setSupplierClinicId(user.getUserId().toString());
                if(roleType == 4){
                    // 供应商
                    TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                            .eq(TCrmSupplier::getUserId, user.getUserId())
                            .last("LIMIT 1"));
                    goods.setSupplierClinicId(crmSupplier.getId());
                goods.setGoodsSource(1);
                }
                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);
                }
                // 判空
                if(erpGoodsExcel.getGoodsName()==null || erpGoodsExcel.getGoodsName().isEmpty()){
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpSupplierWarehousingController.java
@@ -1,6 +1,7 @@
package com.ruoyi.web.controller.api;
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;
@@ -9,7 +10,11 @@
import com.ruoyi.system.dto.InventoryDto;
import com.ruoyi.system.dto.InventoryGoodsDto;
import com.ruoyi.system.dto.WarehousingGoodsDto;
import com.ruoyi.system.model.TCrmClinic;
import com.ruoyi.system.model.TCrmSupplier;
import com.ruoyi.system.query.*;
import com.ruoyi.system.service.TCrmClinicService;
import com.ruoyi.system.service.TCrmSupplierService;
import com.ruoyi.system.service.TErpGoodsService;
import com.ruoyi.system.service.TErpSupplierWarehousingService;
import com.ruoyi.system.vo.*;
@@ -39,12 +44,17 @@
    private final TErpSupplierWarehousingService erpSupplierWarehousingService;
    private final TErpGoodsService erpGoodsService;
    private final TokenService tokenService;
    private final TCrmClinicService crmClinicService;
    private final TCrmSupplierService crmSupplierService;
    @Autowired
    public TErpSupplierWarehousingController(TErpSupplierWarehousingService erpSupplierWarehousingService, TErpGoodsService erpGoodsService, TokenService tokenService) {
    public TErpSupplierWarehousingController(TErpSupplierWarehousingService erpSupplierWarehousingService, TErpGoodsService erpGoodsService, TokenService tokenService,
                                             TCrmClinicService crmClinicService,TCrmSupplierService crmSupplierService) {
        this.erpSupplierWarehousingService = erpSupplierWarehousingService;
        this.erpGoodsService = erpGoodsService;
        this.tokenService = tokenService;
        this.crmClinicService = crmClinicService;
        this.crmSupplierService = crmSupplierService;
    }
@@ -61,6 +71,22 @@
        request.setTermNo(LakalaAlipayConfig.TermNo);
        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(erpSupplierWarehousingService.pageList(query,user));
    }
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java
@@ -26,5 +26,5 @@
    List<TErpGoodsVO> listExport(@Param("query") TErpGoodsQuery query, @Param("user") SysUser user);
    List<TErpGoodsInventoryVO> pageInventoryGoodsPageList(@Param("query") TErpGoodsInventoryQuery query, @Param("pageInfo") PageInfo<TErpGoodsInventoryVO> pageInfo, @Param("user") SysUser user);
    List<TErpGoodsInventoryVO> pageInventoryGoodsPageList(@Param("query") TErpGoodsInventoryQuery query, @Param("pageInfo") PageInfo<TErpGoodsInventoryVO> pageInfo, @Param("user") SysUser user, @Param("supplierClinicId") String supplierClinicId);
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpMaintenanceReminderMapper.java
@@ -20,5 +20,5 @@
 */
public interface TErpMaintenanceReminderMapper extends BaseMapper<TErpMaintenanceReminder> {
    List<TErpMaintenanceReminderListVo> pageList(@Param("page") PageInfo<TErpMaintenanceReminderListVo> page, @Param("query") TErpMaintenanceReminderQuery query, @Param("user") SysUser user);
    List<TErpMaintenanceReminderListVo> pageList(@Param("page") PageInfo<TErpMaintenanceReminderListVo> page, @Param("query") TErpMaintenanceReminderQuery query, @Param("user") SysUser user, @Param("supplierClinicId") String supplierClinicId);
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpProcurementMapper.java
@@ -20,6 +20,6 @@
 */
public interface TErpProcurementMapper extends BaseMapper<TErpProcurement> {
    List<TErpProcurementVo> pageList(@Param("query") TErpProcurementQuery query, @Param("pageInfo") PageInfo<TErpProcurementVo> pageInfo, @Param("user") SysUser user, @Param("sTime") String sTime, @Param("eTime") String eTime);
    List<TErpProcurementVo> pageList(@Param("query") TErpProcurementQuery query, @Param("pageInfo") PageInfo<TErpProcurementVo> pageInfo, @Param("user") SysUser user, @Param("sTime") String sTime, @Param("eTime") String eTime, @Param("supplierClinicId") String supplierClinicId);
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpSupplierWarehousingMapper.java
@@ -31,9 +31,9 @@
    List<TErpGoodsWarehouseRecordLastVO> pageWarehouseList(@Param("query") TErpGoodsWarehouseQuery query, @Param("pageInfo") PageInfo<TErpGoodsWarehouseRecordLastVO> pageInfo, @Param("user") SysUser user, @Param("sTime") String sTime, @Param("eTime") String eTime);
    PageInfo<ValidityPeriodWarningVo> validityPeriodWarning(@Param("pageInfo") PageInfo<ValidityPeriodWarningVo> pageInfo, @Param("query") ValidityPeriodWarningQuery query, @Param("user") SysUser user, @Param("time") LocalDateTime nineMonthLater);
    PageInfo<ValidityPeriodWarningVo> validityPeriodWarning(@Param("pageInfo") PageInfo<ValidityPeriodWarningVo> pageInfo, @Param("query") ValidityPeriodWarningQuery query, @Param("user") SysUser user, @Param("time") LocalDateTime nineMonthLater, @Param("supplierClinicId") String supplierClinicId);
    List<PageInventoryListVo> pageInventoryList(@Param("pageInfo") PageInfo<PageInventoryListVo> pageInfo, @Param("query") TErpInventoryQuery query, @Param("user") SysUser user, @Param("sTime") String sTime, @Param("eTime") String eTime);
    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);
}
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsWarehouseQuery.java
@@ -24,4 +24,6 @@
    @NotBlank(message = "商品id不能为空")
    private String goodsId;
    private String supplierClinicId;
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
@@ -58,6 +59,12 @@
    @Resource
    private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper;
    @Resource
    private  TCrmClinicMapper crmClinicMapper;
    @Resource
    private  TCrmSupplierMapper crmSupplierMapper;
    @Override
@@ -122,8 +129,24 @@
    @Override
    public PageInfo<TErpGoodsInventoryVO> pageInventoryGoodsPageList(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();
        }
        PageInfo<TErpGoodsInventoryVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsPageList(query, pageInfo, user);
        List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsPageList(query, pageInfo, user,supplierClinicId);
        if (list.isEmpty()) {
            return pageInfo;
        }
@@ -148,11 +171,27 @@
    @Override
    public void inventoryGoods(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();
        }
        TErpSupplierInventory tErpSupplierInventory = new TErpSupplierInventory();
        String s = DateUtils.dateTimeNow();
        tErpSupplierInventory.setInventoryNumber("P" + s);
        tErpSupplierInventory.setWarehouseId(dto.getWarehouseId());
        tErpSupplierInventory.setSupplierId(String.valueOf(user.getUserId()));
        tErpSupplierInventory.setSupplierId(supplierClinicId);
        erpSupplierInventoryMapper.insert(tErpSupplierInventory);
        List<InventoryGoodsDto> dtos = dto.getDtos();
@@ -168,7 +207,7 @@
            if (inventoryGoodsDto.getNum() < inventoryGoodsDto.getInventoryCount()) {
                // 添加入库信息
                tErpSupplierWarehousing.setWarehouseId(dto.getWarehouseId());
                tErpSupplierWarehousing.setSupplierId(String.valueOf(user.getUserId()));
                tErpSupplierWarehousing.setSupplierId(supplierClinicId);
                tErpSupplierWarehousing.setGoodsId(tErpSupplierWarehousing1.getGoodsId());
                tErpSupplierWarehousing.setGoodsName(erpGoods.getGoodsName());
                tErpSupplierWarehousing.setGoodsCount(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum());
@@ -206,7 +245,7 @@
                TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound();
                tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
                tErpSupplierOutbound.setSupplierId(String.valueOf(user.getUserId()));
                tErpSupplierOutbound.setSupplierId(supplierClinicId);
                tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing1.getGoodsId());
                tErpSupplierOutbound.setOutboundType(6);
                tErpSupplierOutbound.setOutboundNumber("G" + s);
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpMaintenanceReminderServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
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.*;
@@ -48,10 +49,32 @@
    @Resource
    private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper;
    @Resource
    private  TCrmClinicMapper crmClinicMapper;
    @Resource
    private  TCrmSupplierMapper crmSupplierMapper;
    @Override
    public PageInfo<TErpMaintenanceReminderListVo> pageList(TErpMaintenanceReminderQuery 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();
        }
        PageInfo<TErpMaintenanceReminderListVo> page = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TErpMaintenanceReminderListVo> list = baseMapper.pageList(page, query, user);
        List<TErpMaintenanceReminderListVo> list = baseMapper.pageList(page, query, user,supplierClinicId);
        if(list.isEmpty()){
            return page;
        }
@@ -79,9 +102,6 @@
        TErpMaintenanceReminderDetailVo tErpMaintenanceReminderDetailVo = new TErpMaintenanceReminderDetailVo();
        TErpMaintenanceReminder tErpMaintenanceReminder = baseMapper.selectById(id);
        if(tErpMaintenanceReminder == null || tErpMaintenanceReminder.getMaintenanceType()!=1 || !tErpMaintenanceReminder.getClinicSupplierId().equals(user.getUserId().toString())){
            return tErpMaintenanceReminderDetailVo;
        }
        tErpMaintenanceReminderDetailVo.setId(tErpMaintenanceReminder.getId());
        tErpMaintenanceReminderDetailVo.setMaintenanceTime(tErpMaintenanceReminder.getMaintenanceTime());
        tErpMaintenanceReminderDetailVo.setMaintenanceRecord(tErpMaintenanceReminder.getMaintenanceRecord());
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.toolkit.Wrappers;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.*;
@@ -42,10 +43,32 @@
    private TCrmClinicMapper crmClinicMapper;
    @Resource
    private  TCrmSupplierMapper crmSupplierMapper;
    @Resource
    private SysUserMapper sysUserMapper;
    @Override
    public PageInfo<TErpProcurementVo> pageList(TErpProcurementQuery 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();
        }
        String sTime=null;
        String eTime =null;
        if(query.getTime()!=null && !query.getTime().isEmpty()){
@@ -54,12 +77,13 @@
            eTime = split[1] + " 23:59:59";
        }
        PageInfo<TErpProcurementVo> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TErpProcurementVo> list = this.baseMapper.pageList(query,pageInfo,user,sTime,eTime);
        List<TErpProcurementVo> list = this.baseMapper.pageList(query,pageInfo,user,sTime,eTime,supplierClinicId);
        if(list.isEmpty()){
            return pageInfo;
        }
        List<String> ids = list.stream().map(TErpProcurementVo::getId).collect(Collectors.toList());
        List<TErpProcurementGoods> tErpProcurementGoods = erpProcurementGoodsMapper.selectList(new LambdaQueryWrapper<TErpProcurementGoods>().in(TErpProcurementGoods::getProcurementId, ids).eq(TErpProcurementGoods::getSupplierId, user.getUserId()));
        List<TErpProcurementGoods> tErpProcurementGoods = erpProcurementGoodsMapper.selectList
                (new LambdaQueryWrapper<TErpProcurementGoods>().in(TErpProcurementGoods::getProcurementId, ids).eq(TErpProcurementGoods::getSupplierId, supplierClinicId));
        List<TSysCommission> tSysCommissions =new ArrayList<>();
        if(!tErpProcurementGoods.isEmpty()){
            List<String> collect = tErpProcurementGoods.stream().map(TErpProcurementGoods::getId).collect(Collectors.toList());
@@ -89,6 +113,24 @@
    @Override
    public TErpProcurementDetailVo detail(String id, SysUser user, String goodsName) {
        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();
        }
        TErpProcurementDetailVo tErpProcurementVo = new TErpProcurementDetailVo();
        TErpProcurement tErpProcurement = this.getById(id);
@@ -111,7 +153,10 @@
        tErpProcurementVo.setStatus(tErpProcurement.getStatus());
        tErpProcurementVo.setSendTime(tErpProcurement.getSendTime());
        List<TErpProcurementGoods> tErpProcurementGoods = erpProcurementGoodsMapper.selectList(new LambdaQueryWrapper<TErpProcurementGoods>().eq(TErpProcurementGoods::getProcurementId, id).like(goodsName != null && !goodsName.isEmpty(), TErpProcurementGoods::getGoodsName, goodsName).eq(TErpProcurementGoods::getSupplierId, user.getUserId()));
        List<TErpProcurementGoods> tErpProcurementGoods = erpProcurementGoodsMapper.selectList
                (new LambdaQueryWrapper<TErpProcurementGoods>().eq(TErpProcurementGoods::getProcurementId, id)
                        .like(goodsName != null && !goodsName.isEmpty(), TErpProcurementGoods::getGoodsName, goodsName)
                        .eq(TErpProcurementGoods::getSupplierId, supplierClinicId));
        if(tErpProcurementGoods.isEmpty()){
            return tErpProcurementVo;
        }
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
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.common.utils.DateUtils;
@@ -13,6 +14,8 @@
import com.ruoyi.system.query.TErpGoodsWarehouseQuery;
import com.ruoyi.system.query.TErpInventoryQuery;
import com.ruoyi.system.query.ValidityPeriodWarningQuery;
import com.ruoyi.system.service.TCrmClinicService;
import com.ruoyi.system.service.TCrmSupplierService;
import com.ruoyi.system.service.TErpSupplierWarehousingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.vo.*;
@@ -70,6 +73,11 @@
    @Resource
    private TErpGoodsUnitMapper erpGoodsUnitMapper;
    @Resource
    private  TCrmClinicMapper crmClinicMapper;
    @Resource
    private  TCrmSupplierMapper crmSupplierMapper;
    @Override
    public PageInfo<TErpGoodsVO> pageList(TErpGoodsQuery query, SysUser user) {
@@ -92,6 +100,23 @@
    @Override
    public List<TErpGoodsWarehouseLastVO> detail(String id, String warehouseName, 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();
        }
        TErpGoods goods = erpGoodsMapper.selectById(id);
@@ -99,7 +124,7 @@
        if(tCrmWarehouses.isEmpty()){
            return Collections.emptyList();
        }
        List<TErpSupplierWarehousing> tErpSupplierWarehousings = erpSupplierWarehousingMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousing>().in(TErpSupplierWarehousing::getWarehouseId, tCrmWarehouses.stream().map(TCrmWarehouse::getId).collect(Collectors.toList())).eq(TErpSupplierWarehousing::getSupplierId, user.getUserId()).eq(TErpSupplierWarehousing::getGoodsId, id));
        List<TErpSupplierWarehousing> tErpSupplierWarehousings = erpSupplierWarehousingMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousing>().in(TErpSupplierWarehousing::getWarehouseId, tCrmWarehouses.stream().map(TCrmWarehouse::getId).collect(Collectors.toList())).eq(TErpSupplierWarehousing::getSupplierId, supplierClinicId).eq(TErpSupplierWarehousing::getGoodsId, id));
        if(tErpSupplierWarehousings.isEmpty()){
            return Collections.emptyList();
        }
@@ -155,6 +180,27 @@
    @Override
    public PageInfo<TErpGoodsWarehouseRecordLastVO> pageWarehouseList(TErpGoodsWarehouseQuery 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();
        }
        query.setSupplierClinicId(supplierClinicId);
        TErpGoods goods = erpGoodsMapper.selectById(query.getGoodsId());
        PageInfo<TErpGoodsWarehouseRecordLastVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
@@ -202,12 +248,28 @@
    @Override
    public void warehousingGoods(List<WarehousingGoodsDto> dtos, 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();
        }
        for (WarehousingGoodsDto dto : dtos) {
            TErpSupplierWarehousing tErpSupplierWarehousing = new TErpSupplierWarehousing();
            // 当前年月日时分秒
            String time = DateUtils.dateTimeNow();
            tErpSupplierWarehousing.setWarehouseNo("G"+time);
            tErpSupplierWarehousing.setSupplierId(user.getUserId().toString());
            tErpSupplierWarehousing.setSupplierId(supplierClinicId);
            tErpSupplierWarehousing.setWarehouseId(dto.getWarehouseId());
            tErpSupplierWarehousing.setGoodsId(dto.getGoodsId());
            TErpGoods goods = erpGoodsMapper.selectById(dto.getGoodsId());
@@ -228,7 +290,7 @@
                if(goods.getMaintenanceInterval()!=null){
                    TErpMaintenanceReminder tErpMaintenanceReminder = new TErpMaintenanceReminder();
                    tErpMaintenanceReminder.setClinicSupplierId(user.getUserId().toString());
                    tErpMaintenanceReminder.setClinicSupplierId(supplierClinicId);
                    tErpMaintenanceReminder.setMaintenanceType(1);
                    tErpMaintenanceReminder.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
                    Integer day = Integer.valueOf(goods.getMaintenanceInterval());
@@ -245,17 +307,52 @@
    @Override
    public PageInfo<ValidityPeriodWarningVo> validityPeriodWarning(ValidityPeriodWarningQuery 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();
        }
        // 获取当前时间后9个月的时间
        LocalDateTime nineMonthLater = LocalDateTime.now().plusMonths(9);
        PageInfo<ValidityPeriodWarningVo> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        return this.baseMapper.validityPeriodWarning(pageInfo,query,user,nineMonthLater);
        return this.baseMapper.validityPeriodWarning(pageInfo,query,user,nineMonthLater,supplierClinicId);
    }
    @Override
    public PageInfo<PageInventoryListVo> pageInventoryList(TErpInventoryQuery 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();
        }
        String sTime=null;
        String eTime =null;
        if(query.getTime()!=null && !query.getTime().isEmpty()){
@@ -264,7 +361,7 @@
            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);
        List<PageInventoryListVo> list = this.baseMapper.pageInventoryList(pageInfo,query,user,sTime,eTime,supplierClinicId);
        if(list.isEmpty()){
            return pageInfo;
        }
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -37,7 +37,8 @@
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, supplier_clinic_id, goods_source, goods_name, goods_id_code, quasi_number, manufacturer, formulation_spec, packing_spec, type_id, goods_yards, maintenance_interval, low_purchase_quantity, low_unit_id, is_prescription_drug, goods_spec, warning_inventory, sales_amount, packing_unit_id, instructions_use, side_effect, clinic_purchase_price, platform_commission_price, create_time, update_time, create_by,`state`, update_by, disabled,
        id
        , supplier_clinic_id, goods_source, goods_name, goods_id_code, quasi_number, manufacturer, formulation_spec, packing_spec, type_id, goods_yards, maintenance_interval, low_purchase_quantity, low_unit_id, is_prescription_drug, goods_spec, warning_inventory, sales_amount, packing_unit_id, instructions_use, side_effect, clinic_purchase_price, platform_commission_price, create_time, update_time, create_by,`state`, update_by, disabled,
          simplified_code,
dosage_form,
usage_classification,
@@ -53,7 +54,8 @@
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select <include refid="Base_Column_List"/>
        select
        <include refid="Base_Column_List"/>
            from t_erp_goods where disabled = 0
        <if test="query.goodsName != null and query.goodsName != ''">
            and goods_name like concat('%',#{query.goodsName},'%')
@@ -79,7 +81,8 @@
        order by create_time desc
    </select>
    <select id="listExport" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select <include refid="Base_Column_List"/>
        select
        <include refid="Base_Column_List"/>
        from t_erp_goods where disabled = 0
        <if test="query.goodsName != null and query.goodsName != ''">
            and goods_name like concat('%',#{query.goodsName},'%')
@@ -97,10 +100,10 @@
            and state = #{query.state}
        </if>
        <if test="user.roleType != null and user.roleType == 4 ">
            and goods_source =1 and supplier_clinic_id =#{user.userId}
            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 =#{user.userId}
            and goods_source =2 and supplier_clinic_id =#{query.supplierClinicId}
        </if>
        order by create_time desc
    </select>
@@ -131,8 +134,11 @@
        <if test="query.goodsName != null and query.goodsName != ''">
            and t3.goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="user.roleType ==4">
            and t3.supplier_clinic_id =#{user.userId}
        <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>
        <if test="query.supplierName != null and query.supplierName != ''">
            and t4.supplier_name like concat('%',#{query.supplierName},'%')
ruoyi-system/src/main/resources/mapper/system/TErpMaintenanceReminderMapper.xml
@@ -36,7 +36,13 @@
                 LEFT JOIN t_erp_supplier_warehousing_batch t2 on t1.warehousing_batch_id = t2.id
                 left join t_erp_supplier_warehousing t3 on t2.warehousing_id = t3.id
                 left join t_erp_goods t4 on t3.goods_id = t4.id
        where t1.disabled = 0 and t1.maintenance_type =1 and t1.clinic_supplier_id =#{user.userId}
        where t1.disabled = 0
          <if test="user.roleType !=null and user.roleType==4">
              and t1.clinic_supplier_id = #{user.supplierClinicId} and t1.maintenance_type=1
          </if>
          <if test="user.roleType !=null and user.roleType==5">
              and t1.clinic_supplier_id = #{user.supplierClinicId} and t1.maintenance_type=2
          </if>
         <if test="query.warehouseNo != null and query.warehouseNo != ''">
            and t3.warehouse_no =#{query.warehouseNo}
        </if>
ruoyi-system/src/main/resources/mapper/system/TErpProcurementMapper.xml
@@ -37,7 +37,10 @@
                 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 sys_user t4 on t1.create_id = t4.user_id
        where t1.disabled = 0 and t2.supplier_id =#{user.userId}
        where t1.disabled = 0
        <if test="user.roleType !=null and user.roleType==4">
            and t2.supplier_id =#{supplierClinicId}
        </if>
        <if test="query.procurementCode != null and query.procurementCode != ''">
            and t1.procurement_code = #{query.procurementCode}
        </if>
ruoyi-system/src/main/resources/mapper/system/TErpSupplierWarehousingMapper.xml
@@ -52,10 +52,10 @@
            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 =#{user.userId}
            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 =#{user.userId}
            and t1.goods_source =2 and t1.supplier_clinic_id =#{query.supplierClinicId}
        </if>
        ) o where 1=1
            <if test="query.type != null and query.type ==1">
@@ -70,7 +70,10 @@
        select * from (
        select t1.id,t1.warehouse_id houseId,t2.warehouse_name houseName,t1.total_price allTotalPrice,t1.type,1 category,null as outboundReason,t1.create_time operationTime
        from t_erp_supplier_warehousing t1 left join t_crm_warehouse t2 on t1.warehouse_id = t2.id
        where t1.disabled = 0 and t1.goods_id = #{query.goodsId}  and t1.supplier_id =#{user.userId}
        where t1.disabled = 0 and t1.goods_id = #{query.goodsId}
          <if test="user.roleType != null and user.roleType == 4 ">
            and t1.supplier_id =#{query.supplierClinicId}
        </if>
        <if test="query.warehouseName != null and query.warehouseName != ''">
            and t2.warehouse_name =#{query.warehouseName}
        </if>
@@ -82,7 +85,11 @@
        select t1.id,t1.warehouse_id houseId,t2.warehouse_name houseName,t1.total_money allTotalPrice,t1.outbound_type as type,2 category,t1.outbound_reason as outboundReason,t1.create_time operationTime
        from t_erp_supplier_outbound t1 left join t_crm_warehouse t2 on t1.warehouse_id = t2.id
        where t1.disabled = 0 and t1.goods_id = #{query.goodsId} and t1.supplier_id =#{user.userId}
        where t1.disabled = 0 and t1.goods_id = #{query.goodsId}
        <if test="user.roleType != null and user.roleType == 4 ">
            and t1.supplier_id =#{query.supplierClinicId}
        </if>
        <if test="query.warehouseName != null and query.warehouseName != ''">
            and t2.warehouse_name =#{query.warehouseName}
        </if>
@@ -110,8 +117,11 @@
                 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 t2.supplier_id =#{user.userId}
        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 ==4">
              and t2.supplier_id =#{supplierClinicId}
          </if>
        <if test="query.name != null and query.name != ''">
            and t4.goods_name like concat('%',#{query.goodsName},'%')
        </if>
@@ -131,7 +141,10 @@
        select t1.id,t1.create_time,t2.user_name createBy,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 and t1.supplier_id = #{user.userId}
        where t1.disabled = 0
        <if test="user.roleType !=null and user.roleType ==4">
            and t1.supplier_id = #{supplierClinicId}
        </if>
        <if test="query.warehouseId != null and query.warehouseId != ''">
            and t1.warehouse_id = #{query.warehouseId}
        </if>