jiangping
2024-01-05 2c4cfb7ed1ece6c3b80f7d551a267e9367ddb12b
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/erp/ErpSyncServiceImpl.java
@@ -122,6 +122,9 @@
    @Override
    @Transactional
    public String syncCompany(OrgListRequest param){
        if(!StringUtils.equals(Constants.ONE+"", systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ORG_USER_ORIGIN).getCode())){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,当前不支持组织同步操作~");
        }
        //获取ERP组织信息(全量同步)
        List<ErpOrgListResponse>  list = ErpTool.getErpOrgList(ErpConstants.orgListUrl,param);
        if(list !=null && list.size()>0){
@@ -219,13 +222,16 @@
     */
    private Company getAddCompanyModel(ErpOrgListResponse respone, Date date) {
        Company    company = new Company();
        company.setStatus(respone.getStatus());
        company.setIsdeleted(Constants.ZERO);
        company.setName(respone.getName());
        company.setErpId(respone.getId());
        company.setCreateDate(date);
        company.setType(Constants.ONE);
        company.setCode(respone.getCode());
        company.setErpParentId(respone.getParentOrgId());
        if(StringUtils.isNotBlank(respone.getParentOrgId())&&!respone.getParentOrgId().equals("orgRoot")){
            company.setErpParentId(respone.getParentOrgId());
        }
        company.setErpDate(date);
        company.setHkStatus(Constants.ZERO);
        return  company;
@@ -262,6 +268,9 @@
    @Override
    @Transactional
    public  String syncUsers(UserListRequest param){
        if(!StringUtils.equals(Constants.ONE+"", systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ORG_USER_ORIGIN).getCode())){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,当前不支持人员同步操作~");
        }
        List<ErpUserListResponse>  list = ErpTool.getErpUserList(ErpConstants.userListUrl,param);
        if(list !=null && list.size()>0) {
            List<Member> addList = new ArrayList<>();
@@ -298,7 +307,6 @@
        }else{
            throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "同步ERP数据为空!");
        }
    }
    public void dealRoleEmpower(Member member,Date startTime , Date endTime){
@@ -715,9 +723,9 @@
            if(Objects.isNull(param)
                    ||Objects.isNull(param.getId())
                    ||StringUtils.isBlank(param.getName())
                    ||StringUtils.isBlank(param.getLinkName())
                    ||StringUtils.isBlank(param.getLinkPhone())
                    ||Objects.isNull(param.getEditDate())
//                    ||StringUtils.isBlank(param.getLinkName())
//                    ||StringUtils.isBlank(param.getLinkPhone())
//                    ||Objects.isNull(param.getEditDate())
            ){
                throw new BusinessException(ResponseStatus.BAD_REQUEST);
            }
@@ -729,6 +737,7 @@
                    throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到上级组织数据");
                }
            }
            String rootOrgId = systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_ROOTORG_CODE).getCode();
            if(Objects.isNull(company)){
                company = new Company();
                company.setId(null);
@@ -736,9 +745,14 @@
                company.setHkStatus(Constants.ZERO);
                company.setErpStatus(Constants.ONE);
                company.setErpDate(new Date());
                company.setName(param.getName());
               /* if(StringUtils.isNotBlank(param.getParentId())){
                    company.setHkId(rootOrgId);
                }*/
                company.setErpId(param.getId());
                company.setErpParentId(param.getParentId());
                company.setParentId(Objects.isNull(parentCompany)?null:parentCompany.getId());
                company.setErpParentId(param.getParentId());
                company.setFsStatus(Constants.ZERO);
                company.setType(Constants.ONE);
                company.setLinkName(param.getLinkName());
@@ -749,8 +763,12 @@
//                BeanUtils.copyProperties(param,company);
                company.setEditDate(new Date());
                company.setErpId(param.getId());
            /*    if(StringUtils.isNotBlank(param.getParentId())){
                    company.setHkId(rootOrgId);
                }*/
                company.setHkStatus(Constants.ZERO);
                company.setErpDate(new Date());
                company.setName(param.getName());
                company.setErpParentId(param.getParentId());
                company.setParentId(Objects.isNull(parentCompany)?null:parentCompany.getId());
                company.setLinkName(param.getLinkName());
@@ -771,16 +789,16 @@
    public void userUpdate(UserUpdateRequest param){
        try{
            if(Objects.isNull(param)
                    ||Objects.isNull(param.getId())
                    ||StringUtils.isBlank(param.getName())
                    ||StringUtils.isBlank(param.getIdNo())
                    ||Objects.isNull(param.getIdType())
                    ||Objects.isNull(param.getSex())
                    ||Objects.isNull(param.getOrgId())
                    ||StringUtils.isNotBlank(param.getFaceImg())
                    ||StringUtils.isNotBlank(param.getCode())
                    ||StringUtils.isNotBlank(param.getPhone())
                    ||Objects.isNull(param.getEditDate())){
                    ||Objects.isNull(param.getId())//编码
                    ||StringUtils.isBlank(param.getName())//名称
                    ||StringUtils.isBlank(param.getIdNo())//证件号
                    ||Objects.isNull(param.getIdType())//证件类型
                    ||Objects.isNull(param.getSex())//性别
                    ||Objects.isNull(param.getOrgId())//所属组织编码
                    ||StringUtils.isBlank(param.getFaceImg())//人脸照片
                    ||StringUtils.isBlank(param.getCode())//工号
                    ||StringUtils.isBlank(param.getPhone())//手机号
             ){
                throw new BusinessException(ResponseStatus.BAD_REQUEST);
            }
            Member member = memberMapper.selectOne(new QueryWrapper<Member>().lambda().eq(Member::getErpId,param.getId()).last("limit 1"));
@@ -972,7 +990,7 @@
                .set(ParkBook::getHkStatus,Constants.ZERO)
        );
        //查询车库信息
        List<Parks> parksList = parksMapper.selectList(new QueryWrapper<Parks>().lambda().in(Parks::getId,param.getPartIdList()));
        List<Parks> parksList = parksMapper.selectList(new QueryWrapper<Parks>().lambda().in(Parks::getId,param.getParkIdList()));
        if(CollectionUtils.isNotEmpty(parksList)){
            List<ParkBook> parkBookList = new ArrayList<>();
            for (Parks parks:parksList) {