commit
This commit is contained in:
@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -18,9 +19,9 @@ import java.util.Map;
|
||||
* @注释 没有定义的数据对象的读取
|
||||
*/
|
||||
@Slf4j
|
||||
public class NoModelDataListener implements ReadListener<Map<String, Object>> {
|
||||
public class NoModelDataListener implements ReadListener<Map<Integer, String>> {
|
||||
|
||||
private boolean isFirstRow = true;
|
||||
private boolean firstRow = true;
|
||||
// 表头数据
|
||||
@Getter
|
||||
private List<String> headers = new ArrayList<>();
|
||||
@@ -29,17 +30,31 @@ public class NoModelDataListener implements ReadListener<Map<String, Object>> {
|
||||
private List<NutMap> dataList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void invoke(Map<String, Object> rowMap, AnalysisContext context) {
|
||||
if (isFirstRow) {
|
||||
headers = new ArrayList<>(rowMap.keySet());
|
||||
isFirstRow = false;
|
||||
public void invoke(Map<Integer, String> rowMap, AnalysisContext context) {
|
||||
if (firstRow) {
|
||||
// 第一行是表头:按列索引存 header
|
||||
headers = new ArrayList<>(Collections.nCopies(rowMap.size(), ""));
|
||||
for (Map.Entry<Integer, String> entry : rowMap.entrySet()) {
|
||||
headers.set(entry.getKey(), entry.getValue());
|
||||
}
|
||||
firstRow = false;
|
||||
} else {
|
||||
// 后续行是数据:用 header 作为 key
|
||||
NutMap nutMap = new NutMap();
|
||||
nutMap.putAll(rowMap);
|
||||
for (Map.Entry<Integer, String> entry : rowMap.entrySet()) {
|
||||
Integer colIndex = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
String header = colIndex < headers.size() ? headers.get(colIndex) : "Column" + colIndex;
|
||||
nutMap.put(header, value);
|
||||
}
|
||||
dataList.add(nutMap);
|
||||
}
|
||||
}
|
||||
|
||||
public List<NutMap> getDataList() {
|
||||
return dataList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
log.info("共读取 {} 行数据(不含表头)", dataList.size());
|
||||
|
||||
+12
-1
@@ -3,6 +3,7 @@ package com.budwk.app.zhgh.staffmanage.personnelcheck.controller;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.zhgh.staffmanage.personnelcheck.model.CheckTaskBusinessConfig;
|
||||
import com.budwk.app.zhgh.staffmanage.personnelcheck.service.CheckTaskCommonService;
|
||||
import com.budwk.app.zhgh.staffmanage.personnelcheck.vo.pageform.CheckTaskCommonPageForm;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -13,10 +14,12 @@ import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
@@ -71,8 +74,16 @@ public class CheckTaskSingleController {
|
||||
LEFT JOIN `user` u ON u.loginname = person.loginname
|
||||
$condition
|
||||
""");
|
||||
CheckTaskBusinessConfig config = dao.fetch(CheckTaskBusinessConfig.class, Cnd.where(CheckTaskBusinessConfig::getCode, "=", pageForm.getTaskCode()));
|
||||
List<NutMap> list = config.getWorkflowSteps();
|
||||
|
||||
// 找出第一个步骤
|
||||
String stepCode = list.get(0).getString("stepCode");
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
pageForm.buildSearch(cnd, "u.");
|
||||
|
||||
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = checkTaskCommonService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return Result.success(pagination);
|
||||
@@ -89,6 +100,6 @@ public class CheckTaskSingleController {
|
||||
@At
|
||||
@SaCheckPermission("personnel.check.verification.single")
|
||||
public Result findOne(@Valid String id){
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
||||
+26
-9
@@ -9,6 +9,7 @@ import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.flow.engine.FlowEngine;
|
||||
import com.budwk.app.sys.services.SysFileService;
|
||||
import com.budwk.app.zhgh.staffmanage.personnelcheck.model.CheckTaskBusinessConfig;
|
||||
import com.budwk.app.zhgh.staffmanage.personnelcheck.model.CheckTaskFiledConfig;
|
||||
import com.budwk.app.zhgh.staffmanage.personnelcheck.model.CheckTaskVerification;
|
||||
@@ -55,6 +56,8 @@ public class CheckTaskVerificationController {
|
||||
@Inject
|
||||
private FlowEngine flowEngine;
|
||||
@Inject
|
||||
private SysFileService sysFileService;
|
||||
@Inject
|
||||
private CheckTaskCommonService checkTaskCommonService;
|
||||
|
||||
|
||||
@@ -68,10 +71,12 @@ public class CheckTaskVerificationController {
|
||||
@At
|
||||
@SaCheckPermission("personnel.check.verification.manage")
|
||||
public Result pageData(CheckTaskManagePageForm pageForm){
|
||||
Sql sql = Sqls.create("SELECT * FROM check_task $condition");
|
||||
Sql sql = Sqls.create("SELECT * FROM check_task_verification $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("YEAR(createTime)", "=", pageForm.getYear());
|
||||
cnd.andEX("taskName", "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.and("taskName", "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = checkTaskCommonService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return Result.success(pagination);
|
||||
@@ -98,14 +103,26 @@ public class CheckTaskVerificationController {
|
||||
// 1.界面可能会对相关审核步骤做修改,修改审核流程配置
|
||||
dao.update(vo.getBusinessConfig());
|
||||
|
||||
// 2.新增或者修改事项任务
|
||||
// 2.保存文件
|
||||
String filePath = sysFileService.uploadReturnUrl("MINIO", file);
|
||||
|
||||
// 3.新增或者修改事项任务
|
||||
CheckTaskVerification verification = new CheckTaskVerification();
|
||||
verification.setId(vo.getId());
|
||||
verification.setYear(DateUtil.thisYear());
|
||||
verification.setTitle(vo.getTitle());
|
||||
verification.setBusinessType(vo.getBusinessType());
|
||||
// 存储文件名及文件路径
|
||||
verification.setFileName(file.getSubmittedFileName());
|
||||
verification.setFilePath(filePath);
|
||||
verification.setStartTime(vo.getStartTime());
|
||||
verification.setEndTime(vo.getEndTime());
|
||||
verification.setStatus("进行中");
|
||||
verification.setCreateTime(vo.getCreateTime() == null ? DateUtil.date() : vo.getCreateTime());
|
||||
verification.setYear(DateUtil.year(verification.getCreateTime()));
|
||||
dao.insertOrUpdate(verification);
|
||||
|
||||
// 3.往字段表里面插入数据,最好做下字段映射,把相关字段与数据库的字段对应(忽略,前端做好了字段对应)
|
||||
// 4.往字段表里面插入数据,最好做下字段映射,把相关字段与数据库的字段对应(忽略,前端做好了字段对应)
|
||||
// todo 字段映射
|
||||
List<CheckTaskFiledConfig> fieldConfig = vo.getFieldConfig();
|
||||
fieldConfig.forEach(v -> {
|
||||
@@ -114,10 +131,10 @@ public class CheckTaskVerificationController {
|
||||
});
|
||||
dao.insert(fieldConfig);
|
||||
|
||||
// 4.读取文件,构造数据(动态字段 data),往 CheckTaskPersonnel 表中插入数据
|
||||
// 5.读取文件,构造数据(动态字段 data),往 CheckTaskPersonnel 表中插入数据
|
||||
// todo 读取文件 转换成数据 同时还要把字段转化成数据库的字段来存储
|
||||
List<CheckTaskPersonnel> personnelData = checkTaskCommonService.readFile(fieldConfig, file);
|
||||
|
||||
dao.fastInsert(personnelData);
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
@@ -128,9 +145,9 @@ public class CheckTaskVerificationController {
|
||||
@SaCheckPermission("personnel.check.verification.manage")
|
||||
@SLog(tag = "核对任务", msg = "删除核对任务ID:${args[0]}")
|
||||
public Result onDelete(String id){
|
||||
dao.clear(CheckTaskVerification.class, Cnd.where("id", "=", id));
|
||||
dao.clear(CheckTaskPersonnel.class, Cnd.where("taskId", "=", id));
|
||||
flowEngine.processInstanceService().deleteProcessInstanceByBusinessKey(id);
|
||||
dao.clear(CheckTaskVerification.class, Cnd.where(CheckTaskVerification::getId, "=", id));
|
||||
dao.clear(CheckTaskPersonnel.class, Cnd.where(CheckTaskPersonnel::getTaskId, "=", id));
|
||||
dao.clear(CheckTaskFiledConfig.class, Cnd.where(CheckTaskFiledConfig::getTaskId, "=", id));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class CheckTaskPersonnel extends BaseModel {
|
||||
@Column
|
||||
@Comment("动态扩展字段(用户表其余列)")
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
private List<NutMap> data;
|
||||
private NutMap data;
|
||||
|
||||
@Column
|
||||
@Default("0")
|
||||
|
||||
+5
@@ -52,6 +52,11 @@ public class CheckTaskVerification extends BaseModel {
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String fileName;
|
||||
|
||||
@Column
|
||||
@Comment("文件路径")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String filePath;
|
||||
|
||||
@Column
|
||||
@Comment("开始时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
|
||||
+55
-2
@@ -11,10 +11,13 @@ import com.budwk.app.zhgh.staffmanage.personnelcheck.service.CheckTaskCommonServ
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
@@ -37,16 +40,66 @@ public class CheckTaskCommonServiceImpl extends BaseServiceImpl<CheckTaskPersonn
|
||||
|
||||
EasyExcel.read(file.getInputStream(), listener)
|
||||
.sheet()
|
||||
.headRowNumber(0)
|
||||
.doRead();
|
||||
|
||||
// 表格数据列
|
||||
List<NutMap> dataList = listener.getDataList();
|
||||
|
||||
// 处理fieldConfig中存储的字段名称和字段代码
|
||||
List<NutMap> result = convertExcelHeadersToFieldCodes(dataList, fieldConfig);
|
||||
|
||||
// 上面取到的result,需要转换成CheckTaskPersonnel插入数据库
|
||||
List<CheckTaskPersonnel> personnelList = result.stream().map(item -> {
|
||||
CheckTaskPersonnel personnel = new CheckTaskPersonnel();
|
||||
personnel.setId(R.UU32());
|
||||
// 工号是必须的,所以不能为空
|
||||
personnel.setLoginname(item.getString("loginname"));
|
||||
personnel.setTaskId(fieldConfig.get(0).getTaskId());
|
||||
personnel.setData(item);
|
||||
// 设置默认的当前步骤
|
||||
personnel.setCurrentStep("待核对");
|
||||
return personnel;
|
||||
}).toList();
|
||||
|
||||
return personnelList;
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 将 Excel 表头转换为字段代码
|
||||
*
|
||||
* @param excelData Excel 表数据
|
||||
* @param fieldConfigs 字段配置列表
|
||||
* @return 转换后的数据
|
||||
*/
|
||||
public static List<NutMap> convertExcelHeadersToFieldCodes(
|
||||
List<NutMap> excelData,
|
||||
List<CheckTaskFiledConfig> fieldConfigs) {
|
||||
|
||||
Map<String, String> headerToCode = fieldConfigs.stream()
|
||||
.collect(Collectors.toMap(
|
||||
CheckTaskFiledConfig::getFieldName,
|
||||
CheckTaskFiledConfig::getFieldCode,
|
||||
(a, b) -> a // 保留第一个
|
||||
));
|
||||
|
||||
return excelData.stream().map(original -> {
|
||||
NutMap converted = new NutMap();
|
||||
original.forEach((header, value) -> {
|
||||
String code = headerToCode.get(header);
|
||||
if (code != null) {
|
||||
converted.put(code, value);
|
||||
}
|
||||
// 否则忽略或保留,按需
|
||||
});
|
||||
return converted;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-5
@@ -21,23 +21,24 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CheckTaskCommonPageForm extends PageForm {
|
||||
|
||||
// 工会id
|
||||
@ApiModelProperty("事项id")
|
||||
private String taskId;
|
||||
|
||||
@ApiModelProperty("事项CODE")
|
||||
private String taskCode;
|
||||
|
||||
@ApiModelProperty("工会id")
|
||||
private String unionId;
|
||||
|
||||
// 单位id
|
||||
@ApiModelProperty("单位id")
|
||||
private String unitId;
|
||||
|
||||
// 在职状态
|
||||
@ApiModelProperty("在职状态")
|
||||
private List<String> userStates;
|
||||
|
||||
// 在职状态
|
||||
@ApiModelProperty("编制类别")
|
||||
private List<String> preparedBys;
|
||||
|
||||
// 教职工类别
|
||||
@ApiModelProperty("教职工类别")
|
||||
private List<String> personTypes;
|
||||
|
||||
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
const COMMON_QUERY = {
|
||||
template: /*language=HTML*/ `
|
||||
<search @search="doSearch">
|
||||
<search-item label="姓名/工号">
|
||||
<el-input placeholder="请输入姓名或工号" clearable v-model="pageForm.searchKeyword"></el-input>
|
||||
</search-item>
|
||||
|
||||
<template v-if="$auth.hasRoleOr('SYSADMIN, SCHOOL_UNION_ADMIN, BRANCH_UNION_ADMIN, BRANCH_UNION_CHAIRMAN, BRANCH_UNION_GROUP_LEADER')">
|
||||
<search-item label="所属工会">
|
||||
<el-select @change="flushUnits" @clear="flushUnits" clearable filterable
|
||||
placeholder="请选择所属工会" style="width: 100%;" v-model="pageForm.unionId">
|
||||
<el-option :key="item.id" :label="item.name" :value="item.id"
|
||||
v-for="item in unions"></el-option>
|
||||
</el-select>
|
||||
</search-item>
|
||||
<search-item label="所属单位">
|
||||
<el-select clearable filterable placeholder="请选择所属单位" style="width: 100%"
|
||||
v-model="pageForm.unitId">
|
||||
<el-option :key="item.id" :label="item.name" :value="item.id"
|
||||
v-for="item in units"></el-option>
|
||||
</el-select>
|
||||
</search-item>
|
||||
<search-item label="在职状态">
|
||||
<dict-select v-model="pageForm.userStates" placeholder="请选择在职状态" @change="doSearch"
|
||||
code="USER_STATE" multiple collapse-tags></dict-select>
|
||||
</search-item>
|
||||
<search-item label="教职工类别">
|
||||
<dict-select v-model="pageForm.personTypes" placeholder="请选择教职工类别" @change="doSearch"
|
||||
code="USER_PERSON_TYPE" multiple collapse-tags></dict-select>
|
||||
</search-item>
|
||||
<search-item label="编制类别">
|
||||
<dict-select v-model="pageForm.preparedBys" placeholder="请选择编制类别" @change="doSearch"
|
||||
code="USER_PREPARED_BY_TYPE" multiple collapse-tags></dict-select>
|
||||
</search-item>
|
||||
</template>
|
||||
</search>
|
||||
`,
|
||||
store,
|
||||
mixins: [initTableMixins],
|
||||
data() {
|
||||
return{
|
||||
unions: [],
|
||||
units: [],
|
||||
pageForm: {
|
||||
searchKeyword: '',
|
||||
unionId: '',
|
||||
unitId: '',
|
||||
userStates: [],
|
||||
personTypes: [],
|
||||
preparedBys: [],
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
doSearch(){
|
||||
const pageForm = clone(this.pageForm)
|
||||
pageForm.userStates = JSON.stringify(this.pageForm.userStates)
|
||||
pageForm.personTypes = JSON.stringify(this.pageForm.personTypes)
|
||||
pageForm.preparedBys = JSON.stringify(this.pageForm.preparedBys)
|
||||
this.$emit('search', pageForm)
|
||||
},
|
||||
async initData(){
|
||||
if (this.$auth.hasRoleOr("SYSADMIN, SCHOOL_UNION_ADMIN, SCHOOL_UNION_MEMBER_ADMIN")) {
|
||||
this.$businessTool.listUnion(this.pageForm.unionId).then((data) => {
|
||||
this.unions = data
|
||||
})
|
||||
this.$businessTool.listUnit().then((data) => {
|
||||
this.units = data
|
||||
})
|
||||
} else {
|
||||
this.$businessTool.listUnion(this.$store.state.user.union.id).then((data) => {
|
||||
this.unions = data
|
||||
})
|
||||
this.$businessTool.listUnit(this.$store.state.user.union.id).then((data) => {
|
||||
this.units = data
|
||||
})
|
||||
}
|
||||
},
|
||||
async flushUnits(){
|
||||
this.$set(this.pageForm, "unitId", null)
|
||||
this.units = []
|
||||
if (this.pageForm.unionId) {
|
||||
this.$businessTool.listUnit(this.pageForm.unionId).then((data) => {
|
||||
this.units = data
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.initData()
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -329,7 +329,7 @@ const importAndMap = {
|
||||
try {
|
||||
this.baseData.fieldConfig = this.headerList
|
||||
.map(h => ({
|
||||
fieldCode: h.name,
|
||||
fieldCode: h.dbField,
|
||||
fieldName: h.name,
|
||||
isRequired: h.selected,
|
||||
sortOrder: this.headers.indexOf(h.name)
|
||||
|
||||
@@ -45,8 +45,12 @@ layout("/layouts/platform.html"){
|
||||
:prop="column.prop"
|
||||
:width="column.width"
|
||||
:sortable="column.sortable"
|
||||
></el-table-column>
|
||||
<el-table-column align="center" header-align="center" label="操作" width="200px" fixed="right">
|
||||
>
|
||||
<template scope="{row}" v-if="column.prop === 'status'">
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" header-align="center" label="操作" width="220px" fixed="right">
|
||||
<template scope="{row}">
|
||||
<el-button size="mini" @click="openView(row)" type="primary">查看</el-button>
|
||||
<el-button size="mini" @click="openEdit(row)" type="primary">编辑</el-button>
|
||||
@@ -76,8 +80,8 @@ layout("/layouts/platform.html"){
|
||||
data() {
|
||||
return{
|
||||
tableColumns: [
|
||||
{ prop: "taskName", label: "任务名称", sortable: true },
|
||||
{ prop: "fileName", label: "导入文件名称", sortable: true },
|
||||
{ prop: "title", label: "任务名称", sortable: true },
|
||||
{ prop: "fileName", label: "文件名称", sortable: true },
|
||||
{ prop: "startTime", label: "开始时间", sortable: true },
|
||||
{ prop: "endTime", label: "结束时间", sortable: true },
|
||||
{ prop: "status", label: "当前状态" }
|
||||
@@ -117,7 +121,7 @@ layout("/layouts/platform.html"){
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
this.pageData()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
+13
-2
@@ -2,14 +2,25 @@
|
||||
layout("/layouts/platform.html"){
|
||||
#-->
|
||||
<div id="app" v-cloak>
|
||||
|
||||
<guava ref="guava">
|
||||
<el-card shadow="never">
|
||||
<common-query ref="commonQueryRef"></common-query>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="mt10">
|
||||
<table-tool></table-tool>
|
||||
|
||||
</el-card>
|
||||
|
||||
</guava>
|
||||
</div>
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
mixins: [initTableMixins],
|
||||
data() {
|
||||
return {
|
||||
formData: {}
|
||||
tableColumns: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
Reference in New Issue
Block a user