xuhy
2025-12-05 78881cf9099157cf609c53b895d8456f6fdb1469
Merge remote-tracking branch 'origin/master'

# Conflicts:
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
1个文件已添加
8个文件已修改
582 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java 285 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java 254 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/AdminAuditDto.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpGoods.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/BranchAdminStatisticsOneQuery.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsAdminQuery.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/BranchAdminListVO.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java
@@ -100,7 +100,7 @@
                .eq(TCrmSupplier::getUserId, userId)
                .last("LIMIT 1"));
        // ***
        if(Objects.isNull(crmSupplier)){
        if (Objects.isNull(crmSupplier)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
        }
@@ -147,7 +147,7 @@
                    .eq(TCrmSupplier::getUserId, userId)
                    .last("LIMIT 1"));
            // ***
            if(Objects.isNull(crmSupplier)){
            if (Objects.isNull(crmSupplier)) {
                SysUser sysUser = sysUserService.selectUserById(userId);
                crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
            }
@@ -156,11 +156,11 @@
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, userId)
                    .last("LIMIT 1"));
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(userId);
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                return R.fail("未找到该账号诊所信息");
            }
            supplierAndClinicId = crmClinic.getId();
@@ -214,11 +214,11 @@
        TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                .eq(TCrmClinic::getUserId, userId)
                .last("LIMIT 1"));
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmClinic = crmClinicService.getById(sysUser.getObjectId());
        }
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            return R.fail("未找到该账号诊所信息");
        }
@@ -242,11 +242,11 @@
        TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                .eq(TCrmClinic::getUserId, userId)
                .last("LIMIT 1"));
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmClinic = crmClinicService.getById(sysUser.getObjectId());
        }
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            return R.fail("未找到该账号诊所信息");
        }
        List<TCrmClinicPoints> crmClinicPoints = crmClinicPointsService.clinicPointsStatistics(crmClinic.getId(), LocalDate.now() + " 23:59:59");
@@ -275,7 +275,7 @@
                .eq(TCrmSupplier::getUserId, userId)
                .last("LIMIT 1"));
        // ***
        if(Objects.isNull(crmSupplier)){
        if (Objects.isNull(crmSupplier)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
        }
@@ -325,7 +325,7 @@
                .eq(TCrmSupplier::getUserId, userId)
                .last("LIMIT 1"));
        // ***
        if(Objects.isNull(crmSupplier)){
        if (Objects.isNull(crmSupplier)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
        }
@@ -439,11 +439,11 @@
        TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                .eq(TCrmClinic::getUserId, userId)
                .last("LIMIT 1"));
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmClinic = crmClinicService.getById(sysUser.getObjectId());
        }
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            return R.fail("未找到该账号诊所信息");
        }
        // 查询药品总类和总数
@@ -491,11 +491,11 @@
        TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                .eq(TCrmClinic::getUserId, userId)
                .last("LIMIT 1"));
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmClinic = crmClinicService.getById(sysUser.getObjectId());
        }
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            return R.fail("未找到该账号诊所信息");
        }
        ClinicSalesStatisticsVO clinicSalesStatisticsVO = new ClinicSalesStatisticsVO();
