generated from dxfeng/secondev-wugang-dxfeng
parent
325a79c870
commit
50de564224
|
|
@ -1,12 +1,22 @@
|
|||
package com.weaver.seconddev.entry.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.entry.service.EntryManageService;
|
||||
import com.weaver.teams.hrapp.dto.est.HrComEstEmpDto;
|
||||
import com.weaver.teams.hrapp.dto.est.HrComEstOrgValResDto;
|
||||
import com.weaver.teams.hrapp.dto.est.param.HrComEstCheckParam;
|
||||
import com.weaver.teams.hrapp.service.HrComEstService;
|
||||
import com.weaver.teams.security.context.UserContext;
|
||||
import com.weaver.teams.security.user.User;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -22,6 +32,9 @@ public class EntryManageController {
|
|||
|
||||
@Autowired
|
||||
EntryManageService entryManageService;
|
||||
@Autowired
|
||||
HrComEstService hrComEstService;
|
||||
|
||||
@GetMapping("/checkJobNum")
|
||||
public WeaResult<Map<String, Object>> checkJobNum(@RequestParam("jobNum") String jobNum) {
|
||||
return entryManageService.checkJobNum(jobNum);
|
||||
|
|
@ -31,4 +44,30 @@ public class EntryManageController {
|
|||
private WeaResult<Map<String, Object>> uploadFiles(@RequestBody Map<String, String> params) {
|
||||
return entryManageService.uploadFiles(params);
|
||||
}
|
||||
|
||||
@PostMapping("/testStaff")
|
||||
private WeaResult<Map<String,Object>> testStaff(@RequestBody HrComEstCheckParam checkParam) {
|
||||
//return entryManageService.testStaff(params);
|
||||
User currentUser = UserContext.getCurrentUser();
|
||||
log.error("checkParam==={}", JSON.toJSONString(checkParam));
|
||||
log.error("currentUser==={}", JSON.toJSONString(currentUser));
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
|
||||
HrComEstOrgValResDto hrComEstOrgValResDto = hrComEstService.estValidate(currentUser.getTenantKey(), currentUser.getEmployeeId(), checkParam);
|
||||
log.error("hrComEstOrgValResDto==={}", JSON.toJSONString(hrComEstOrgValResDto));
|
||||
|
||||
map.put("currentUser", JSON.toJSONString(currentUser));
|
||||
map.put("checkParam", JSON.toJSONString(checkParam));
|
||||
map.put("hrComEstOrgValResDto", JSON.toJSONString(hrComEstOrgValResDto));
|
||||
return WeaResult.success(map);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
HrComEstCheckParam checkParam = new HrComEstCheckParam();
|
||||
List<HrComEstEmpDto> empList = new ArrayList<>();
|
||||
HrComEstEmpDto emp = new HrComEstEmpDto();
|
||||
emp.setNewDepartmentId(1151352978370437120L);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public interface EntryManageService {
|
|||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param fileIds 文件ID
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
WeaResult<Map<String, Object>> uploadFiles(Map<String, String> params);
|
||||
|
|
|
|||
|
|
@ -5,8 +5,13 @@ import cn.hutool.http.HttpRequest;
|
|||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.form.metadata.field.FormField;
|
||||
import com.weaver.eteams.file.client.file.FileData;
|
||||
import com.weaver.eteams.file.client.file.FileObj;
|
||||
import com.weaver.eteams.file.client.param.RemoteUploadParam;
|
||||
import com.weaver.eteams.file.client.remote.FileClientService;
|
||||
import com.weaver.file.ud.api.FileDownloadService;
|
||||
import com.weaver.file.ud.api.FileUploadService;
|
||||
import com.weaver.seconddev.entry.entity.FileUploadLoad;
|
||||
import com.weaver.seconddev.entry.enums.FileUploadType;
|
||||
import com.weaver.seconddev.entry.mapper.EntryManageMapper;
|
||||
|
|
@ -22,6 +27,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
|
@ -42,6 +48,12 @@ public class EntryManageServiceImpl implements EntryManageService {
|
|||
@Autowired
|
||||
FileClientService fileClientService;
|
||||
|
||||
@Autowired
|
||||
FileUploadService fileUploadService;
|
||||
|
||||
@Autowired
|
||||
private FileDownloadService fileDownloadService;
|
||||
|
||||
@Autowired
|
||||
EbuilderBaseMapper ebuilderBaseMapper;
|
||||
|
||||
|
|
@ -83,18 +95,18 @@ public class EntryManageServiceImpl implements EntryManageService {
|
|||
}
|
||||
String formatDate = DateUtil.formatDateTime(localDate, DateTimeFormatter.ofPattern("yyyyMMddHHmm"));
|
||||
|
||||
FileUploadLoad fileUploadLoad = new FileUploadLoad(fileObj.getName(), formatDate,field);
|
||||
FileUploadLoad fileUploadLoad = new FileUploadLoad(fileObj.getName(), formatDate, field);
|
||||
fileObj.setName(fileUploadLoad.getFileName());
|
||||
fileClientService.update(fileObj);
|
||||
log.error("fileUploadLoad==={}", fileUploadLoad);
|
||||
fileUploadLoadList.add(fileUploadLoad);
|
||||
}
|
||||
|
||||
log.error("fileUploadLoadList==={}", fileUploadLoadList);
|
||||
Map<String, List<FileUploadLoad>> fileUploadMap = fileUploadLoadList.stream().collect(Collectors.groupingBy(FileUploadLoad::getJobNum));
|
||||
|
||||
|
||||
JSONArray datas = new JSONArray();
|
||||
Long formId = ebuilderBaseMapper.getFormIdByTableName(baseParam, "uf_jcl_rzgl");
|
||||
|
||||
for (Map.Entry<String, List<FileUploadLoad>> entry : fileUploadMap.entrySet()) {
|
||||
String jobNum = entry.getKey();
|
||||
// 入职记录ID
|
||||
|
|
@ -105,15 +117,15 @@ public class EntryManageServiceImpl implements EntryManageService {
|
|||
List<FileUploadLoad> personFileUploadLoadList = entry.getValue();
|
||||
|
||||
// 根据文件类型分组,并将同一类别的附件ID用逗号分隔
|
||||
Map<String, String> fileTypeMap = personFileUploadLoadList.stream().collect(Collectors.groupingBy(FileUploadLoad::getFileTypeName, Collectors.mapping(item -> item.getFileId().toString(), Collectors.joining(","))));
|
||||
Map<String, List<FileUploadLoad>> fileTypeMap = personFileUploadLoadList.stream().collect(Collectors.groupingBy(FileUploadLoad::getFileTypeName));
|
||||
// 组合更新的JOSN对象
|
||||
JSONObject mainDataObj = new JSONObject();
|
||||
mainDataObj.put("id", entryRecordId);
|
||||
fileTypeMap.forEach((fileTypeName, ids) -> {
|
||||
fileTypeMap.forEach((fileTypeName, list) -> {
|
||||
FileUploadType byName = FileUploadType.getByName(fileTypeName);
|
||||
if (null != byName) {
|
||||
// 构建更新数据
|
||||
mainDataObj.put(byName.getDbName(), ids);
|
||||
String fieldIds = reUploadFiled(entryRecordId, list, formId, byName.getDbName());
|
||||
mainDataObj.put(byName.getDbName(), fieldIds);
|
||||
}
|
||||
});
|
||||
JSONObject dataObj = new JSONObject();
|
||||
|
|
@ -126,12 +138,19 @@ public class EntryManageServiceImpl implements EntryManageService {
|
|||
Long userId = UserContext.getCurrentUser().getEmployeeId();
|
||||
|
||||
String updateMsg = updateEbTable(datas, String.valueOf(objId), String.valueOf(userId));
|
||||
log.error("updateMsg===" + updateMsg);
|
||||
Map<String, Object> actionMap = new HashMap<>();
|
||||
actionMap.put("updateMsg", updateMsg);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新EB表单数据
|
||||
*
|
||||
* @param datas
|
||||
* @param objId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
private String updateEbTable(JSONArray datas, String objId, String userId) {
|
||||
JSONObject dataJson = new JSONObject();
|
||||
JSONObject operationinfo = new JSONObject();
|
||||
|
|
@ -160,4 +179,37 @@ public class EntryManageServiceImpl implements EntryManageService {
|
|||
.execute()
|
||||
.body();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件上传到EB
|
||||
*
|
||||
* @param entryRecordId
|
||||
* @param fileUploadLoadList
|
||||
* @param formId
|
||||
* @param fieldName
|
||||
* @return
|
||||
*/
|
||||
private String reUploadFiled(Long entryRecordId, List<FileUploadLoad> fileUploadLoadList, Long formId, String fieldName) {
|
||||
List<String> newFieldIds = new ArrayList<>();
|
||||
FormField formField = ebuilderBaseMapper.getFormFieldByFieldName(baseParam, formId, fieldName);
|
||||
if (null != formField) {
|
||||
Long folderIdByFieldId = ebuilderBaseMapper.getFolderIdByFieldId(baseParam, formField.getId());
|
||||
for (FileUploadLoad fileUploadLoad : fileUploadLoadList) {
|
||||
FileData fileData = fileDownloadService.downloadFile(fileUploadLoad.getFileId());
|
||||
FileObj fileObj = fileData.getFileObj();
|
||||
RemoteUploadParam uploadParam = new RemoteUploadParam(fileObj.getName(), String.valueOf(System.currentTimeMillis()), "ebuilderform");
|
||||
uploadParam.setRefId(entryRecordId);
|
||||
uploadParam.setFolderId(folderIdByFieldId);
|
||||
|
||||
InputStream inputStream = fileData.getInputStream();
|
||||
FileObj fileObj1 = fileUploadService.uploadLocalFile(inputStream, UserContext.getCurrentUser().getEmployeeId(), fileObj.getType(), uploadParam);
|
||||
if (null != fileObj1) {
|
||||
newFieldIds.add(fileObj1.getId().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return StringUtils.join(newFieldIds, ",");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,9 +45,12 @@ public interface EbuilderBaseMapper {
|
|||
|
||||
/**
|
||||
* 根据表名获取对象ID
|
||||
*
|
||||
* @param param
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
Long getObjIdByTableName(@Param("param") BaseParam param, @Param("tableName") String tableName);
|
||||
|
||||
Long getFolderIdByFieldId(@Param("param") BaseParam param, @Param("fieldId") Long fieldId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,10 @@
|
|||
and t.table_name = #{tableName}
|
||||
</select>
|
||||
|
||||
<select id="getFolderIdByFieldId" resultType="java.lang.Long">
|
||||
select t.folder_id from ${param.e10_common}.form_attachment_config t where
|
||||
t.tenant_key = #{param.tenantKey} and t.delete_type = 0
|
||||
and t.field_id = #{fieldId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue