From 39269c81905457378a73dc83050349d7a364a1f8 Mon Sep 17 00:00:00 2001
From: 田源 <tianyuan@vci-tech.com>
Date: 星期四, 16 一月 2025 18:00:49 +0800
Subject: [PATCH] 修改个人信息
---
Source/plt-web/plt-web-parent/plt-web-permission/src/main/java/com/vci/web/service/impl/SmUserQueryServiceImpl.java | 193 +++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 174 insertions(+), 19 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web-permission/src/main/java/com/vci/web/service/impl/SmUserQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web-permission/src/main/java/com/vci/web/service/impl/SmUserQueryServiceImpl.java
index 9c24c4f..bc6b3e2 100644
--- a/Source/plt-web/plt-web-parent/plt-web-permission/src/main/java/com/vci/web/service/impl/SmUserQueryServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web-permission/src/main/java/com/vci/web/service/impl/SmUserQueryServiceImpl.java
@@ -2,21 +2,27 @@
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;
@@ -24,29 +30,39 @@
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
* 鍏朵腑鍖呭惈鐧诲綍鐩稿叧鐨勬帴鍙e拰鍙傜収锛屾牴鎹富閿煡璇㈢瓑鎺ュ彛
@@ -88,6 +104,24 @@
private WebPwdStrategyQueryServiceI smPwdStrategyQueryService;
/**
+ * 鏂囦欢鐨勫嵎鏈嶅姟
+ */
+ @Autowired
+ private VciFileVolumeServiceI vciFileVolumeServiceI;
+
+ /**
+ * 鐗堟湰鍜屽璞℃搷浣滅被
+ */
+ @Autowired(required = false)
+ private RevisionModelUtil revisionModelUtil;
+
+ /**
+ * 閰嶇疆瀵硅薄
+ */
+ @Autowired
+ private WebProperties webProperties;
+
+ /**
* 浣跨敤瑙掕壊鐨勫睘鎬ф煡璇㈢敤鎴锋椂
*/
private final static String QUERY_BY_ROLE_KEY_PREFIX = "pkrole.";
@@ -143,6 +177,18 @@
private Logger logger = LoggerFactory.getLogger(getClass());
/**
+ * 鏂囦欢涓婁紶涓氬姟灞�
+ */
+ @Autowired
+ private VciFileUploadServiceI vciFileUploadServiceI;
+
+ /**
+ * 鏂囦欢淇℃伅鏁版嵁灞�
+ */
+ @Resource
+ private VciFileObjectDaoI vciFileObjectMapper;
+
+ /**
* 骞冲彴閰嶇疆
*/
private OsConfig osConfig;
@@ -390,6 +436,7 @@
smUserVO.setLastModifier(userInfo.updateUser);
smUserVO.setLastLoginTime(VciDateUtil.long2Date(userInfo.updateTime));
smUserVO.setLastModifyPasswordTime(VciDateUtil.long2Date(userInfo.pwdUpdateTime));
+ smUserVO.setPhoto(userInfo.photo);
return smUserVO;
}
@@ -1341,19 +1388,32 @@
@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[] { "褰撳墠淇敼鐨勭敤鎴蜂笉瀛樺湪"});
@@ -1457,6 +1517,7 @@
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;
}
@@ -1486,7 +1547,8 @@
@Transactional(rollbackFor = Exception.class)
public boolean stopUsers(String[] ids, boolean flag) throws PLException {
VciBaseUtil.alertNotNull(ids,"鍋滅敤/鍚敤鐨勭敤鎴穒d鍒楄〃");
- return platformClientUtil.getFrameworkService().stopUsers(ids, flag,null);
+
+ return platformClientUtil.getFrameworkService().stopUsers(ids, flag,new UserEntityInfo(WebUtil.getCurrentUserId(),"鐢ㄦ埛绠$悊"));
}
/**
@@ -1776,6 +1838,99 @@
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 = "";
--
Gitblit v1.10.0