疗休养
This commit is contained in:
+297
-9
@@ -1,32 +1,52 @@
|
||||
package io.v.nutz.zhgh.therapyRecuperation.controller.theRapyConfig;
|
||||
|
||||
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.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import cn.wizzer.framework.base.service.BaseService;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.constant.RedisConstant;
|
||||
import io.v.nutz.zhgh.therapyRecuperation.model.TheRapyRecuperationBaseManagement;
|
||||
import io.v.nutz.zhgh.therapyRecuperation.model.TheRapyRecuperationConfig;
|
||||
import io.v.nutz.zhgh.therapyRecuperation.model.TheRapyRecuperationLine;
|
||||
import io.v.nutz.zhgh.therapyRecuperation.model.TheRapyRecuperationLot;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.web.commons.slog.annotation.SLog;
|
||||
import io.v.nutz.zhgh.therapyRecuperation.mode.TheRapyRecuperationCanApplyOutUserMode;
|
||||
import io.v.nutz.zhgh.therapyRecuperation.model.*;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
import org.nutz.trans.Trans;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -36,14 +56,16 @@ import java.util.stream.Collectors;
|
||||
* @date 2022/06/01
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/theRapyRecuperation/TheRapyConfig")
|
||||
@Ok("json:full")
|
||||
@At("/platform/theRapyRecuperation/TheRapyConfig")
|
||||
public class TheRapyRecuperationConfigController {
|
||||
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
|
||||
|
||||
@@ -137,4 +159,270 @@ public class TheRapyRecuperationConfigController {
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("theRapyRecuperation.TheRapyConfig")
|
||||
@SLog(tag = "疗休养基础配置", msg = "下载省外名额人员导入模版", param = true, result = true)
|
||||
public void downloadImportTemp(HttpServletResponse response) {
|
||||
try {
|
||||
ViTool.excelResponse(response, "省外名额人员导入模版.xlsx");
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook sheets = ExcelExportUtil.exportExcel(exportParams, TheRapyRecuperationCanApplyOutUserMode.class, new ArrayList<>());
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
sheets.write(outputStream);
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock(true);
|
||||
|
||||
|
||||
/**
|
||||
* 导入省外名额人员
|
||||
* @param file 文件数据
|
||||
* @param isFlag 是否清空更新
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@RequiresPermissions("theRapyRecuperation.TheRapyConfig")
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@SLog(tag = "疗休养基础配置", msg = "导入省外名额人员", param = true, result = true)
|
||||
public Result doImport(TempFile file, boolean isFlag){
|
||||
try {
|
||||
lock.lock();
|
||||
List<TheRapyRecuperationCanApplyOutUserMode> importList = ExcelImportUtil.importExcel(file.getFile(),
|
||||
TheRapyRecuperationCanApplyOutUserMode.class, new ImportParams());
|
||||
|
||||
if (Lang.isEmpty(importList)) {
|
||||
return Result.error("excel无数据");
|
||||
}
|
||||
// 获取数据库人员,看这些人在不在数据库里边
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
id,
|
||||
loginname AS loginName,
|
||||
username AS userName,
|
||||
sex,
|
||||
mobile,
|
||||
userState,
|
||||
personType,
|
||||
preparedBy,
|
||||
unitid AS unitId,
|
||||
unitname AS unitName,
|
||||
unionid AS unionId,
|
||||
unionname AS unionName
|
||||
FROM
|
||||
`user`
|
||||
""");
|
||||
sql.setCallback(Sqls.callback.maps());
|
||||
dao.execute(sql);
|
||||
List<NutMap> userInfoList = (List<NutMap>) sql.getResult();
|
||||
Map<String, NutMap> userMap = userInfoList.stream().collect(Collectors.toMap(v -> v.getString("loginName"), v -> v));
|
||||
|
||||
// 查询表中原有的人员
|
||||
// 查个蛋,直接删了再加
|
||||
// List<TheRapyRecuperationCanApplyOutUserMode> query;
|
||||
// if (!isFlag) {
|
||||
// query = dao.query(TheRapyRecuperationCanApplyOutUserMode.class, Cnd.NEW());
|
||||
// }
|
||||
|
||||
// 错误信息存储集合
|
||||
List<TheRapyRecuperationCanApplyOutUserMode> errorInfos = new ArrayList<>();
|
||||
// 结果数据
|
||||
List<TheRapyRecuperationCanApplyOutUser> resultList = new ArrayList<>();
|
||||
// 遍历excel数据,比对数据并插入数据库
|
||||
for (TheRapyRecuperationCanApplyOutUserMode mode : importList) {
|
||||
NutMap map = userMap.get(mode.getLoginName());
|
||||
if (Lang.isEmpty(map)) {
|
||||
mode.setRemark("请检查此人员工号是否正确,系统查不到此人");
|
||||
errorInfos.add(mode);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 不是清空更新,就去检验这个人员是否在省外名额库里面,在的话去忽略
|
||||
// 艹,判断个毛,直接删了再加
|
||||
TheRapyRecuperationCanApplyOutUser apply = new TheRapyRecuperationCanApplyOutUser();
|
||||
apply.setId(R.UU32());
|
||||
apply.setUserId(map.getString("id"));
|
||||
apply.setLoginName(map.getString("loginName"));
|
||||
apply.setUserName(map.getString("userName"));
|
||||
apply.setSex(map.getString("sex"));
|
||||
apply.setMobile(map.getString("mobile"));
|
||||
apply.setUserState(map.getString("userState"));
|
||||
apply.setPersonType(map.getString("personType"));
|
||||
apply.setPreparedBy(map.getString("preparedBy"));
|
||||
apply.setUnitId(map.getString("unitId"));
|
||||
apply.setUnitName(map.getString("unitName"));
|
||||
apply.setUnionId(map.getString("unionId"));
|
||||
apply.setUnionName(map.getString("unionName"));
|
||||
resultList.add(apply);
|
||||
}
|
||||
|
||||
if (!isFlag) {
|
||||
List<String> clearUserLoginNameList = importList.stream().map(TheRapyRecuperationCanApplyOutUserMode::getLoginName).toList();
|
||||
dao.clear(TheRapyRecuperationCanApplyOutUser.class, Cnd.where("loginName", "in", clearUserLoginNameList));
|
||||
} else {
|
||||
dao.clear(TheRapyRecuperationCanApplyOutUser.class);
|
||||
}
|
||||
|
||||
dao.fastInsert(resultList);
|
||||
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
nutMap.setv("totalCount", importList.size());
|
||||
nutMap.setv("successCount", resultList.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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@SLog(tag = "疗休养基础配置", msg = "清空省外名额人员")
|
||||
@RequiresPermissions("theRapyRecuperation.TheRapyConfig")
|
||||
public Object clearUser(){
|
||||
dao.clear(TheRapyRecuperationCanApplyOutUser.class);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("theRapyRecuperation.TheRapyConfig")
|
||||
public Object getCanApplyOutUserPageData(PageForm pageForm,
|
||||
@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "unitId", required = false) String unitId,
|
||||
@Param(value = "sex", required = false) String sex,
|
||||
@Param(value = "userState", required = false) String userState,
|
||||
@Param(value = "personType", required = false) String personType,
|
||||
@Param(value = "preparedBy", required = false) String preparedBy){
|
||||
Sql sql = Sqls.create("SELECT * FROM the_rapy_recuperation_can_apply_out_user $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("unionId", "=", unionId);
|
||||
cnd.andEX("unitId", "=", unitId);
|
||||
cnd.andEX("sex", "=", sex);
|
||||
cnd.andEX("userState", "=", userState);
|
||||
cnd.andEX("personType", "=", personType);
|
||||
cnd.andEX("preparedBy", "=", preparedBy);
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("loginName", "%" + pageForm.getSearchKeyword() + "%");
|
||||
seg.orLike("userName", "%" + pageForm.getSearchKeyword() + "%");
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
|
||||
return baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("theRapyRecuperation.TheRapyConfig")
|
||||
public Object deleteCanApplyOutUser(String id) {
|
||||
return dao.delete(TheRapyRecuperationCanApplyOutUser.class, id);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("theRapyRecuperation.TheRapyConfig")
|
||||
public Object queryNotListUsers(@Param("query") String query){
|
||||
if (StrUtil.isBlank(query)) {
|
||||
return null;
|
||||
}
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
id,
|
||||
loginname,
|
||||
username,
|
||||
unitid,
|
||||
unitname
|
||||
FROM
|
||||
`user`
|
||||
$condition
|
||||
AND id not in (select userId from the_rapy_recuperation_can_apply_out_user)
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("loginname", query);
|
||||
seg.orLike("username", query);
|
||||
cnd.and(seg);
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = baseService.listPageMap(1, 10, sql);
|
||||
return pagination;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("theRapyRecuperation.TheRapyConfig")
|
||||
public Object addList(@Param("userIds") String[] userIds){
|
||||
List<String> userIdList = Arrays.stream(userIds).toList();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
id,
|
||||
loginname AS loginName,
|
||||
username AS userName,
|
||||
sex,
|
||||
mobile,
|
||||
userState,
|
||||
personType,
|
||||
preparedBy,
|
||||
unitid AS unitId,
|
||||
unitname AS unitName,
|
||||
unionid AS unionId,
|
||||
unionname AS unionName
|
||||
FROM
|
||||
`user`
|
||||
WHERE id in (@userIdList)
|
||||
""").setParam("userIdList", userIdList);
|
||||
sql.setCallback(Sqls.callback.maps());
|
||||
dao.execute(sql);
|
||||
List<NutMap> userInfoList = (List<NutMap>) sql.getResult();
|
||||
|
||||
List<TheRapyRecuperationCanApplyOutUser> list = userInfoList.stream().map(map -> {
|
||||
TheRapyRecuperationCanApplyOutUser apply = new TheRapyRecuperationCanApplyOutUser();
|
||||
apply.setId(R.UU32());
|
||||
apply.setUserId(map.getString("id"));
|
||||
apply.setLoginName(map.getString("loginName"));
|
||||
apply.setUserName(map.getString("userName"));
|
||||
apply.setSex(map.getString("sex"));
|
||||
apply.setMobile(map.getString("mobile"));
|
||||
apply.setUserState(map.getString("userState"));
|
||||
apply.setPersonType(map.getString("personType"));
|
||||
apply.setPreparedBy(map.getString("preparedBy"));
|
||||
apply.setUnitId(map.getString("unitId"));
|
||||
apply.setUnitName(map.getString("unitName"));
|
||||
apply.setUnionId(map.getString("unionId"));
|
||||
apply.setUnionName(map.getString("unionName"));
|
||||
return apply;
|
||||
}).toList();
|
||||
|
||||
dao.fastInsert(list);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package io.v.nutz.zhgh.therapyRecuperation.mode;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:TheRapyRecuperationCanApplyOutUserMode
|
||||
* @Date 2025/6/13 10:26
|
||||
* @注释 省外名额参加人员导入模板
|
||||
*/
|
||||
@Data
|
||||
public class TheRapyRecuperationCanApplyOutUserMode {
|
||||
|
||||
@Excel(name = "工号", width = 20)
|
||||
private String loginName;
|
||||
|
||||
@Excel(name = "姓名", width = 20)
|
||||
private String userName;
|
||||
|
||||
// 错误记录
|
||||
private String remark;
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package io.v.nutz.zhgh.therapyRecuperation.model;
|
||||
|
||||
import io.v.nutz.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:TheRapyRecuperationCanApplyOutUser
|
||||
* @Date 2025/6/13 9:54
|
||||
* @注释 省外的可报名人员
|
||||
*/
|
||||
@Data
|
||||
@Table
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TheRapyRecuperationCanApplyOutUser extends BaseModel {
|
||||
|
||||
@Name
|
||||
@Comment("id")
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("用户Id")
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("工号")
|
||||
private String loginName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("姓名")
|
||||
private String userName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("性别")
|
||||
private String sex;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("联系方式")
|
||||
private String mobile;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("在职状态")
|
||||
private String userState;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("人员类型")
|
||||
private String personType;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("人员性质")
|
||||
private String preparedBy;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("单位Id")
|
||||
private String unitId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("单位名称")
|
||||
private String unitName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("工会Id")
|
||||
private String unionId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("工会名称")
|
||||
private String unionName;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user