疗休养

This commit is contained in:
Paidax
2025-06-11 17:57:42 +08:00
parent c243daddec
commit e9f9d44c06
4 changed files with 172 additions and 27 deletions
@@ -1,7 +1,9 @@
package io.v.nutz.zhgh.lxy.controller; package io.v.nutz.zhgh.lxy.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.wizzer.framework.base.Result; import cn.wizzer.framework.base.Result;
import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.annontation.ViReturn;
@@ -9,10 +11,12 @@ import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.PageUtil; import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Vi; import io.v.nutz.base.utils.Vi;
import io.v.nutz.base.utils.ViTool; import io.v.nutz.base.utils.ViTool;
import io.v.nutz.sys.models.User;
import io.v.nutz.sys.services.SysUserService; import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.lxy.model.Lxy_bm; import io.v.nutz.zhgh.lxy.model.Lxy_bm;
import io.v.nutz.zhgh.lxy.model.Lxy_grxx; import io.v.nutz.zhgh.lxy.model.Lxy_grxx;
import io.v.nutz.zhgh.lxy.model.Lxy_mefp;
import io.v.nutz.zhgh.lxy.service.LxyBmService; import io.v.nutz.zhgh.lxy.service.LxyBmService;
import io.v.nutz.zhgh.lxy.service.LxyGrxxService; import io.v.nutz.zhgh.lxy.service.LxyGrxxService;
import io.v.nutz.zhgh.lxy.service.LxyHdService; import io.v.nutz.zhgh.lxy.service.LxyHdService;
@@ -20,16 +24,19 @@ import io.v.nutz.zhgh.lxy.template.LxyImportTemp;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd; import org.nutz.dao.Cnd;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.dao.Sqls; import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record; import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql; import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static; import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang; import org.nutz.lang.Lang;
import org.nutz.lang.Strings; import org.nutz.lang.Strings;
import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap; import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.AdaptBy; import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.At;
@@ -43,6 +50,9 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
/** /**
* @Author: 1V * @Author: 1V
@@ -341,14 +351,121 @@ public class LxyGhbmController {
} }
private final ReentrantLock lock = new ReentrantLock(true);
@At @At
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("zgfw.lxy.ghbm") @RequiresPermissions("zgfw.lxy.ghbm")
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
public Result doImport(TempFile file, String projectId){ public Result doImport(TempFile file, String projectId){
String unionId = Vi.getUnionId(); try {
// 已经报名的人 lock.lock();
int count = dao.count(Lxy_bm.class, Cnd.where("hdid", "=", projectId).and("ghid", "=", unionId) String unionId = Vi.getUnionId();
.and("bmzt", "in", List.of("1", "2", "3", "4", "5", "6"))); // 已经报名的,排除审核未通过
return null; int count = dao.count(Lxy_bm.class, Cnd.where("hdid", "=", projectId).and("ghid", "=", unionId)
.and("bmzt", "in", List.of("1", "2", "3", "4", "5", "6")));
Lxy_mefp fetch = dao.fetch(Lxy_mefp.class, Cnd.where("hdid", "=", projectId).and("ghid", "=", unionId));
if (count >= fetch.getNumber()) {
return Result.error("报名人数已满");
}
List<LxyImportTemp> tempList = ExcelImportUtil.importExcel(file.getFile(), LxyImportTemp.class, new ImportParams());
if ((tempList.size() + count) >= fetch.getNumber()) {
return Result.error("文件数据超过名额限制,请检查是否存在已报名人员");
}
// 获取本 基层工会的会员,判断是不是报名了其他工会的教工和校验有没有用户数据
List<User> list = dao.query(User.class, Cnd.where("unionid", "=", unionId).and("member", "=", 1));
Map<String, User> userMap = list.stream().collect(Collectors.toMap(User::getLoginname, v -> v));
List<Lxy_bm> sourceList = dao.query(Lxy_bm.class, Cnd.where("hdid", "=", projectId).and("ghid", "=", unionId));
List<String> sourUserIdList = sourceList.stream().map(Lxy_bm::getUserid).collect(Collectors.toList());
String today = cn.hutool.core.date.DateUtil.today();
// 要插入的数据
List<Lxy_bm> bmList = new ArrayList<>();
// 删除lxy_grxx里面的数据
List<String> delUserIds = new ArrayList<>();
// 插入lxy_grxx的数据
List<Lxy_grxx> grxxList = new ArrayList<>();
List<LxyImportTemp> errorInfos = new ArrayList<>();
for (LxyImportTemp temp : tempList) {
User user = userMap.get(temp.getLoginname());
if (Lang.isEmpty(user)) {
temp.setRemark("获取不到此用户信息,请确保该教工归属在本基层工会");
errorInfos.add(temp);
continue;
}
if (sourUserIdList.contains(user.getId())) {
temp.setRemark("报名数据重复");
errorInfos.add(temp);
continue;
}
Lxy_bm bm = new Lxy_bm();
bm.setId(R.UU32());
bm.setHdid(projectId);
bm.setLoginname(temp.getLoginname());
bm.setUserid(user.getId());
bm.setGhid(unionId);
bm.setUnionname(user.getUnitname());
bm.setBmsj(today);
bm.setBmzt(3);
bm.setBmlx(1);
bm.setUnitname(user.getUnitname());
bm.setUnitid(user.getUnitid());
bm.setNation(temp.getNation());
bm.setZyhj(temp.getZyhj());
bm.setIdcard(temp.getIdcard());
bm.setMobile(temp.getMobile());
bm.setTalent(temp.getTalent());
bmList.add(bm);
delUserIds.add(user.getId());
Lxy_grxx grxx = new Lxy_grxx();
grxx.setId(R.UU32());
grxx.setHdid(projectId);
grxx.setGhid(unionId);
grxx.setUserid(user.getId());
grxx.setLoginname(temp.getLoginname());
grxx.setUsername(user.getUsername());
grxx.setMobile(temp.getMobile());
grxx.setSex(user.getSex());
grxx.setMz(temp.getNation());
grxx.setIdcard(temp.getIdcard());
grxxList.add(grxx);
}
dao.fastInsert(bmList);
dao.clear(Lxy_grxx.class, Cnd.where("userid", "in", delUserIds));
dao.fastInsert(grxxList);
NutMap nutMap = NutMap.NEW();
nutMap.setv("totalCount", tempList.size());
nutMap.setv("successCount", bmList.size());
nutMap.setv("errorCount", errorInfos.size());
if (Lang.isNotEmpty(errorInfos)) {
nutMap.setv("errorList", errorInfos.stream().map(v -> {
return NutMap.NEW().addv("工号", v.getLoginname()).addv("姓名", v.getUsername()).addv("错误原因", v.getRemark());
}).collect(Collectors.toList()));
} else {
nutMap.setv("errorList", new ArrayList<>());
}
return Result.success().addData(nutMap);
} catch (Exception e) {
e.printStackTrace();
return Result.error();
} finally {
lock.unlock();
}
} }
} }
@@ -13,25 +13,25 @@ import lombok.Data;
@Data @Data
public class LxyImportTemp { public class LxyImportTemp {
@Excel(name = "工号") @Excel(name = "工号", width = 20)
String loginname; String loginname;
@Excel(name = "姓名") @Excel(name = "姓名", width = 20)
String username; String username;
@Excel(name = "民族") @Excel(name = "民族", width = 20)
String nation; String nation;
@Excel(name = "疗休养员身份") @Excel(name = "疗休养员身份", width = 40)
String zyhj; String zyhj;
@Excel(name = "身份证号") @Excel(name = "身份证号", width = 40)
String idcard; String idcard;
@Excel(name = "联系电话") @Excel(name = "联系电话", width = 20)
String mobile; String mobile;
@Excel(name = "是否为ABCDE类高层次人才") @Excel(name = "是否为ABCDE类高层次人才", width = 30)
String talent; String talent;
String remark; String remark;
@@ -40,7 +40,7 @@
:file-list="importData.fileList" :file-list="importData.fileList"
> >
<el-button size="medium" type="" icon="el-icon-upload" style="width: 200px">选择文件</el-button> <el-button size="medium" type="" icon="el-icon-upload" style="width: 200px">选择文件</el-button>
<div class="el-upload__tip" slot="tip" style="color: #f56c6c">只能上传 xls/xlsx 文件</div> <div class="el-upload__tip" slot="tip" style="color: #f56c6c">只能上传 xls/xlsx 文件{{ "," + text }}</div>
</el-upload> </el-upload>
</el-form> </el-form>
</el-card> </el-card>
@@ -62,8 +62,8 @@
</el-timeline> </el-timeline>
<div style="text-align: right"> <div style="text-align: right">
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<!-- <el-button @click="importVisible = false" :disabled="importLoading">取 消</el-button>--> <el-button @click="$emit('flush')">关 闭</el-button>
<el-button type="primary" @click="doImport" :loading="importLoading">确 定</el-button> <el-button type="primary" @click="doImport">导 入</el-button>
</span> </span>
</div> </div>
</div> </div>
@@ -75,6 +75,7 @@ module.exports = {
temp_url: { type: String }, temp_url: { type: String },
post_url: { type: String }, post_url: { type: String },
project_id: { type: String, default: "" }, project_id: { type: String, default: "" },
text: { type: String, default: "" },
is_show_radio: { type: Boolean, default: false } is_show_radio: { type: Boolean, default: false }
}, },
mounted() { mounted() {
@@ -128,7 +129,14 @@ module.exports = {
this.importData.fileList.forEach((val) => { this.importData.fileList.forEach((val) => {
data.append("file", val.raw, val.raw.name) data.append("file", val.raw, val.raw.name)
}) })
this.importLoading = true
const loading = this.$loading({
lock: true,
text: "导入中,请稍后...",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)"
})
$.ajax({ $.ajax({
url: this.post_url, url: this.post_url,
type: "post", type: "post",
@@ -136,22 +144,29 @@ module.exports = {
processData: false, processData: false,
contentType: false, contentType: false,
success: (data) => { success: (data) => {
this.importLoading = false loading.close()
if (data.code === 0 && data.data === null) { if (data.code === 0) {
this.$notify.success("导入成功") if (data.data) {
this.importVisible = false this.errorInfoData = data.data
this.$emit("flush") this.$message.success("导入成功条数:" + data.data.successCount + ",错误条数:" + data.data.errorCount)
if (this.errorInfoData.errorCount <= 0) {
this.$emit("flush")
}
} else {
this.importVisible = false
this.$emit("flush")
this.$message.success("导入成功")
}
} else { } else {
this.$notify.warning("导入失败") loading.close()
this.errorInfoData = data.data this.$message.warning(data.msg)
} }
}, },
error: (data) => { error: (data) => {
this.$notify.warning(data.msg) loading.close()
this.importLoading = false this.$message.warning(data.msg)
} }
}) })
this.importLoading = false
}, },
exportErrors() { exportErrors() {
const data = this.errorInfoData.errorList const data = this.errorInfoData.errorList
@@ -487,6 +487,7 @@ display: -webkit-box;
temp_url="/platform/zgfw/lxy/ghbm/downloadImportTemp" temp_url="/platform/zgfw/lxy/ghbm/downloadImportTemp"
post_url="/platform/zgfw/lxy/ghbm/doImport" post_url="/platform/zgfw/lxy/ghbm/doImport"
:project_id="pageForm.hdid" :project_id="pageForm.hdid"
:text="'请确保信息完整并准确,高层次人才一栏中请填写A-E的大写字母,非高层次人才请填写否'"
@flush="successImport" @flush="successImport"
></file-import> ></file-import>
</el-dialog> </el-dialog>
@@ -565,7 +566,19 @@ display: -webkit-box;
"file-import": httpVueLoader("/components/plugins/FileImport.vue") "file-import": httpVueLoader("/components/plugins/FileImport.vue")
}, },
methods: { methods: {
openImport() {}, openImport() {
this.importDialog = true
this.$nextTick(() => {
this.$refs.viewImport.resetImportData()
})
},
successImport() {
this.importDialog = false
this.$nextTick(() => {
this.$refs.viewImport.resetImportData()
this.pageData()
})
},
openBm2(row) { openBm2(row) {
this.checkTableRowData = row this.checkTableRowData = row
this.tabKey = new Date().getTime() this.tabKey = new Date().getTime()