积分管理
This commit is contained in:
@@ -120,6 +120,11 @@ public class Sys_user extends BaseModel implements Serializable {
|
||||
@DataCenterColumn(name = "学历", key = "zgxlmc")
|
||||
private String education;
|
||||
|
||||
@Column
|
||||
@Comment("婚姻状况")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
private String marriage;
|
||||
|
||||
@Column
|
||||
@Comment("学位")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.budwk.app.zhgh.integral.constant;
|
||||
|
||||
import com.budwk.app.base.annotation.DictEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @ClassName IntegralOtherModelConstant
|
||||
* @Description 哪些类型可以获得积分
|
||||
* @Author zhf
|
||||
* @Date 2024/1/24 10:51
|
||||
*/
|
||||
@Getter
|
||||
@DictEnum(key = "IntegralOtherModelConstant", name = "哪些类型可以获得积分")
|
||||
@AllArgsConstructor
|
||||
public enum IntegralOtherModelConstant {
|
||||
PROPOSAL_DETERMINE("proposalDetermine", "写一条提案(立案)获得积分", false),
|
||||
PROPOSAL_OPINION("proposalOpinion", "写一条提案(作为意见)获得积分", false),
|
||||
TRAIN_SING_UP("trainSingUp", "参加品牌活动获得积分", false),
|
||||
ACTIVITY_SCHOOL("activitySchool", "参加体育活动获得积分", false),
|
||||
ACTIVITY_TISSUE("activityTissue", "参加文化活动获得积分", false),
|
||||
WMHD("wmhd", "参加教工作品征集获得积分", false),
|
||||
CAHD("cahd", "参加亲子作品征集获得积分", false),
|
||||
QUESTION("question", "填写问卷获得积分", false),
|
||||
FELLOWSHIP("fellowship", "参加单身联谊获得积分", false);
|
||||
|
||||
private final String otherModeCode;
|
||||
private final String otherModeName;
|
||||
private final Boolean disabled;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.budwk.app.zhgh.integral.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.zhgh.integral.model.IntegralConfig;
|
||||
import com.budwk.app.zhgh.integral.service.IntegralInsertTaskOrSelectConfigService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2025/7/14 10:24
|
||||
* @description 积分管理配置
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/integral/config")
|
||||
@Ok("json:full")
|
||||
@Slf4j
|
||||
@Api(tags = "积分基础设置")
|
||||
public class IntegralConfigController {
|
||||
|
||||
|
||||
@Inject
|
||||
private IntegralInsertTaskOrSelectConfigService integralInsertTaskOrSelectConfigService;
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/integral/config/index.html")
|
||||
@SaCheckPermission("integral.config")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("积分基础配置提交")
|
||||
@SaCheckPermission("integral.config")
|
||||
public Result submit(@Param("integralConfig") IntegralConfig integralConfig) {
|
||||
integralInsertTaskOrSelectConfigService.insertOrUpdate(integralConfig);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("积分基础配置查询")
|
||||
@SaCheckPermission("integral.config")
|
||||
public Result findOne() {
|
||||
IntegralConfig integralConfig = integralInsertTaskOrSelectConfigService.fetch(Cnd.NEW());
|
||||
return Result.success(integralConfig);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.budwk.app.zhgh.integral.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.CommonDownloadUtil;
|
||||
import com.budwk.app.sys.models.Sys_union;
|
||||
import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.integral.service.IntegralDetailService;
|
||||
import com.budwk.app.zhgh.integral.service.IntegralManageService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2025/7/14 14:31
|
||||
* @description 扣减/增加积分明细
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/integral/detail")
|
||||
@Ok("json:full")
|
||||
@Slf4j
|
||||
@Api(tags = "积分明细")
|
||||
public class IntegralDetailController {
|
||||
|
||||
|
||||
@Inject
|
||||
private IntegralDetailService integralDetailService;
|
||||
|
||||
@Inject
|
||||
private IntegralManageService integralManageService;
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/integral/detail/index.html")
|
||||
@SaCheckPermission("integral.detail")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("分页查询")
|
||||
@SaCheckPermission("integral.detail")
|
||||
public Result pageData(PageForm pageForm,
|
||||
String month,
|
||||
String unionId,
|
||||
String unitId,
|
||||
String integralTime) {
|
||||
Sql sql = integralDetailService.getSql(pageForm.getPageOrderName(), pageForm.getPageOrderBy(), pageForm.getSearchKeyword(), month, unionId, unitId, integralTime);
|
||||
return Result.success(integralDetailService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql));
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("删除积分记录")
|
||||
@SaCheckPermission("integral.detail")
|
||||
@SLog(tag = "积分增扣明细", msg = "删除积分记录:${args[0]}")
|
||||
public Result doDelete(String id){
|
||||
integralDetailService.delete(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@ApiOperation("导出年度积分详情")
|
||||
@SaCheckPermission("integral.manage")
|
||||
public void exportIntegralDetail(String searchKeyword,
|
||||
String month,
|
||||
String unionId,
|
||||
String unitId,
|
||||
String integralTime,
|
||||
boolean isZip, HttpServletResponse response) {
|
||||
Sql sql = integralDetailService.getSql(null, null, searchKeyword, month, unionId, unitId, integralTime);
|
||||
List<NutMap> list = integralDetailService.listMap(sql);
|
||||
List<Sys_union> unionList = integralDetailService.dao().query(Sys_union.class, Cnd.NEW());
|
||||
try {
|
||||
if (isZip) {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("content-disposition", "attachment;filename="
|
||||
+ URLEncoder.encode("积分详情.zip", "UTF-8"));
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
|
||||
for (Sys_union union : unionList) {
|
||||
String fileName = union.getUnionCode() + union.getName().replaceAll("/", "、") + "积分详情表.xlsx";
|
||||
zipOutputStream.putNextEntry(new ZipEntry(fileName));
|
||||
List<NutMap> usersByUnion = list.stream().filter(v -> Strings.isNotBlank(v.getString("unionId")) && v.getString("unionId").equals(union.getId())).collect(Collectors.toList());
|
||||
Workbook workbook = integralManageService.exportIntegral(usersByUnion, false, zipOutputStream);
|
||||
workbook.write(zipOutputStream);
|
||||
zipOutputStream.closeEntry();
|
||||
response.flushBuffer();
|
||||
}
|
||||
zipOutputStream.flush();
|
||||
zipOutputStream.close();
|
||||
} else {
|
||||
Workbook workbook = integralManageService.exportIntegral(list, false, response.getOutputStream());
|
||||
CommonDownloadUtil.download("积分详情表.xlsx", workbook, response);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
package com.budwk.app.zhgh.integral.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.CommonDownloadUtil;
|
||||
import com.budwk.app.base.utils.EasyExcelUtil;
|
||||
import com.budwk.app.sys.models.Sys_union;
|
||||
import com.budwk.app.sys.views.View_user;
|
||||
import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.benefit.mode.BenefitUserTemp;
|
||||
import com.budwk.app.zhgh.integral.model.IntegralDetail;
|
||||
import com.budwk.app.zhgh.integral.service.IntegralManageService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
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.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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@IocBean
|
||||
@At("/platform/integral/manage")
|
||||
@Ok("json:full")
|
||||
@Slf4j
|
||||
@Api(tags = "积分台账")
|
||||
public class IntegralManageController {
|
||||
|
||||
@Inject
|
||||
private IntegralManageService integralManageService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/integral/manage/index.html")
|
||||
@SaCheckPermission("integral.manage")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 首页查询
|
||||
* @param pageForm
|
||||
* @param year
|
||||
* @param unionId
|
||||
* @param unitId
|
||||
* @param personType
|
||||
* @param userState
|
||||
* @param integralTime
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ApiOperation("分页查询")
|
||||
@SaCheckPermission("integral.manage")
|
||||
public Result pageData(PageForm pageForm,
|
||||
String year,
|
||||
String unionId,
|
||||
String unitId,
|
||||
String personType,
|
||||
String userState,
|
||||
String integralTime) {
|
||||
Sql sql = integralManageService.getSql(pageForm.getPageOrderName(), pageForm.getPageOrderBy(), pageForm.getSearchKeyword(), year, unionId, unitId, personType, userState, integralTime);
|
||||
return Result.success(integralManageService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询积分详情
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param integralTime 获取积分时间
|
||||
* @return 积分详情分页列表
|
||||
*/
|
||||
@At
|
||||
@ApiOperation("根据用户ID查询积分详情")
|
||||
@SaCheckPermission("integral.manage")
|
||||
public Result getDetailByUserId(String userId,
|
||||
String month,
|
||||
String integralTime) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
ind.id,
|
||||
ind.userId,
|
||||
ind.integral,
|
||||
ind.integralNotes,
|
||||
ind.integralTime,
|
||||
u.loginname,
|
||||
u.username,
|
||||
u.sex
|
||||
FROM
|
||||
integral_detail ind
|
||||
LEFT JOIN `vw_user` u ON ind.userId = u.id
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("DATE_FORMAT(ind.`integralTime`,'%Y-%m')", "=", month);
|
||||
cnd.and("ind.userId", "=", userId);
|
||||
cnd.andEX("DATE(ind.integralTime)", "=", integralTime);
|
||||
cnd.desc("ind.integralTime");
|
||||
sql.setCondition(cnd);
|
||||
return Result.success(integralManageService.listMap(sql));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 扣减积分
|
||||
*
|
||||
* @param userIds 用户ID
|
||||
* @param integral 积分
|
||||
* @param integralNotes 积分说明
|
||||
* @return 扣减结果
|
||||
*/
|
||||
@At
|
||||
@ApiOperation("根据userid扣减积分")
|
||||
@SaCheckPermission("integral.manage")
|
||||
public Result doDeductions(@Param("userIds") String[] userIds,
|
||||
String integral, String integralNotes) {
|
||||
List<String> userIdList = Arrays.asList(userIds);
|
||||
List<View_user> userList = integralManageService.dao().query(View_user.class, Cnd.NEW().andEX(View_user::getId, "in", userIdList));
|
||||
if (Lang.isNotEmpty(userIdList)) {
|
||||
List<IntegralDetail> integralDetailList = new ArrayList<>();
|
||||
userIdList.forEach(v -> {
|
||||
View_user viewUser = userList.stream().filter(user -> user.getId().equals(v)).findFirst().orElse(null);
|
||||
IntegralDetail detail = new IntegralDetail();
|
||||
detail.setIntegral("-" + integral);
|
||||
detail.setIntegralNotes(integralNotes);
|
||||
detail.setYear(String.valueOf(DateUtil.thisYear()));
|
||||
detail.setUserId(v);
|
||||
detail.setUnionId(viewUser.getUnionId());
|
||||
detail.setUnitId(viewUser.getUnitId());
|
||||
detail.setUnionName(viewUser.getUnionName());
|
||||
detail.setUnitName(viewUser.getUnitName());
|
||||
detail.setIntegralTime(new Date());
|
||||
integralDetailList.add(detail);
|
||||
});
|
||||
integralManageService.insert(integralDetailList);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出积分汇总/分工会积分汇总压缩包
|
||||
*
|
||||
* @param searchKeyword 模糊查询值
|
||||
* @param year 年度
|
||||
* @param unionId 工会Id
|
||||
* @param unitId 单位Id
|
||||
* @param personType 人员类型
|
||||
* @param userState 在职状态
|
||||
* @param integralTime 获取积分时间
|
||||
* @param response response
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@ApiOperation("导出积分汇总/分工会积分汇总压缩包")
|
||||
@SaCheckPermission("integral.manage")
|
||||
public void exportIntegralSum(String searchKeyword,
|
||||
String year,
|
||||
String unionId,
|
||||
String unitId,
|
||||
String personType,
|
||||
String userState,
|
||||
String integralTime,
|
||||
boolean isZip, HttpServletResponse response) {
|
||||
Sql sql = integralManageService.getSql(null, null, searchKeyword, year, unionId, unitId, personType, userState, integralTime);
|
||||
List<NutMap> list = integralManageService.listMap(sql);
|
||||
List<Sys_union> unionList = integralManageService.dao().query(Sys_union.class, Cnd.NEW());
|
||||
try {
|
||||
if (isZip) {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("content-disposition", "attachment;filename="
|
||||
+ URLEncoder.encode(year + "年度积分汇总.zip", "UTF-8"));
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
|
||||
for (Sys_union union : unionList) {
|
||||
String fileName = union.getUnionCode() + union.getName().replaceAll("/", "、") + "积分汇总表.xlsx";
|
||||
zipOutputStream.putNextEntry(new ZipEntry(fileName));
|
||||
List<NutMap> usersByUnion = list.stream().filter(v -> Strings.isNotBlank(v.getString("unionid")) && v.getString("unionid").equals(union.getId())).collect(Collectors.toList());
|
||||
Workbook workbook = integralManageService.exportIntegral(usersByUnion, true, zipOutputStream);
|
||||
workbook.write(zipOutputStream);
|
||||
zipOutputStream.closeEntry();
|
||||
response.flushBuffer();
|
||||
}
|
||||
zipOutputStream.flush();
|
||||
zipOutputStream.close();
|
||||
} else {
|
||||
Workbook workbook = integralManageService.exportIntegral(list, true, response.getOutputStream());
|
||||
CommonDownloadUtil.download("年度积分汇总表.xlsx", workbook, response);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("修改每条记录")
|
||||
@SaCheckPermission("integral.manage")
|
||||
public Result doEdit(IntegralDetail detail) {
|
||||
integralManageService.updateIgnoreNull(detail);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("根据id删除每条记录的信息")
|
||||
@SaCheckPermission("integral.manage")
|
||||
public Result removeById(String id) {
|
||||
integralManageService.doDeleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@ApiOperation("下载积分扣减导入模版")
|
||||
@SaCheckPermission("integral.manage")
|
||||
public void downloadImportTemp(HttpServletResponse response) {
|
||||
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();) {
|
||||
EasyExcel.write(byteArrayOutputStream, IntegralTemp.class)
|
||||
.sheet("积分扣减导入模版")
|
||||
.doWrite(ArrayList::new);
|
||||
CommonDownloadUtil.download("积分扣减导入模版.xlsx", byteArrayOutputStream.toByteArray(), response);
|
||||
} catch (Exception e) {
|
||||
log.error("下载福利名单导入模版失败", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@ApiOperation("下载福利名单导入模板")
|
||||
@SaCheckPermission("benefit.user")
|
||||
public void downloadImport(HttpServletResponse response) {
|
||||
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();) {
|
||||
EasyExcel.write(byteArrayOutputStream, BenefitUserTemp.class)
|
||||
.sheet("福利名单导入模版")
|
||||
.doWrite(ArrayList::new);
|
||||
CommonDownloadUtil.download("福利名单导入模版.xlsx", byteArrayOutputStream.toByteArray(), response);
|
||||
} catch (Exception e) {
|
||||
log.error("下载福利名单导入模版失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("integral.manage")
|
||||
@ApiOperation("导入扣减积分名单")
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
public Result doImport(TempFile file) {
|
||||
try {
|
||||
List<T> ts = EasyExcelUtil.syncReadModel(file.getFile(), IntegralTemp.class, 0, 1);
|
||||
List<IntegralTemp> integralTempList = JSONUtil.parseArray(JSONUtil.toJsonStr(ts)).toList(IntegralTemp.class);
|
||||
|
||||
List<String> loginNames = integralTempList.stream().map(IntegralTemp::getLoginName).toList();
|
||||
List<View_user> userList = integralManageService.dao().query(View_user.class, Cnd.NEW().andEX(View_user::getLoginname, "in", loginNames));
|
||||
Map<String, String> userMap = userList.stream().collect(Collectors.toMap(View_user::getLoginname, View_user::getId));
|
||||
|
||||
List<IntegralTemp> errorInfos = new ArrayList<>();
|
||||
List<IntegralDetail> insertInfos = new ArrayList<>();
|
||||
integralTempList.forEach(v -> {
|
||||
if (userMap.containsKey(v.getLoginName().trim())) {
|
||||
View_user viewUser = userList.stream().filter(user -> user.getLoginname().equals(v.getLoginName())).findFirst().orElse(null);
|
||||
IntegralDetail detail = new IntegralDetail();
|
||||
detail.setYear(String.valueOf(DateUtil.thisYear()));
|
||||
detail.setIntegral("-" + v.getIntegral());
|
||||
detail.setIntegralTime(v.getIntegralTime() == null ? new Date() : v.getIntegralTime());
|
||||
detail.setIntegralNotes(Strings.isNotBlank(v.getIntegralNotes()) ? v.getIntegralNotes() : "扣减导入");
|
||||
detail.setUserId(viewUser.getId());
|
||||
detail.setUnionId(viewUser.getUnionId());
|
||||
detail.setUnitId(viewUser.getUnitId());
|
||||
detail.setUnionName(viewUser.getUnionName());
|
||||
detail.setUnitName(viewUser.getUnitName());
|
||||
insertInfos.add(detail);
|
||||
} else {
|
||||
v.setResult("获取不到该用户信息,请检查工号是否正确!");
|
||||
errorInfos.add(v);
|
||||
}
|
||||
});
|
||||
|
||||
int successCount = Lang.isNotEmpty(insertInfos) ? integralManageService.insert(insertInfos).size() : 0;
|
||||
|
||||
if (Lang.isNotEmpty(errorInfos)) {
|
||||
NutMap nutMap = new NutMap();
|
||||
nutMap.setv("totalCount", integralTempList.size());
|
||||
nutMap.setv("successCount", successCount);
|
||||
nutMap.setv("errorCount", errorInfos.size());
|
||||
nutMap.setv("errorList", errorInfos.stream().map(v -> {
|
||||
return NutMap.NEW().addv("工号", v.getLoginName()).addv("姓名", v.getUserName()).addv("错误原因", v.getResult());
|
||||
}).collect(Collectors.toList()));
|
||||
return Result.success(nutMap);
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@ContentRowHeight(20) // 内容行高
|
||||
@HeadRowHeight(20) // 表头行高
|
||||
@ColumnWidth(25)
|
||||
public static class IntegralTemp {
|
||||
|
||||
@ExcelProperty("工号")
|
||||
private String loginName;
|
||||
|
||||
@ExcelProperty("姓名")
|
||||
private String userName;
|
||||
|
||||
@ExcelProperty("扣减积分")
|
||||
private String integral;
|
||||
|
||||
@ExcelProperty("扣减原因")
|
||||
private String integralNotes;
|
||||
|
||||
@ExcelProperty("扣减时间")
|
||||
private Date integralTime;
|
||||
|
||||
@ExcelIgnore
|
||||
private String result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.budwk.app.zhgh.integral.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName IntegralConfig
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2024/1/19 15:32
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("integral_config")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("积分配置表")
|
||||
public class IntegralConfig extends BaseModel implements Serializable {
|
||||
|
||||
|
||||
@Name
|
||||
@PrevInsert(uu32 = true)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("ID")
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("每日签到积分")
|
||||
private Integer dailyAttendanceIntegral;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("个人活动报名积分")
|
||||
private Integer userApplyActivityIntegral;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("参加活动积分")
|
||||
private Integer attendActivityIntegral;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("几号几积分")
|
||||
private List<dayIntegral> dayIntegralList;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("荣誉等级积分")
|
||||
private List<honorLevel> honorLevelList;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("自定义其他模块积分")
|
||||
private List<otherModel> otherModelList;
|
||||
|
||||
@Data
|
||||
public static class dayIntegral {
|
||||
private String day;
|
||||
private String integral;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class honorLevel {
|
||||
private String id;
|
||||
private String name;
|
||||
private String integral;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class otherModel {
|
||||
private String otherModeCode;
|
||||
private Integer otherModeSort;
|
||||
private String otherModeName;
|
||||
private String integral;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.budwk.app.zhgh.integral.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("integral_detail")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("积分详情表")
|
||||
@TableIndexes({
|
||||
@Index(name = "INDEX_USER_ID", fields = {"userId"}, unique = false),
|
||||
@Index(name = "INDEX_INTEGRAL", fields = {"integral"}, unique = false)
|
||||
})
|
||||
public class IntegralDetail extends BaseModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Prev(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 4)
|
||||
@Comment("年度")
|
||||
private String year;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("用户id")
|
||||
private String userId;
|
||||
|
||||
@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;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
@Comment("积分")
|
||||
private String integral;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
@Comment("积分来源备注")
|
||||
private String integralNotes;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("业务Id")
|
||||
private String bizId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
@Comment("积分时间")
|
||||
private Date integralTime;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.budwk.app.zhgh.integral.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.zhgh.integral.model.IntegralDetail;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
|
||||
public interface IntegralDetailService extends BaseService<IntegralDetail> {
|
||||
|
||||
|
||||
|
||||
Sql getSql(String pageOrderName,
|
||||
String pageOrderBy,
|
||||
String searchKeyword,
|
||||
String month,
|
||||
String unionId,
|
||||
String unitId,
|
||||
String integralTime);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.budwk.app.zhgh.integral.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.zhgh.integral.model.IntegralConfig;
|
||||
|
||||
public interface IntegralInsertTaskOrSelectConfigService extends BaseService<IntegralConfig> {
|
||||
|
||||
/**
|
||||
* @param otherModel
|
||||
* @return io.v.nutz.zhgh.integral.model.IntegralConfig.otherModel
|
||||
* @author zhf
|
||||
* @description 根据code查询自定义模块的积分
|
||||
*/
|
||||
IntegralConfig.otherModel findOneOtherModel(String otherModel);
|
||||
|
||||
/**
|
||||
* @param honorLevel
|
||||
* @return io.v.nutz.zhgh.integral.model.IntegralConfig.honorLevel
|
||||
* @author zhf
|
||||
* @description 根据评优评先的等级id查询积分
|
||||
*/
|
||||
IntegralConfig.honorLevel findOneHonorLevel(String honorLevel);
|
||||
|
||||
|
||||
IntegralConfig findOne();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.budwk.app.zhgh.integral.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.zhgh.integral.model.IntegralDetail;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
public interface IntegralManageService extends BaseService<IntegralDetail> {
|
||||
|
||||
|
||||
Workbook exportIntegral(List<NutMap> integralList, boolean isSum, OutputStream outputStream) throws Exception;
|
||||
|
||||
/**
|
||||
* 根据业务Id删除
|
||||
*
|
||||
* @param bizId 业务Id
|
||||
* @return
|
||||
*/
|
||||
int doDeleteBYBizId(String bizId);
|
||||
|
||||
/**
|
||||
* 根据Id删除
|
||||
*
|
||||
* @param id Id
|
||||
* @return
|
||||
*/
|
||||
int doDeleteById(String id);
|
||||
|
||||
/**
|
||||
* @param userIds
|
||||
* @param bizId 业务id
|
||||
* @param integralNotes 备注
|
||||
* @param model IntegralOtherModelConstant里的otherModeCode
|
||||
* @author zhf
|
||||
* @description 自定义加积分除活动以外调用加积分
|
||||
*/
|
||||
void insertIntegralDetail(List<String> userIds, String bizId, String integralNotes, String model);
|
||||
|
||||
void insertIntegralDetail(String userId, String bizId, String integralNotes, String model);
|
||||
|
||||
void insertHonorLevelDetail(List<String> userIds, String bizId, String integralNotes, String honorLevelId);
|
||||
|
||||
|
||||
/**
|
||||
* 首页列表和导出使用
|
||||
* @param pageOrderName
|
||||
* @param pageOrderBy
|
||||
* @param searchKeyword
|
||||
* @param year
|
||||
* @param unionId
|
||||
* @param unitId
|
||||
* @param personType
|
||||
* @param userState
|
||||
* @param integralTime
|
||||
* @return
|
||||
*/
|
||||
Sql getSql(String pageOrderName,
|
||||
String pageOrderBy,
|
||||
String searchKeyword,
|
||||
String year,
|
||||
String unionId,
|
||||
String unitId,
|
||||
String personType,
|
||||
String userState,
|
||||
String integralTime);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.budwk.app.zhgh.integral.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.integral.model.IntegralDetail;
|
||||
import com.budwk.app.zhgh.integral.service.IntegralDetailService;
|
||||
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.ioc.loader.annotation.IocBean;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2025/7/14 15:26
|
||||
* @description
|
||||
*/
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class IntegralDetailServiceImpl extends BaseServiceImpl<IntegralDetail> implements IntegralDetailService {
|
||||
public IntegralDetailServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sql getSql(String pageOrderName,
|
||||
String pageOrderBy,
|
||||
String searchKeyword,
|
||||
String month,
|
||||
String unionId,
|
||||
String unitId,
|
||||
String integralTime) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
ind.id,
|
||||
ind.userId,
|
||||
ind.YEAR,
|
||||
ind.unionName,
|
||||
ind.unionId,
|
||||
ind.unitName,
|
||||
ind.unitId,
|
||||
ind.integral,
|
||||
ind.integralTime,
|
||||
ind.integralNotes,
|
||||
u.loginname,
|
||||
u.username,
|
||||
u.sex,
|
||||
u.personType,
|
||||
u.userState,
|
||||
u.mobile,
|
||||
u.birthday
|
||||
FROM
|
||||
integral_detail ind
|
||||
LEFT JOIN `vw_user` u ON ind.userId = u.id
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(searchKeyword)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("u.username", searchKeyword);
|
||||
seg.orLike("u.loginname", searchKeyword);
|
||||
cnd.and(seg);
|
||||
}
|
||||
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("ind.unionId", "=", SecurityUtil.getUnionId());
|
||||
}
|
||||
}
|
||||
cnd.andEX("DATE_FORMAT(ind.`integralTime`,'%Y-%m')", "=", month);
|
||||
cnd.andEX("ind.unionId", "=", unionId);
|
||||
cnd.andEX("ind.unionId", "=", unitId);
|
||||
cnd.andEX("DATE(ind.integralTime)", "=", integralTime);
|
||||
cnd.and("u.member", "=", 1);
|
||||
cnd.groupBy("u.id");
|
||||
|
||||
|
||||
if (StrUtil.isNotBlank(pageOrderName) && StrUtil.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy(pageOrderName, pageOrderBy.equalsIgnoreCase("ascending") ? "ASC" : "DESC");
|
||||
} else {
|
||||
cnd.desc("ind.integralTime");
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.budwk.app.zhgh.integral.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.zhgh.integral.model.IntegralConfig;
|
||||
import com.budwk.app.zhgh.integral.service.IntegralInsertTaskOrSelectConfigService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2025/7/14 09:32
|
||||
* @description
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class IntegralInsertTaskOrSelectConfigServiceImpl extends BaseServiceImpl<IntegralConfig> implements IntegralInsertTaskOrSelectConfigService {
|
||||
public IntegralInsertTaskOrSelectConfigServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IntegralConfig.otherModel findOneOtherModel(String otherModel) {
|
||||
|
||||
IntegralConfig config = dao().fetch(IntegralConfig.class, Cnd.NEW());
|
||||
if (StrUtil.isNotBlank(otherModel)) {
|
||||
List<IntegralConfig.otherModel> otherModelList = config.getOtherModelList();
|
||||
IntegralConfig.otherModel otherModelClass = otherModelList.stream().filter(o -> o.getOtherModeCode().equals(otherModel)).findFirst().orElse(null);
|
||||
return otherModelClass;
|
||||
}
|
||||
return new IntegralConfig.otherModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegralConfig.honorLevel findOneHonorLevel(String honorLevel) {
|
||||
IntegralConfig config = dao().fetch(IntegralConfig.class, Cnd.NEW());
|
||||
if (StrUtil.isNotBlank(honorLevel)) {
|
||||
List<IntegralConfig.honorLevel> honorLevelList = config.getHonorLevelList();
|
||||
IntegralConfig.honorLevel honorLevelClass = honorLevelList.stream().filter(o -> o.getId().equals(honorLevel)).findFirst().orElse(null);
|
||||
return honorLevelClass;
|
||||
}
|
||||
return new IntegralConfig.honorLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegralConfig findOne() {
|
||||
return dao().fetch(IntegralConfig.class, Cnd.NEW());
|
||||
}
|
||||
}
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
package com.budwk.app.zhgh.integral.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.views.View_user;
|
||||
import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.integral.model.IntegralConfig;
|
||||
import com.budwk.app.zhgh.integral.model.IntegralDetail;
|
||||
import com.budwk.app.zhgh.integral.service.IntegralManageService;
|
||||
import com.budwk.app.zhgh.integral.service.IntegralInsertTaskOrSelectConfigService;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
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.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.util.NutMap;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class IntegralManageServiceImpl extends BaseServiceImpl<IntegralDetail> implements IntegralManageService {
|
||||
public IntegralManageServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private IntegralInsertTaskOrSelectConfigService integralInsertOrSelectService;
|
||||
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Override
|
||||
public Workbook exportIntegral(List<NutMap> integralList, boolean isSum, OutputStream outputStream) throws Exception {
|
||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
exportEntities.add(new ExcelExportEntity("性别", "sex", 20));
|
||||
exportEntities.add(new ExcelExportEntity("联系电话", "mobile", 20));
|
||||
// exportEntities.add(new ExcelExportEntity("身份证号", "idcard", 30));
|
||||
exportEntities.add(new ExcelExportEntity("在职状态", "userState", 20));
|
||||
exportEntities.add(new ExcelExportEntity("人员类型", "personType", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所属工会", "unionName", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所属单位", "unitName", 30));
|
||||
if (isSum) {
|
||||
exportEntities.add(new ExcelExportEntity("总积分", "sumIntegral", 20));
|
||||
} else {
|
||||
exportEntities.add(new ExcelExportEntity("积分", "integral", 20));
|
||||
exportEntities.add(new ExcelExportEntity("积分备注", "integralNotes", 30));
|
||||
exportEntities.add(new ExcelExportEntity("积分时间", "integralTime", 20));
|
||||
}
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setHeight((short) 10);
|
||||
return ExcelExportUtil.exportExcel(exportParams, exportEntities, integralList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据业务Id删除
|
||||
*
|
||||
* @param bizId 业务Id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int doDeleteBYBizId(String bizId) {
|
||||
return this.clear(Cnd.where("bizId", "=", bizId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据Id删除
|
||||
*
|
||||
* @param id Id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int doDeleteById(String id) {
|
||||
return this.clear(Cnd.where("id", "=", id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SLog(type = "Integral", tag = "积分管理", msg = "根据模式添加积分")
|
||||
public void insertIntegralDetail(List<String> userIds, String bizId, String integralNotes, String model) {
|
||||
//根据模式查询所得的积分
|
||||
IntegralConfig.otherModel oneOtherModel = integralInsertOrSelectService.findOneOtherModel(model);
|
||||
|
||||
if (Lang.isEmpty(oneOtherModel)) {
|
||||
return;
|
||||
}
|
||||
List<View_user> userList = dao().query(View_user.class, Cnd.NEW().andEX(View_user::getId, "in", userIds));
|
||||
List<IntegralDetail> integralDetails = new ArrayList<>();
|
||||
userIds.forEach(u -> {
|
||||
View_user viewUser = userList.stream().filter(user -> user.getId().equals(u)).findFirst().orElse(null);
|
||||
IntegralDetail detail = new IntegralDetail();
|
||||
detail.setIntegral(oneOtherModel.getIntegral());
|
||||
detail.setIntegralNotes(integralNotes);
|
||||
detail.setIntegralTime(DateUtil.date());
|
||||
detail.setYear(String.valueOf(DateUtil.thisYear()));
|
||||
detail.setUserId(u);
|
||||
detail.setUnionId(viewUser.getUnionId());
|
||||
detail.setUnitId(viewUser.getUnitId());
|
||||
detail.setUnionName(viewUser.getUnionName());
|
||||
detail.setUnitName(viewUser.getUnitName());
|
||||
detail.setBizId(bizId);
|
||||
integralDetails.add(detail);
|
||||
});
|
||||
if (Lang.isNotEmpty(userIds)) {
|
||||
integralInsertOrSelectService.insert(integralDetails);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertIntegralDetail(String userId, String bizId, String integralNotes, String model) {
|
||||
insertIntegralDetail(List.of(userId), bizId, integralNotes, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SLog(type = "Integral", tag = "积分管理", msg = "评优评先添加积分")
|
||||
public void insertHonorLevelDetail(List<String> userIds, String bizId, String integralNotes, String honorLevelId) {
|
||||
IntegralConfig.honorLevel oneHonorLevel = integralInsertOrSelectService.findOneHonorLevel(honorLevelId);
|
||||
if (Lang.isEmpty(oneHonorLevel) && StrUtil.isBlank(oneHonorLevel.getIntegral())) {
|
||||
return;
|
||||
}
|
||||
List<View_user> userList = dao().query(View_user.class, Cnd.where("id", "in", userIds));
|
||||
List<IntegralDetail> integralDetails = new ArrayList<>();
|
||||
userIds.forEach(u -> {
|
||||
View_user viewUser = userList.stream().filter(user -> user.getId().equals(u)).findFirst().orElse(null);
|
||||
IntegralDetail detail = new IntegralDetail();
|
||||
detail.setIntegral(oneHonorLevel.getIntegral());
|
||||
detail.setIntegralNotes(integralNotes);
|
||||
detail.setIntegralTime(DateUtil.date());
|
||||
detail.setYear(String.valueOf(DateUtil.thisYear()));
|
||||
detail.setUserId(u);
|
||||
detail.setUnionId(viewUser.getUnionId());
|
||||
detail.setUnitId(viewUser.getUnitId());
|
||||
detail.setUnionName(viewUser.getUnionName());
|
||||
detail.setUnitName(viewUser.getUnitName());
|
||||
detail.setBizId(bizId);
|
||||
integralDetails.add(detail);
|
||||
});
|
||||
if (Lang.isNotEmpty(userIds)) {
|
||||
integralInsertOrSelectService.insert(integralDetails);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sql getSql(String pageOrderName, String pageOrderBy, String searchKeyword, String year, String unionId, String unitId, String personType, String userState, String integralTime) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
ind.year,
|
||||
u.id userId,
|
||||
u.unionName,
|
||||
u.unionId,
|
||||
u.unitName,
|
||||
u.unitId,
|
||||
u.loginname,
|
||||
u.username,
|
||||
u.sex,
|
||||
u.personType,
|
||||
u.userState,
|
||||
u.mobile,
|
||||
u.birthday,
|
||||
SUM( ind.integral ) AS sumIntegral
|
||||
FROM
|
||||
vw_user u
|
||||
LEFT JOIN integral_detail ind ON ind.userId = u.id
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(searchKeyword)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("u.username", searchKeyword);
|
||||
seg.orLike("u.loginname", searchKeyword);
|
||||
cnd.and(seg);
|
||||
}
|
||||
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("u.unionId", "=", SecurityUtil.getUnionId());
|
||||
}
|
||||
}
|
||||
cnd.andEX("u.unionId", "=", unionId);
|
||||
cnd.andEX("u.unionId", "=", unitId);
|
||||
cnd.andEX("u.personType", "=", personType);
|
||||
cnd.andEX("u.userState", "=", userState);
|
||||
cnd.andEX("DATE(ind.integralTime)", "=", integralTime);
|
||||
cnd.and("u.member", "=", 1);
|
||||
cnd.groupBy("u.id");
|
||||
|
||||
|
||||
if (StrUtil.isNotBlank(pageOrderName) && StrUtil.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy("sumIntegral".equals(pageOrderName) ? "SUM( ind.integral )" : pageOrderName, pageOrderBy.equalsIgnoreCase("ascending") ? "ASC" : "DESC");
|
||||
} else {
|
||||
cnd.desc("SUM( ind.integral )");
|
||||
cnd.asc("u.loginname");
|
||||
cnd.desc("ind.integralTime");
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user