| | |
| | | package doumeemes.service.system.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iflytek.antelope.other.client.dto.resp.UserDTO; |
| | | import doumeemes.biz.system.SystemDictDataBiz; |
| | | import doumeemes.config.shiro.ShiroToken; |
| | |
| | | import doumeemes.core.utils.dingding.LingyangUtil; |
| | | import doumeemes.core.utils.edpg.EdgpServerUtil; |
| | | import doumeemes.core.utils.edpg.bean.AppUserInfoModel; |
| | | import doumeemes.core.utils.excel.EasyExcelUtil; |
| | | import doumeemes.dao.business.BizLingyangMapper; |
| | | import doumeemes.dao.business.dto.AutoLoginUserDTO; |
| | | import doumeemes.dao.business.model.BizLingyang; |
| | | import doumeemes.dao.business.model.Company; |
| | | import doumeemes.dao.business.model.CompanyUser; |
| | | import doumeemes.dao.business.model.Material; |
| | | import doumeemes.dao.ext.CompanyExtMapper; |
| | | import doumeemes.dao.ext.CompanyUserExtMapper; |
| | | import doumeemes.dao.ext.dto.LingYangUserDto; |
| | | import doumeemes.dao.ext.dto.QueryCompanyUserExtDTO; |
| | | import doumeemes.dao.ext.vo.CompanyExtListVO; |
| | | import doumeemes.dao.ext.vo.CompanyUserExtListVO; |
| | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.authc.AuthenticationException; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | |
| | | @Autowired |
| | | private CompanyUserExtMapper companyUserExtMapper; |
| | | @Autowired |
| | | private BizLingyangMapper bizLingyangMapper; |
| | | @Autowired |
| | | private CompanyExtMapper companyExtMapper; |
| | | |
| | |
| | | systemLoginLogService.create(loginLog); |
| | | throw ee; |
| | | } |
| | | } |
| | | // @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | @Override |
| | | public String importLyAuth(MultipartFile file,HttpServletRequest request) { |
| | | //解析excel |
| | | List<AutoLoginUserDTO> materialList = EasyExcelUtil.importExcel(file, 0, 1, AutoLoginUserDTO.class); |
| | | if (materialList == null || materialList.size() == 0) { |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "导入数据内容有误!"); |
| | | } |
| | | int num = 0; |
| | | for(AutoLoginUserDTO u : materialList){ |
| | | UserDTO user = new UserDTO(); |
| | | BeanUtils.copyProperties(u, user); |
| | | user.setManager("1"); |
| | | user.setOrgName(user.getName()); |
| | | Date date = null; |
| | | if(StringUtils.isBlank(user.getName())){ |
| | | continue; |
| | | } |
| | | try { |
| | | date = new Date(u.getDate().getTime()+ (long) Math.random()*60*1000); |
| | | }catch (Exception e){ |
| | | } |
| | | boolean r = logiglingyangModel(user,date,"lingyang_import",request,false); |
| | | num = r?(num+1):num; |
| | | } |
| | | return "成功导入【"+num+"】个,失败【"+(materialList.size()-num)+"】个"; |
| | | |
| | | } |
| | | public boolean logiglingyangModel(UserDTO user,Date date,String remark, HttpServletRequest request,boolean isDemo){ |
| | | SystemLoginLog loginLog = new SystemLoginLog(); |
| | | loginLog.setLoginUsername("lingyangAuto_"+JSONObject.toJSONString(user)); |
| | | loginLog.setLoginTime(date); |
| | | loginLog.setOrgin(Constants.USER_LOGIN_ORIGIN.lingyang); |
| | | loginLog.setSystemVersion(systemVersion); |
| | | loginLog.setIp(Utils.User_Client.getIP(request)); |
| | | loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | loginLog.setPlatform(Utils.User_Client.getPlatform(request)); |
| | | loginLog.setClientInfo(Utils.User_Client.getBrowser(request)); |
| | | loginLog.setOsInfo(Utils.User_Client.getOS(request)); |
| | | loginLog.setServerIp(Utils.Server.getIP()); |
| | | String mobile = null; |
| | | if(user == null){ |
| | | return false; |
| | | } |
| | | //查询企业信息 |
| | | Company qc = new Company(); |
| | | qc.setDeleted(Constants.ZERO); |
| | | qc.setCreditCode(user.getCreditCode()); |
| | | qc.setOrigin(Constants.COMPANY_ORIGIN.lingyang); |
| | | //根据行政区代码查询企业信息 |
| | | if(companyExtMapper.selectOne(new QueryWrapper<>(qc).last(" limit 1") )!=null){ |
| | | return false; |
| | | } |
| | | |
| | | Company com = companyExtService.createByLingyang(user,date,remark,systemDictDataBiz.queryByCode(Constants.DEFAULT,Constants.USER_PWD).getCode()); |
| | | if(com == null){ |
| | | return false; |
| | | } |
| | | //企业用户信息 |
| | | CompanyUserExtListVO model =com.getUserModel(); |
| | | if(model != null && StringUtils.isNotBlank(model.getPhone())){ |
| | | mobile=model.getPhone(); |
| | | }else{ |
| | | //获取羚羊手机号 |
| | | mobile= user.getPhone(); |
| | | } |
| | | loginLog.setLoginUsername(mobile); |
| | | loginLog.setUserId(model.getUserId()); |
| | | loginLog.setCompanyId(com.getId()); |
| | | loginLog.setCompanyUserId(model.getId()); |
| | | loginLog.setSuccess(Boolean.TRUE); |
| | | systemLoginLogService.create(loginLog); |
| | | CompanyUser cu = new CompanyUser(); |
| | | cu.setLingyangUserid(user.getUserId()); |
| | | cu.setId(model.getId()); |
| | | cu.setName(user.getName());//同步羚羊的名字 |
| | | cu.setUpdateTime(new Date()); |
| | | //更新用户绑定的钉钉信息 |
| | | companyUserExtMapper.updateById(cu); |
| | | |
| | | BizLingyang biz = new BizLingyang(); |
| | | biz.setActionTimes(1); |
| | | biz.setCreateTime(date); |
| | | biz.setCreditCode(user.getCreditCode()); |
| | | biz.setCompanyId(com.getId()); |
| | | biz.setAppKey(systemDictDataBiz.queryByCode(Constants.LINGYANG_PARAM,Constants.LINGYANG_APPKEY ).getCode()); |
| | | biz.setUserPhone(user.getPhone()); |
| | | // biz.setRemark(remark); |
| | | bizLingyangMapper.insert(biz); |
| | | return true; |
| | | |
| | | } |
| | | @Override |
| | | public String getDingdingCorpId(Integer companyId){ |
| | |
| | | throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT); |
| | | } |
| | | //查询企业信息 |
| | | Company com = companyExtService.createByLingyang(user,systemDictDataBiz.queryByCode(Constants.DEFAULT,Constants.USER_PWD).getCode()); |
| | | Company com = companyExtService.createByLingyang(user,new Date(),null,systemDictDataBiz.queryByCode(Constants.DEFAULT,Constants.USER_PWD).getCode()); |
| | | if(com == null){ |
| | | throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT); |
| | | } |