| | |
| | | |
| | | import com.vci.common.util.ThreeDES; |
| | | import com.vci.common.utility.ObjectUtility; |
| | | import com.vci.constant.FrameWorkLangCodeConstant; |
| | | import com.vci.constant.WebLangCodeConstant; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.common.data.UserEntityInfo; |
| | | import com.vci.corba.framework.data.*; |
| | | import com.vci.corba.omd.data.BusinessObject; |
| | | import com.vci.corba.omd.etm.EnumItem; |
| | | import com.vci.corba.omd.etm.EnumType; |
| | | import com.vci.corba.volume.VolumeServicePrx; |
| | | import com.vci.dto.SmUserDTO; |
| | | import com.vci.dto.VciFileObjectDTO; |
| | | import com.vci.enumpck.UI.OrgTypeEnum; |
| | | import com.vci.enumpck.UI.VciFileTransProtocolEnum; |
| | | import com.vci.enumpck.UserTypeEnum; |
| | | import com.vci.lcstatuspck.FileLCStatus; |
| | | import com.vci.model.SmUserDO; |
| | | import com.vci.model.VciFileDocClassifyDO; |
| | | import com.vci.model.VciFileObjectDO; |
| | | import com.vci.model.VciFileVolumeDO; |
| | | import com.vci.omd.utils.ObjectTool; |
| | | import com.vci.pagemodel.OrgDepartmentVO; |
| | | import com.vci.pagemodel.SmPasswordStrategyVO; |
| | | import com.vci.pagemodel.SmRoleVO; |
| | | import com.vci.pagemodel.SmUserVO; |
| | | import com.vci.pagemodel.*; |
| | | import com.vci.po.SmUserPO; |
| | | import com.vci.properties.OsConfig; |
| | | import com.vci.starter.poi.bo.ReadExcelOption; |
| | |
| | | import com.vci.starter.poi.bo.WriteExcelOption; |
| | | import com.vci.starter.poi.constant.ExcelLangCodeConstant; |
| | | import com.vci.starter.poi.util.ExcelUtil; |
| | | import com.vci.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.starter.web.enumpck.BooleanEnum; |
| | | import com.vci.starter.web.enumpck.DataSecretEnum; |
| | | import com.vci.starter.web.enumpck.UserSecretEnum; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.*; |
| | | import com.vci.starter.web.util.*; |
| | | import com.vci.starter.web.util.Lcm.Func; |
| | | import com.vci.starter.web.wrapper.VciQueryWrapperForDO; |
| | | import com.vci.web.dao.VciFileObjectDaoI; |
| | | import com.vci.web.properties.WebProperties; |
| | | import com.vci.web.service.*; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.hssf.util.HSSFColor; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import javax.annotation.Resource; |
| | | import java.io.*; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.constant.FrameWorkLangCodeConstant.UPLOAD_FAIL; |
| | | |
| | | /** |
| | | * 用户的查询相关的服务,可以兼容老平台和老的pdm |
| | |
| | | */ |
| | | @Autowired |
| | | private WebPwdStrategyQueryServiceI smPwdStrategyQueryService; |
| | | |
| | | /** |
| | | * 文件的卷服务 |
| | | */ |
| | | @Autowired |
| | | private VciFileVolumeServiceI vciFileVolumeServiceI; |
| | | |
| | | /** |
| | | * 版本和对象操作类 |
| | | */ |
| | | @Autowired(required = false) |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | /** |
| | | * 配置对象 |
| | | */ |
| | | @Autowired |
| | | private WebProperties webProperties; |
| | | |
| | | /** |
| | | * 使用角色的属性查询用户时 |
| | |
| | | * 日志 |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | /** |
| | | * 文件上传业务层 |
| | | */ |
| | | @Autowired |
| | | private VciFileUploadServiceI vciFileUploadServiceI; |
| | | |
| | | /** |
| | | * 文件信息数据层 |
| | | */ |
| | | @Resource |
| | | private VciFileObjectDaoI vciFileObjectMapper; |
| | | |
| | | /** |
| | | * 平台配置 |
| | |
| | | smUserVO.setLastModifier(userInfo.updateUser); |
| | | smUserVO.setLastLoginTime(VciDateUtil.long2Date(userInfo.updateTime)); |
| | | smUserVO.setLastModifyPasswordTime(VciDateUtil.long2Date(userInfo.pwdUpdateTime)); |
| | | smUserVO.setPhoto(userInfo.photo); |
| | | return smUserVO; |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateUser(SmUserDTO smUserDTO) throws PLException { |
| | | //判空 |
| | | VciBaseUtil.alertNotNull( |
| | | smUserDTO,"修改的用户对象", |
| | | smUserDTO.getOid(),"用户主键", |
| | | smUserDTO.getId(),"用户名", |
| | | smUserDTO.getPassword(),"密码", |
| | | smUserDTO.getConfirmPassword(),"确认密码", |
| | | smUserDTO.getName(),"姓名" |
| | | ); |
| | | //校验 |
| | | check(smUserDTO,false,false); |
| | | //查询数据库中的 |
| | | SmUserVO dbSmUserVO = getUserByUserOid(smUserDTO.getOid()); |
| | | SmUserVO dbSmUserVO; |
| | | if(StringUtils.isBlank(smUserDTO.getId()) && StringUtils.isNotBlank(smUserDTO.getOid()) |
| | | && StringUtils.isNotBlank(smUserDTO.getName())){ |
| | | |
| | | //查询数据库中的 |
| | | dbSmUserVO = getUserByUserOid(smUserDTO.getOid()); |
| | | dbSmUserVO.setName(smUserDTO.getName()); |
| | | dbSmUserVO.setEmail(smUserDTO.getEmail()); |
| | | BeanUtils.copyProperties(dbSmUserVO,smUserDTO); |
| | | //校验 |
| | | check(smUserDTO,false,false); |
| | | }else{ |
| | | //判空 |
| | | VciBaseUtil.alertNotNull( |
| | | smUserDTO,"修改的用户对象", |
| | | smUserDTO.getOid(),"用户主键", |
| | | smUserDTO.getId(),"用户名", |
| | | smUserDTO.getPassword(),"密码", |
| | | smUserDTO.getConfirmPassword(),"确认密码", |
| | | smUserDTO.getName(),"姓名" |
| | | ); |
| | | //校验 |
| | | check(smUserDTO,false,false); |
| | | //查询数据库中的 |
| | | dbSmUserVO = getUserByUserOid(smUserDTO.getOid()); |
| | | } |
| | | //根据主键没查询到了用户 |
| | | if(Func.isEmpty(dbSmUserVO) || Func.isBlank(dbSmUserVO.getOid())){ |
| | | throw new PLException("500", new String[] { "当前修改的用户不存在"}); |
| | |
| | | userInfo.grantor = user.getGrantor() == null ? "" : user.getGrantor(); |
| | | userInfo.secretGrade = user.getSecretGrade() == null ? 2 : Integer.valueOf(user.getSecretGrade()); |
| | | userInfo.isDeptLeader = user.getIsDeptLeader() == null ? "0" : user.getIsDeptLeader(); |
| | | userInfo.photo = user.getPhoto() == null ? "" : user.getPhoto(); |
| | | return userInfo; |
| | | } |
| | | |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean stopUsers(String[] ids, boolean flag) throws PLException { |
| | | VciBaseUtil.alertNotNull(ids,"停用/启用的用户id列表"); |
| | | return platformClientUtil.getFrameworkService().stopUsers(ids, flag,null); |
| | | |
| | | return platformClientUtil.getFrameworkService().stopUsers(ids, flag,new UserEntityInfo(WebUtil.getCurrentUserId(),"用户管理")); |
| | | } |
| | | |
| | | /** |
| | |
| | | ExcelUtil.writeDataToFile(excelPath, excelOption); |
| | | return excelPath; |
| | | } |
| | | /** |
| | | * 修改用户头像 |
| | | * @param file 文件 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateUserPhoto(MultipartFile file) throws PLException { |
| | | //获取文件仓位置 |
| | | VciFileVolumeDO vciFileVolumeDO = vciFileVolumeServiceI.getUploadVolume(); |
| | | String volumeName = vciFileVolumeDO.getName(); |
| | | VolumeServicePrx volumnCorbaService = platformClientUtil.getVolumeService(volumeName); |
| | | if(volumnCorbaService == null){ |
| | | throw new VciBaseException("没有获取到卷服务"); |
| | | } |
| | | InputStream in = null; |
| | | String path = vciFileVolumeDO.getId() + ":/userphoto/" + WebUtil.getSessionInfo().getUserOid() + "." + |
| | | FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | UserInfo userInfo = platformClientUtil.getFrameworkService().getUserObjectByoid(WebUtil.getSessionInfo().getUserOid()); |
| | | if(StringUtils.isNotBlank(userInfo.photo)){ |
| | | volumnCorbaService.deleteFile(userInfo.photo); |
| | | } |
| | | try{ |
| | | long currentTime = volumnCorbaService.getCurrrentTimeMillions(); |
| | | in = file.getInputStream(); |
| | | long fileSize = file.getSize(); |
| | | int blockSize = webProperties.getBlockLength()*1024; |
| | | byte[] buffer = new byte[blockSize]; |
| | | long temp =0L; |
| | | for(temp = 0L; temp < fileSize - (long)blockSize; temp += (long)blockSize) { |
| | | in.read(buffer, 0, blockSize); |
| | | volumnCorbaService.receiveFile(path, buffer, temp, currentTime, fileSize); |
| | | } |
| | | int remainSize = (int)(fileSize - temp); |
| | | buffer = new byte[remainSize]; |
| | | in.read(buffer, 0, remainSize); |
| | | volumnCorbaService.receiveFile(path, buffer, temp, currentTime, fileSize); |
| | | }catch(IOException e){ |
| | | throw new VciBaseException("读取文件[" + file.getName() + "]出现了错误," + e.getMessage() ,new String[0],e); |
| | | }catch(Exception e){ |
| | | throw new VciBaseException("处理上传文件[" + file.getName() + "]出现了错误," + e.getMessage() ,new String[0],e); |
| | | }finally { |
| | | if(in!=null){ |
| | | try { |
| | | in.close(); |
| | | } catch (IOException e) { |
| | | } |
| | | } |
| | | } |
| | | userInfo.photo = path; |
| | | boolean b = platformClientUtil.getFrameworkService().updateUser(userInfo, new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(), null)); |
| | | if(!b){ |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public String getUserPhoto() throws PLException { |
| | | //获取文件仓位置 |
| | | VciFileVolumeDO vciFileVolumeDO = vciFileVolumeServiceI.getUploadVolume(); |
| | | String volumeName = vciFileVolumeDO.getName(); |
| | | VolumeServicePrx volumnCorbaService = platformClientUtil.getVolumeService(volumeName); |
| | | if(volumnCorbaService == null){ |
| | | throw new VciBaseException("没有获取到卷服务"); |
| | | } |
| | | UserInfo userInfo = platformClientUtil.getFrameworkService().getUserObjectByoid(WebUtil.getSessionInfo().getUserOid()); |
| | | String serverPath = userInfo.photo; |
| | | String tempFilePath = LocalFileUtil.getDefaultTempFolder() + File.separator+serverPath.substring(serverPath.lastIndexOf("/") + 1); |
| | | try { |
| | | FileOutputStream destFileOs = new FileOutputStream(tempFilePath); |
| | | long blockSize = webProperties.getBlockLength()*1024; |
| | | if(blockSize> Integer.MAX_VALUE){ |
| | | blockSize = Integer.MAX_VALUE; |
| | | } |
| | | long fileSize = volumnCorbaService.getFileSize(serverPath); |
| | | long temp = 0; |
| | | while (fileSize - temp > blockSize) { |
| | | destFileOs.write(volumnCorbaService.sendFile(serverPath, temp)); |
| | | temp += blockSize; |
| | | } |
| | | destFileOs.write(volumnCorbaService.sendFile(serverPath, temp)); |
| | | destFileOs.flush(); |
| | | destFileOs.close(); |
| | | } catch (FileNotFoundException e) { |
| | | throw new VciBaseException("要写入的文件没有找到",new String[]{tempFilePath},e); |
| | | } catch (IOException e) { |
| | | throw new VciBaseException("写入文件出错" + e.getMessage(),new String[]{tempFilePath},e); |
| | | } catch (Exception e){ |
| | | throw new VciBaseException("卷服务传输文件时出现了错误" + e.getMessage(),new String[0],e); |
| | | } |
| | | return tempFilePath; |
| | | } |
| | | |
| | | //根据子部门查询所属的父类部门,并拼接成字符串形式,返回 |
| | | public String getDeptObjectAllByDeptId(DeptInfo obj) throws PLException { |
| | | String fetchDepName = ""; |