@@ -596,6 +596,160 @@
        return R.ok(clinicSalesStatisticsVO);
    }
    public static void main(String[] args) {
        System.out.println(LocalDate.now().minusMonths(6));
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            list.add(i);
        }
        System.out.println(list.subList(2, list.size()));
        System.out.println(list.subList(0, 2));
    }
    @ApiOperation(value = "分公司管理员-首页统计(获取所有分公司信息)")
    @GetMapping(value = "/branchAdminList")
    public R<List<BranchAdminListVO>> branchAdminList() {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        ArrayList<BranchAdminListVO> branchAdminListVOs = new ArrayList<>();
        if (roleType == 2) {
            TCrmBranch branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                    .eq(TCrmBranch::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            if (branch != null) {
                // 如果是区
                if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                    // 区查下面所有城市的公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3));
                    if (!crmBranches.isEmpty()) {
                        for (TCrmBranch crmBranch : crmBranches) {
                            BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                            branchAdminListVO.setId(crmBranch.getId());
                            branchAdminListVO.setName(crmBranch.getBranchName());
                            branchAdminListVOs.add(branchAdminListVO);
                        }
                    }
                }
                // 省
                if (branch.getPersonType() != null && branch.getPersonType() == 1) {
                    // 所有的区 公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2));
                    if (!crmBranches.isEmpty()) {
                        Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                        for (TCrmBranch crmBranch : crmBranches) {
                            BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                            branchAdminListVO.setId(crmBranch.getId());
                            branchAdminListVO.setName(crmBranch.getBranchName());
                            branchAdminListVOs.add(branchAdminListVO);
                        }
                        // 城市公司
                        List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3));
                        if (!crmBranchesThree.isEmpty()) {
                            for (TCrmBranch crmBranch : crmBranchesThree) {
                                BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                                branchAdminListVO.setId(crmBranch.getId());
                                branchAdminListVO.setName(crmBranch.getBranchName());
                                branchAdminListVOs.add(branchAdminListVO);
                            }
                        }
                    }
                }
            }
            BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
            branchAdminListVO.setId(branch.getId());
            branchAdminListVO.setName(branch.getBranchName());
            branchAdminListVOs.add(branchAdminListVO);
        }
        return R.ok(branchAdminListVOs);
    }
    @ApiOperation(value = "分公司管理员-首页统计(获取所有业务员信息)")
    @GetMapping(value = "/branchAdminSaleList")
    public R<List<BranchAdminListVO>> branchAdminSaleList(String branchId) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        ArrayList<BranchAdminListVO> branchAdminListVOs = new ArrayList<>();
        if (roleType == 2) {
            TCrmBranch branch =null;
            if(branchId==null || branchId.isEmpty()){
                branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                        .eq(TCrmBranch::getUserId, user.getUserId())
                        .last("LIMIT 1"));
            }else {
                branch = crmBranchService.getById(branchId);
            }
            if (branch != null) {
                // 如果是区
                if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                    // 区查下面所有城市的公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3));
                    if (!crmBranches.isEmpty()) {
                        for (TCrmBranch crmBranch : crmBranches) {
                            BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                            branchAdminListVO.setId(crmBranch.getId());
                            branchAdminListVO.setName(crmBranch.getBranchName());
                            branchAdminListVOs.add(branchAdminListVO);
                        }
                    }
                }
                // 省
                if (branch.getPersonType() != null && branch.getPersonType() == 1) {
                    // 所有的区 公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2));
                    if (!crmBranches.isEmpty()) {
                        Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                        for (TCrmBranch crmBranch : crmBranches) {
                            BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                            branchAdminListVO.setId(crmBranch.getId());
                            branchAdminListVO.setName(crmBranch.getBranchName());
                            branchAdminListVOs.add(branchAdminListVO);
                        }
                        // 城市公司
                        List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3));
                        if (!crmBranchesThree.isEmpty()) {
                            for (TCrmBranch crmBranch : crmBranchesThree) {
                                BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                                branchAdminListVO.setId(crmBranch.getId());
                                branchAdminListVO.setName(crmBranch.getBranchName());
                                branchAdminListVOs.add(branchAdminListVO);
                            }
                        }
                    }
                }
            }
            BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
            branchAdminListVO.setId(branch.getId());
            branchAdminListVO.setName(branch.getBranchName());
            branchAdminListVOs.add(branchAdminListVO);
        }
        ArrayList<BranchAdminListVO> list = new ArrayList<>();
        if(!branchAdminListVOs.isEmpty()){
            Set<String> branchIds = branchAdminListVOs.stream().map(BranchAdminListVO::getId).collect(Collectors.toSet());
            List<TCrmSalesperson> tCrmSalespersonList = crmSalespersonService.list(new LambdaQueryWrapper<TCrmSalesperson>().in(TCrmSalesperson::getBranchId, branchIds));
            if(!tCrmSalespersonList.isEmpty()){
                for (TCrmSalesperson tCrmSalesperson : tCrmSalespersonList) {
                    BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                    branchAdminListVO.setId(tCrmSalesperson.getId());
                    branchAdminListVO.setName(tCrmSalesperson.getSalespersonName());
                    list.add(branchAdminListVO);
                }
            }
        }
        return R.ok(list);
    }
    /**
     * 分公司管理员-首页统计(第一部分)
     */
@@ -605,14 +759,42 @@
        BranchAdminStatisticsOneVo branchAdminStatisticsOneVo = new BranchAdminStatisticsOneVo();
        // 找出分公司下的所有员工 -》 所有诊所-》订单(状态 3=待发货 4=已发货 5=已入库)
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        if (roleType == 2) {
            TCrmBranch branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                    .eq(TCrmBranch::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            if (branch != null) {
                // 先查自己本身的
                List<TCrmClinic> list = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).eq(TCrmClinic::getBranchId, branch.getId()).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5)));
                // 如果是区
                if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                    // 区查下面所有城市的公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3));
                    if (!crmBranches.isEmpty()) {
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                    }
                }
                if (branch.getPersonType() != null && branch.getPersonType() == 3) {
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2));
                    if (!crmBranches.isEmpty()) {
                        // 区公司
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                        // 城市公司
                        List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3));
                        if (!crmBranchesThree.isEmpty()) {
                            List<String> branchIdsThree = crmBranchesThree.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsThree).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                }
                if (!list.isEmpty()) {
                    List<String> crmClinicIds = list.stream().map(TCrmClinic::getId).collect(Collectors.toList());
@@ -731,15 +913,39 @@
                    .eq(TCrmBranch::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            if (branch != null) {
                LambdaQueryWrapper<TCrmClinic> eq = Wrappers.lambdaQuery(TCrmClinic.class);
                if (query.getSalespersonId() != null && !query.getSalespersonId().isEmpty()) {
                    eq.eq(TCrmClinic::getSalespersonId, query.getSalespersonId());
                } else {
                    eq.eq(TCrmClinic::getBranchId, branch.getId());
                // 先查自己本身的
                List<TCrmClinic> list = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).eq(TCrmClinic::getBranchId, branch.getId()).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5)));
                // 如果是区
                if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                    // 区查下面所有城市的公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3));
                    if (!crmBranches.isEmpty()) {
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                    }
                }
                eq.in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
                List<TCrmClinic> list = crmClinicService.list(eq);
                if (branch.getPersonType() != null && branch.getPersonType() == 3) {
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2));
                    if (!crmBranches.isEmpty()) {
                        // 区公司
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                        // 城市公司
                        List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3));
                        if (!crmBranchesThree.isEmpty()) {
                            List<String> branchIdsThree = crmBranchesThree.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsThree).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                }
                if (query.getSalespersonId() != null && !query.getSalespersonId().isEmpty()) {
                    list = list.stream().filter(e -> e.getSalespersonId().equals(query.getSalespersonId())).collect(Collectors.toList());
                }
                branchAdminStatisticsTwoVo.setClinicNum(list.size());
                // 金额
@@ -822,10 +1028,35 @@
                    .eq(TCrmBranch::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            if (branch != null) {
                LambdaQueryWrapper<TCrmClinic> eq = Wrappers.lambdaQuery(TCrmClinic.class);
                eq.eq(TCrmClinic::getBranchId, branch.getId());
                eq.eq(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
                List<TCrmClinic> list = crmClinicService.list(eq);
                // 先查自己本身的
                List<TCrmClinic> list = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).eq(TCrmClinic::getBranchId, branch.getId()).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5)));
                // 如果是区
                if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                    // 区查下面所有城市的公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3));
                    if (!crmBranches.isEmpty()) {
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                    }
                }
                if (branch.getPersonType() != null && branch.getPersonType() == 3) {
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2));
                    if (!crmBranches.isEmpty()) {
                        // 区公司
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                        // 城市公司
                        List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3));
                        if (!crmBranchesThree.isEmpty()) {
                            List<String> branchIdsThree = crmBranchesThree.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsThree).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                }
                List<String> clinicIds = list.stream().map(TCrmClinic::getId).collect(Collectors.toList());
                if (clinicIds.isEmpty()) {
@@ -1396,7 +1627,7 @@
        if (roleType == 3) {
            TCrmSalesperson one = crmSalespersonService.getOne(new LambdaQueryWrapper<TCrmSalesperson>().eq(TCrmSalesperson::getUserId, user.getUserId()));
            LambdaQueryWrapper<TCrmClinic> eq = Wrappers.lambdaQuery(TCrmClinic.class);
            eq.eq(TCrmClinic::getSalespersonId,one.getId());
            eq.eq(TCrmClinic::getSalespersonId, one.getId());
            eq.in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
            List<TCrmClinic> list = crmClinicService.list(eq);
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
@@ -94,7 +94,6 @@
    }
    /**
     * 获取erp问题上报管理列表
     */
@@ -103,33 +102,33 @@
    public R<PageInfo<TErpGoodsVO>> pageList(@RequestBody TErpGoodsQuery query) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        if(roleType == 4){
        if (roleType == 4) {
            // 供应商
            TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                    .eq(TCrmSupplier::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ***
            if(Objects.isNull(crmSupplier)){
            if (Objects.isNull(crmSupplier)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
            }
            query.setSupplierClinicId(crmSupplier.getId());
        }
        if(roleType == 5){
        if (roleType == 5) {
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ---
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
            query.setSupplierClinicId(crmClinic.getId());
        }
        return R.ok(erpGoodsService.pageList(query,user));
        return R.ok(erpGoodsService.pageList(query, user));
    }
    /**
@@ -140,7 +139,7 @@
    public R<PageInfo<TErpGoodsVO>> pageAdminList(@RequestBody TErpGoodsAdminQuery query) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        if(roleType == 1){
        if (roleType == 1) {
            // 平台
            return R.ok(erpGoodsService.pageAdminList(query));
        }
@@ -151,12 +150,16 @@
    @ApiOperation(value = "平台审核商品内容")
    @PostMapping(value = "/adminAudit")
    @Log(title = "商品管理-平台审核商品内容", businessType = BusinessType.UPDATE)
    public R<?> adminAudit(@RequestBody  AdminAuditDto dto) {
    public R<?> adminAudit(@RequestBody AdminAuditDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        List<TErpGoods> tErpGoods = erpGoodsService.listByIds(dto.getIds());
        if(roleType == 1){
            tErpGoods.stream().forEach(e->e.setContentState(dto.getContentState()));
        if (roleType == 1) {
            tErpGoods.stream().forEach(e -> {
                        e.setContentState(dto.getContentState());
                        e.setContentRemark(dto.getContentRemark());
                    }
            );
            erpGoodsService.updateBatchById(tErpGoods);
            // 平台
            return R.ok();
@@ -165,23 +168,21 @@
    }
    @ApiOperation(value = "供应商提交商品内容")
    @PostMapping(value = "/supplierSubmitContent")
    @Log(title = "商品管理-供应商提交商品内容", businessType = BusinessType.UPDATE)
    public R<?> adminAudit(@RequestBody  SupplierSubmitContentDto dto) {
    public R<?> adminAudit(@RequestBody SupplierSubmitContentDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        TErpGoods erpGoods = erpGoodsService.getById(dto.getId());
        if(roleType == 4){
        if (roleType == 4) {
            erpGoods.setContent(dto.getContent());
            erpGoods.setContentState(0);
            erpGoodsService.updateById(erpGoods);
            return R.ok();
        }
        return R.ok();
    }
    /**
@@ -192,14 +193,14 @@
    public R<Page<TErpGoods>> pageAddList(@RequestBody PageAddListQuery query) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        String clinicSupplierId=null;
        if(roleType == 5){
        String clinicSupplierId = null;
        if (roleType == 5) {
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ---
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
@@ -207,7 +208,7 @@
        }
        Page<TErpGoods> tErpGoodsPage = new Page<>(query.getPageNum(), query.getPageSize());
        List<TErpGoods> page = erpGoodsService.pageAddList(tErpGoodsPage,clinicSupplierId,query);
        List<TErpGoods> page = erpGoodsService.pageAddList(tErpGoodsPage, clinicSupplierId, query);
        tErpGoodsPage.setRecords(page);
        return R.ok(tErpGoodsPage);
    }
@@ -221,34 +222,34 @@
    public R<?> getAllGoodsList() {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        String clinicSupplierId=null;
        if(roleType == 5){
        String clinicSupplierId = null;
        if (roleType == 5) {
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ---
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
            clinicSupplierId = crmClinic.getId();
        }
        List<TErpGoods> list = erpGoodsService.list(new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getGoodsSource, 1).eq(TErpGoods::getState,1).eq(BaseModel::getDisabled, 0).isNotNull(TErpGoods::getPlatformCommissionPrice).last("and (NOT FIND_IN_SET(" + clinicSupplierId + ",clinic_ids) or  clinic_ids is null)"));
        List<TErpGoods> list = erpGoodsService.list(new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getGoodsSource, 1).eq(TErpGoods::getState, 1).eq(BaseModel::getDisabled, 0).isNotNull(TErpGoods::getPlatformCommissionPrice).last("and (NOT FIND_IN_SET(" + clinicSupplierId + ",clinic_ids) or  clinic_ids is null)"));
        for (TErpGoods goods : list) {
            String clinicIds = goods.getClinicIds();
            if(clinicIds == null || clinicIds.isEmpty()){
            if (clinicIds == null || clinicIds.isEmpty()) {
                goods.setClinicIds(clinicSupplierId);
            }else {
            } else {
                String[] split = clinicIds.split(",");
                ArrayList<String> split1 = new ArrayList<>();
                for (String s : split) {
                    split1.add(s);
                }
                if(!split1.contains(clinicSupplierId)){
                if (!split1.contains(clinicSupplierId)) {
                    split1.add(clinicSupplierId);
                    goods.setClinicIds(String.join(",",split1));
                    goods.setClinicIds(String.join(",", split1));
                }
            }
@@ -258,37 +259,36 @@
    }
    @ApiOperation(value = "供应商添加商品")
    @PostMapping(value = "/add")
    @Log(title = "商品管理-供应商添加", businessType = BusinessType.INSERT)
    public R<Boolean> add(@Validated @RequestBody TErpGoodsAddDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(),null)) {
        if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(), null)) {
            return R.fail("erp商品已存在");
        }
        Integer roleType = user.getRoleType();
        TErpGoods goods = new TErpGoods();
        if(roleType == 4){
        if (roleType == 4) {
            // 供应商
            TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                    .eq(TCrmSupplier::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ***
            if(Objects.isNull(crmSupplier)){
            if (Objects.isNull(crmSupplier)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
            }
            goods.setSupplierClinicId(crmSupplier.getId());
            goods.setGoodsSource(1);
        }
        if(roleType == 5){
        if (roleType == 5) {
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ---
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
@@ -303,31 +303,32 @@
        goods.setPackingSpec(dto.getPackingSpec());
        goods.setGoodsName(dto.getGoodsName());
        goods.setIsPrescriptionDrug(null);
        goods.setGoodsSpec(dto.getFormulationSpec()+"*"+dto.getPackingSpec());
        goods.setGoodsSpec(dto.getFormulationSpec() + "*" + dto.getPackingSpec());
        return R.ok(erpGoodsService.save(goods));
    }
    @ApiOperation(value = "诊所添加商品")
    @PostMapping(value = "/clinicAdd")
    @Log(title = "商品管理-诊所添加", businessType = BusinessType.INSERT)
    public R<Boolean> clinicAdd(@Validated @RequestBody TErpClinicGoodsAddDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(),null)) {
        if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(), null)) {
            return R.fail("erp商品已存在,商品条码重复");
        }
        if (erpGoodsService.isExitOne(dto.getGoodsIdCode(), dto.getQuasiNumber(),null)) {
        if (erpGoodsService.isExitOne(dto.getGoodsIdCode(), dto.getQuasiNumber(), null)) {
            return R.fail("erp商品已存在,国药准字号重复");
        }
        Integer roleType = user.getRoleType();
        TErpGoods goods = new TErpGoods();
        BeanUtils.copyProperties(dto,goods);
        goods.setGoodsSpec(dto.getFormulationSpec()+"*"+dto.getPackingSpec());
        if(roleType == 5){
        BeanUtils.copyProperties(dto, goods);
        goods.setGoodsSpec(dto.getFormulationSpec() + "*" + dto.getPackingSpec());
        if (roleType == 5) {
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ---
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
@@ -336,9 +337,9 @@
        }
        goods.setCreateId(user.getUserId().toString());
        goods.setGoodsIdCode(dto.getGoodsIdCode());
        goods.setGoodsSpec(dto.getFormulationSpec()+"*"+dto.getPackingSpec());
        goods.setGoodsSpec(dto.getFormulationSpec() + "*" + dto.getPackingSpec());
//        goods.setClinicPurchasePrice(dto.getSalesAmount());
        if(goods.getIsPrescriptionDrug()!=null && goods.getIsPrescriptionDrug()==3){
        if (goods.getIsPrescriptionDrug() != null && goods.getIsPrescriptionDrug() == 3) {
            goods.setIsPrescriptionDrug(null);
        }
        return R.ok(erpGoodsService.save(goods));
@@ -349,19 +350,19 @@
    @Log(title = "商品管理-诊所编辑", businessType = BusinessType.UPDATE)
    public R<Boolean> clinicUpdate(@Validated @RequestBody TErpClinicGoodsUpdateDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(),dto.getId())) {
        if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber(), dto.getId())) {
            return R.fail("erp商品已存在");
        }
        Integer roleType = user.getRoleType();
        TErpGoods goods = new TErpGoods();
        BeanUtils.copyProperties(dto,goods);
        if(roleType == 5){
        BeanUtils.copyProperties(dto, goods);
        if (roleType == 5) {
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ---
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
@@ -371,8 +372,8 @@
        goods.setCreateId(user.getUserId().toString());
        goods.setGoodsIdCode(dto.getGoodsIdCode());
        goods.setId(dto.getId());
        goods.setGoodsSpec(dto.getFormulationSpec()+"*"+dto.getPackingSpec());
        if(goods.getIsPrescriptionDrug()!=null && goods.getIsPrescriptionDrug()==3){
        goods.setGoodsSpec(dto.getFormulationSpec() + "*" + dto.getPackingSpec());
        if (goods.getIsPrescriptionDrug() != null && goods.getIsPrescriptionDrug() == 3) {
            goods.setIsPrescriptionDrug(null);
        }
        return R.ok(erpGoodsService.updateById(goods));
@@ -386,30 +387,30 @@
        SysUser user = tokenService.getLoginUser().getUser();
        String cid = null;
        if(user.getRoleType() == 5){
        if (user.getRoleType() == 5) {
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ---
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
            cid = crmClinic.getId();
            if(goods.getGoodsSource()==1){
            if (goods.getGoodsSource() == 1) {
                String clinicIds = goods.getClinicIds();
                String[] split = clinicIds.split(",");
                // clinicIds 移除cid
                ArrayList<String> strings = new ArrayList<>();
                for (String s : split) {
                    if(!s.equals(cid)){
                    if (!s.equals(cid)) {
                        strings.add(s);
                    }
                }
                goods.setClinicIds(String.join(",",strings));
                goods.setClinicIds(String.join(",", strings));
                erpGoodsService.updateById(goods);
            }else {
            } else {
                erpGoodsService.removeById(id);
            }
            return R.ok();
@@ -427,29 +428,29 @@
        SysUser user = tokenService.getLoginUser().getUser();
        String cid = null;
        if(user.getRoleType() == 5){
        if (user.getRoleType() == 5) {
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ---
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
            cid = crmClinic.getId();
            for (TErpGoods goods : list) {
                String clinicIds = goods.getClinicIds();
                if(clinicIds==null || clinicIds.isEmpty()){
                    goods.setClinicIds( cid);
                }else {
                if (clinicIds == null || clinicIds.isEmpty()) {
                    goods.setClinicIds(cid);
                } else {
                    String[] split = clinicIds.split(",");
                    List<String> split1 = new ArrayList<>();
                    for (String s : split) {
                        split1.add(s);
                    }
                    if(!split1.contains(cid)){
                    if (!split1.contains(cid)) {
                        split1.add(cid);
                        goods.setClinicIds(String.join(",",split1));
                        goods.setClinicIds(String.join(",", split1));
                    }
                }
@@ -470,21 +471,21 @@
        SysUser user = tokenService.getLoginUser().getUser();
        TErpGoods goods = erpGoodsService.getById(dto.getId());
        if(goods.getState()==2 && dto.getState()==2){
        if (goods.getState() == 2 && dto.getState() == 2) {
            return R.fail("操作失败,该商品已是禁用状态");
        }
        if(dto.getState()==1 && goods.getTypeId()==null){
        if (dto.getState() == 1 && goods.getTypeId() == null) {
            return R.fail("操作失败,请先完善商品信息");
        }
        if(dto.getState()==1 && goods.getClinicPurchasePrice()==null){
        if (dto.getState() == 1 && goods.getClinicPurchasePrice() == null) {
            return R.fail("操作失败,请设置供应商分佣比例后再启用");
        }
        if(dto.getState()==1 && Objects.nonNull(goods.getStateUser()) && goods.getStateUser()==1 && user.getRoleType()==5){
        if (dto.getState() == 1 && goods.getStateUser() == 1 && user.getRoleType() == 5) {
            return R.fail("操作失败,平台禁用商品不可启用");
        }
        if(user.getRoleType()==1){
        if (user.getRoleType() == 1) {
            goods.setStateUser(1);
        }else if(user.getRoleType()==5){
        } else if (user.getRoleType() == 5) {
            goods.setStateUser(2);
        }
        goods.setStateRemark(dto.getStateRemark());
@@ -499,44 +500,44 @@
    public R<Boolean> saveDataInfo(@RequestBody @Valid TErpGoodsInfoSaveDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        String clinicSupplierId=null;
        if(roleType == 4){
        String clinicSupplierId = null;
        if (roleType == 4) {
            // 供应商
            TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                    .eq(TCrmSupplier::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ***
            if(Objects.isNull(crmSupplier)){
            if (Objects.isNull(crmSupplier)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
            }
            clinicSupplierId = crmSupplier.getId();
        }
        if(roleType == 5){
        if (roleType == 5) {
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ---
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
            clinicSupplierId =crmClinic.getId();
            clinicSupplierId = crmClinic.getId();
        }
        TErpGoods goods = erpGoodsService.getById(dto.getId());
        BeanUtils.copyProperties(dto,goods);
        if(goods.getMaintenanceInterval()!=null){
        BeanUtils.copyProperties(dto, goods);
        if (goods.getMaintenanceInterval() != null) {
            List<TErpSupplierWarehousing> list = erpSupplierWarehousingService.list(new LambdaQueryWrapper<TErpSupplierWarehousing>().eq(TErpSupplierWarehousing::getGoodsId, dto.getId()));
            if(!list.isEmpty()){
            if (!list.isEmpty()) {
                List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchService.list(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().in(TErpSupplierWarehousingBatch::getWarehousingId, list.stream().map(TErpSupplierWarehousing::getId).collect(Collectors.toList())));
                for (TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch : tErpSupplierWarehousingBatches) {
                    List<TErpSupplierOutboundGoods> list1 = erpSupplierOutboundGoodsService.list(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getWarehousingBatchId, tErpSupplierWarehousingBatch.getId()));
                    if(!list1.isEmpty()){
                    if (!list1.isEmpty()) {
                        int sum = list1.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum();
                        if (tErpSupplierWarehousingBatch.getWarehousingNumber()-sum>0) {
                        if (tErpSupplierWarehousingBatch.getWarehousingNumber() - sum > 0) {
                            // 生成保养单
                            TErpMaintenanceReminder tErpMaintenanceReminder = new TErpMaintenanceReminder();
                            tErpMaintenanceReminder.setClinicSupplierId(clinicSupplierId);
@@ -555,7 +556,7 @@
            }
        }
        if(goods.getIsPrescriptionDrug()!=null && goods.getIsPrescriptionDrug()==3){
        if (goods.getIsPrescriptionDrug() != null && goods.getIsPrescriptionDrug() == 3) {
            goods.setIsPrescriptionDrug(null);
        }
@@ -564,7 +565,7 @@
    @ApiOperation(value = "商品详情")
    @GetMapping(value = "/detail/{id}")
    public R<TErpGoods> detail( @PathVariable String  id) {
    public R<TErpGoods> detail(@PathVariable String id) {
        TErpGoods goods = erpGoodsService.getById(id);
        return R.ok(goods);
    }
@@ -572,37 +573,36 @@
    @ApiOperation(value = "商品管理信息导出--导出")
    @PostMapping("/export")
    @Log(title = "商品管理-导出", businessType = BusinessType.EXPORT)
    public void listExport(@RequestBody TErpGoodsQuery query)
    {
    public void listExport(@RequestBody TErpGoodsQuery query) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        if(roleType == 4){
        if (roleType == 4) {
            // 供应商
            TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                    .eq(TCrmSupplier::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ***
            if(Objects.isNull(crmSupplier)){
            if (Objects.isNull(crmSupplier)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
            }
            query.setSupplierClinicId(crmSupplier.getId());
        }
        if(roleType == 5){
        if (roleType == 5) {
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            // ---
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
            query.setSupplierClinicId(crmClinic.getId());
        }
        List<TErpGoodsVO> pageList = erpGoodsService.listExport(query,user);
        List<TErpGoodsVO> pageList = erpGoodsService.listExport(query, user);
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TErpGoodsVO.class, pageList);
        HttpServletResponse response = WebUtils.response();
        assert response != null;
@@ -632,7 +632,7 @@
    @ApiOperation(value = "商品管理信息导入")
    @PostMapping("/importFile")
    @Log(title = "商品管理-导入", businessType = BusinessType.IMPORT)
    public AjaxResult importFile(@RequestParam(value = "file") MultipartFile file ) {
    public AjaxResult importFile(@RequestParam(value = "file") MultipartFile file) {
        SysUser user = tokenService.getLoginUser().getUser();
        JSONObject jsonObject = new JSONObject();
@@ -653,26 +653,26 @@
            for (TErpGoodsExcel erpGoodsExcel : carAnnuallyImportExcels) {
                TErpGoods goods = new TErpGoods();
                if(roleType == 4){
                if (roleType == 4) {
                    // 供应商
                    TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                            .eq(TCrmSupplier::getUserId, user.getUserId())
                            .last("LIMIT 1"));
                    // ***
                    if(Objects.isNull(crmSupplier)){
                    if (Objects.isNull(crmSupplier)) {
                        SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                        crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
                    }
                    goods.setSupplierClinicId(crmSupplier.getId());
                    goods.setGoodsSource(1);
                }
                if(roleType == 5){
                if (roleType == 5) {
                    // 诊所
                    TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                            .eq(TCrmClinic::getUserId, user.getUserId())
                            .last("LIMIT 1"));
                    // ---
                    if(Objects.isNull(crmClinic)){
                    if (Objects.isNull(crmClinic)) {
                        SysUser sysUser = sysUserService.selectUserById(user.getUserId());
                        crmClinic = crmClinicService.getById(sysUser.getObjectId());
                    }
@@ -681,26 +681,26 @@
                }
                // 判空
                if(erpGoodsExcel.getGoodsName()==null || erpGoodsExcel.getGoodsName().isEmpty()){
                if (erpGoodsExcel.getGoodsName() == null || erpGoodsExcel.getGoodsName().isEmpty()) {
                    names.add("商品名称不能为空");
                    continue;
                }
                if(erpGoodsExcel.getGoodsIdCode()==null || erpGoodsExcel.getGoodsIdCode().isEmpty()
                || erpGoodsExcel.getQuasiNumber() ==null || erpGoodsExcel.getQuasiNumber().isEmpty()
                || erpGoodsExcel.getManufacturer()==null || erpGoodsExcel.getManufacturer().isEmpty()
                || erpGoodsExcel.getFormulationSpec()==null || erpGoodsExcel.getFormulationSpec().isEmpty()
                || erpGoodsExcel.getPackingSpec()==null || erpGoodsExcel.getPackingSpec().isEmpty()
                || erpGoodsExcel.getClinicPurchasePrice()==null|| erpGoodsExcel.getClinicPurchasePrice().isEmpty()
                || erpGoodsExcel.getWarningInventory()==null|| erpGoodsExcel.getWarningInventory().isEmpty()
                || erpGoodsExcel.getTypeName()==null|| erpGoodsExcel.getTypeName().isEmpty()){
                    names.add(erpGoodsExcel.getGoodsName()+" :信息有误,请检查后重新提交。");
                if (erpGoodsExcel.getGoodsIdCode() == null || erpGoodsExcel.getGoodsIdCode().isEmpty()
                        || erpGoodsExcel.getQuasiNumber() == null || erpGoodsExcel.getQuasiNumber().isEmpty()
                        || erpGoodsExcel.getManufacturer() == null || erpGoodsExcel.getManufacturer().isEmpty()
                        || erpGoodsExcel.getFormulationSpec() == null || erpGoodsExcel.getFormulationSpec().isEmpty()
                        || erpGoodsExcel.getPackingSpec() == null || erpGoodsExcel.getPackingSpec().isEmpty()
                        || erpGoodsExcel.getClinicPurchasePrice() == null || erpGoodsExcel.getClinicPurchasePrice().isEmpty()
                        || erpGoodsExcel.getWarningInventory() == null || erpGoodsExcel.getWarningInventory().isEmpty()
                        || erpGoodsExcel.getTypeName() == null || erpGoodsExcel.getTypeName().isEmpty()) {
                    names.add(erpGoodsExcel.getGoodsName() + " :信息有误,请检查后重新提交。");
                    continue;
                }
                goods.setGoodsName(erpGoodsExcel.getGoodsName());
                // 判断数据是否正确
                // 判断条码是否重复
                long count = erpGoodsService.count(new QueryWrapper<TErpGoods>().eq("goods_id_code", erpGoodsExcel.getGoodsIdCode()));
                if(count>0){
                if (count > 0) {
                    names.add(erpGoodsExcel.getGoodsName() + " :条码重复");
                    continue;
                }
@@ -712,7 +712,7 @@
                // 商品类型
                TErpGoodsType one = erpGoodsTypeService.getOne(new LambdaQueryWrapper<TErpGoodsType>().eq(TErpGoodsType::getTypeName, erpGoodsExcel.getTypeName()));
                if(one==null){
                if (one == null) {
                    names.add(erpGoodsExcel.getGoodsName() + " :商品类型不存在");
                    continue;
                }
@@ -721,38 +721,38 @@
                // 采购价
                try {
                    goods.setClinicPurchasePrice(new BigDecimal(erpGoodsExcel.getClinicPurchasePrice()).setScale(2, RoundingMode.HALF_UP));
                }catch (Exception e){
                } catch (Exception e) {
                    names.add(erpGoodsExcel.getGoodsName() + " :采购价有误");
                    continue;
                }
                // 预警库存
                try {
                    goods.setWarningInventory(Integer.valueOf(erpGoodsExcel.getWarningInventory()));
                }catch (Exception e){
                } catch (Exception e) {
                    names.add(erpGoodsExcel.getGoodsName() + " :预警库存有误");
                    continue;
                }
                goods.setGoodsYards(erpGoodsExcel.getGoodsYards());
                try {
                    if(erpGoodsExcel.getMaintenanceInterval()!=null && !erpGoodsExcel.getMaintenanceInterval().isEmpty()){
                    if (erpGoodsExcel.getMaintenanceInterval() != null && !erpGoodsExcel.getMaintenanceInterval().isEmpty()) {
                        Integer i = Integer.valueOf(erpGoodsExcel.getMaintenanceInterval());
                    }
                }catch (Exception e){
                } catch (Exception e) {
                    names.add(erpGoodsExcel.getGoodsName() + " :保养周期有误");
                    continue;
                }
                goods.setMaintenanceInterval(erpGoodsExcel.getMaintenanceInterval());
                try {
                    if(erpGoodsExcel.getLowPurchaseQuantity()!=null && !erpGoodsExcel.getLowPurchaseQuantity().isEmpty()){
                    if (erpGoodsExcel.getLowPurchaseQuantity() != null && !erpGoodsExcel.getLowPurchaseQuantity().isEmpty()) {
                        goods.setLowPurchaseQuantity(Integer.valueOf(erpGoodsExcel.getLowPurchaseQuantity()));
                    }
                }catch (Exception e){
                } catch (Exception e) {
                    names.add(erpGoodsExcel.getGoodsName() + " :最低采购数量有误");
                    continue;
                }
                if(erpGoodsExcel.getLowUnitName()!=null && !erpGoodsExcel.getLowUnitName().isEmpty()){
                if (erpGoodsExcel.getLowUnitName() != null && !erpGoodsExcel.getLowUnitName().isEmpty()) {
                    TErpGoodsUnit one1 = erpGoodsUnitService.getOne(new LambdaQueryWrapper<TErpGoodsUnit>().eq(TErpGoodsUnit::getUnitName, erpGoodsExcel.getLowUnitName()));
                    if (one1 == null) {
                        names.add(erpGoodsExcel.getGoodsName() + " :最低采购单位有误");
@@ -762,22 +762,22 @@
                }
                if(erpGoodsExcel.getIsPrescriptionDrug() !=null && !erpGoodsExcel.getIsPrescriptionDrug().isEmpty()){
                    if(erpGoodsExcel.getIsPrescriptionDrug().equals("是")){
                if (erpGoodsExcel.getIsPrescriptionDrug() != null && !erpGoodsExcel.getIsPrescriptionDrug().isEmpty()) {
                    if (erpGoodsExcel.getIsPrescriptionDrug().equals("是")) {
                        goods.setIsPrescriptionDrug(1);
                    }else if (erpGoodsExcel.getIsPrescriptionDrug().equals("否")){
                    } else if (erpGoodsExcel.getIsPrescriptionDrug().equals("否")) {
                        goods.setIsPrescriptionDrug(2);
                    }else {
                    } else {
                        names.add(erpGoodsExcel.getGoodsName() + " :是否为处方药有误");
                        continue;
                    }
                }
                if(erpGoodsExcel.getPackingUnitName() !=null && !erpGoodsExcel.getPackingUnitName().isEmpty()){
                if (erpGoodsExcel.getPackingUnitName() != null && !erpGoodsExcel.getPackingUnitName().isEmpty()) {
                    TErpGoodsUnit unit = erpGoodsUnitService.getOne(new LambdaQueryWrapper<TErpGoodsUnit>().eq(TErpGoodsUnit::getUnitName, erpGoodsExcel.getPackingUnitName()));
                    if(unit != null){
                    if (unit != null) {
                        goods.setPackingUnitId(unit.getId());
                    }else {
                    } else {
                        names.add(erpGoodsExcel.getGoodsName() + " :包装单位有误");
                        continue;
                    }
@@ -797,27 +797,25 @@
                goods.setPrecautions(erpGoodsExcel.getPrecautions());
                goods.setInteraction(erpGoodsExcel.getInteraction());
                goods.setStorage(erpGoodsExcel.getStorage());
                tErpGoods.add( goods);
                tErpGoods.add(goods);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("记录导入失败!");
        }finally {
        } finally {
            try {
                inputStream.close();
            } catch (IOException e) {
                throw new ServiceException(e.getMessage());
            }
        }
        if(names.size()>0){
            return AjaxResult.error("导入失败记录如下:",names);
        if (names.size() > 0) {
            return AjaxResult.error("导入失败记录如下:", names);
        }
        erpGoodsService.saveBatch(tErpGoods);
        return AjaxResult.success();
    }
    @ApiOperation(value = "平台设置分佣")
@@ -826,11 +824,11 @@
    public R<Boolean> setCommission(@RequestBody @Valid TErpGoodsSetCommissionDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        if(user.getRoleType()==1){
        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);
            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-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -125,6 +125,7 @@
                        "/t-sys-educational-info/list","/t-sys-educational-info/getDetailById","/t-sys-educational-info/pageList",
                        "/t-sys-live/list","/t-sys-live/getDetailById","/t-sys-live/pageList","/t-sys-qualifications/list",
                        "/open/**","/cos/get/**","/openIdByJsCode","/t-sys-order/**","/openIdByCode","/tRegion/sendTest"
                        ,"/t-sys-qualifications/pageList"
                ).permitAll()
                // 静态资源,可匿名访问
                .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
ruoyi-system/src/main/java/com/ruoyi/system/dto/AdminAuditDto.java
@@ -14,4 +14,7 @@
    @ApiModelProperty("审核状态 1通过 2拒绝")
    private Integer contentState;
    @ApiModelProperty("审核备注")
    private String contentRemark;
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpGoods.java
@@ -244,6 +244,10 @@
    @TableField("content_state")
    private Integer contentState;
    @ApiModelProperty(value = "内容审核备注")
    @TableField("content_remark")
    private String contentRemark;
    @ApiModelProperty(value = "下架备注")
    @TableField("state_remark")
    private String stateRemark;
ruoyi-system/src/main/java/com/ruoyi/system/query/BranchAdminStatisticsOneQuery.java
@@ -15,4 +15,7 @@
    @ApiModelProperty("1:今天 2:昨日 3:最近7天 4:最近半年 5:最近一年")
    @NotNull(message = "请选择员工时间类型")
    private Integer staffType;
    @ApiModelProperty("公司id")
    private String branchId ;
}
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsAdminQuery.java
@@ -1,5 +1,6 @@
package com.ruoyi.system.query;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.common.core.domain.BasePage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -25,4 +26,11 @@
    @ApiModelProperty(value = "1启用 2禁用")
    private Integer state;
    @ApiModelProperty(value = "内容状态0待审核 1通过 2拒绝")
    private Integer contentState;
    @ApiModelProperty(value = "1审核")
    private Integer category;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/BranchAdminListVO.java
New file
@@ -0,0 +1,15 @@
package com.ruoyi.system.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("获取当前下级分公司列表/业务员列表")
public class BranchAdminListVO {
    @ApiModelProperty("id")
    private String id;
    @ApiModelProperty("名称")
    private String name;
}
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -71,6 +71,9 @@
        t1.precautions,
        t1.interaction,
        t1.storage,
        t1.content,
        t1.content_state,
        t1.content_remark,
        case t1.goods_source
        when 1 then t2.supplier_name
        when 2 then t1.supplier_name
@@ -362,6 +365,12 @@
        <if test="query.state != null ">
            and t1.state = #{query.state}
        </if>
        <if test="query.contentState != null ">
            and t1.content_state = #{contentState}
        </if>
        <if test="query.category != null ">
            and t1.content is not null
        </if>
        order by t1.create_time desc
    </select>
    <select id="pageAddList" resultType="com.ruoyi.system.model.TErpGoods">