优化
This commit is contained in:
@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.ruoyi.common.constant.Constants.WGZ;
|
import static com.ruoyi.common.constant.Constants.WGZ;
|
||||||
@ -109,8 +110,9 @@ public class AnnexController extends BaseController {
|
|||||||
.eq(Annex::getRecruitId, recruitId)
|
.eq(Annex::getRecruitId, recruitId)
|
||||||
.eq(Annex::getUserId, userId)
|
.eq(Annex::getUserId, userId)
|
||||||
.eq(Annex::getUserType, WGZ)
|
.eq(Annex::getUserType, WGZ)
|
||||||
.eq(Annex::getAnnexType, annexType)
|
.eq(!"3".equals(annexType),Annex::getAnnexType, annexType)
|
||||||
);
|
.in("3".equals(annexType),Annex::getAnnexType, Arrays.asList("1","2")
|
||||||
|
));
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,11 @@ import com.ruoyi.bgt.domain.BgtProjectRecruit;
|
|||||||
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
|
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
|
||||||
import com.ruoyi.bgt.service.IBgtUserService;
|
import com.ruoyi.bgt.service.IBgtUserService;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.BgtUser;
|
import com.ruoyi.common.core.domain.entity.BgtUser;
|
||||||
import com.ruoyi.common.domain.Annex;
|
import com.ruoyi.common.domain.Annex;
|
||||||
import com.ruoyi.common.domain.AnnexRecord;
|
import com.ruoyi.common.domain.AnnexRecord;
|
||||||
|
import com.ruoyi.common.exception.BaseException;
|
||||||
import com.ruoyi.common.service.IAnnexRecordService;
|
import com.ruoyi.common.service.IAnnexRecordService;
|
||||||
import com.ruoyi.common.service.IAnnexService;
|
import com.ruoyi.common.service.IAnnexService;
|
||||||
import com.ruoyi.wgz.domain.WgzUser;
|
import com.ruoyi.wgz.domain.WgzUser;
|
||||||
@ -16,7 +18,6 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -57,18 +58,23 @@ public class UploadZipController {
|
|||||||
|
|
||||||
@ApiOperation("上传压缩文件")
|
@ApiOperation("上传压缩文件")
|
||||||
@PostMapping("/upload-zip")
|
@PostMapping("/upload-zip")
|
||||||
public ResponseEntity<String> uploadZipFile(@RequestParam("file") MultipartFile file, @RequestParam("recruitId") Long recruitId, @RequestParam("userId") Long userId) {
|
public AjaxResult<Void> uploadZipFile(@RequestParam("file") MultipartFile file, @RequestParam("recruitId") Long recruitId, @RequestParam("userId") Long userId) {
|
||||||
if (file.isEmpty()) {
|
if (file.isEmpty()) {
|
||||||
return ResponseEntity.badRequest().body("上传的文件为空");
|
throw new BaseException("上传的文件为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
String originalFilename = file.getOriginalFilename();
|
||||||
|
if (originalFilename == null || !originalFilename.toLowerCase().endsWith(".zip")) {
|
||||||
|
throw new BaseException("上传的文件不是有效的 ZIP 文件!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(recruitService.queryById(recruitId) == null){
|
if(recruitService.queryById(recruitId) == null){
|
||||||
return ResponseEntity.badRequest().body("招工信息不存在");
|
throw new BaseException("招工信息不存在!");
|
||||||
}
|
}
|
||||||
|
|
||||||
BgtUser bgtUser = bgtUserService.selectUserByUserId(userId);
|
BgtUser bgtUser = bgtUserService.selectUserByUserId(userId);
|
||||||
if (bgtUser == null){
|
if (bgtUser == null){
|
||||||
return ResponseEntity.badRequest().body("当前用户不存在!");
|
throw new BaseException("当前用户不存在!");
|
||||||
}
|
}
|
||||||
|
|
||||||
String username = bgtUser.getUsername();
|
String username = bgtUser.getUsername();
|
||||||
@ -97,10 +103,10 @@ public class UploadZipController {
|
|||||||
// 异步执行 RECORD_DIR 操作和删除临时文件操作
|
// 异步执行 RECORD_DIR 操作和删除临时文件操作
|
||||||
asyncProcessRecordAndDeleteTemp(extractDir, zipFile, recruitId,username,userId);
|
asyncProcessRecordAndDeleteTemp(extractDir, zipFile, recruitId,username,userId);
|
||||||
|
|
||||||
return ResponseEntity.ok("文件上传并处理成功");
|
return AjaxResult.success("文件上传并处理成功");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return ResponseEntity.status(500).body("文件处理过程中出现错误: " + e.getMessage());
|
return AjaxResult.error("文件处理过程中出现错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,10 @@ public class BgtPayCalculationDetailBaseVO {
|
|||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
private LocalDate entryTime;
|
private LocalDate entryTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("离场时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private LocalDate leaveTime;
|
||||||
|
|
||||||
@ApiModelProperty("总工资")
|
@ApiModelProperty("总工资")
|
||||||
private BigDecimal allAmount;
|
private BigDecimal allAmount;
|
||||||
|
|
||||||
|
@ -480,6 +480,7 @@ public class WgzPayCalculationServiceImpl extends ServicePlusImpl<WgzPayCalculat
|
|||||||
//招工申请信息
|
//招工申请信息
|
||||||
BgtProjectRecruitApply apply = iBgtProjectRecruitApplyService.getById(recruitApplyId);
|
BgtProjectRecruitApply apply = iBgtProjectRecruitApplyService.getById(recruitApplyId);
|
||||||
vo.setEntryTime(apply.getEntryTime());
|
vo.setEntryTime(apply.getEntryTime());
|
||||||
|
vo.setLeaveTime(apply.getLeaveTime());
|
||||||
|
|
||||||
//招工信息
|
//招工信息
|
||||||
Long recruitId = apply.getRecruitId();
|
Long recruitId = apply.getRecruitId();
|
||||||
|
332
ruoyi/uploadPath/appResource/html/upload.html
Normal file
332
ruoyi/uploadPath/appResource/html/upload.html
Normal file
@ -0,0 +1,332 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>文件上传管理系统</title>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://unpkg.com/element-plus/dist/index.css"
|
||||||
|
/>
|
||||||
|
<style>
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
height: 100vh;
|
||||||
|
padding: 20px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
.left-panel {
|
||||||
|
width: 300px;
|
||||||
|
padding: 20px;
|
||||||
|
border-right: 1px solid #ebeef5;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
.right-panel {
|
||||||
|
flex: 1;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.checkbox-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
.action-bar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
/* 拖拽上传区域样式 */
|
||||||
|
.upload-area {
|
||||||
|
height: 300px;
|
||||||
|
border: 2px dashed #dcdfe6;
|
||||||
|
border-radius: 6px;
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.upload-area .el-upload {
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.upload-area:hover {
|
||||||
|
border-color: #409eff;
|
||||||
|
}
|
||||||
|
.submit-btn {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="app">
|
||||||
|
<div class="container">
|
||||||
|
<!-- 左侧选择面板 -->
|
||||||
|
<div class="left-panel">
|
||||||
|
<h3>选择主题</h3>
|
||||||
|
<el-select
|
||||||
|
v-model="selectedTheme"
|
||||||
|
placeholder="请选择主题"
|
||||||
|
@change="handleThemeChange"
|
||||||
|
style="width: 100%; margin-bottom: 20px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in themeOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
|
||||||
|
<div class="action-bar">
|
||||||
|
<el-checkbox
|
||||||
|
v-model="checkAll"
|
||||||
|
:indeterminate="isIndeterminate"
|
||||||
|
@change="handleCheckAllChange"
|
||||||
|
>
|
||||||
|
全选({{ userIds.length }})
|
||||||
|
</el-checkbox>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="downloadTemplateFile"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
下载模板
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-loading="loading" class="checkbox-group">
|
||||||
|
<template v-if="currentList.length">
|
||||||
|
<el-checkbox
|
||||||
|
v-for="item in currentList"
|
||||||
|
:key="item.userId"
|
||||||
|
v-model="userIds"
|
||||||
|
:label="item.userId"
|
||||||
|
class="checkbox-item"
|
||||||
|
>
|
||||||
|
{{ item.username }}
|
||||||
|
</el-checkbox>
|
||||||
|
</template>
|
||||||
|
<div v-else class="el-upload__tip">{{ listStatusText }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 右侧上传面板 -->
|
||||||
|
<div class="right-panel">
|
||||||
|
<h3 style="margin-bottom: 15px">文件上传区域</h3>
|
||||||
|
<el-upload
|
||||||
|
ref="uploadRef"
|
||||||
|
class="upload-area"
|
||||||
|
drag
|
||||||
|
action="#"
|
||||||
|
:auto-upload="false"
|
||||||
|
:on-change="handleFileChange"
|
||||||
|
:limit="1"
|
||||||
|
:on-exceed="handleExceed"
|
||||||
|
:on-remove="handleFileRemove"
|
||||||
|
accept=".zip"
|
||||||
|
>
|
||||||
|
<div class="el-upload__text">
|
||||||
|
<i
|
||||||
|
class="el-icon-upload"
|
||||||
|
style="font-size: 40px; color: #409eff"
|
||||||
|
></i>
|
||||||
|
<div style="margin-top: 10px">
|
||||||
|
将文件拖到此处,或<em style="color: #409eff">点击上传</em>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-upload>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
class="submit-btn"
|
||||||
|
@click="submitUpload"
|
||||||
|
:disabled="!uploadFile"
|
||||||
|
>
|
||||||
|
确认上传
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
||||||
|
<script src="https://unpkg.com/element-plus/dist/index.full.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const { createApp } = Vue;
|
||||||
|
const app = createApp({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
baseUrl: "http://192.168.110.3:9099",
|
||||||
|
themeOptions: [],
|
||||||
|
selectedTheme: "",
|
||||||
|
currentList: [],
|
||||||
|
userIds: [],
|
||||||
|
loading: false,
|
||||||
|
listStatusText: "请先选择主题",
|
||||||
|
userId: "1893247598219890699",
|
||||||
|
checkAll: false,
|
||||||
|
isIndeterminate: false,
|
||||||
|
uploadFile: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getRecruitList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 初始化加载主题列表
|
||||||
|
async getRecruitList() {
|
||||||
|
this.loading = true;
|
||||||
|
try {
|
||||||
|
const response = await this.ajaxRequest({
|
||||||
|
url: `/ruoyi/app/bgt/recruit/htmlList?userId=${this.userId}`,
|
||||||
|
method: "GET",
|
||||||
|
});
|
||||||
|
|
||||||
|
this.themeOptions = response.data.map((item) => ({
|
||||||
|
value: item.id,
|
||||||
|
label: item.recruitName,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// 自动选中第一个主题
|
||||||
|
if (this.themeOptions.length > 0) {
|
||||||
|
this.selectedTheme = this.themeOptions[0].value;
|
||||||
|
this.handleThemeChange(this.selectedTheme);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 主题切换处理
|
||||||
|
async handleThemeChange(val) {
|
||||||
|
this.loading = true;
|
||||||
|
try {
|
||||||
|
const response = await this.ajaxRequest({
|
||||||
|
url: `/ruoyi/app/bgt/apply/htmlList?recruitId=${val}`,
|
||||||
|
method: "GET",
|
||||||
|
});
|
||||||
|
this.currentList = response.data;
|
||||||
|
this.userIds = [];
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 文件超出限制处理
|
||||||
|
handleExceed(files) {
|
||||||
|
this.$refs.uploadRef.clearFiles();
|
||||||
|
const file = files[0];
|
||||||
|
file.uid = ElementPlus.genFileId();
|
||||||
|
this.$refs.uploadRef.handleStart(file);
|
||||||
|
this.uploadFile = file;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 文件变化处理
|
||||||
|
handleFileChange(file) {
|
||||||
|
console.log("文件", file.raw?.type);
|
||||||
|
|
||||||
|
if (
|
||||||
|
file.raw?.type != "application/zip" &&
|
||||||
|
file.raw?.type != "application/x-zip-compressed"
|
||||||
|
) {
|
||||||
|
this.$refs.uploadRef.handleRemove(file);
|
||||||
|
ElementPlus.ElMessage.warning("仅支持ZIP格式文件");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.uploadFile = file.raw;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 文件删除处理
|
||||||
|
handleFileRemove(file) {
|
||||||
|
this.uploadFile = null;
|
||||||
|
ElementPlus.ElMessage.success("文件已删除");
|
||||||
|
},
|
||||||
|
|
||||||
|
// 提交上传
|
||||||
|
async submitUpload() {
|
||||||
|
if (!this.uploadFile) return;
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("file", this.uploadFile);
|
||||||
|
formData.append("recruitId", this.selectedTheme);
|
||||||
|
formData.append("userId", this.userId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.ajaxRequest({
|
||||||
|
url: "/ruoyi/upload-zip",
|
||||||
|
method: "POST",
|
||||||
|
body: formData,
|
||||||
|
});
|
||||||
|
this.$refs.uploadRef.clearFiles();
|
||||||
|
this.uploadFile = null;
|
||||||
|
ElementPlus.ElMessage.success("上传成功");
|
||||||
|
} catch (error) {
|
||||||
|
ElementPlus.ElMessage.error("上传失败");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleCheckAllChange(val) {
|
||||||
|
this.userIds = val ? this.currentList.map((i) => i.userId) : [];
|
||||||
|
},
|
||||||
|
|
||||||
|
async downloadTemplateFile() {
|
||||||
|
try {
|
||||||
|
const response = await this.ajaxRequest({
|
||||||
|
url: "/ruoyi/download-folders",
|
||||||
|
method: "POST",
|
||||||
|
body: { recruitId: this.selectedTheme, userIds: this.userIds },
|
||||||
|
isDownload: true,
|
||||||
|
});
|
||||||
|
const temp = this.themeOptions.find(
|
||||||
|
(item) => item.value == this.selectedTheme
|
||||||
|
);
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.href = URL.createObjectURL(new Blob([response]));
|
||||||
|
link.setAttribute(
|
||||||
|
"download",
|
||||||
|
`${this.selectedTheme}_${temp.label}.zip`
|
||||||
|
); // 设置文件名
|
||||||
|
link.click();
|
||||||
|
} catch (error) {
|
||||||
|
ElementPlus.ElMessage.error("下载失败");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async ajaxRequest(options) {
|
||||||
|
const config = {
|
||||||
|
method: options.method,
|
||||||
|
headers: options.headers || {},
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.body) {
|
||||||
|
if (options.body instanceof FormData) {
|
||||||
|
config.body = options.body;
|
||||||
|
} else {
|
||||||
|
config.headers["Content-Type"] = "application/json";
|
||||||
|
config.body = JSON.stringify(options.body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(this.baseUrl + options.url, config);
|
||||||
|
if (!response.ok) throw new Error(response.statusText);
|
||||||
|
|
||||||
|
return options.isDownload ? response.arrayBuffer() : response.json();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
userIds(newVal) {
|
||||||
|
const total = this.currentList.length;
|
||||||
|
this.checkAll = newVal.length === total && total > 0;
|
||||||
|
this.isIndeterminate = newVal.length > 0 && newVal.length < total;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use(ElementPlus);
|
||||||
|
app.mount("#app");
|
||||||
|
</script>
|
||||||
|
</html>
|
Reference in New Issue
Block a user