k94314517
2023-12-28 5c16e998fdcef5f5645eb71697a95c6f45157bbf
ERP接口
已修改1个文件
89 ■■■■■ 文件已修改
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
@@ -19,18 +19,20 @@
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
import com.doumee.dao.admin.request.UpdateCompanySortDTO;
import com.doumee.dao.admin.response.CompanyDTO;
import com.doumee.dao.business.CompanyMapper;
import com.doumee.dao.business.join.CompanyJoinMapper;
import com.doumee.dao.business.model.Category;
import com.doumee.dao.business.model.Company;
import com.doumee.dao.business.model.Member;
import com.doumee.dao.business.model.*;
import com.doumee.dao.system.dto.UpdateSystemMenuSortDTO;
import com.doumee.dao.system.model.SystemMenu;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.CompanyService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.doumee.service.common.tree.CompanyTree;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.collections.CollectionUtils;
@@ -81,11 +83,10 @@
            if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,父级组织信息不存在~");
            }
            if(StringUtils.isBlank(parent.getHkParentId())){
            if(StringUtils.isBlank(parent.getHkId())){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,父级组织信息尚未同步下发成功~");
            }
            company.setHkParentId(parent.getHkParentId());
            company.setHkParentId(parent.getHkId());
        }
        company.setCreateDate(new Date());
        company.setCreator(user.getId());
@@ -198,6 +199,7 @@
        if(StringUtils.isBlank(model.getHkId())){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,组织信息尚未同步下发成功,暂不支持修改,请尝试删除后重新添加~");
        }
        Company company = new Company();
        company.setId(id);
        company.setEditDate(new Date());
@@ -494,4 +496,79 @@
            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"公司名称已存在");
        }
    }
    @Override
    public List<Company> companyTree(Integer type) {
        MPJLambdaWrapper<Company> queryWrapper = new MPJLambdaWrapper<>();
        queryWrapper.selectAll(Company.class);
        queryWrapper.selectAs(Member::getName,Company::getHeadName);
        queryWrapper.selectAs(Member::getPhone,Company::getHeadPhone);
        queryWrapper.leftJoin(Member.class,Member::getId,Company::getHeadId);
        queryWrapper.eq(Company::getIsdeleted,Constants.ZERO);
        queryWrapper.eq(Company::getType,type);
        List<Company> companyList = companyJoinMapper.selectJoinList(Company.class,queryWrapper);
        //配置组员人员类型来源方式 0自建 1ERP
        String origin = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ORG_USER_ORIGIN).getCode();
        CompanyTree treeBuild = new CompanyTree(companyList,Integer.valueOf(origin));
        companyList = treeBuild.buildTree();
        return companyList;
    }
    @Override
    public void updateSort(UpdateCompanySortDTO dto) {
        Company company = companyMapper.selectById(dto.getId());
        if(Objects.isNull(company)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        List<Company> companyPool;
        if (company.getParentId() == null) {
            companyPool = companyMapper.selectList(new QueryWrapper<Company>().lambda()
                    .eq(Company::getIsdeleted,Constants.ZERO)
                    .isNull(Company::getParentId)
                    .orderByAsc(Company::getSortnum)
            );
        } else {
            companyPool = companyMapper.selectList(new QueryWrapper<Company>().lambda()
                    .eq(Company::getIsdeleted,Constants.ZERO)
                    .eq(Company::getParentId,company.getParentId())
                    .orderByAsc(Company::getSortnum)
            );
        }
        int currentMenuIndex = 0;
        for (int i = 0; i < companyPool.size(); i++) {
            if (companyPool.get(i).getId().equals(dto.getId())) {
                currentMenuIndex = i;
                break;
            }
        }
        // 上移
        if ("top".equals(dto.getDirection())) {
            if (currentMenuIndex - 1 < 0) {
                return;
            }
            Company preMenu = companyPool.remove(currentMenuIndex - 1);
            companyPool.add(currentMenuIndex, preMenu);
        }
        // 下移
        else {
            if (currentMenuIndex + 1 > companyPool.size() - 1) {
                return;
            }
            Company nextMenu = companyPool.remove(currentMenuIndex + 1);
            companyPool.add(currentMenuIndex, nextMenu);
        }
        for (int i = 0; i < companyPool.size(); i++) {
            companyPool.get(i).setSortnum(i);
        }
        for (Company updCompany:companyPool) {
            companyMapper.updateById(updCompany);
        }
    }
}